CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au ›...

56
CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal 1

Transcript of CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au ›...

Page 1: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

CSE 311 Lecture 04: Boolean AlgebraEmina Torlak and Kevin Zatloukal

1

Page 2: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 4: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 5: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

Boolean algebraA notation for combinational circuits.

5

Page 6: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 7: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 8: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 9: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 10: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 11: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 12: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 13: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 14: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 15: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 16: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 17: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 18: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 19: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 20: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 21: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 22: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 23: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 24: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 25: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 26: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 27: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 28: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 29: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 30: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 31: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 32: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 33: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 34: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 35: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 36: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 37: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 38: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 39: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 40: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 41: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

Simplification and proofsOptimizing circuits and proving theorems.

16

Page 42: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 43: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 44: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 45: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 46: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 47: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 48: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 49: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 50: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 51: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 52: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 53: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 54: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 55: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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

Page 56: CSE 311 Lecture 04: Boolean Algebra - University of Washington › courses › cse311 › 18au › doc › le… · CSE 311 Lecture 04: Boolean Algebra Emina Torlak and Kevin Zatloukal

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