Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Laws of Logic: Boolean Algebra A State High Math Club Presentation START==TRUE.

Similar presentations


Presentation on theme: "The Laws of Logic: Boolean Algebra A State High Math Club Presentation START==TRUE."— Presentation transcript:

1 The Laws of Logic: Boolean Algebra A State High Math Club Presentation START==TRUE

2 What is Boolean Algebra? Two values –True and False - Logic + Set Theory –1 and 0 - Computers + Probability –High and Low – Digital Electronics

3 AND - Basic Notation - AND ^ && (A AND B) returns true iff A and B are both true Numerically: A * B Identity - 1 –0 AND 1 = 0 –1 AND 1 = 1 Annihilator - 0 –0 AND 0 = 0 –1 AND 0 = 0

4 AND - Representations

5 OR (Inclusive or) - Basic Notation - OR v || (A OR B) returns true if either (or both) of A and B are true Numerically: A + B - A * B –Probability: P(A or B) = P(A)+P(B)-P(A AND B) “And/Or” Construction Identity - 0 Annihilator - 1

6 OR - Representations

7 NOT - Basic Notation NOT ¬ ~ ! Unary - only takes one argument –Others are called binary Returns the opposite of its argument Analogous to negative sign

8 NOT - Representations

9 XOR (Exclusive or) - Derived Notation XOR ^ + (A XOR B) returns true iff exactly one of A and B is true –Can also be considered “not equals” –“Either/or” construction –A XOR B = (A ^ ~B) v (~A ^ B) Numerically: A+B (mod 2) –Also A+B – 2*(A*B) – Same formula in probability A XOR 1 = NOT(A) A XOR 0 = A

10 XOR - Representations

11 Equivalence - Derived Notation ≡ == Returns true iff A=B

12 Material Implication - Derived Notation x–>y Linguistically “If X, then Y” –X is called the antecedent; y is called the consequent False ONLY when x is true and y is false NOT(X) OR Y –More intuitively NOT(X AND NOT(Y)) Why is x->y true when x is false??? –This means that “If two is odd, then two is even” is a true statement!

13 Tautologies: The Theorems of Boolean Algebra Called laws Proven with either truth tables or derivations –Truth table – true iff last column is all 1s (i.e. true for all input values) Example: Proof of X ^ ~X == 0 X~XX^~XX^~X== 0 1001 0101

14 De Morgan’s Laws: Distributing a NOT ¬(xVy)=(¬x)^(¬y) ¬(x^y)=(¬x)V(¬y) Proofs? XY(¬x)^(¬y)¬(xvy) 1100 1000 0100 0011 XY(¬x)v(¬y)¬(x^y) 1100 1011 0111 0011

15 Important Laws AND and OR are: –Distributive over each other –Associative –Commutative ~~X = X X^~X==0 Xv~X==1 De Morgan’s Laws

16 A Derivation (w V x) V (y V z) = ((w V x) V y) V z = (w V (x V y)) V z = (w V (y V x)) V z = ((w V y) V x) V z = (w V y) V (x V z) Why is this valid?

17 Applications: Logic + Deduction Propositional Calculus – gives valid forms of arguments –Arguments are valid iff they are laws of boolean algebra –Tends to use “->” a lot Examples –(P ^ (P->Q)) -> Q – Modus Ponens –(~Q ^ (P->Q)) -> ~P – Modus Tollens –((P->Q) ^ (Q->R)) -> (P->R) – Hypothetical Syllogism

18 Modus Ponens Proof PQP->Q(P ^ (P->Q))(P ^ (P->Q)) -> Q 11111 10001 01101 00101

19 Modus Tollens Proof PQP->Q(~Q ^ (P->Q))(~Q ^ (P->Q)) -> ~P 11101 10001 01101 00111

20 Hypothetical Syllogism Proof PQRP->QQ->RP->Q ^ Q->RP->R 1111111 1101000 1010101 1000100 0111111 0101001 0011111 0001111

21 Applications: Computer Curcuits Everything in a computer is either a 1 or 0 (called a bit, or binary unit) –1 is high voltage; 0 is low voltage –Why? Calculations are done with AND, OR, and NOT logic gates –Sound familiar?

22 How Do Computers Add? We want to add two numbers, which are sequences of bits –We add one place value (two bits) at a time Input: The two bits, A and B Output: sum bit (the actual place value) and carry bit (if we need to carry a 2) How can we make this circuit?

23 Adding ABSumCarry 1101 1010 0110 0000 Make a truth table and translate it into a circuit diagram

24 Adding Sum = A XOR B Carry = A AND B

25 What about the carry bit? We forgot we might need to add a carry bit as well So we really have three inputs: A,B, and Cin (carry in) Still two outputs: –Cout (carry out) –Sum

26 Take Two ABCinSCout 11111 11001 10101 10010 01101 01010 00110 00000 How do we make this circuit diagram?

27 Full 1-bit Adder

28 How about more bits?

29 How many basic gates? We use AND, OR, and NOT as basic gates –Wouldn’t it be nice to have ONE basic gate? –Can mass-produce a single circuit; don’t have to worry about which (tiny and impossible to see) circuit is which

30 NAND – Sheffer Stroke Notation NAND | ↑ A NAND B = NOT (A AND B) Can be used to make AND, OR, and NOT gates –How?

31 NAND as a Universal Gate NOT(A) = A NAND A A AND B = NOT(A NAND B) = (A NAND B) NAND (A NAND B) A OR B = NOT(A) NAND NOT(B) by Demorgan’s Law = (A NAND A) NAND (B NAND B) A -> B = NOT(A) OR B = A NAND NOT(B) = A NAND (B NAND B)

32 NOR – Pierce Arrow Notation NOR ↓ A NOR B = NOT(A OR B) Can be used to make AND,OR, and NOT gates –How?

33 NOR as a Universal Gate NOT(A) = A NOR A A OR B = NOT(A OR B) = (A NOR B) NOR (A NOR B) A AND B = NOT(A) NOR NOT(B) by Demorgan’s Law = (A NOR A) NOR (B NOR B) A->B = NOT(A) OR B = (NOT(A) NOR B) NOR (NOT(A) NOR B) = ((A NOR A) NOR B) NOR ((A NOR A) NOR B)

34 An Everyday Example: Search Engines Google uses boolean algebra on your search terms –Automatically uses AND (i.e. whitespace = AND) boolean algebra -> Pages with BOTH ‘boolean’ and ‘algebra’ in them –Use OR for logical OR Boolean OR algebra -> Pages with EITHER ‘boolean’ or ‘algebra’ in them –Use - for NOT Boolean –Algebra ->Pages WITH ‘boolean’ but WITHOUT ‘algebra’

35 END==1


Download ppt "The Laws of Logic: Boolean Algebra A State High Math Club Presentation START==TRUE."

Similar presentations


Ads by Google