Post on 27-Jun-2020
CSE 311 Lecture 04: Boolean AlgebraEmina Torlak and Kevin Zatloukal
1
TopicsEquivalence and proofs
A brief review of .Boolean algebra
A notation for combinational circuits.Simplification and proofs
Optimizing circuits and proving theorems.
Lecture 03
2
Equivalence and proofsA brief review of .Lecture 03
3
Equivalence via truth tables and proofs is an assertion that two propositions and have the same
truth values in all possible cases.
and have the same meaning.
Checking equivalence has many real-world applications.Verification, optimization, and more!
There are two ways to check equivalence of propositional formulas.Brute-force: compare their truth tables.Proof-based: apply equivalences to transform one into the other.
A ≡ B A B
A ≡ B (A ↔ B) ≡ # $%&$'(')*
4
Boolean algebraA notation for combinational circuits.
5
Recall the relationship between logic and circuits …Digital circuits implement propositional logic:
corresponds to 1 or high voltage. corresponds to 0 or low voltage.
Digital circuits are functions that
take values 0/1 as inputs and produce 0/1 as output;, where is built out of wires and gates; and
every bit of output is computed from some bits of the input.
#+
out = F(input) F
6
Recall the relationship between logic and circuits …Digital circuits implement propositional logic:
corresponds to 1 or high voltage. corresponds to 0 or low voltage.
Digital circuits are functions that
take values 0/1 as inputs and produce 0/1 as output;, where is built out of wires and gates; and
every bit of output is computed from some bits of the input.
#+
out = F(input) F
We call these types of digital circuits combinational logic circuits.There are other kinds of digital circuits (called sequential circuits) butwe’ll focus on combinational circuits in this course.
6
Boolean algebra is a notation for combinational logicThink of it as a notation for propositional logic used in circuit design.
Boolean algebra consists of the following elements and operations:
a set of elements ,binary operations ,a unary operation .
B = {0, 1}{+, ⋅}{ }′
These correspond to the truthvalues , and the logicalconnectives .
{+, #}∨, ∧, ¬
7
Boolean algebra is a notation for combinational logicThink of it as a notation for propositional logic used in circuit design.
Boolean algebra consists of the following elements and operations:
a set of elements ,binary operations ,a unary operation .
Boolean operations satisfy the following axioms for any :
Closure
Commutativity
Associativity
Distributivity
Identity
Complementarity
Null
Idempotency
Involution
B = {0, 1}{+, ⋅}{ }′
These correspond to the truthvalues , and the logicalconnectives .
{+, #}∨, ∧, ¬
a, b, c ∈ B
a + b ∈ Ba ⋅ b ∈ B
a + b = b + aa ⋅ b = b ⋅ a
a + (b + c) = (a + b) + ca ⋅ (b ⋅ c) = (a ⋅ b) ⋅ c
a + (b ⋅ c) = (a + b) ⋅ (a + c)a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c)
a + 0 = aa ⋅ 1 = a
a + = 1a′
a ⋅ = 0a′
a + 1 = 1a ⋅ 0 = 0
a + a = aa ⋅ a = a
( = aa′)′
7
Example: from spec to code to logic to circuitsSuppose that we want to compute the number of lectures or sectionsremaining at the start of a given day of the week.
8
Example: from spec to code to logic to circuitsSuppose that we want to compute the number of lectures or sectionsremaining at the start of a given day of the week.
The function for this computation has the following signature:
Inputs: day of the week (integers from 0 to 6), lecture flag (boolean).Output: number of sessions le! (integer from 0 to 3).
8
Example: from spec to code to logic to circuitsSuppose that we want to compute the number of lectures or sectionsremaining at the start of a given day of the week.
The function for this computation has the following signature:
Inputs: day of the week (integers from 0 to 6), lecture flag (boolean).Output: number of sessions le! (integer from 0 to 3).
Here are some examples of the function’s input/output behavior:
Input: (Wednesday, Lecture), Output: 2Input: (Monday, Section), Output: 1
How would you implement this function in Java?
8
From spec to …codepublic class Sessions {
public static int classesLeft(int day, boolean lecture) { switch (day) { case 0: // SUNDAY case 1: // MONDAY return lecture ? 3 : 1; case 2: // TUESDAY case 3: // WEDNESDAY return lecture ? 2 : 1; case 4: // THURSDAY return lecture ? 1 : 1; case 5: // FRIDAY return lecture ? 1 : 0; default: //case 6: // SATURDAY return lecture ? 0 : 0; } }
public static void main(String []args){ System.out.println("(W, L) -> " + classesLeft(3,true)); System.out.println("(M, S) -> " + classesLeft(1,false)); }}
9
From spec to …
Suppose that we need this function run really fast …
codepublic class Sessions {
public static int classesLeft(int day, boolean lecture) { switch (day) { case 0: // SUNDAY case 1: // MONDAY return lecture ? 3 : 1; case 2: // TUESDAY case 3: // WEDNESDAY return lecture ? 2 : 1; case 4: // THURSDAY return lecture ? 1 : 1; case 5: // FRIDAY return lecture ? 1 : 0; default: //case 6: // SATURDAY return lecture ? 0 : 0; } }
public static void main(String []args){ System.out.println("(W, L) -> " + classesLeft(3,true)); System.out.println("(M, S) -> " + classesLeft(1,false)); }}
9
From spec to …
Suppose that we need this function run really fast … To do that, we’llimplement a custom circuit (hardware accelerator!).
codepublic class Sessions {
public static int classesLeft(int day, boolean lecture) { switch (day) { case 0: // SUNDAY case 1: // MONDAY return lecture ? 3 : 1; case 2: // TUESDAY case 3: // WEDNESDAY return lecture ? 2 : 1; case 4: // THURSDAY return lecture ? 1 : 1; case 5: // FRIDAY return lecture ? 1 : 0; default: //case 6: // SATURDAY return lecture ? 0 : 0; } }
public static void main(String []args){ System.out.println("(W, L) -> " + classesLeft(3,true)); System.out.println("(M, S) -> " + classesLeft(1,false)); }}
9
From code to combinational logic …Recall the signature of our function:
Inputs: day of the week (integers from 0 to 6), lecture flag (boolean).Output: number of sessions le! (integer from 0 to 3).
How many bits for each input/output?
10
From code to combinational logic …Recall the signature of our function:
Inputs: day of the week (integers from 0 to 6), lecture flag (boolean).Output: number of sessions le! (integer from 0 to 3).
How many bits for each input/output?
Inputs: 3 bits for day of the week, 1 bit for the lecture flag.Output: 2 bits for the number of sessions le!.
day lecture
count
d 2 d 1 Ld 0c1 c 0
10
From code to combinational logic via a truth table
day lecture
count
d 2 d 1 Ld 0c1 c 0
DaySUN 000 0SUN 000 1MON 001 0MON 001 1TUE 010 0TUE 010 1WED 011 0WED 011 1THU 100 0THU 100 1FRI 101 0FRI 101 1SAT 110 0SAT 110 1
- 111 0- 111 1
switch (day) { case 0: // SUNDAY case 1: // MONDAY return lecture ? 3 : 1; case 2: // TUESDAY case 3: // WEDNESDAY return lecture ? 2 : 1; case 4: // THURSDAY return lecture ? 1 : 1; case 5: // FRIDAY return lecture ? 1 : 0; default: // SATURDAY etc. return lecture ? 0 : 0;}
d2d1d0 L c1c0
11
From code to combinational logic via a truth table
day lecture
count
d 2 d 1 Ld 0c1 c 0
DaySUN 000 0 01SUN 000 1 11MON 001 0MON 001 1TUE 010 0TUE 010 1WED 011 0WED 011 1THU 100 0THU 100 1FRI 101 0FRI 101 1SAT 110 0SAT 110 1
- 111 0- 111 1
switch (day) { case 0: // SUNDAY case 1: // MONDAY return lecture ? 3 : 1; case 2: // TUESDAY case 3: // WEDNESDAY return lecture ? 2 : 1; case 4: // THURSDAY return lecture ? 1 : 1; case 5: // FRIDAY return lecture ? 1 : 0; default: // SATURDAY etc. return lecture ? 0 : 0;}
d2d1d0 L c1c0
11
From code to combinational logic via a truth table
day lecture
count
d 2 d 1 Ld 0c1 c 0
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0TUE 010 1WED 011 0WED 011 1THU 100 0THU 100 1FRI 101 0FRI 101 1SAT 110 0SAT 110 1
- 111 0- 111 1
switch (day) { case 0: // SUNDAY case 1: // MONDAY return lecture ? 3 : 1; case 2: // TUESDAY case 3: // WEDNESDAY return lecture ? 2 : 1; case 4: // THURSDAY return lecture ? 1 : 1; case 5: // FRIDAY return lecture ? 1 : 0; default: // SATURDAY etc. return lecture ? 0 : 0;}
d2d1d0 L c1c0
11
From code to combinational logic via a truth table
day lecture
count
d 2 d 1 Ld 0c1 c 0
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0WED 011 1THU 100 0THU 100 1FRI 101 0FRI 101 1SAT 110 0SAT 110 1
- 111 0- 111 1
switch (day) { case 0: // SUNDAY case 1: // MONDAY return lecture ? 3 : 1; case 2: // TUESDAY case 3: // WEDNESDAY return lecture ? 2 : 1; case 4: // THURSDAY return lecture ? 1 : 1; case 5: // FRIDAY return lecture ? 1 : 0; default: // SATURDAY etc. return lecture ? 0 : 0;}
d2d1d0 L c1c0
11
From code to combinational logic via a truth table
day lecture
count
d 2 d 1 Ld 0c1 c 0
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0THU 100 1FRI 101 0FRI 101 1SAT 110 0SAT 110 1
- 111 0- 111 1
switch (day) { case 0: // SUNDAY case 1: // MONDAY return lecture ? 3 : 1; case 2: // TUESDAY case 3: // WEDNESDAY return lecture ? 2 : 1; case 4: // THURSDAY return lecture ? 1 : 1; case 5: // FRIDAY return lecture ? 1 : 0; default: // SATURDAY etc. return lecture ? 0 : 0;}
d2d1d0 L c1c0
11
From code to combinational logic via a truth table
day lecture
count
d 2 d 1 Ld 0c1 c 0
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0FRI 101 1SAT 110 0SAT 110 1
- 111 0- 111 1
switch (day) { case 0: // SUNDAY case 1: // MONDAY return lecture ? 3 : 1; case 2: // TUESDAY case 3: // WEDNESDAY return lecture ? 2 : 1; case 4: // THURSDAY return lecture ? 1 : 1; case 5: // FRIDAY return lecture ? 1 : 0; default: // SATURDAY etc. return lecture ? 0 : 0;}
d2d1d0 L c1c0
11
From code to combinational logic via a truth table
day lecture
count
d 2 d 1 Ld 0c1 c 0
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0SAT 110 1
- 111 0- 111 1
switch (day) { case 0: // SUNDAY case 1: // MONDAY return lecture ? 3 : 1; case 2: // TUESDAY case 3: // WEDNESDAY return lecture ? 2 : 1; case 4: // THURSDAY return lecture ? 1 : 1; case 5: // FRIDAY return lecture ? 1 : 0; default: // SATURDAY etc. return lecture ? 0 : 0;}
d2d1d0 L c1c0
11
From code to combinational logic via a truth table
day lecture
count
d 2 d 1 Ld 0c1 c 0
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0- 111 1
switch (day) { case 0: // SUNDAY case 1: // MONDAY return lecture ? 3 : 1; case 2: // TUESDAY case 3: // WEDNESDAY return lecture ? 2 : 1; case 4: // THURSDAY return lecture ? 1 : 1; case 5: // FRIDAY return lecture ? 1 : 0; default: // SATURDAY etc. return lecture ? 0 : 0;}
d2d1d0 L c1c0
11
From code to combinational logic via a truth table
day lecture
count
d 2 d 1 Ld 0c1 c 0
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0 00- 111 1 00
switch (day) { case 0: // SUNDAY case 1: // MONDAY return lecture ? 3 : 1; case 2: // TUESDAY case 3: // WEDNESDAY return lecture ? 2 : 1; case 4: // THURSDAY return lecture ? 1 : 1; case 5: // FRIDAY return lecture ? 1 : 0; default: // SATURDAY etc. return lecture ? 0 : 0;}
d2d1d0 L c1c0
11
From code to combinational logic via a truth table:
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0 00- 111 1 00
To find an expression for , look at the rows where .
==000 && L==1
==001 && L==1
==010 && L==1
==011 && L==1
c1
d2d1d0 L c1c0 c1 = 1c1
d2d1d0d2d1d0d2d1d0d2d1d0
12
From code to combinational logic via a truth table:
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0 00- 111 1 00
To find an expression for , look at the rows where .
==000 && L==1
==001 && L==1
==010 && L==1
==011 && L==1
Split up the bits of the day to get a formula for each row.
==0 && ==0 && ==0 && L==1
==0 && ==0 && ==1 && L==1
==0 && ==1 && ==0 && L==1
==0 && ==1 && ==1 && L==1
c1
d2d1d0 L c1c0 c1 = 1c1
d2d1d0d2d1d0d2d1d0d2d1d0
d2 d1 d0d2 d1 d0d2 d1 d0d2 d1 d0
12
From code to combinational logic via a truth table:
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0 00- 111 1 00
To find an expression for , look at the rows where .
==000 && L==1
==001 && L==1
==010 && L==1
==011 && L==1
Split up the bits of the day to get a formula for each row.
==0 && ==0 && ==0 && L==1
==0 && ==0 && ==1 && L==1
==0 && ==1 && ==0 && L==1
==0 && ==1 && ==1 && L==1
Translate to Boolean algebra to get an expression for .
c1
d2d1d0 L c1c0 c1 = 1c1
d2d1d0d2d1d0d2d1d0d2d1d0
d2 d1 d0d2 d1 d0d2 d1 d0d2 d1 d0
c1
⋅ ⋅ ⋅ Ld ′2 d ′
1 d ′0
⋅ ⋅ ⋅ Ld ′2 d ′
1 d0⋅ ⋅ ⋅ Ld ′
2 d1 d ′0
⋅ ⋅ ⋅ Ld ′2 d1 d0
12
From code to combinational logic via a truth table:
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0 00- 111 1 00
To find an expression for , look at the rows where .
==000 && L==1
==001 && L==1
==010 && L==1
==011 && L==1
Split up the bits of the day to get a formula for each row.
==0 && ==0 && ==0 && L==1
==0 && ==0 && ==1 && L==1
==0 && ==1 && ==0 && L==1
==0 && ==1 && ==1 && L==1
Translate to Boolean algebra to get an expression for .
c1
d2d1d0 L c1c0 c1 = 1c1
d2d1d0d2d1d0d2d1d0d2d1d0
d2 d1 d0d2 d1 d0d2 d1 d0d2 d1 d0
c1
⋅ ⋅ ⋅ Ld ′2 d ′
1 d ′0
⋅ ⋅ ⋅ Ld ′2 d ′
1 d0⋅ ⋅ ⋅ Ld ′
2 d1 d ′0
⋅ ⋅ ⋅ Ld ′2 d1 d0
=c1 ⋅ ⋅ ⋅ L +d ′2 d ′
1 d ′0
⋅ ⋅ ⋅ L +d ′2 d ′
1 d0⋅ ⋅ ⋅ L +d ′
2 d1 d ′0
⋅ ⋅ ⋅ Ld ′2 d1 d0
12
From code to combinational logic via a truth table:
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0 00- 111 1 00
Now we repeat this process to get .
c0
d2d1d0 L c1c0=c1 ⋅ ⋅ ⋅ L +d ′
2 d ′1 d ′
0⋅ ⋅ ⋅ L +d ′
2 d ′1 d0
⋅ ⋅ ⋅ L +d ′2 d1 d ′
0⋅ ⋅ ⋅ Ld ′
2 d1 d0
c0
=c0
13
From code to combinational logic via a truth table:
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0 00- 111 1 00
Now we repeat this process to get .
c0
d2d1d0 L c1c0=c1 ⋅ ⋅ ⋅ L +d ′
2 d ′1 d ′
0⋅ ⋅ ⋅ L +d ′
2 d ′1 d0
⋅ ⋅ ⋅ L +d ′2 d1 d ′
0⋅ ⋅ ⋅ Ld ′
2 d1 d0
c0
=c0 ⋅ ⋅ ⋅ +d ′2 d ′
1 d ′0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d ′0
13
From code to combinational logic via a truth table:
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0 00- 111 1 00
Now we repeat this process to get .
c0
d2d1d0 L c1c0=c1 ⋅ ⋅ ⋅ L +d ′
2 d ′1 d ′
0⋅ ⋅ ⋅ L +d ′
2 d ′1 d0
⋅ ⋅ ⋅ L +d ′2 d1 d ′
0⋅ ⋅ ⋅ Ld ′
2 d1 d0
c0
=c0 ⋅ ⋅ ⋅ +d ′2 d ′
1 d ′0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d ′0
⋅ ⋅ ⋅ +d ′2 d ′
1 d0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d0
13
From code to combinational logic via a truth table:
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0 00- 111 1 00
Now we repeat this process to get .
c0
d2d1d0 L c1c0=c1 ⋅ ⋅ ⋅ L +d ′
2 d ′1 d ′
0⋅ ⋅ ⋅ L +d ′
2 d ′1 d0
⋅ ⋅ ⋅ L +d ′2 d1 d ′
0⋅ ⋅ ⋅ Ld ′
2 d1 d0
c0
=c0 ⋅ ⋅ ⋅ +d ′2 d ′
1 d ′0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d ′0
⋅ ⋅ ⋅ +d ′2 d ′
1 d0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d0⋅ ⋅ ⋅ +d ′
2 d1 d ′0 L ′
13
From code to combinational logic via a truth table:
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0 00- 111 1 00
Now we repeat this process to get .
c0
d2d1d0 L c1c0=c1 ⋅ ⋅ ⋅ L +d ′
2 d ′1 d ′
0⋅ ⋅ ⋅ L +d ′
2 d ′1 d0
⋅ ⋅ ⋅ L +d ′2 d1 d ′
0⋅ ⋅ ⋅ Ld ′
2 d1 d0
c0
=c0 ⋅ ⋅ ⋅ +d ′2 d ′
1 d ′0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d ′0
⋅ ⋅ ⋅ +d ′2 d ′
1 d0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d0⋅ ⋅ ⋅ +d ′
2 d1 d ′0 L ′
⋅ ⋅ ⋅ +d ′2 d1 d0 L ′
13
From code to combinational logic via a truth table:
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0 00- 111 1 00
Now we repeat this process to get .
c0
d2d1d0 L c1c0=c1 ⋅ ⋅ ⋅ L +d ′
2 d ′1 d ′
0⋅ ⋅ ⋅ L +d ′
2 d ′1 d0
⋅ ⋅ ⋅ L +d ′2 d1 d ′
0⋅ ⋅ ⋅ Ld ′
2 d1 d0
c0
=c0 ⋅ ⋅ ⋅ +d ′2 d ′
1 d ′0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d ′0
⋅ ⋅ ⋅ +d ′2 d ′
1 d0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d0⋅ ⋅ ⋅ +d ′
2 d1 d ′0 L ′
⋅ ⋅ ⋅ +d ′2 d1 d0 L ′
⋅ ⋅ ⋅ +d2 d ′1 d ′
0 L ′
⋅ ⋅ ⋅ L +d2 d ′1 d ′
0
13
From code to combinational logic via a truth table:
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0 00- 111 1 00
Now we repeat this process to get .
c0
d2d1d0 L c1c0=c1 ⋅ ⋅ ⋅ L +d ′
2 d ′1 d ′
0⋅ ⋅ ⋅ L +d ′
2 d ′1 d0
⋅ ⋅ ⋅ L +d ′2 d1 d ′
0⋅ ⋅ ⋅ Ld ′
2 d1 d0
c0
=c0 ⋅ ⋅ ⋅ +d ′2 d ′
1 d ′0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d ′0
⋅ ⋅ ⋅ +d ′2 d ′
1 d0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d0⋅ ⋅ ⋅ +d ′
2 d1 d ′0 L ′
⋅ ⋅ ⋅ +d ′2 d1 d0 L ′
⋅ ⋅ ⋅ +d2 d ′1 d ′
0 L ′
⋅ ⋅ ⋅ L +d2 d ′1 d ′
0⋅ ⋅ ⋅ Ld2 d ′
1 d0
13
From combinational logic to circuits
Here is as a circuit …
d 2
d 1
L
d 0 c1
=c0 ⋅ ⋅ ⋅ +d ′2 d ′
1 d ′0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d ′0
⋅ ⋅ ⋅ +d ′2 d ′
1 d0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d0⋅ ⋅ ⋅ +d ′
2 d1 d ′0 L ′
⋅ ⋅ ⋅ +d ′2 d1 d0 L ′
⋅ ⋅ ⋅ +d2 d ′1 d ′
0 L ′
⋅ ⋅ ⋅ L +d2 d ′1 d ′
0⋅ ⋅ ⋅ Ld2 d ′
1 d0
=c1 ⋅ ⋅ ⋅ L +d ′2 d ′
1 d ′0
⋅ ⋅ ⋅ L +d ′2 d ′
1 d0⋅ ⋅ ⋅ L +d ′
2 d1 d ′0
⋅ ⋅ ⋅ Ld ′2 d1 d0
c1
14
What can we do with the logic encoding?
Create hardware implementations!
And perform program verification …
Example: verify that classesLeftreturns 3 only if lecture is true.
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0 00- 111 1 00
=c0 ⋅ ⋅ ⋅ +d ′2 d ′
1 d ′0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d ′0
⋅ ⋅ ⋅ +d ′2 d ′
1 d0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d0⋅ ⋅ ⋅ +d ′
2 d1 d ′0 L ′
⋅ ⋅ ⋅ +d ′2 d1 d0 L ′
⋅ ⋅ ⋅ +d2 d ′1 d ′
0 L ′
⋅ ⋅ ⋅ L +d2 d ′1 d ′
0⋅ ⋅ ⋅ Ld2 d ′
1 d0
=c1 ⋅ ⋅ ⋅ L +d ′2 d ′
1 d ′0
⋅ ⋅ ⋅ L +d ′2 d ′
1 d0⋅ ⋅ ⋅ L +d ′
2 d1 d ′0
⋅ ⋅ ⋅ Ld ′2 d1 d0
d2d1d0 L c1c0
15
What can we do with the logic encoding?
Create hardware implementations!
And perform program verification …
Example: verify that classesLeftreturns 3 only if lecture is true.
Check that .
DaySUN 000 0 01SUN 000 1 11MON 001 0 01MON 001 1 11TUE 010 0 01TUE 010 1 10WED 011 0 01WED 011 1 10THU 100 0 01THU 100 1 01FRI 101 0 00FRI 101 1 01SAT 110 0 00SAT 110 1 00
- 111 0 00- 111 1 00
∧ → L ≡ #c1 c0
=c0 ⋅ ⋅ ⋅ +d ′2 d ′
1 d ′0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d ′0
⋅ ⋅ ⋅ +d ′2 d ′
1 d0 L ′
⋅ ⋅ ⋅ L +d ′2 d ′
1 d0⋅ ⋅ ⋅ +d ′
2 d1 d ′0 L ′
⋅ ⋅ ⋅ +d ′2 d1 d0 L ′
⋅ ⋅ ⋅ +d2 d ′1 d ′
0 L ′
⋅ ⋅ ⋅ L +d2 d ′1 d ′
0⋅ ⋅ ⋅ Ld2 d ′
1 d0
=c1 ⋅ ⋅ ⋅ L +d ′2 d ′
1 d ′0
⋅ ⋅ ⋅ L +d ′2 d ′
1 d0⋅ ⋅ ⋅ L +d ′
2 d1 d ′0
⋅ ⋅ ⋅ Ld ′2 d1 d0
d2d1d0 L c1c0
15
Simplification and proofsOptimizing circuits and proving theorems.
16
So far, we’ve used the basics of Boolean algebra …Boolean algebra consists of the following elements and operations:
a set of elements ,binary operations ,a unary operation .
Boolean operations satisfy the following axioms for any :
Closure
Commutativity
Associativity
Distributivity
Identity
Complementarity
Null
Idempotency
Involution
B = {0, 1}{+, ⋅}{ }′
These correspond to the truthvalues , and the logicalconnectives .
{+, #}∨, ∧, ¬
a, b, c ∈ B
a + b ∈ Ba ⋅ b ∈ B
a + b = b + aa ⋅ b = b ⋅ a
a + (b + c) = (a + b) + ca ⋅ (b ⋅ c) = (a ⋅ b) ⋅ c
a + (b ⋅ c) = (a + b) ⋅ (a + c)a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c)
a + 0 = aa ⋅ 1 = a
a + = 1a′
a ⋅ = 0a′
a + 1 = 1a ⋅ 0 = 0
a + a = aa ⋅ a = a
( = aa′)′
17
We can use the basics to prove some useful theoremsUniting
Absorption
Factoring
Consensus
DeMorgan’s
a ⋅ b + a ⋅ = ab′
(a + b) ⋅ (a + ) = ab′
a + a ⋅ b = aa ⋅ (a + b) = a(a + ) ⋅ b = a ⋅ bb′
(a ⋅ ) + b = a + bb′
(a + b) ⋅ ( + c) = a ⋅ c + ⋅ ba′ a′
a ⋅ b + ⋅ c = (a + c) ⋅ ( + b)a′ a′
(a ⋅ b) + (b ⋅ c) + ( ⋅ c) = a ⋅ b + ⋅ ca′ a′
(a + b) ⋅ (b + c) ⋅ ( + c) = (a + b) ⋅ ( + c)a′ a′
(a + b + … = ⋅ ⋅ …)′ a′ b′
(a ⋅ b ⋅ … = + + …)′ a′ b′
18
Example: proving theorems using the axioms
Uniting
Absorption
Closure
Commutativity
Associativity
Distributivity
Identity
Complementarity
Null
Idempotency
Involution
X ⋅ Y + X ⋅ Y ′ === X
X + X ⋅ Y ===== X
a + b ∈ Ba ⋅ b ∈ B
a + b = b + aa ⋅ b = b ⋅ a
a + (b + c) = (a + b) + ca ⋅ (b ⋅ c) = (a ⋅ b) ⋅ c
a + (b ⋅ c) = (a + b) ⋅ (a + c)a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c)
a + 0 = aa ⋅ 1 = a
a + = 1a′
a ⋅ = 0a′
a + 1 = 1a ⋅ 0 = 0
a + a = aa ⋅ a = a
( = aa′)′
19
Example: proving theorems using the axioms
Uniting Distributivity
Absorption
Closure
Commutativity
Associativity
Distributivity
Identity
Complementarity
Null
Idempotency
Involution
X ⋅ Y + X ⋅ Y ′ = X ⋅ (Y + )Y ′
== X
X + X ⋅ Y ===== X
a + b ∈ Ba ⋅ b ∈ B
a + b = b + aa ⋅ b = b ⋅ a
a + (b + c) = (a + b) + ca ⋅ (b ⋅ c) = (a ⋅ b) ⋅ c
a + (b ⋅ c) = (a + b) ⋅ (a + c)a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c)
a + 0 = aa ⋅ 1 = a
a + = 1a′
a ⋅ = 0a′
a + 1 = 1a ⋅ 0 = 0
a + a = aa ⋅ a = a
( = aa′)′
19
Example: proving theorems using the axioms
Uniting DistributivityComplementarity
Absorption
Closure
Commutativity
Associativity
Distributivity
Identity
Complementarity
Null
Idempotency
Involution
X ⋅ Y + X ⋅ Y ′ = X ⋅ (Y + )Y ′
= X ⋅ 1= X
X + X ⋅ Y ===== X
a + b ∈ Ba ⋅ b ∈ B
a + b = b + aa ⋅ b = b ⋅ a
a + (b + c) = (a + b) + ca ⋅ (b ⋅ c) = (a ⋅ b) ⋅ c
a + (b ⋅ c) = (a + b) ⋅ (a + c)a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c)
a + 0 = aa ⋅ 1 = a
a + = 1a′
a ⋅ = 0a′
a + 1 = 1a ⋅ 0 = 0
a + a = aa ⋅ a = a
( = aa′)′
19
Example: proving theorems using the axioms
Uniting DistributivityComplementarityIdentity
Absorption
Closure
Commutativity
Associativity
Distributivity
Identity
Complementarity
Null
Idempotency
Involution
X ⋅ Y + X ⋅ Y ′ = X ⋅ (Y + )Y ′
= X ⋅ 1= X
X + X ⋅ Y ===== X
a + b ∈ Ba ⋅ b ∈ B
a + b = b + aa ⋅ b = b ⋅ a
a + (b + c) = (a + b) + ca ⋅ (b ⋅ c) = (a ⋅ b) ⋅ c
a + (b ⋅ c) = (a + b) ⋅ (a + c)a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c)
a + 0 = aa ⋅ 1 = a
a + = 1a′
a ⋅ = 0a′
a + 1 = 1a ⋅ 0 = 0
a + a = aa ⋅ a = a
( = aa′)′
19
Example: proving theorems using the axioms
Uniting DistributivityComplementarityIdentity
Absorption Identity
Closure
Commutativity
Associativity
Distributivity
Identity
Complementarity
Null
Idempotency
Involution
X ⋅ Y + X ⋅ Y ′ = X ⋅ (Y + )Y ′
= X ⋅ 1= X
X + X ⋅ Y = X ⋅ 1 + X ⋅ Y==== X
a + b ∈ Ba ⋅ b ∈ B
a + b = b + aa ⋅ b = b ⋅ a
a + (b + c) = (a + b) + ca ⋅ (b ⋅ c) = (a ⋅ b) ⋅ c
a + (b ⋅ c) = (a + b) ⋅ (a + c)a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c)
a + 0 = aa ⋅ 1 = a
a + = 1a′
a ⋅ = 0a′
a + 1 = 1a ⋅ 0 = 0
a + a = aa ⋅ a = a
( = aa′)′
19
Example: proving theorems using the axioms
Uniting DistributivityComplementarityIdentity
Absorption IdentityDistributivity
Closure
Commutativity
Associativity
Distributivity
Identity
Complementarity
Null
Idempotency
Involution
X ⋅ Y + X ⋅ Y ′ = X ⋅ (Y + )Y ′
= X ⋅ 1= X
X + X ⋅ Y = X ⋅ 1 + X ⋅ Y= X ⋅ (1 + Y)=== X
a + b ∈ Ba ⋅ b ∈ B
a + b = b + aa ⋅ b = b ⋅ a
a + (b + c) = (a + b) + ca ⋅ (b ⋅ c) = (a ⋅ b) ⋅ c
a + (b ⋅ c) = (a + b) ⋅ (a + c)a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c)
a + 0 = aa ⋅ 1 = a
a + = 1a′
a ⋅ = 0a′
a + 1 = 1a ⋅ 0 = 0
a + a = aa ⋅ a = a
( = aa′)′
19
Example: proving theorems using the axioms
Uniting DistributivityComplementarityIdentity
Absorption IdentityDistributivityCommutativity
Closure
Commutativity
Associativity
Distributivity
Identity
Complementarity
Null
Idempotency
Involution
X ⋅ Y + X ⋅ Y ′ = X ⋅ (Y + )Y ′
= X ⋅ 1= X
X + X ⋅ Y = X ⋅ 1 + X ⋅ Y= X ⋅ (1 + Y)= X ⋅ (Y + 1)== X
a + b ∈ Ba ⋅ b ∈ B
a + b = b + aa ⋅ b = b ⋅ a
a + (b + c) = (a + b) + ca ⋅ (b ⋅ c) = (a ⋅ b) ⋅ c
a + (b ⋅ c) = (a + b) ⋅ (a + c)a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c)
a + 0 = aa ⋅ 1 = a
a + = 1a′
a ⋅ = 0a′
a + 1 = 1a ⋅ 0 = 0
a + a = aa ⋅ a = a
( = aa′)′
19
Example: proving theorems using the axioms
Uniting DistributivityComplementarityIdentity
Absorption IdentityDistributivityCommutativityNull
Closure
Commutativity
Associativity
Distributivity
Identity
Complementarity
Null
Idempotency
Involution
X ⋅ Y + X ⋅ Y ′ = X ⋅ (Y + )Y ′
= X ⋅ 1= X
X + X ⋅ Y = X ⋅ 1 + X ⋅ Y= X ⋅ (1 + Y)= X ⋅ (Y + 1)= X ⋅ 1= X
a + b ∈ Ba ⋅ b ∈ B
a + b = b + aa ⋅ b = b ⋅ a
a + (b + c) = (a + b) + ca ⋅ (b ⋅ c) = (a ⋅ b) ⋅ c
a + (b ⋅ c) = (a + b) ⋅ (a + c)a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c)
a + 0 = aa ⋅ 1 = a
a + = 1a′
a ⋅ = 0a′
a + 1 = 1a ⋅ 0 = 0
a + a = aa ⋅ a = a
( = aa′)′
19
Example: proving theorems using the axioms
Uniting DistributivityComplementarityIdentity
Absorption IdentityDistributivityCommutativityNullIdentity
Closure
Commutativity
Associativity
Distributivity
Identity
Complementarity
Null
Idempotency
Involution
X ⋅ Y + X ⋅ Y ′ = X ⋅ (Y + )Y ′
= X ⋅ 1= X
X + X ⋅ Y = X ⋅ 1 + X ⋅ Y= X ⋅ (1 + Y)= X ⋅ (Y + 1)= X ⋅ 1= X
a + b ∈ Ba ⋅ b ∈ B
a + b = b + aa ⋅ b = b ⋅ a
a + (b + c) = (a + b) + ca ⋅ (b ⋅ c) = (a ⋅ b) ⋅ c
a + (b ⋅ c) = (a + b) ⋅ (a + c)a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c)
a + 0 = aa ⋅ 1 = a
a + = 1a′
a ⋅ = 0a′
a + 1 = 1a ⋅ 0 = 0
a + a = aa ⋅ a = a
( = aa′)′
19
Example: proving theorems using truth tables
DeMorgan’s law
NOR is equivalent to AND with inputscomplemented
0 0 1 1 1 10 1 1 0 0 01 0 0 1 0 01 1 0 0 0 0
DeMorgan’s law
NAND is equivalent to OR with inputscomplemented
0 0 1 1 1 10 1 1 0 1 11 0 0 1 1 11 1 0 0 0 0
(X + Y = ⋅)′ X ′ Y ′X Y X ′ Y ′ (X + Y)′ ⋅X ′ Y ′
(X ⋅ Y = +)′ X ′ Y ′X Y X ′ Y ′ (X ⋅ Y)′ +X ′ Y ′
20
Example: simplifying (circuits) using Boolean algebra(from classesLe!)(HW2)(HW2)
Closure
Commutativity
Associativity
Distributivity
Identity
Complementarity
Null
Idempotency
Involution
c1 = ⋅ ⋅ ⋅ L + ⋅ ⋅ ⋅ L + ⋅ ⋅ ⋅ L + ⋅ ⋅ ⋅ Ld ′2 d ′
1 d ′0 d ′
2 d ′1 d0 d ′
2 d1 d ′0 d ′
2 d1 d0= …= ⋅ Ld ′
2
a + b ∈ Ba ⋅ b ∈ B
a + b = b + aa ⋅ b = b ⋅ a
a + (b + c) = (a + b) + ca ⋅ (b ⋅ c) = (a ⋅ b) ⋅ c
a + (b ⋅ c) = (a + b) ⋅ (a + c)a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c)
a + 0 = aa ⋅ 1 = a
a + = 1a′
a ⋅ = 0a′
a + 1 = 1a ⋅ 0 = 0
a + a = aa ⋅ a = a
( = aa′)′
21
Example: simplifying (circuits) using Boolean algebra(from classesLe!)(HW2)(HW2)
Here is the simplified circuit …
d 2L
c1
c1 = ⋅ ⋅ ⋅ L + ⋅ ⋅ ⋅ L + ⋅ ⋅ ⋅ L + ⋅ ⋅ ⋅ Ld ′2 d ′
1 d ′0 d ′
2 d ′1 d0 d ′
2 d1 d ′0 d ′
2 d1 d0= …= ⋅ Ld ′
2
c1
22
SummaryBoolean algebra is a notation for combinational circuits.
It consists of elements and operations .The operations satisfy the axioms of Boolean algebra.
We can translate specs to code to logic and to circuits forfaster implementation in hardware, andprogram verification.
We can use axioms of Boolean algebra and truth tables toprove useful theorems, andsimplify and optimize combinational circuits.
{0, 1} {+, ⋅, }′
23