Upcoming SlideShare
×

# 02 - Boolean algebra

2,144 views
1,842 views

Published on

I used this set of slides for the lecture on Computational Thinking I gave at the University of Zurich for the 1st year students following the course of Formale Grundlagen der Informatik.

Published in: Technology
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
2,144
On SlideShare
0
From Embeds
0
Number of Embeds
545
Actions
Shares
0
36
0
Likes
1
Embeds 0
No embeds

No notes for slide

### 02 - Boolean algebra

1. 1. Boolean algebra www.tudorgirba.com
2. 2. computer information information computation
3. 3. Alan Turing, 1937
4. 4. George Boole 1815 – 1864
5. 5. George Boole 1815 – 1864 Claude Shannon 1916 – 2001
6. 6. +
7. 7. + a = 0
8. 8. + y = 0 a = 0
9. 9. ++ y = 0 a = 0
10. 10. + a = 1 + y = 0 a = 0
11. 11. + y = 1 a = 1 + y = 0 a = 0
12. 12. +
13. 13. b = 0 a = 0 +
14. 14. b = 0 a = 0 y = 0 ∧ ba = y 00 0 +
15. 15. b = 1 a = 0 ∧ ba = y 00 0 +
16. 16. b = 1 a = 0 y = 0 ∧ ba = y 00 0 10 0 +
17. 17. b = 0 a = 1 ∧ ba = y 00 0 10 0 +
18. 18. b = 0 a = 1 y = 0 ∧ ba = y 00 0 10 0 01 0 +
19. 19. b = 1 a = 1 ∧ ba = y 00 0 10 0 01 0 +
20. 20. b = 1 a = 1 y = 1 ∧ ba = y 00 0 10 0 01 0 11 1 +
21. 21. b = x a = 0 ∧ ba = y 00 0 10 0 01 0 11 1 +
22. 22. b = x a = 0 y = 0 ∧ ba = y 00 0 10 0 01 0 11 1 x0 0 +
23. 23. b = x a = 1 ∧ ba = y 00 0 10 0 01 0 11 1 x0 0 +
24. 24. b = x a = 1 y = x ∧ ba = y 00 0 10 0 01 0 11 1 x0 0 x1 x +
25. 25. b = x a = x ∧ ba = y 00 0 10 0 01 0 11 1 x0 0 x1 x +
26. 26. b = x a = x y = x ∧ ba = y 00 0 10 0 01 0 11 1 x0 0 x1 x xx x +
27. 27. a = 0 b = 0 +
28. 28. a = 0 b = 0 y = 0 ∨ ba = y 00 0 +
29. 29. a = 0 b = 1 ∨ ba = y 00 0 +
30. 30. a = 0 b = 1 y = 1 ∨ ba = y 00 0 10 1 +
31. 31. a = 1 b = 0 ∨ ba = y 00 0 10 1 +
32. 32. a = 1 b = 0 y = 1 ∨ ba = y 00 0 10 1 01 1 +
33. 33. a = 1 b = 1 ∨ ba = y 00 0 10 1 01 1 +
34. 34. a = 1 b = 1 y = 1 ∨ ba = y 00 0 10 1 01 1 11 1 +
35. 35. a = 0 b = x ∨ ba = y 00 0 10 1 01 1 11 1 +
36. 36. a = 0 b = x y = x ∨ ba = y 00 0 10 1 01 1 11 1 x0 x +
37. 37. a = 1 b = x ∨ ba = y 00 0 10 1 01 1 11 1 x0 x +
38. 38. a = 1 b = x y = 1 ∨ ba = y 00 0 10 1 01 1 11 1 x0 x x1 1 +
39. 39. a = x b = x ∨ ba = y 00 0 10 1 01 1 11 1 x0 x x1 1 +
40. 40. a = x b = x y = x ∨ ba = y 00 0 10 1 01 1 11 1 x0 x x1 1 xx x +
41. 41. ∨ ba = y 00 0 10 1 01 1 11 1 ∧ ba = y 00 0 10 0 01 0 11 1 Conjunction (AND) Disjunction (OR)
42. 42. ∨ ba = y 00 0 10 1 01 1 11 1 ∧ ba = y 00 0 10 0 01 0 11 1 ? Conjunction (AND) Disjunction (OR)
43. 43. a = 0
44. 44. a = 0 y = 1 a =¬ y 0 1
45. 45. a = 1 a =¬ y 0 1
46. 46. a = 1 y = 0 a =¬ y 0 1 1 0
47. 47. ∨ ba = y 00 0 10 1 01 1 11 1 ∧ ba = y 00 0 10 0 01 0 11 1 a =¬ y 0 1 1 0 Conjunction (AND) Disjunction (OR) Negation (NOT)
48. 48. ¬ a a ∧ b a ∨ b
49. 49. - a a * b a + b ¬ a a ∧ b a ∨ b
50. 50. - a a * b a + b ¬ a a ∧ b a ∨ b ! a a & b a | b
51. 51. - a a * b a + b ¬ a a ∧ b a ∨ b ! a a & b a | b NOT OR AND
52. 52. - a a * b a + b ¬ a a ∧ b a ∨ b ! a a & b a | b NOT OR AND
53. 53. a ∧ 1 = a a ∨ 0 = a Neutral elements
54. 54. a ∧ 1 = a a ∨ 0 = a Neutral elements a ∧ 0 = 0 a ∨ 1 = 1 Zero elements
55. 55. a ∧ 1 = a a ∨ 0 = a Neutral elements a ∧ 0 = 0 a ∨ 1 = 1 Zero elements a ∧ a = a a ∨ a = a Idempotence
56. 56. a ∧ 1 = a a ∨ 0 = a Neutral elements a ∧ 0 = 0 a ∨ 1 = 1 Zero elements a ∧ a = a a ∨ a = a Idempotence a ∧ ¬ a = 0 a ∨ ¬ a = 1 Negation
57. 57. a ∧ 1 = a a ∨ 0 = a Neutral elements a ∧ 0 = 0 a ∨ 1 = 1 Zero elements a ∧ a = a a ∨ a = a Idempotence a ∧ ¬ a = 0 a ∨ ¬ a = 1 Negation a ∨ b = b ∨ a a ∧ b = b ∧ a Commutativity
58. 58. a ∧ 1 = a a ∨ 0 = a Neutral elements a ∧ 0 = 0 a ∨ 1 = 1 Zero elements a ∧ a = a a ∨ a = a Idempotence a ∧ ¬ a = 0 a ∨ ¬ a = 1 Negation a ∨ b = b ∨ a a ∧ b = b ∧ a Commutativity a ∧ (b ∧ c) = (a ∧ b) ∧ c a ∨ (b ∨ c) = (a ∨ b) ∨ c Associativity
59. 59. a ∧ 1 = a a ∨ 0 = a Neutral elements a ∧ 0 = 0 a ∨ 1 = 1 Zero elements a ∧ a = a a ∨ a = a Idempotence a ∧ ¬ a = 0 a ∨ ¬ a = 1 Negation a ∨ b = b ∨ a a ∧ b = b ∧ a Commutativity a ∧ (b ∧ c) = (a ∧ b) ∧ c a ∨ (b ∨ c) = (a ∨ b) ∨ c Associativity a ∧ (b ∨ c) = (a ∧ b) ∨ (a ∧ c) a ∨ (b ∧ c) = (a ∨ b) ∧ (a ∨ c) Distributivity
60. 60. De Morgan (1806 – 1871) ¬ (a ∧ b) = (¬ a) ∨ (¬ b) ¬ (a ∨ b) = (¬ a) ∧ (¬ b) DeMorgan’s laws NAND NOR
61. 61. De Morgan (1806 – 1871) ¬ (a ∧ b) = (¬ a) ∨ (¬ b) ¬ (a ∨ b) = (¬ a) ∧ (¬ b) a b a ∨ b ¬ (a ∨ b) ¬ a ¬ b (¬ a) ∧ (¬ b) 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 0 DeMorgan’s laws NAND NOR
62. 62. De Morgan (1806 – 1871) ¬ (a ∧ b) = (¬ a) ∨ (¬ b) ¬ (a ∨ b) = (¬ a) ∧ (¬ b) a b a ∨ b ¬ (a ∨ b) ¬ a ¬ b (¬ a) ∧ (¬ b) 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 0 DeMorgan’s laws NAND NOR
63. 63. De Morgan (1806 – 1871) ¬ (a ∧ b) = (¬ a) ∨ (¬ b) ¬ (a ∨ b) = (¬ a) ∧ (¬ b) a b a ∨ b ¬ (a ∨ b) ¬ a ¬ b (¬ a) ∧ (¬ b) 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 0 DeMorgan’s laws NAND NOR
64. 64. De Morgan (1806 – 1871) ¬ (a ∧ b) = (¬ a) ∨ (¬ b) ¬ (a ∨ b) = (¬ a) ∧ (¬ b) a b a ∨ b ¬ (a ∨ b) ¬ a ¬ b (¬ a) ∧ (¬ b) 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 0 DeMorgan’s laws NAND NOR
65. 65. De Morgan (1806 – 1871) ¬ (a ∧ b) = (¬ a) ∨ (¬ b) ¬ (a ∨ b) = (¬ a) ∧ (¬ b) a b a ∨ b ¬ (a ∨ b) ¬ a ¬ b (¬ a) ∧ (¬ b) 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 0 DeMorgan’s laws NAND NOR
66. 66. De Morgan (1806 – 1871) ¬ (a ∧ b) = (¬ a) ∨ (¬ b) ¬ (a ∨ b) = (¬ a) ∧ (¬ b) a b a ∨ b ¬ (a ∨ b) ¬ a ¬ b (¬ a) ∧ (¬ b) 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 0 DeMorgan’s laws NAND NOR
67. 67. De Morgan (1806 – 1871) ¬ (a ∧ b) = (¬ a) ∨ (¬ b) ¬ (a ∨ b) = (¬ a) ∧ (¬ b) a b a ∨ b ¬ (a ∨ b) ¬ a ¬ b (¬ a) ∧ (¬ b) 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 0 DeMorgan’s laws NAND NOR
68. 68. a ∧ 1 = a a ∨ b = b ∨ a a ∨ 0 = a a ∧ 0 = 0 a ∨ 1 = 1 a ∧ a = a a ∨ a = a a ∧ ¬ a = 0 a ∨ ¬ a = 1 Neutral elements Zero elements Idempotence Negation a ∧ (b ∧ c) = (a ∧ b) ∧ c a ∧ b = b ∧ a a ∨ (b ∨ c) = (a ∨ b) ∨ c a ∧ (b ∨ c) = (a ∧ b) ∨ (a ∧ c) a ∨ (b ∧ c) = (a ∨ b) ∧ (a ∨ c) ¬ (a ∧ b) = (¬ a) ∨ (¬ b) ¬ (a ∨ b) = (¬ a) ∧ (¬ b) Commutativity Associativity Distributivity DeMorgan’s
69. 69. ≠ ba = y 00 0 10 1 01 1 11 0 Exclusive OR (XOR)
70. 70. ≠ ba = y 00 0 10 1 01 1 11 0 Exclusive OR (XOR) ba = y 00 1 10 1 01 0 11 1 Implication
71. 71. ≠ ba = y 00 0 10 1 01 1 11 0 Exclusive OR (XOR) ba = y 00 1 10 1 01 0 11 1 ba = y 00 1 10 0 01 0 11 1 Implication Equivalence
72. 72. ≠ ba = y 00 0 10 1 01 1 11 0 Exclusive OR (XOR) ba = y 00 1 10 1 01 0 11 1 ba = y 00 1 10 0 01 0 11 1 Implication Equivalence ∨ ba = y 00 0 10 1 01 1 11 1 ∧ ba = y 00 0 10 0 01 0 11 1 Conjunction (AND) Disjunction (OR) a =¬ y 0 1 1 0 Negation (NOT)
73. 73. ≠ ba = y 00 0 10 1 01 1 11 0 Exclusive OR (XOR) ba = y 00 1 10 1 01 0 11 1 ba = y 00 1 10 0 01 0 11 1 Implication Equivalence ∨ ba = y 00 0 10 1 01 1 11 1 ∧ ba = y 00 0 10 0 01 0 11 1 Conjunction (AND) Disjunction (OR) a =¬ y 0 1 1 0 Negation (NOT) 4 3 3 3 2 1
74. 74. Tautology f = 1 (a ∧ (a b)) b Contradiction f = 0 a ∧ (¬ a) Satisﬁable f = 1 sometimes a b
75. 75. How many basic boolean functions with 2 parameters are possible?
76. 76. How many basic boolean functions with 2 parameters are possible?
77. 77. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
78. 78. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
79. 79. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
80. 80. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
81. 81. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
82. 82. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
83. 83. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
84. 84. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
85. 85. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
86. 86. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
87. 87. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
88. 88. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
89. 89. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
90. 90. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
91. 91. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
92. 92. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
93. 93. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
94. 94. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible?
95. 95. 0011 0101 a b 0000 y0 = 0 0001 y1 = a ∧ b 0010 y2 = a ∧ ¬ b 0011 y3 = a 0100 y4 = ¬ a ∧ b 0101 y5 = b 0110 y6 = a ≠ b 0111 y7 = a ∨ b How many basic boolean functions with 2 parameters are possible? 0011 0101 a b 1111 y15 = 1 1110 y14 = ¬ a ∨ ¬ b 1101 y13 = ¬ a ∨ b 1100 y12 = ¬ a 1011 y11 = a ∨ ¬ b 1010 y10 = ¬ b 1001 y9 = a b 1000 y8 = ¬ a ∧ ¬ b
96. 96. How to create a half adder?
97. 97. How to create a half adder? + ba = co 00 0 10 0 01 0 11 1 q 0 1 1 0
98. 98. How to create a half adder? a b q co + ba = co 00 0 10 0 01 0 11 1 q 0 1 1 0 AND XOR
99. 99. How to create a full adder?
100. 100. How to create a full adder? + ba = co 00 0 10 0 01 0 11 1 q 0 1 1 0 ci + 0 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1
101. 101. How to create a full adder? + ba = co 00 0 10 0 01 0 11 1 q 0 1 1 0 ci + 0 0 0 0 1 1 1 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 Full adder a b coci q
102. 102. How to create a full adder? Full adder a b coci q
103. 103. How to create a full adder? Full adder a b coci q Full adder a b coci q Full adder a b coci q
104. 104. Tudor Gîrba www.tudorgirba.com creativecommons.org/licenses/by/3.0/