1 CS 1502 Formal Methods in Computer Science Lecture Notes 12 Variables and Quantifiers.

35
1 CS 1502 Formal Methods CS 1502 Formal Methods in Computer Science in Computer Science Lecture Notes 12 Lecture Notes 12 Variables and Variables and Quantifiers Quantifiers

Transcript of 1 CS 1502 Formal Methods in Computer Science Lecture Notes 12 Variables and Quantifiers.

11

CS 1502 Formal Methods in CS 1502 Formal Methods in Computer ScienceComputer Science

Lecture Notes 12Lecture Notes 12

Variables and QuantifiersVariables and Quantifiers

22

VariablesVariables

A A variablevariable is a placeholder for a name in a is a placeholder for a name in a sentencesentence

FOL gives us an infinite number of FOL gives us an infinite number of variablesvariables

Tarski’s World/Fitch/Boole gives us only Tarski’s World/Fitch/Boole gives us only uu, , vv, , ww, , xx, , yy, and , and zz as variables as variables

33

Atomic wffsAtomic wffs

Cube(b)Cube(b)

Cube(x)Cube(x)

LeftOf(c,y)LeftOf(c,y)

Between(z,b,d)Between(z,b,d)

Larger(x,y)Larger(x,y)

44

VariablesVariables

Cube(b) Cube(b) Cube(d) Cube(d) The truth of this sentence is determined by the truth-The truth of this sentence is determined by the truth-

values of Cube(b) and Cube(d) values of Cube(b) and Cube(d) ..

Cube(x) Cube(x) Cube(d) Cube(d) Cube(x) is neither true nor false, since x is a Cube(x) is neither true nor false, since x is a placeholder for the name of an object. x is said to be placeholder for the name of an object. x is said to be

free or unbound. free or unbound.

sentence

not asentence

55

Forming wffForming wff

If If PP is wff then so is is wff then so is PP..

If If PP11, P, P22, … , P, … , Pnn are wffs then so is are wffs then so is (P(P1 1 P P2 2 … … P Pnn).).

If If PP11, P, P22, … , P, … , Pnn are wffs then so is are wffs then so is (P(P1 1 P P2 2 … … P Pnn).).

If If PP and and QQ are wffs, so is are wffs, so is (P (P Q). Q).

If If PP and and QQ are wffs, so is are wffs, so is (P (P Q). Q).

If If P P is a wff and is a wff and vv is a variable, then is a variable, then v v PP is a wff. Every is a wff. Every occurrence of occurrence of vv is said to be is said to be bound.bound.

If If P P is a wff and is a wff and vv is a variable, then is a variable, then v v PP is a wff. Every is a wff. Every occurrence of occurrence of vv is said to be bound. is said to be bound.

66

SentencesSentences

A sentence is a A sentence is a well-formed formulawell-formed formula with with no unbound (free) variables.no unbound (free) variables.

The The scopescope of a quantifier is defined as of a quantifier is defined as those variables that fall under the those variables that fall under the quantifier’s influence quantifier’s influence as indicated by the as indicated by the enclosing parentheses.enclosing parentheses.

77

Which are Sentences?Which are Sentences?

x LeftOf(x, x LeftOf(x, yy))

x (Cube(x) x (Cube(x) Large( Large(xx))))

x (Small(x) x (Small(x) Tet( Tet(yy))))

x (Cube(c) x (Cube(c) SameRow(x, c)) SameRow(x, c))

88

Satisfaction Satisfaction (diff meaning!)(diff meaning!) of a wff of a wff

Let Let S(x)S(x) be a wff with free variable be a wff with free variable xx. . Object Object b b is said to satisfy is said to satisfy S(x)S(x) if and only if if and only if S(b)S(b) is a true sentence. EG, is a true sentence. EG, b b satisfies satisfies Cube(x).Cube(x).

99

Semantics of QuantifiersSemantics of Quantifiers

x S(x) is true if and only if there is at least x S(x) is true if and only if there is at least one object that satisfies S(x). one object that satisfies S(x).

