CSE 311: Foundations of Computing Lecture 3: Digital Circuits & - - PowerPoint PPT Presentation

cse 311 foundations of computing
SMART_READER_LITE
LIVE PREVIEW

CSE 311: Foundations of Computing Lecture 3: Digital Circuits & - - PowerPoint PPT Presentation

CSE 311: Foundations of Computing Lecture 3: Digital Circuits & Equivalence Announcements Homework #1 is linked in the right column of the CSE 311 homepage Read Grading Guidelines before starting Read Submission


slide-1
SLIDE 1

CSE 311: Foundations of Computing

Lecture 3: Digital Circuits & Equivalence

slide-2
SLIDE 2

Announcements

  • Homework #1 is linked in the right column of the

CSE 311 homepage

– Read “Grading Guidelines” before starting – Read “Submission Instructions” for everything you need to do for Gradescope submission

  • Full office hour slate is posted:

– M 12:30-1:20, 2:30-4:00, 4:00-4:50 – T 1:00-1:50, 3:30-4:20 – W 10:30-11:20, 2:30-3:00 – F 2:30-3:00, 3:30-4:20

  • If you don’t have a “tent card” come see me.
slide-3
SLIDE 3

Last class: Logical Equivalence A ≡ B

A ≡ B is an assertion that two propositions A and B always have the same truth values. A ≡ B and (A ↔ B) ≡ T have the same meaning. p ∧ q ≡ q ∧ p p ∧ q ≢ q ∨ p

When p=T and q=F, p ∧ q is false, but q ∨ p is true

p q p ∧ q q ∧ p (p ∧ q) ↔(q ∧ p)

T T T T T T F F F T F T F F T F F F F T

tautology

slide-4
SLIDE 4

Last class: De Morgan’s Laws

∧ ∨ ∨ ∧

De Morgan’s Laws

slide-5
SLIDE 5

Last class: Equivalences Related to Implication

Law of Implication → ≡ ∨ Contrapositive → ≡ → Biconditional ≡ ( ) ∧ ()

slide-6
SLIDE 6

Last class: Properties of Logical Connectives

slide-7
SLIDE 7

One more easy equivalence

p ¬ p ¬ ¬ p p ↔ ¬ ¬ p

T F T T F T F T

Double Negation ↔

slide-8
SLIDE 8

Last class: Digital Circuits

Computing With Logic

– T corresponds to 1 or “high” voltage – F corresponds to 0 or “low” voltage

Gates es

– Take inputs and produce outputs (functions) – Several kinds of gates – Correspond to propositional connectives (most

  • f them)
slide-9
SLIDE 9

Last class: AND, OR, NOT Gates

p q p ∧ q T T T T F F F T F F F F p q

OUT

1 1 1 1 1

AND Gate

p

OUT AND

q

OR Gate

p q

OUT

1 1 1 1 1 1 1

p

OUT OR

q

p q p ∨ q T T T T F T F T T F F F

NOT Gate

p

OUT

1 1

p

OUT NOT

p

¬ p

T F F T

slide-10
SLIDE 10

Last Class: Combinational Logic Circuits

Wires can send one value to multiple gates!

OR AND NOT AND

p q r

OUT

∧ ∨ ( ∧ )

slide-11
SLIDE 11

Other Useful Gates

NAND ( ∧ ) NOR ( ∨ ) XOR ⊕ XNOR ↔

p q

  • ut

p q

  • ut

1 1 1 1 1 1 1 p q

  • ut

1 1 1 1 1

  • ut

p q p q

  • ut

p q

  • ut

1 1 1 1 1 1 p q

  • ut

1 1 1 1 1 1

  • ut

p q

slide-12
SLIDE 12

Understanding logic and circuits

When do two logic formulas mean the same thing? When do two circuits compute the same function? What logical properties can we infer from other

  • nes?
slide-13
SLIDE 13

Basic rules of reasoning and logic

  • Allow manipulation of logical formulas

– Simplification – Testing for equivalence

  • Applications

– Query optimization – Search optimization and caching – Artificial Intelligence – Program verification

slide-14
SLIDE 14

Computing Equivalence

Given two propositions, can we write an algorithm to determine if they are equivalent? What is the runtime of our algorithm?

slide-15
SLIDE 15

Computing Equivalence

Given two propositions, can we write an algorithm to determine if they are equivalent?

