Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Boolean Logic: Understanding Boolean Operators, Truth Tables, and Circuits, Slides of Computer Science

An introduction to boolean logic, including the roots of logic, boolean operators (not, and, or, implies, and equivalence), boolean searching, truth tables, and circuits. It also covers boolean logic in python and boolean identities. Examples and exercises.

Typology: Slides

2012/2013

Uploaded on 03/22/2013

dhirendra
dhirendra 🇮🇳

4.3

(78)

279 documents

1 / 66

Toggle sidebar

Related documents


Partial preview of the text

Download Boolean Logic: Understanding Boolean Operators, Truth Tables, and Circuits and more Slides Computer Science in PDF only on Docsity! Boolean Logic Chapter 4 (Sections 4.1 and 4.2) Docsity.com The Roots: Logic 1848 George Boole The Calculus of Logic chocolate and ¬nuts and mint Docsity.com Boolean Searching Google Docsity.com Truth Tables cheese and (pepperoni or sausage) Ch Pe Sa Pe ∨ Sa Ch ∧ (Pe ∨ Sa) True True True True True True True False True True True False True True True True False False False False False True True True False False True False True False False False True True False False False False False False Docsity.com 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 Docsity.com Boolean Operators NOT P ¬ True False False True Docsity.com Boolean Operators AND P Q P ∧ Q True True True False False True False False Docsity.com Boolean Operators AND P Q P ∧ Q True True True True False False False True False False False False Docsity.com Boolean Operators IMPLIES P Q P → Q True True True False False True False False Docsity.com Boolean Operators IMPLIES P Q P → Q True True True True False False False True True False False True Docsity.com Boolean Operators EQUIVALENCE P Q P ↔ Q True True True False False True False False Docsity.com Using Boolean Logic P Q ¬P True True True False False True False False ¬P ∧ ((P ∨ Q)→ Q) Docsity.com Using Boolean Logic P Q ¬P P ∨ Q True True False True False False False True True False False True ¬P ∧ ((P ∨ Q)→ Q) Docsity.com Using Boolean Logic P Q ¬P P ∨ Q P → Q True True False True True False False True False True True True False False True False ¬P ∧ ((P ∨ Q)→ Q) Docsity.com Using Boolean Logic P Q ¬P P ∨ Q P → Q (P ∨ Q)→ Q ¬P ∧ ((P ∨ Q)→ Q) True True False True True True False True False False True False False False False True True True True True True False False True False True True True ¬P ∧ ((P ∨ Q)→ Q) Docsity.com Another Example E H N S E ∧ H ((E ∧ H) ∨ N → S True True True True True True True True True True True False True True True False True True True True True True True True True True True False True True False True • • • Docsity.com Another Example E H N S E ∧ H ((E ∧ H) ∨ N → S True True True True True True True True True True True False True True True False True True True True True True True True True True True False True True False True • • • ((Exhausted ∧ HidingPlaceNearby) ∨ Nightime) → StopToSleep Docsity.com 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!!") Docsity.com 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!!") Docsity.com Boolean Identities This notation: • Multiply for AND • Add for OR Docsity.com Satisfiability A Boolean formula is satisfiable if and only if there is some row of the truth table that is T. P Q ¬P P ∨ Q P → Q (P ∨ Q)→ Q ¬P ∧ ((P ∨ Q)→ Q) True True False True True True False True False False True False False False False True True True True True True False False True False True True True The job of a SAT solver is to determine satisfiability. Docsity.com Using Boolean Expressions (¬W ∧ C ∧¬D) ∨ (W ∧ A ∧ D) Is this expression satisfiable? Docsity.com Using Boolean Expressions (¬Wounded ∧ CanRun ∧¬Daylight) ∨ (Wounded ∧ InAmbulance ∧ Daylight) Is this expression satisfiable? Docsity.com Boolean Operators Exclusive Or XOR P Q P ⊕ Q True True False True False True False True True False False False Chips OR Fries Docsity.com Boolean Operators Not And NAND P Q ∧ NAND True True True True False False False True False False False False Docsity.com Boolean Operators Not And NAND P Q ∧ NAND True True True False True False False True False True False True False False False True Docsity.com Binary Boolean Operators P Q ∨ → ↔ ∧ NAND ⊕ NOR T T T T T T T T T T F F F F F F F F T F T T T T F F F F T T T T F F F F F T T T F F T T F F T T F F T T F F F F T F T F T F T F T F T F T F T F Docsity.com Boolean Circuits NOT Logic Diagram Symbol Truth Table A X A X —\>o— 0 1 1 0 Docsity.com Boolean Circuits AND Logic Diagram Symbol Truth Table A X A B xX — )- 0 0 0 B 0 1 0 1 0 0 1 1 1 Docsity.com Boolean Circuits Logic Diagram Symbol NAND Truth Table B xX 0 1 1 1 0 1 1 0 ’ =-|/-|O/oO| mR Docsity.com Boolean Circuits NOR Logic Diagram Symbol Truth Table A A B X ——- boot B 0 1 0 1 0 0 1 1 0 Docsity.com Not And Or ° XOR ¢ NAND NOR Boolean Gates t mt ~< ’ > w 7 Docsity.com Circuits That Compute Building an Adder 0 0 1 1 + 0 + 1 + 0 + 1 0 1 1 1 0 A full adder: Docsity.com Reasoning About Circuits (and Programs) • CircuitA → Specification • ProgramB → Specification Docsity.com Satisfiability Recall: A Boolean formula is satisfiable if and only if there is some row of the truth table that is T. P Q ¬P P ∨ Q P → Q (P ∨ Q)→ Q ¬P ∧ ((P ∨ Q)→ Q) True True False True True True False True False False True False False False False True True True True True True False False True False True True True The job of a SAT solver is to determine satisfiability. Docsity.com Other Applications of SAT Solvers • Is new fact1 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 ) Docsity.com Other Applications of SAT Solvers • Is new fact1 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 → T Houston → Texan D → T Dallas → Texan U → ¬A UT → ¬Aggie U ∧ H ∧ ¬L UT ∧ Houston ∧ ¬Longhorn Docsity.com How Big Are the Truth Tables? P Q R True True True True True False True False True True False False False True True False True False False False True False False False Docsity.com 2n 0 200000 400000 600000 800000 1000000 1200000 1 3 5 7 9 11 13 15 17 19 21 Docsity.com But Practical Solutions Exist They routinely solve problems with hundreds of thousands of variables. Docsity.com
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved