Suppose you have a boolean expression(eg. A or B) with a certain number of boolean variables(taking values True or False). For a certain set of values of the variables, we know the expression evaluated to True.
Given the expression and the values of the variables, find which variables were responsible for it.
For example,
Case 1: The expression is A or (B and C).
A = True,
B = False,
C = True
The output will be A
Case 2: The expression is A and (B or C).
A = True,
B = False,
C = True
The output will be A, C.
Case 3: The expression is A and (B or C).
A = True,
B = True,
C = True
The output will be A, B, C
Case 4: The expression is A or (B and (C or D)).
A = True,
B = True,
C = False,
D = True
The output will be A, B, D.
I want to know how do I go about finding the output. What would be the logic or algorithm I would use?
First convert your general form equation to sum of products form. Converting to this form is always possible. Once in this form you will have an equation that is a series of clauses composed of ANDs. All the clauses will be ORed together. For example a converted equation may look like (bars represent NOT):
($A$ and $B$ and $\bar C$) or ($B$ and $D$) or ($\bar B$ and $E$) or ($F$)
Note how this is an expression composed of 4 clauses. The clauses happen to have varying length.
Then we can look at each clause individually. Since the clauses are only composed of ANDs and NOTs it is possible to mechanically check if each clause is true based on the given values of the variables. Since this is sum of products form any clause resulting in a true value will cause the entire expression to be true, so the answer to your question is every variable which shows up in a clause which is true is "responsible" for the truth value of the entire equation.
With the given values: $A$ = True, $B$ = True, $C$ = False, $D$ = False, $F$ = True.
One can see that the first and fourth clauses are individually true. Therefore, $A, B, C, F$ are "responsible" for the truth value.