Yes! Generate the truth tables for both propositions and check if they are the same for every entry.

What is the runtime of our algorithm?

Every atomic proposition has two possibilities (T, F). If there are atomic propositions, there are rows in the truth table.

slide-16
SLIDE 16

Another approach: Logical Proofs To show A is equivalent to B

– Apply a series of logical equivalences to sub-expressions to convert A to B

To show A is a tautology

– Apply a series of logical equivalences to sub-expressions to convert A to T

slide-17
SLIDE 17

Another approach: Logical Proofs To show A is equivalent to B

– Apply a series of logical equivalences to sub-expressions to convert A to B

Example: Let A be “ ∨ ( ∧ )”, and B be “”. Our general proof looks like: ∨ ∧ ≡ ( ) ≡

slide-18
SLIDE 18

Logical Proofs

Example: Let A be “ ∨ ( ∧ )”, and B be “”. Our general proof looks like: ∨ ∧ ≡ ( ) ≡

slide-19
SLIDE 19

Logical Proofs

Example: Let A be “ ∨ ( ∧ )”, and B be “”. Our general proof looks like: ∨ ∧ ≡ ( ) ≡ ∨

Idempotent Idempotent

slide-20
SLIDE 20

Logical Proofs To show A is a tautology

– Apply a series of logical equivalences to sub-expressions to convert A to T

Example: Let A be “ ∨ ( ∨ )”. Our general proof looks like: ∨ ∨ ≡ ( ) ≡ ( ) ≡ T

slide-21
SLIDE 21

Logical Proofs

Example: Let A be “ ∨ ( ∨ )”. Our general proof looks like: ∨ ∨ ≡ ( ) ≡ ( ) ≡ T

slide-22
SLIDE 22

Logical Proofs

Example: Let A be “ ∨ ( ∨ )”. Our general proof looks like: ∨ ∨ ≡ ( ) ≡ ( ) ≡ T ∨

Idempotent Negation

Commutative

slide-23
SLIDE 23

Prove these propositions are equivalent: Option 1

∧ ( → ) ∧ ∧ ( → ) ⟷ ∧

T T T T T T T F F F F T F T T F F T F F T F F T

Make a Truth Table and show: ∧ ( → ) ⟷ ∧ ≡ T

Prove: p ∧ (p → q) ≡ p ∧ q

slide-24
SLIDE 24

Prove these propositions are equivalent: Option 2

Prove: p ∧ (p → q) ≡ p ∧ q

∧ → ≡ ≡ ≡ ≡ ≡ ∧

slide-25
SLIDE 25

Prove these propositions are equivalent: Option 2

Prove: p ∧ (p → q) ≡ p ∧ q

∧ → ≡ ∧ ( ∨ ) ≡ ∧ ∨ ( ∧ ) ≡ F ∨ ( ∧ ) ≡ ∧ ∨ F ≡ ∧

Law of Implication Distributive Negation Commutative Identity

slide-26
SLIDE 26

Prove this is a Tautology: Option 1 (p ∧ q) → (q ∨ p)

∨ ∧ → ∨

T T T T T T F F T T F T F T T F F F F T

Make a Truth Table and show: ∧ → ∨ ≡ T

slide-27
SLIDE 27

Prove this is a Tautology: Option 2 (p ∧ q) → (q ∨ p)

Use a series of equivalences like so:

∧ → ∨ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ T

slide-28
SLIDE 28

Prove this is a Tautology: Option 2 (p ∧ q) → (q ∨ p)

Use a series of equivalences like so:

∧ → ∨ ≡ ∧ ∨ ( ∨ ) ≡ ∨ ∨ ( ∨ ) ≡ ∨ ( ∨ ∨ ) ≡ ∨ ( ∨ ∨ ) ≡ ∨ ( ∨ ∨ ) ≡ ( ∨ ) ∨ ∨ ≡ ( ∨ ) ∨ ∨ ≡ T ∨ T ≡ T

Law of Implication DeMorgan Associative Associative Commutative Associative Commutative (twice) Negation (twice) Domination/Identity

slide-29
SLIDE 29

Logical Proofs of Equivalence/Tautology

  • Not smaller than truth tables when there are only

a few propositional variables...

  • ...but usually much shorter than truth table proofs

when there are many propositional variables

  • A big advantage will be that we can extend them

to a more in-depth understanding of logic for which truth tables don’t apply.