| ! ( cond1 && cond2 ) | ==> | ( !cond1 || !cond2 ) |
| ! ( cond1 || cond2 ) | ==> | ( !cond1 && !cond2 ) |
Truth Table Example
Problem# 4.29a
The problem asks you to apply DeMorgan's Law to the above expression and then write a program to show the two expressions (initial and result) are equivalent.
By applying DeMorgan's Law to the above expression, you get:
To show equivalency, I am going to use a Truth Table instead of writting a program (you can write the program on your own time). There are 4 possible combinations of the two conditions above (T is true and F is false):
| x < 5 | y >= 7 |
| T | T |
| T | F |
| F | T |
| F | F |
When both of these are negated (column 2) and then and'ed (column 3) together, The resulting Truth Table looks like this for the initial Expression:
|
|
||
| !T && !T | F && F | F |
| !T && !F | F && T | F |
| !F && !T | T && F | F |
| !F && !F | T && T | T |
The Truth Table for the expression after we have applied DeMorgan's Law looks like this:
|
|
||
| !(T || T) | !T | F |
| !(T || F) | !T | F |
| !(F || T) | !T | F |
| !(F || F) | !F | T |
By looking in column three of each table, we can see quite clearly that these two expressions are equivalent. Please try some at home and email me if you have any problems.