In: Computer Science
Overview and objective: Basic logic
In this homework, you will exercise your understanding of boolean logic and the gates and circuits that embody it. A thorough understanding of boolean logic is extremely useful for almost all programming tasks and necessary to correctly implement complex systems. Additionally, greater familiarity with boolean logic should improve one’s ability to think critically in general as it forms the basis for all human reasoning.
Technical Description and Instructions:
1. Consider the logical expression ( !x && y) && ! (x && !y). Make a truth table for this expression.
2. Construct a truth table for the expression (!x && y). Is the output column of the truth table the same as the previous expression’s truth table? What does this mean?
3. Simplify the following expressions using the boolean algebra properties with which you are familiar. Name the properties that you use to simplify them.
a) (x && y) && (x &&!y)
b) !x || (!y || x)
c) T || ( !y || x )
d) T && (( !y || x) || x )
1. ( !x && y) && ! (x && !y)
Truth Table : ( !x && y) && ! (x && !y)
x | y | !x | !y | (!x && y) | (x && !y) | ! (x && !y) | ( !x && y) && ! (x && !y) |
0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 |
0 | 1 | 1 | 0 | 1 | 0 | 1 | 1 |
1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 |
2. (!x && y)
Truth table : (!x && y)
x | y | !x | (!x && y) |
0 | 0 | 1 | 0 |
0 | 1 | 1 | 1 |
1 | 0 | 0 | 0 |
1 | 1 | 0 | 0 |
The expressions ( !x && y) && ! (x && !y) and (!x && y) are equivalent expressions i.e the expression ( !x && y) && ! (x && !y) can be simplified and reduced to (!x && y).
3.
(a) (x && y) && (x &&!y)
= x && y && x && !y (Using Associative law)
= x && (y && !y) (since x && x = x)
= x && False (Since y && !y = False, If y = 1 then !y = 0 , so 1 && 0 = 0)
= False (Since the output of AND operation is False is one of the inputs are False)
(b) !x || (!y || x)
= !x || !y || x (Using Associative law)
= True || !y (Since x || !x = True)
= True (Since output of OR operation is True is one of the inputs are True)
(c) T || ( !y || x )
= T || !y || x (Using Associative law)
= T (Since output of OR operation is True if one of the inputs are True)
= True
(d) T && (( !y || x) || x )
= (T && (!y || x)) || (T && x) (Using Distributive Law)
=( (T && !y) || (T && x) ) || (T && x) (Using Distributive Law)
= (!y || x ) || (x) (If one of the inputs of AND operation is True, then the output depends on the value of other inputs)
= !y || x || x (Using Associative Law)
= !y || x (Since x OR x = x)