x S(x) is true if and only if every object x S(x) is true if and only if every object satisfies S(x).satisfies S(x).

The truth-value is determined withrespect to a domain of discourse

(or world, or universe)

1010

ExampleExample

Universe = {2, 5, 17, 93, 67}Universe = {2, 5, 17, 93, 67}

x Prime(x)

x RightmostDigitIsPrime(x)

x Prime(x)

x RightmostDigitIsPrime(x)

1111

Some Tetrahedron is to the left of c.

a is to the left of every Cube.

Some Cube is to the left of c.

Every Cube is in back of c.

C is supposed to be back one square – as it is on the next slide

1212

1313

Aristotelian FormsAristotelian Forms

All P’s are Q’sAll P’s are Q’s

x [P(x) Q(x)]

Q

+ P

1414

Aristotelian FormsAristotelian Forms

Some P’s are Q’sSome P’s are Q’s

x [P(x) Q(x)]

Q P +

1515

Aristotelian FormsAristotelian Forms

No P’s are Q’sNo P’s are Q’s

x [P(x) Q(x)]

Q

+ P

1616

Aristotelian FormsAristotelian Forms

Some P’s are not Q’sSome P’s are not Q’s

x [P(x) Q(x)]

Q+ P

1717

TranslationTranslation

x (Tet(x) x (Tet(x) LeftOf(x, c)) LeftOf(x, c))

x (Tet(x) x (Tet(x) Large(x) Large(x) LeftOf(x, c)) LeftOf(x, c))

x [Cube(x) x [Cube(x) BackOf(x, c)] BackOf(x, c)]

x [(Small(x) x [(Small(x) Cube(x)) Cube(x)) BackOf(x, c)] BackOf(x, c)]

Some Tet is to the left of c.

Every cube is in back of c.

Some large Tet is to the left of c.

Every small cube is in back of c.

1818

TranslationTranslation

all x (Student(x) all x (Student(x) Smart(x)). Smart(x)).

““Every student is smart.’’Every student is smart.’’

““Pick anything at all. Either it’s not a Pick anything at all. Either it’s not a student or it’s smart (or both!)” student or it’s smart (or both!)”

““Pick anything at all. It cannot be a Pick anything at all. It cannot be a student who is not smart.”student who is not smart.”

““Pick anything at all. If it’s a student, it’s Pick anything at all. If it’s a student, it’s smart.” smart.”

1919

What’s wrong with this What’s wrong with this translation?translation?

““Every student is smart”Every student is smart”

Bad translation:Bad translation:

all x (Student(x) ^ Smart(x))all x (Student(x) ^ Smart(x))

Good translation:Good translation:

all x (Student(x) all x (Student(x) Smart(x)) Smart(x))

2020

What’s wrong with this What’s wrong with this translation?translation?

““Some student is smart”Some student is smart”

Bad translation:Bad translation:

exists x (student(x) exists x (student(x) smart(x)) smart(x))

Good translation:Good translation:

exists x (student(x) ^ smart(x))exists x (student(x) ^ smart(x))

2121

TranslationTranslation

x and x and

x and x and

2222

Quantifiers and FunctionsQuantifiers and Functions

Everyone is taller than Max’s father.Everyone is taller than Max’s father.

Someone’s father is taller than Max.Someone’s father is taller than Max.

e is the leftmost object in the row of e is the leftmost object in the row of something.something.

x (Person(x) ^ ~(x = father(max))) Taller(x, father(max))

x (Person(x) ^ Taller(father(x), Max))

x (lm(x) = e)

2323

Quantifiers can make things interestingQuantifiers can make things interesting……

Which are valid?Which are valid? 1. all x (Student(x) Smart(x))2. all x (Student(x))

3. all x (Smart(x))

1. all x (Student(x))2. all x (Smart(x))

3. all x (Student(x) ^ Smart(x))

1. exist x (Student(x) Smart(x))2. exist x (Student(x))

3. exist x (Smart(x))

1. exist x (Student(x))2. exist x (Smart(x))

3. exist x (Student(x) ^ Smart(x))

Yup!

Nope!

Yup!

