Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today...

26
Boolean Algebra Monday/Wednesday 7th Week

Transcript of Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today...

Page 1: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Boolean Algebra

Monday/Wednesday

7th Week

Page 2: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Logical Statements

Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it is sunny. Today is Monday OR it is raining. Today is Friday OR it is NOT raining.

Page 3: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

A More Challenging Example

Are these two statements the same? It is NOT Friday OR it is raining. It is NOT the case that it is Friday AND it is NOT

raining.

Page 4: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Boolean Algebra

Boolean Algebra allows us to formalize this sort of reasoning.

Boolean variables may take one of only two possible values: TRUE or FALSE

Algebraic operators: + - * / Logical operators - AND, OR, NOT, XOR, NOR,

NAND

Page 5: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Logical Operators

A AND B is True when both A and B are true. A OR B is always True unless both A and B are

false. NOT A changes the value from True to False or

False to True. XOR = either a or b but not both NOR = NOT OR NAND = NOT AND

Page 6: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Writing AND, OR, NOT

A AND B = A ^ B = AB A OR B = A v B = A+B NOT A = ~A = A’ TRUE = T = 1 FALSE = F = 0

Page 7: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Exercise

AB + AB’ A AND B OR A AND NOT B (A + B)’(B) NOT (A OR B) AND B

Page 8: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Boolean Algebra

The = in Boolean Algebra means equivalent Two statements are equivalent if they have the

same truth table. For example,

True = True, A = A,

Page 9: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Truth Tables

Provide an exhaustive approach to describing when some statement is true (or false)

Page 10: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Truth Table

M R M’ R’ MR M + R

T T

T F

F T

F F

Page 11: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Truth Table

M R M’ R’ MR M + R

T T F F

T F F T

F T T F

F F T T

Page 12: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Truth Table

M R M’ R’ MR M + R

T T F F T

T F F T F

F T T F F

F F T T F

Page 13: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Truth Table

M R M’ R’ MR M +R

T T F F T T

T F F T F T

F T T F F T

F F T T F F

Page 14: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Example

Write the truth table for A(A’ + B) + AB’ (p 266, exercise #3a)

First, write in words: A AND (NOT A OR B) OR (A AND NOT B)

Then do a truth table with the following columns: A, B, A’, B’, A’ + B, AB’, A (A’ + B), whole expression.

Page 15: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

A (A’ + B) + AB’

A B A’ B’ A’ + B A B’ A(A’+B) Whole

T T F F T F T T

T F F T F T F T

F T T F T F F F

F F T T T F F F

Page 16: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Exercise

Write the truth table for (A + A’) B First, write in words. Then do a truth table.

Page 17: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Solution to (A + A’) B

A B A’ A + A’ (A + A’) B

T T F T T

T F F T F

F T T T T

F F T T F

Page 18: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Boolean Algebra - Identities

A OR True = True A OR False = A A OR A = A

A + B = B + A

(commutative)

A AND True = A A AND False = False A AND A = A

AB = BA

(commutative)

Page 19: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Associative and Distributive Identities

A(BC) = (AB)C A + (B + C) = (A + B) + C A + (BC) = (A + B) (A + C) A (B + C) = (AB)+(AC) Exercise: using truth tables prove -

A(A + B) = A

Page 20: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Solution: A AND (A OR B) = A

A B A + B A (A + B)

T T T T

T F T T

F T T F

F F F F

Page 21: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Using Identities

A + (BC) = (A + B)(A + C) A(B + C) = (AB) +(AC) A(A + B) = A A + A = A Exercise - using identities prove:

A + (AB) = A A +(AB) = (A +A)(A + B) = A (A + B) = A

Page 22: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Identities with NOT

(A’)’ = A A + A’ = True AA’ = False On and on and on and on …

Page 23: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

DeMorgan’s Laws

(A + B)’ = A’B’ (AB)’ = A’ + B’ Exercise - Simplify the following with identities

(A’B)’

Page 24: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Solving a Truth Table

A B X When you see a True value in the X column, you must have a term in the expression. Each term consists of the variables AB. A will be NOT A when the truth value of A is False, B will be NOT B when the truth value of B is false. They will be connected by OR.

T T T

T F T

F T F

F F F

For example,

X = AB + AB’ = (A AND B) OR ( A AND NOT B)

Page 25: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Exercise: Solving a Truth Table

A B X When you see a True value in the X column, you must have a term in the expression. Each term consists of the variables AB. A will be NOT A when the truth value of A is False, B will be NOT B when the truth value of B is false. They will be connected by OR.

T T T

T F F

F T T

F F F

Solve the Truth Table given above.

Page 26: Boolean Algebra Monday/Wednesday 7th Week. Logical Statements Today is Friday AND it is sunny. Today is Friday AND it is rainy. Today is Monday OR it.

Exercise: Solving a Truth Table

A B X When you see a True value in the X column, you must have a term in the expression. Each term consists of the variables AB. A will be NOT A when the truth value of A is False, B will be NOT B when the truth value of B is false. They will be connected by OR.

T T T

T F F

F T T

F F F

Solution is,

X = AB + A’B = (A AND B) OR ( NOT A AND B)