Download presentation
Presentation is loading. Please wait.
Published bySabina Gordon Modified over 9 years ago
1
Boolean Logic Chapter 4 (Sections 4.1 and 4.2)
2
The Roots: Logic 1848 George Boole The Calculus of Logic chocolate and nuts and mint
3
The Roots: Logic cheese and (pepperoni or sausage)
4
Boolean Searching crane silk Washington (pin,button,charm)
5
Boolean Searching
6
Truth Tables cheese and (pepperoni or sausage) ChPeSa Pe SaCh (Pe Sa) True FalseTrue FalseTrue False True False TrueFalseTrueFalse True False
7
What’s the “Native Language” of Our Computers? The first “computers” were actually people who crunched numbers. The Mathematical Tables Project NY in the 1940’s http://gridtalk-project.blogspot.com/2010/09/when-computers-were-human.html Top Secret Rosies: http://www.cnn.com/2011/TECH/innovation/02/08/women.rosies.math/index.html?hpt=C2
8
Would You Like the Job?
9
Babbage’s Analytical Engine In 1833 Charles Babbage (1791-1871) conceived a plan for a general purpose calculating machine. It was designed to contain a store, a mill, capable of performing the four operations of arithmetic, an input/output system which used punched cards, and a printer to display the results. The engine would have been steam-driven and programmed by the punched cards. It was designed in great detail on paper but it was never completed. This is a portion of the mill with a printing mechanism.
10
What’s the “Native Language” of Our Computers? CDC 6600 c. 1980
11
Computing Today
12
Computing Is About Boolean Logic The rules of the logic tell us how to manipulate inputs and produce outputs. We define the rules so that we get answers that are useful to us.
13
Boolean Operators NOT P True False
14
Boolean Operators NOT P TrueFalse True
15
Boolean Operators AND PQ P Q True False True False
16
Boolean Operators AND PQ P Q True False TrueFalse
17
Boolean Operators OR PQ P Q True False True False
18
Boolean Operators OR PQ P Q True FalseTrue FalseTrue False
19
Boolean Operators IMPLIES PQ P Q True False True False
20
Boolean Operators IMPLIES PQ P Q True False True False True
21
Boolean Operators EQUIVALENCE PQ P Q True False True False
22
Boolean Operators EQUIVALENCE PQ P Q True False TrueFalse True
23
Boolean Logic PQ PPP QP QP QP Q True FalseTrue False TrueFalse True FalseTrueFalse TrueFalse True
24
Using Boolean Logic PQ PP True False True False P ((P Q) Q)
25
Using Boolean Logic PQ PPP Q True False TrueFalse True False True P ((P Q) Q)
26
Using Boolean Logic PQ PPP QP Q True FalseTrue False True FalseTrue False TrueFalse P ((P Q) Q)
27
Using Boolean Logic PQ PPP QA B(P Q) Q True FalseTrue False TrueFalse True False TrueFalseTrue P ((P Q) Q)
28
Using Boolean Logic PQ PPP QP Q(P Q) Q P ((P Q) Q) True FalseTrue False TrueFalse True False TrueFalseTrue P ((P Q) Q)
29
Using Boolean Logic PQ PPP QP Q(P Q) Q P ((P Q) Q) True FalseTrue False TrueFalse TrueFalse True False TrueFalseTrue P ((P Q) Q)
30
Another Example EHNS E H((E H) N S True FalseTrue FalseTrue FalseTrue FalseTrue
31
Another Example EHNS E H((E H) N S True FalseTrue FalseTrue FalseTrue FalseTrue ((Exhausted HidingPlaceNearby) Nightime) StopToSleep
32
Boolean Logic PQ PPP QP QP QP Q True FalseTrue False TrueFalse True FalseTrueFalse TrueFalse True Let’s practice.
33
Booleans in Python def chocolate(): password = input("Type your password: ") while password != "chocolate": password = input("Try again: ") print("Got it!!")
34
Booleans in Python def for_dummies(): password = input("Type your password: ") tries = 0 while password != "chocolate" and tries < 5: password = input("Try again: ") tries +=1 if tries == 5: print("Okay, you've tried hard enough") else: print("Got it!!")
35
Booleans in Python def for_dummies1(): password = input("Type your password: ") tries = 0 while not(password == "chocolate" or tries >= 5): password = input("Try again: ") tries +=1 if tries == 5: print("Okay, you've tried hard enough") else: print("Got it!!")
36
Boolean Identities This notation: Multiply for AND Add for OR
37
Proving These Things AB A B (A B) True False TrueFalse True FalseTrueFalseTrue False True AB AA BB A BA B False TrueFalse True FalseTrue FalseTrue False True Prove the first of deMorgan’s laws: (A B) A B
38
Proving These Things AB A B (A B) True False TrueFalse True FalseTrueFalseTrue False True AB AA BB A BA B False TrueFalse True FalseTrue FalseTrue False True Prove the first of deMorgan’s laws: (A B) A B
39
Satisfiability A Boolean formula is satisfiable if and only if there is some row of the truth table that is T. PQ PPP QP Q(P Q) Q P ((P Q) Q) True FalseTrue False TrueFalse TrueFalse True False TrueFalseTrue The job of a SAT solver is to determine satisfiability.
40
Using Boolean Expressions ( W C D) (W A D) Is this expression satisfiable?
41
Using Boolean Expressions ( Wounded CanRun Daylight) (Wounded InAmbulance Daylight) Is this expression satisfiable?
42
Binary Boolean Operators PQ TTTTTTTTTTFFFFFFFF TFTTTTFFFFTTTTFFFF FTTTFFTTFFTTFFTTFF FFTFTFTFTFTFTFTFTF What about the other 12 columns?
43
Boolean Operators Exclusive Or XOR PQ P Q True False True False Chips OR Fries
44
Boolean Operators Exclusive Or XOR PQ P Q True False TrueFalseTrue FalseTrue False Chips OR Fries
45
Boolean Operators Not And NAND PQ NAND True False TrueFalse
46
Boolean Operators Not And NAND PQ NAND True False TrueFalse True FalseTrueFalseTrue False True
47
Boolean Operators Not Or NOR PQ NOR True FalseTrue FalseTrue False
48
Boolean Operators Not Or NOR PQ NOR True False TrueFalseTrueFalse True False True
49
Binary Boolean Operators PQ NA ND NOR TTTTTTTTTTFFFFFFFF TFTTTTFFFFTTTTFFFF FTTTFFTTFFTTFFTTFF FFTFTFTFTFTFTFTFTF
50
Boolean Circuits NOT
51
Boolean Circuits AND
52
Boolean Circuits OR
53
Boolean Circuits XOR
54
Boolean Circuits NAND
55
Boolean Circuits NOR
56
Why NAND and NOR? Let’s try them: http://www.spsu.edu/cs/faculty/bbrown/web_lectures/transistors/http://www.spsu.edu/cs/faculty/bbrown/web_lectures/transistors/ NAND
57
Boolean Gates Not And Or XOR NAND NOR
58
Circuits That Compute Building an Adder 0 0 1 1 + 0+ 1+ 0+ 1 0 1 11 0 A half adder:
59
Circuits That Compute Building an Adder 0 0 1 1 + 0+ 1+ 0+ 1 0 1 11 0 A half adder:
60
Circuits That Compute Building an Adder 0 0 1 1 + 0+ 1+ 0+ 1 0 1 11 0 A full adder:
61
Reasoning About Circuits (and Programs) Circuit A Specification Program B Specification
62
Satisfiability Recall: A Boolean formula is satisfiable if and only if there is some row of the truth table that is T. PQ PPP QP Q(P Q) Q P ((P Q) Q) True FalseTrue False TrueFalse TrueFalse True False TrueFalseTrue The job of a SAT solver is to determine satisfiability.
63
Reasoning About Circuits (and Programs) Circuit A Specification Program B Specification So we want to assure that: (Circuit A Specification) is not satisfiable.
64
Other Applications of SAT Solvers Cryptography Artificial Intelligence: Plan c Problem solved Is new fact 1 consistent with what we already know?
65
Other Applications of SAT Solvers Is new fact 1 consistent with what we already know? (T A) L H T D T U A U H L Put another way, is the following formula satisfiable? ((T A) L) (H T) (D T ) (U A ) (U H L )
66
Other Applications of SAT Solvers Is new fact 1 consistent with what we already know? So what’s the problem? Write out the truth table and we are done. (T A) L(Texan Aggie) Longhorn H THouston Texan D TDallas Texan U AUT Aggie U H LUT Houston Longhorn
67
How Big Are the Truth Tables? PQR True False TrueFalseTrue False True FalseTrueFalse True False
68
Back to the Longhorn Problem (T A) L H T D T U A U H L How many rows in the truth table for this?
69
The Longhorn Problem TALHDU True FalseTrue FalseTrue FalseTrue FalseTrue
70
2n2n
71
But Practical Solutions Exist They routinely solve problems with hundreds of thousands of variables.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.