30
CS322 Week 2 - Wednesday

CS322

  • Upload
    magda

  • View
    52

  • Download
    0

Embed Size (px)

DESCRIPTION

Week 2 - Wednesday. CS322. Last time. What did we talk about last time? Arguments Digital logic circuits Predicate logic Universal quantifier Existential quantifier. Questions?. Logical warmup. 1. Four men are standing in front of a firing-squad #1 and #3 are wearing black hats - PowerPoint PPT Presentation

Citation preview

Page 1: CS322

CS322Week 2 - Wednesday

Page 2: CS322

Last time

What did we talk about last time? Arguments Digital logic circuits Predicate logic

Universal quantifier Existential quantifier

Page 3: CS322

Questions?

Page 4: CS322

Logical warmup Four men are standing in front of a firing-

squad #1 and #3 are wearing black hats #2 and #4 are wearing white hats They are all facing the same direction with a

wall between #3 and #4 Thus,

#1 sees #2 and #3 #2 sees #3 #3 and #4 see no one

The men are told that two white hats and two black hats are being worn

The men can go if one man says what color hat he's wearing

No talking is allowed, with the exception of a man announcing what color hat he's wearing.

Are they set free? If so, how?

1

3

2

4

Page 5: CS322

Digital Logic Review

Page 6: CS322

Common gates The following gates have the same function as

the logical operators with the same names:

NOT gate:

AND gate:

OR gate:

Page 7: CS322

Digital logic exercises

Build an OR circuit using only AND and NOT gates

Build a bidirectional implication circuit using AND, OR, and NOT gates

Page 8: CS322

Predicate Logic

Page 9: CS322

Universal quantification

The universal quantifier means “for all” The statement “All DJ’s are mad ill” can

be written more formally as:x D, M(x)

Where D is the set of DJ’s and M(x) denotes that x is mad ill

Notation: P(x) Q(x) means, for predicates P(x) and

Q(x) with domain D: x D, P(x) Q(x)

Page 10: CS322

Existential quantification The universal quantifier means

“there exists” The statement “Some emcee can

bust a rhyme” can be written more formally as:

y E, B(y) Where E is the set of emcees and B(y)

denotes that y can bust a rhyme

Page 11: CS322

Quantified examples Consider the following:

S(x) means that x is a square R(x) means that x is a rectangle H(x) means that x is a rhombus P is the set of all polygons

Which of the following is true: x P, S(x) R(x) x P, R(x) S(x) x P, R(x) H(x) S(x) x P, R(x) ~S(x) x P, ~R(x) H(x) x P, R(x) ~S(x) x P, ~H(x) S(x)

Page 12: CS322

More quantified examples Convert the following statements in

English into quantified statements of predicate logic Every son is a descendant Every person is a son or a daughter There is someone who is not a

descendant Every parent is a son or a daughter There is a descendant who is not a son

Page 13: CS322

Negating Quantifiers and Multiple QuantifiersStudent Lecture

Page 14: CS322

Negating quantified statements When doing a negation, negate the

predicate and change the universal quantifier to existential or vice versa

Formally: ~(x, P(x)) x, ~P(x) ~(x, P(x)) x, ~P(x)

Thus, the negation of "Every dragon breathes fire" is "There is one dragon that does not breathe fire"

Page 15: CS322

Negation example Argue the following:

"Every unicorn has five legs" First, let's write the statement formally

Let U(x) be "x is a unicorn" Let F(x) be "x has five legs" x, U(x) F(x)

Its negation is x, ~(U(x) F(x)) We can rewrite this as x, U(x) ~F(x)

Informally, this is "There is a unicorn which does not have five legs"

Clearly, this is false If the negation is false, the statement must be true

Page 16: CS322

Vacuously true

The previous slide gives an example of a statement which is vacuously true

When we talk about "all things" and there's nothing there, we can say anything we want

Page 17: CS322

Conditionals Recall:

Statement: p q Contrapositive:~q ~p Converse:q p Inverse: ~p ~q

These can be extended to universal statements: Statement: x, P(x) Q(x) Contrapositive:x, ~Q(x) ~P(x) Converse:x, Q(x) P(x) Inverse: x, ~P(x) ~Q(x)

Similar properties relating a statement equating a statement to its contrapositive (but not to its converse and inverse) apply

Page 18: CS322

Necessary and sufficient

The ideas of necessary and sufficient are meaningful for universally quantified statements as well:

x, P(x) is a sufficient condition for Q(x) means x, P(x) Q(x)

x, P(x) is a necessary condition for Q(x) means x, Q(x) P(x)

Page 19: CS322

Multiple Quantifiers

Page 20: CS322

Multiple quantifiers

So far, we have not had too much trouble converting informal statements of predicate logic into formal statements and vice versa

Many statements with multiple quantifiers in formal statements can be ambiguous in English

Example: “There is a person supervising every

detail of the production process.”

Page 21: CS322

Example

“There is a person supervising every detail of the production process.”

What are the two ways that this could be written formally? Let D be the set of all details of the production

process Let P be the set of all people Let S(x,y) mean “x supervises y”

x D, y P such that S(x,y)

y P, x D such that S(x,y)

Page 22: CS322

Mechanics Intuitively, we imagine that corresponding

“actions” happen in the same order as the quantifiers

The action for x A is something like, “pick any x from A you want”

Since a “for all” must work on everything, it doesn’t matter which you pick

The action for y B is something like, “find some y from B”

Since a “there exists” only needs one to work, you should try to find the one that matches

Page 23: CS322

Tarski’s World Example

Is the following statement true? “For all blue items x, there is a green item y with the

same shape.” Write the statement formally. Reverse the order of the quantifiers. Does its truth value

change?

a

c

g

b

d

f

i

k

e

h

j

Page 24: CS322

Practice

Given the formal statements with multiple quantifiers for each of the following: There is someone for everyone. All roads lead to some city. Someone in this class is smarter than

everyone else. There is no largest prime number.

Page 25: CS322

Negating multiply quantified statements The rules don’t change Simply switch every to and every

to Then negate the predicate Write the following formally:

“Every rose has a thorn” Now, negate the formal version Convert the formal version back to

informal

Page 26: CS322

Changing quantifier order As show before, changing the order of

quantifiers can change the truth of the whole statement

However, it does not necessarily Furthermore, quantifiers of the same type

are commutative: You can reorder a sequence of quantifiers

however you want The same goes for Once they start overlapping, however, you can’t

be sure anymore

Page 27: CS322

Quiz

Page 28: CS322

Upcoming

Page 29: CS322

Next time…

Arguments with quantifiers

Page 30: CS322

Reminders Keep reading Chapter 3 Assignment 1 is due Friday at midnight The company EC Key is sponsoring a contest to

come up with novel uses for their BlueTooth door access technology Interested? Come to the meeting this Friday, 1/22 at

3:30pm in Hoover 110 Teams will be formed from CS, engineering, and

business students Ask me for more information!

Also, there's a field trip to Cargas Systems in Lancaster next Friday