Combine two boolean equations to separate a boolean variables from others
I have 2 programs: X and Y.
X has two bitmaps A and C.
X calls Y.
Y has a bitMap B.
The code I need to execute in Y is
if AB == B && BC == C
开发者_如何学JAVA //do some action Z
I want to combine on A and C using boolean operations such that I can pass a single bitMap to Y. This single bitmap can then do any boolean operation with B to return true / false and accordingly I can decide to do action Z.
There is no way to simplify by combining A and C.
Here is our truth table:
B A C Z
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
We can see from the truth table that when B = 0, we have Z = not C; when B = 1, we have Z = A.
Suppose for the sake of contradiction that we have a one-bit function Y = f(A, C) that "summarizes" A and C. We use B to choose whether the summary equals 'not C' versus 'A'. But this is clearly impossible, because a single bit cannot preserve enough information to be able to extract the value 'not C' and also the value 'A'.
精彩评论