36
CS322 Week 1 - Wednesday

Week 1 - Wednesday. Course overview Propositional logic Truth tables AND, OR, NOT Logical equivalence

Embed Size (px)

Citation preview

Page 1: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

CS322Week 1 - Wednesday

Page 2: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Last time

Course overview Propositional logic

Truth tables AND, OR, NOT Logical equivalence

Page 3: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Questions?

Page 4: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Logical warmup

You come to a fork in the road Two men stand beneath a sign that

reads: Ask for the way, but waste not your

breath One road is freedom, the other is death Just one of the pair will lead you aright For one is a Knave, the other a Knight

What single yes or no question can you ask to determine which fork to take?

Page 5: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

De Morgan’s Laws

What’s an expression that logically equivalent to ~(p q) ?

What about logically equivalent to ~(p q) ?

De Morgan’s Laws state: ~(p q) ~p ~q ~(p q) ~p ~q Essentially, the negation flips an AND to

an OR and vice versa

Page 6: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Tautologies and Contradictions

Page 7: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Tautology

A tautology is something that is true no matter what

Examples: T p ~p p p

The final column in a truth table for a tautology is all true values

The book sometimes writes a statement which is a tautology as a t

Page 8: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Contradiction

A contradiction is something that is false no matter what

Examples: F p ~p ~(p p)

The final column in a truth table for a contradiction is all false values

The book sometimes writes a statement which is a contradiction as a c

Page 9: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Laws of Boolean algebraName Law Dual

Commutative p q q p p q q p

Associative (p q) r p (q r) (p q) r p (q r)

Distributive p (q r) (p q) (p r) p (q r) (p q) (p r)

Identity p t p p c p

Negation p ~p t p ~p c

Double Negative ~(~p) p

Idempotent p p p p p p

Universal Bound p t t p c c

De Morgan’s ~(p q) ~p ~q ~(p q) ~p ~q

Absorption p (p q) p p (p q) p

Negations of t and c

~t c ~c t

Page 10: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Back to Implications

Page 11: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

What are you implying?

You can construct all possible outputs using combinations of AND, OR, and NOT

But, sometimes it’s useful to introduce notation for common operations

This truth table is for p qp q p qT T TT F FF T TF F T

Page 12: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

If…

We use to represent an if-then statement Let p be “The moon is made of green

cheese” Let q be “The earth is made of rye bread” Thus, p q is how a logician would write:

If the moon is made of green cheese, then the earth is made of rye bread

Here, p is called the hypothesis and q is called the conclusion

What other combination of p and q is logically equivalent to p q ?

Page 13: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Why is implication used that way?

p q is true when: p is true and q is true p is false

Why? For the whole implication to be true, the

conclusion must always be true when the hypothesis is true

If the hypothesis is false, it doesn’t matter what the conclusion is

“If I punch the tooth fairy in the face, I will be Emperor of the World”

What’s the negation of an implication?

Page 14: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Contrapositive

Given a conditional statement p q, its contrapositive is ~q ~p

Conditional:“If a murderer cuts off my head, then I will

be dead.” Contrapositive:

“If I am not dead, then a murderer did not cut off my head.”

What’s the relationship between a conditional and its contrapositive?

Page 15: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Converse and inverse

Given a conditional statement p q: Its converse is q p Its inverse is ~p ~q Consider the statement:

“If angry ham sandwiches explode, George Clooney will become immortal.”

What is its converse? What is its inverse? How are they related?

Page 16: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Biconditional

Sometimes people say “if and only if”, as in: “A number is prime if and only if it is divisible only by

itself and 1.” This can be written p iff q or p q This is called the biconditional and has this truth

table:

What is the biconditional logically equivalent to?

p q p qT T T

T F F

F T F

F F T

Page 17: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Arguments

Page 18: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Arguments

An argument is a list of statements (called premises) followed by a single statement (called a conclusion)

Whenever all of the premises are true, the conclusion must also be true, in order to make the argument valid

Page 19: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Examples

Are the following arguments valid? p q ~r (premise) q p r (premise) p q (conclusion)

p (q r) (premise) ~r (premise) p q (conclusion)

Page 20: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Common argument tools

Modus ponens is a valid argument of the following form: p q p q

Modus tollens is a contrapositive reworking of the argument, which is also valid: p q ~q ~p

Give verbal examples of each We call these short valid arguments rules of

inference

Page 21: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Generalization

The following are also valid rules of inference: p p q

q p q

English example: “If pigs can fly, then pigs can fly or swans can breakdance.”

Page 22: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Specialization

The following are also valid rules of inference: p q p

p q q

English example: “If the beat is out of control and the bassline just won’t stop, then the beat is out of control.”

Page 23: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Conjunction

The following is also a valid rule of inference: p q p q

English example: “If the beat is out of control and the bassline just won’t stop, then the beat is out of control and the bassline just won’t stop.”

Page 24: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Elimination

The following are also valid rules of inference: p q ~q p

p q ~p q

English example: “If you’re playing it cool or I’m maxing and relaxing, and you’re not playing it cool, then I’m maxing and relaxing.”

Page 25: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Transitivity

The following is also a valid rule of inference: p q q r p r

English example: “If you call my mom ugly I will call my brother, and if I call my brother he will beat you up, then if you call my mom ugly my brother will beat you up.”

Page 26: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Division into cases

The following is also a valid rule of inference: p q p r q r r

English example: “If am fat or sassy, and being fat implies that I will give you trouble, and being sassy implies that I will give you trouble, then I will give you trouble.”

Page 27: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Contradiction Rule

The following is also a valid rule of inference: ~p c p

English example: “If my water is at absolute zero then the universe does not exist, thus my water must not be at absolute zero.”

Page 28: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Fallacies

A fallacy is an argument that is not valid

It could mean that the conclusion is not true in only a single case in the truth table

But, if the conclusion is ever false whenever all the premises are true, the argument is a fallacy

Most arguments presented by politicians are fallacies for one reason or another

Page 29: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Common fallacies

Converse error If Joe sings a sad song, then Joe will

make it better. Joes makes it better. Conclusion: Joe sings a sad song.

FALLACY Inverse error

If you eat too much, you will get sick. You are not eating too much. Conclusion: You will not get sick.

FALLACY

Page 30: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Digital Logic Circuits

Page 31: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Digital logic circuits

Digital logic circuits are the foundation of all computer hardware

Circuits are built out of components called gates

A gate has one or more inputs and an output

Gates model Boolean operations Usually, in digital logic, we use a 1

for true and a 0 for false

Page 32: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Common gates

The following gates have the same function as the logical operators with the same names:

NOT gate:

AND gate:

OR gate:

Page 33: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Example

Draw the digital logic circuit corresponding to:

(p ~q) ~(p r)

What’s the corresponding truth table?

Page 34: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Upcoming

Page 35: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Next time…

Predicate logic Universal quantifier Existential quantifier

Page 36: Week 1 - Wednesday.  Course overview  Propositional logic  Truth tables  AND, OR, NOT  Logical equivalence

Reminders

Read Chapter 3