Boolean Algebra

Boolean Algebra
Philipp Koehn
9 September 2016
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
Core Boolean Operators
A
0
0
1
1
B
0
1
0
1
AND
OR
NOT
∧
∨
¬
A and B
0
0
0
1
AND
Philipp Koehn
1
A
0
0
1
1
B
0
1
0
1
A or B
0
1
1
1
OR
Computer Systems Foundamentals: Boolean Algebra
A
0
1
not A
1
0
NOT
9 September 2016
2
Boolean algebra
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
Boolean Algebra:
Monotone Laws
3
Identity for ∨
Identity for ∧
x∨0=x
x∧1=x
Annihilator for ∨
Annihilator for ∧
x∨1=1
x∧0=0
Idempotence for ∨
Idempotence for ∧
x∨x=x
x∧x=x
Commutativity for ∨
Commutativity for ∧
x∨y=y∨x
x∧y=y∧x
Absorption 1
Absorption 2
x ∧ (x ∨ y) = x
x ∨ (x ∧ y) = x
Associativity for ∨
Associativity for ∧
(x ∨ y) ∨ z = x ∨ (y ∨ z)
(x ∧ y) ∧ z = x ∧ (y ∧ z)
Distributivity of ∧ over ∨
Distributivity of ∨ over ∧
x ∧ (y ∨ z) = (x ∧ y) ∨ (x ∧ z)
x ∨ (y ∧ z) = (x ∨ y) ∧ (x ∨ z)
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
Boolean Algebra:
Nonmonotone Laws
Complementation for ∧
Complementation for ∨
x ∧ ¬x = 0
x ∨ ¬x = 1
De Morgan 1
De Morgan 2
¬x ∧ ¬y = ¬(x ∨ y)
¬x ∨ ¬y = ¬(x ∧ y)
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
4
9 September 2016
5
from Boolean expressions
to circuits
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
Truth Table → Boolean Expression
6
• Truth table
A
0
0
1
1
• Operation:
B
0
1
0
1
OUT
1
0
0
0
not ( A or B )
(also called nor)
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
Boolean Expression → Circuit
• Operation:
7
not ( A or B )
• Circuit:
A
B
Philipp Koehn
OR
NOT
Computer Systems Foundamentals: Boolean Algebra
OUT
9 September 2016
4-Bit AND
8
• 4 inputs (A, B, C, D), output 1 iff all inputs are 1
• Operation:
(A and B) and (C and D)
• Circuit:
A
B
AND
AND
C
D
Philipp Koehn
OUT
AND
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
1-Bit Selector
9
• Truth table
A
0
1
• Operation:
OUT1
1
0
OUT2
0
1
OUT1 = not A
OUT2 = A
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
1-Bit Selector
• Operation:
10
OUT1 = not A
OUT2 = A
• Circuit:
A
NOT
OUT1
OUT2
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
A Complicated Example
11
• Truth table
A
0
0
1
1
0
0
1
1
• Operation:
Philipp Koehn
B
0
1
0
1
0
1
0
1
C
0
0
0
0
1
1
1
1
OUT
0
1
0
0
1
1
0
0
Need a better way of doing this
instead of relying on intuition
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
12
disjunctive normal form
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
DNF: Setup
A
0
0
1
1
0
0
1
1
Goal:
Philipp Koehn
B
0
1
0
1
0
1
0
1
C
0
0
0
0
1
1
1
1
OUT
0
1
0
0
1
1
0
0
13
Expression
find expression for each row that yields 1
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
DNF: One Row
A
0
0
1
1
0
0
1
1
B
0
1
0
1
0
1
0
1
C
0
0
0
0
1
1
1
1
OUT
0
1
0
0
1
1
0
0
14
Expression
(not A) and B and (not C)
Expression is 1 only for this row, 0 for all others
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
DNF: All Rows
A
0
0
1
1
0
0
1
1
Philipp Koehn
B
0
1
0
1
0
1
0
1
C
0
0
0
0
1
1
1
1
OUT
0
1
0
0
1
1
0
0
15
Expression
(not A) and B and (not C)
(not A) and (not B) and C
(not A) and B and C
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
DNF: Complete Operation
A
0
0
1
1
0
0
1
1
B
0
1
0
1
0
1
0
1
C
0
0
0
0
1
1
1
1
OUT
0
1
0
0
1
1
0
0
Expression
(not A) and B and (not C)
(not A) and (not B) and C
(not A) and B and C
Putting it all together:
Philipp Koehn
16
((not A) and B and (not C)) or
((not A) and (not B) and C) or
((not A) and B and C)
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
DNF: Circuit
• Operation:
17
((not A) and B and (not C)) or
((not A) and (not B) and C) or
((not A) and B and C)
• Circuit:
Philipp Koehn
A
NOT
B
NOT
C
NOT
AND
AND
AND
OR
OUT
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
18
conjunctive normal form
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
DNF
A
0
0
1
1
0
0
1
1
B
0
1
0
1
0
1
0
1
C
0
0
0
0
1
1
1
1
OUT
0
1
0
0
1
1
0
0
Expression
(not A) and B and (not C)
(not A) and (not B) and C
(not A) and B and C
Putting it all together:
Philipp Koehn
19
((not A) and B and (not C)) or
((not A) and (not B) and C) or
((not A) and B and C)
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
CNF: One Row
A
0
0
1
1
0
0
1
1
B
0
1
0
1
0
1
0
1
C
0
0
0
0
1
1
1
1
OUT
0
1
0
0
1
1
0
0
20
Expression
not ((not A) and (not B) and (not C))
Expression is 0 only for this row, 1 for all others
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
CNF: All Rows
A
0
0
1
1
0
0
1
1
Philipp Koehn
B
0
1
0
1
0
1
0
1
C
0
0
0
0
1
1
1
1
OUT
0
1
0
0
1
1
0
0
21
Expression
not ((not A) and (not B) and (not C))
not (A and (not B) and (not C))
not (A and B and (not C))
not (A and (not B) and C)
not (A and B and C)
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
CNF: Complete Operation
A
0
0
1
1
0
0
1
1
B
0
1
0
1
0
1
0
1
C
0
0
0
0
1
1
1
1
OUT
0
1
0
0
1
1
0
0
Expression
not ((not A) and (not B) and (not C))
not (A and (not B) and (not C))
not (A and B and (not C))
not (A and (not B) and C)
not (A and B and C)
Putting it all together:
Philipp Koehn
22
(not
(not
(not
(not
(not
((not A) and (not B) and (not C))) and
(A and (not B) and (not C))) and
(A and B and (not C))) and
(A and (not B) and C)) and
(A and B and C))
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
CNF: Circuit
• Operation:
(not
(not
(not
(not
(not
((not A) and (not B) and (not C))) and
(A and (not B) and (not C))) and
(A and B and (not C))) and
(A and (not B) and C)) and
(A and B and C))
OUT
A
NOT
B
NOT
C
NOT
NOT
NOT
NOT
NOT
NOT
AND
AND
AND
AND
AND
AND
• Circuit:
Philipp Koehn
23
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
24
universal gates
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
Universality of NAND
25
• Truth table:
A
0
0
1
1
B
0
1
0
1
A nand B
1
1
1
0
• NOT: A nand A
• AND: (A nand B) nand (A nand B)
• OR: (A nand A) nand (B nand B)
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
9 September 2016
Universality of NOR
26
• Truth table:
A
0
0
1
1
B
0
1
0
1
A nor B
1
0
0
0
• NOT: A nor A
• AND: (A nor A) nor (B nor B)
• OR: (A nor B) nor (A nor B)
Philipp Koehn
Computer Systems Foundamentals: Boolean Algebra
9 September 2016