Nope!

2424

Quantifiers and TautologyQuantifiers and Tautology

When is a sentence involving quantifiers a When is a sentence involving quantifiers a tautology?tautology?

Example: Example: x Cube(x) x Cube(x) x x Cube(x)Cube(x)

Example: Example: x Small(x) x Small(x) x Small(x)x Small(x)

No!

Yes!

2525

Tautologies and QuantifiersTautologies and Quantifiers

One way to arrive at tautologies is to One way to arrive at tautologies is to substitute complex sentences into known substitute complex sentences into known tautologiestautologies

P v ~PP v ~P is a tautology. Thus, so is: is a tautology. Thus, so is:

(all x (Doctor(x) (all x (Doctor(x) Rich(x))) v Rich(x))) v

~(all x (Doctor(x) ~(all x (Doctor(x) Rich(x))) Rich(x)))

2626

Truth-Functional Form AlgorithmTruth-Functional Form Algorithm

Start at the beginning of sentence S and Start at the beginning of sentence S and proceed to the right. proceed to the right. If you encounter a If you encounter a quantifier, underline thequantifier, underline the quantifier and the stuff quantifier and the stuff in its scope.in its scope. If you encounter anIf you encounter an atomic atomic sentence simply underline it.sentence simply underline it. When you come to When you come to the end of an underline assign a letter (A, B, C, the end of an underline assign a letter (A, B, C, …). …). If anIf an underlined sentence is identical to a underlined sentence is identical to a previous one (character for character), use the previous one (character for character), use the samesame letter.letter. If the sentence formed from the If the sentence formed from the letters is a tautology, then the original is too.letters is a tautology, then the original is too.

Note: Note: Small(a)Small(a) is not the same as is not the same as Small(b).Small(b). Similarly, Similarly, Small(x)Small(x) is not the same as is not the same as Small(y).Small(y).

2727

When is a sentence a When is a sentence a tautology?tautology?

A quantified sentence S is a tautology if and A quantified sentence S is a tautology if and only if its truth-functional form is a tautology.only if its truth-functional form is a tautology.

Example:Example:

(exist y (P(y) v R(y)) (exist y (P(y) v R(y)) all x (P(x) ^ Q(x))) all x (P(x) ^ Q(x))) (~all x (P(x) ^ Q(x)) (~all x (P(x) ^ Q(x)) ~exist y (P(y) v R(y))) ~exist y (P(y) v R(y)))

TFF: (A B) (~B ~A) Tautology? Yes

2828

Another ExampleAnother Example

x Cube(x) x Cube(x) x x Cube(x)Cube(x)

A B

Since A B is not a tautology, then neither is the sentence above.

2929

Another ExampleAnother Example

x Cube(x) x Cube(x) [[x Cube(x)]x Cube(x)]

A A

Since A A is a tautology, then so is the sentence above.

3030

Another ExampleAnother Example

(Tet(d) (Tet(d) x Small(x)) x Small(x)) ( (Tet(d) Tet(d) y Small(y)) y Small(y))

A B A C

(A B) (A C)

3131

3232

Tautological Valid?Tautological Valid?

Is the following argument valid or invalid?Is the following argument valid or invalid?

x Cube(x)x Small(x)x (Cube(x) Small(x))

Not tautologically valid!!!In fact, it is not logically valid.

ABC

3333

Tautological Valid?Tautological Valid?

Is the following argument valid or invalid?Is the following argument valid or invalid?

x Cube(x) x Small(x) x Cube(x) x Small(x)

Is tautologically valid!!!A BAB

3434

NoteNote

An argument that is not tautologically valid An argument that is not tautologically valid may still be logically valid. In this case, we may still be logically valid. In this case, we cannot recognize it is valid by checking all cannot recognize it is valid by checking all the rows of the truth table.the rows of the truth table.

3535

Tautological Valid?Tautological Valid?

Is the following argument valid or invalid?Is the following argument valid or invalid?

x [Cube(x) Small(x)]x Cube(x) x Small(x)

Is not tautologically valid.It is logically valid!

A BC