Slide 1

Slide 1 text

cs2102: Discrete Mathematics Class 5: Conjunctive Normal Form, Computing, and Quantifiers David Evans University of Virginia

Slide 2

Slide 2 text

Plan Review: Logic Formulas, Valid, Satisfiable Conjunctive Normal Form, 3CNF Computing Machines Quantifiers Add date is today! If you aren’t enrolled in the class yet, need to get a course action form signed and delivered today. PS1: grading almost finished, everyone should receive grade by tonight. Comments will be posted soon.

Slide 3

Slide 3 text

A formula is valid if there is no way to make it false. A formula is satisfiable if there is some way to make it true. If NOT(X) is valid, what does that mean about X?

Slide 4

Slide 4 text

Conjunctive Normal Form

Slide 5

Slide 5 text

Conjunctive Normal Form clause literal variable or its negation

Slide 6

Slide 6 text

Conjunctive Normal Form Can we write any logical formula in CNF? A ∧ B

Slide 7

Slide 7 text

Conjunctive Normal Form Can we write any logical formula in CNF? A ∧ B A ⇒ B

Slide 8

Slide 8 text

Logical Formula to Truth Table Can we convert any logical formula to a truth table?

Slide 9

Slide 9 text

Logical Formula to Truth Table How big is the table? a1 a2 a3 … an Result T T T … T T T T … F … … … … … … … … F F F … T F F F … F

Slide 10

Slide 10 text

Truth Table to Disjunctive Normal Form Disjunctive normal form: OR of clauses, each clause is AND of literals. a1 a2 a3 … an Result T T T … T T T T … F … … … … … … … … F F F … T F F F … F

Slide 11

Slide 11 text

Truth Table to Disjunctive Normal Form a1 a2 a3 … an Result T T T … T T T T … F … … … … … … … … F F F … T F F F … F clauses = Set() # empty is False for each row in table: if result(row): clauses.add(row as conjunct clause)

Slide 12

Slide 12 text

Truth Table to Conjunctive Form De Morgan’s Law

Slide 13

Slide 13 text

Truth Table to Conjunctive Normal Form a1 a2 a3 … an Result T T T … T T T T … F … … … … … … … … F F F … T F F F … F

Slide 14

Slide 14 text

Truth Table to Conjunctive Normal Form a1 a2 a3 … an Result T T T … T T T T … F … … … … … … … … F F F … T F F F … F clauses = Set() for each row in table: if not result(row): clauses.add(row as disjunctive clause)

Slide 15

Slide 15 text

3CNF Definition. A logical formula that is written as a conjunction of clauses, where each clause is a disjunction of exactly three literals, and each literal is either a variable or a negation of a variable, is in three- conjunctive normal form (3CNF).

Slide 16

Slide 16 text

3CNF Definition. A logical formula that is written as a conjunction of clauses, where each clause is a disjunction of exactly three literals, and each literal is either a variable or a negation of a variable, is in three- conjunctive normal form (3CNF). (A ∨ B ∨ ¬C) ∧ (A ∨ B ∨ C) ∧ (¬A ∨ ¬B ∨ C)

Slide 17

Slide 17 text

Definition. A logical formula that is written as a conjunction of clauses, where each clause is a disjunction of exactly three literals, and each literal is either a variable or a negation of a variable, is in three- conjunctive normal form (3CNF). (A ∨ B) Convert clause with two literals to 3CNF:

Slide 18

Slide 18 text

Definition. A logical formula that is written as a conjunction of clauses, where each clause is a disjunction of exactly three literals, and each literal is either a variable or a negation of a variable, is in three- conjunctive normal form (3CNF). (A) Convert clause with one literal to 3CNF:

Slide 19

Slide 19 text

Definition. A logical formula that is written as a conjunction of clauses, where each clause is a disjunction of exactly three literals, and each literal is either a variable or a negation of a variable, is in three- conjunctive normal form (3CNF). (A ∨ B ∨ C ∨ D) Convert clause with four literals to 3CNF:

Slide 20

Slide 20 text

(A ∨ B ∨ C ∨ D ∨ E ∨ …) Convert clause with any number of literals to 3CNF:

Slide 21

Slide 21 text

Any logical formula → truth table → CNF → 3CNF Universality of 3CNF

Slide 22

Slide 22 text

Computing Machines and Logic

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

First Transistor John Bardeen, Walter Brattain, William Shockley Bell Labs, 1947 Nobel Prize (Physics), 1956 24

Slide 25

Slide 25 text

Physics of Computation #25 control source output If the control is “on”, the source flows to the output. Otherwise, the output is “off”. A transistor is a device used to amplify or switch electronic signals (like a faucet). What logical operation is this?

Slide 26

Slide 26 text

Logic from Transistors With transistors it is possible to make two switches: control source output S C O 1 1 1 1 0 0 0 1 0 0 0 0 normal control

Slide 27

Slide 27 text

Making Transistors Today • A transistor is made of a solid piece of semiconductor material. • A semiconductor is a material that has electrical conductivity that varies dynamically between that of a conductor (on) or an insulator (off). • Silicon is a semiconductor.

Slide 28

Slide 28 text

Transistors in your Smartphone 28 Qualcomm Snapdragon 821 ∼2 Billion transistors Cost: $18 (> 1 Million transistors/cent) 14 nanometers process (about 25M transistors per mm2) Snapdragon 835, mid-2017: 3B transistors, 10nm process

Slide 29

Slide 29 text

Are NANDs efficient? 2-bit adder b a s c

Slide 30

Slide 30 text

Are NANDs the most efficient? 2-bit adder b a s c

Slide 31

Slide 31 text

Are NANDs the most efficient? 2-bit adder b a s c a b s c 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 Check Check

Slide 32

Slide 32 text

4 transistors XOR design Efficient XORs 12 T Hashes/s, each hash is ~40,000 XORs

Slide 33

Slide 33 text

Logic Synthesis Are all the transistors in a chip used to make NAND gates?

Slide 34

Slide 34 text

Car theft rate (by model year) Source: hldi.org

Slide 35

Slide 35 text

Inside the Mifare Chip 0.001 mm (1000 nm) 0.01 mm (10000 nm) Pictures by Karsten Nohl

Slide 36

Slide 36 text

Interconnection Layers Logic Layer Pictures by Karsten Nohl

Slide 37

Slide 37 text

Zooming in on the Logic… rotated rotated + mirrored 4 NAND: Y = !(A & B & C & D) match match Pictures by Karsten Nohl

Slide 38

Slide 38 text

This room has roughly 100 Trillion NAND gates in it…what are most of the doing?

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

b … …

Slide 41

Slide 41 text

Quantifiers

Slide 42

Slide 42 text

Logical Quantifiers ∀ ∈ . () ∃ ∈ . ()

Slide 43

Slide 43 text

Nesting Quantifiers ∀ ∈ ℕ. ∃ ∈ ℕ. = + 1

Slide 44

Slide 44 text

Nesting Quantifiers ∀ ∈ ℕ − {0}. ∃ ∈ ℕ. = + 1

Slide 45

Slide 45 text

Well-Ordering Principle Every nonempty set of non-negative integers has a smallest element. Can we express this using a quantified logical formula?

Slide 46

Slide 46 text

Charge • Add date is today: make sure you are enrolled (or get a course action form signed now!) • Computers are all built on logic – In theory, NAND is all we need – In practice, efficiency matters Due Friday (6:29pm): PS2