C coding .

C coding .

Logical Equivalence Implementation

Write a C program to test for logical equivalence.

Requirements:
1)    Implement the following functions
a.    bool implication(bool a, bool b);  // a -> b
b.    bool bicondition(bool a, bool b);  // a <-> b
2)    Your program must print the truth tables as shown in the sample output below, with the logic expressions and all possible input values
3)    Test (at least) the following expressions
a.      p or q  ?  ~(~p and ~q)
b.      p and (q -> r)  ?  (p and q) xor r
c.      p <-> q  ?  ~(p xor q)
d.      (p <-> q) -> r  ?  p and (~q or r)
e.      ~(p -> (q & r))  ?  p & ~(q & r)

You may hard code each of the test expression “inputs” in any way you want.  You could do it all in loops in main, or create some other kind of functional mechanism, whatever works for you as long as you generate output in the proper format.

Here is an easy way to generate pqr permutations:
count++; p = count & 1; q = count & 2; r = count & 4;

Turn In:
Paper printouts of:

1)    Source Code.
2)    Output for each of the input relations.

Sample Output
p  q  |  p or q  | ~(~p and ~q)

0  0  |    0     |       0
0  1  |    1     |       1
1  0  |    1     |       1
1  1  |    1     |       1
These expressions are equivalent

p  q  r | p and (q -> r) | (p and q) xor r

0  0  0 |       0        |       0
0  0  1 |       0        |       1
0  1  0 |       0        |       0
0  1  1 |       0        |       1
1  0  0 |       1        |       0
1  0  1 |       1        |       1
1  1  0 |       0        |       1
1  1  1 |       1        |       0
These expressions are NOT equivalent

order