1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of...

24
1 Predicate Logic Rosen 6 Rosen 6 th th ed., § 1.3-1.4 ed., § 1.3-1.4

Transcript of 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of...

Page 1: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

1

Predicate Logic

Rosen 6Rosen 6thth ed., § 1.3-1.4 ed., § 1.3-1.4

Page 2: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

2

Predicate Logic

• Predicate logicPredicate logic is an extension of is an extension of propositional logic that permits concisely propositional logic that permits concisely reasoning about whole reasoning about whole classesclasses of entities. of entities.

E.g.,E.g., “x“x>1”, “>1”, “x+yx+y=10”=10”

• Such statements are neither true or false Such statements are neither true or false when the values of the variables are not when the values of the variables are not specified.specified.

Page 3: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

3

Applications of Predicate Logic

• It is It is thethe formal notation for writing formal notation for writing perfectly clear, concise, and unambiguous perfectly clear, concise, and unambiguous mathematical mathematical definitionsdefinitions, , axiomsaxioms, and , and theorems theorems for for any any branch of mathematics.branch of mathematics.

• Supported by some of the more Supported by some of the more sophisticated sophisticated database query engines.database query engines.

• Basis for Basis for automatic theorem proversautomatic theorem provers and and many other Artificial Intelligence systems.many other Artificial Intelligence systems.

Page 4: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

4

Subjects and Predicates

• The proposition The proposition

“ “The dog is sleeping” The dog is sleeping”

has two parts:has two parts:° ““the dog” denotes the the dog” denotes the subjectsubject - the - the objectobject or or

entity entity that the sentence is about.that the sentence is about.° ““is sleeping” denotes the is sleeping” denotes the predicatepredicate- - a property a property

that the subject can havethat the subject can have..

Page 5: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

5

Propositional Functions

• A A predicatepredicate is modeled as a is modeled as a functionfunction PP(·) from (·) from objects to propositions.objects to propositions.° PP((xx) = “) = “xx is sleeping” (where is sleeping” (where xx is any object). is any object).

• The The result ofresult of applyingapplying a predicate a predicate PP to an object to an object x=ax=a is the is the proposition Pproposition P((aa). ). ° e.g.e.g. if if PP((xx) = “) = “xx > 1”, > 1”,

then then PP(3) is the (3) is the propositionproposition “3 is greater than 1.” “3 is greater than 1.”

• Note:Note: The predicate The predicate PP itselfitself ( (e.g. Pe.g. P=“is sleeping”) =“is sleeping”) is is not not a proposition (not a complete sentence).a proposition (not a complete sentence).

Page 6: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

6

Propositional Functions

• Predicate logic includes propositional Predicate logic includes propositional functions of functions of anyany number of arguments. number of arguments.

e.g.e.g. let let PP((xx,,y,zy,z) = “) = “x x gavegave y y the gradethe grade z z”, ”,

x=x=“Mike”, “Mike”, yy=“Mary”, =“Mary”, zz=“A”, =“A”,

PP((xx,,yy,,zz) = “Mike gave Mary the grade A.”) = “Mike gave Mary the grade A.”

Page 7: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

7

Universe of Discourse

• The collection of values that a variable The collection of values that a variable xx can take is called can take is called xx’s ’s universe of discourseuniverse of discourse..

e.g., let e.g., let PP((xx)=“)=“xx+1>+1>xx”. ”.

we could define the course of universe as we could define the course of universe as the the set of integersset of integers. .

Page 8: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

8

Quantifier Expressions

• QuantifiersQuantifiers allow us to allow us to quantify quantify (count) (count) how manyhow many objects in the universe of discourse satisfy a given objects in the universe of discourse satisfy a given predicate:predicate:

- “- “” is the FOR” is the FORLL or LL or universaluniversal quantifier. quantifier. xx PP((xx) means ) means for allfor all x in the u.d x in the u.d., ., PP holds. holds.

- “- “” is the ” is the XISTS or XISTS or existentialexistential quantifier. quantifier. x Px P((xx) means ) means there there existsexists an x in the u.d. an x in the u.d. (that (that is, one or more) such that is, one or more) such that PP((xx) is true.) is true.

Page 9: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

9

Universal Quantifier : Example

• Let Let PP((xx) be the ) be the predicatepredicate “ “xx is full.” is full.”

• Let the u.d. of Let the u.d. of xx be be parking spaces at UNRparking spaces at UNR..

• The The universal quantification of Puniversal quantification of P((xx), ),

xx PP((xx), is the ), is the proposition:proposition:° ““All parking spaces at UNR are full.” orAll parking spaces at UNR are full.” or

° ““Every parking space at UNR is full.” orEvery parking space at UNR is full.” or

° ““For each parking space at UNR, that space is full.”For each parking space at UNR, that space is full.”

Page 10: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

10

The Universal Quantifier

• To prove that a statement of the form To prove that a statement of the form

xx PP((xx) is false, it suffices to find a ) is false, it suffices to find a counterexamplecounterexample (i.e., one value of x in the (i.e., one value of x in the universe of discourse such that universe of discourse such that PP((xx) is false)) is false)

° e.g., e.g., PP((xx) is the predicate “x>0”) is the predicate “x>0”

Page 11: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

11

Existential Quantifier Example

• Let Let PP((xx) be the ) be the predicatepredicate “ “xx is full.” is full.”

• Let the u.d. of x be Let the u.d. of x be parking spaces at UNRparking spaces at UNR..

• The The universal quantification of Puniversal quantification of P((xx), ),

xx PP((xx), is the ), is the propositionproposition::° ““Some parking space at UNR is full.” orSome parking space at UNR is full.” or° ““There is a parking space at UNR that is full.” orThere is a parking space at UNR that is full.” or° ““At least one parking space at UNR is full.”At least one parking space at UNR is full.”

Page 12: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

12

Quantifier Equivalence Laws

• Definitions of quantifiers: If u.d.=a,b,c,… Definitions of quantifiers: If u.d.=a,b,c,… x Px P((xx) ) PP(a) (a) PP(b) (b) PP(c) (c) … … x Px P((xx) ) PP(a) (a) PP(b) (b) PP(c) (c) … …

• We can prove the following laws:We can prove the following laws:x Px P((xx) ) x x PP((xx))x Px P((xx) ) x x PP((xx))

• Which Which propositionalpropositional equivalence laws can equivalence laws can be used to prove this? be used to prove this?

Page 13: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

13

More Equivalence Laws

x Px P((xx) ) x x P P((xx) ) x Px P((xx) ) x x P P((xx) )

x x y Py P((xx,,yy) ) y y x Px P((xx,,yy))x x y Py P((xx,,yy) ) y y x Px P((xx,,yy))

x x ((PP((xx) ) QQ((xx)))) ((x Px P((xx)))) ((x Qx Q((xx))))x x ((PP((xx) ) QQ((xx)))) ((x Px P((xx)))) ((x Qx Q((xx))))

Page 14: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

14

Scope of Quantifiers

• The part of a logical expression to which a The part of a logical expression to which a quantifier is applied is called the scope of quantifier is applied is called the scope of this quantifier.this quantifier.

e.g., (e.g., (xx PP((xx)))) ((y y Q(Q(yy))))

e.g., (e.g., (xx PP((xx)))) ((x x Q(Q(xx))))

Page 15: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

15

Free and Bound Variables

• An expression like An expression like PP((xx) is said to have a ) is said to have a free variablefree variable x x (meaning (meaning xx is undefined). is undefined).

• A quantifier (either A quantifier (either or or ) ) operatesoperates on an on an expression having one or more free expression having one or more free variables, and variables, and bindsbinds one or more of those one or more of those variables, to produce an expression having variables, to produce an expression having one or more one or more boundbound variablesvariables..

Page 16: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

16

Examples of Binding

• PP((x,yx,y) has 2 free variables, ) has 2 free variables, xx and and yy.. xx PP((xx,,yy) has 1 free variable, and one bound ) has 1 free variable, and one bound

variable. [which is which?]variable. [which is which?]• ““PP((xx), where ), where xx=3” is another way to bind =3” is another way to bind xx..• An expression with An expression with zerozero free variables is an actual free variables is an actual

proposition.proposition.• An expression with one or more free variables is An expression with one or more free variables is

still only a predicate: still only a predicate: xx PP((xx,,yy))

Page 17: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

17

More to Know About Binding

xx x Px P((xx) - ) - xx is not a free variable in is not a free variable in x Px P((xx), therefore the ), therefore the xx binding isn’t used. binding isn’t used.

• ((xx PP((xx)))) Q( Q(xx) - The variable ) - The variable xx is outside of the is outside of the scopescope of the of the x x quantifier, and is therefore free. quantifier, and is therefore free. Not a proposition.Not a proposition.

• ((xx PP((xx)))) ((x x Q(Q(xx))) ) - Legal because there are 2 - Legal because there are 2 differentdifferent xx’s!’s!

• Quantifiers bind as loosely as needed:Quantifiers bind as loosely as needed:parenthesize parenthesize x x PP((xx) ) Q( Q(xx))( )

Page 18: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

18

Nested Quantifiers

Exist within the scope of other quantifiersExist within the scope of other quantifiers• Let the u.d. of Let the u.d. of xx & & yy be people. be people.• Let Let PP((xx,,yy)=“)=“x x likes likes yy” (a predicate with 2 f.v.’s)” (a predicate with 2 f.v.’s)• Then Then y Py P((x,yx,y) = “There is someone whom ) = “There is someone whom xx

likes.” (a predicate with 1 free variable, likes.” (a predicate with 1 free variable, xx))• Then Then xx ( (y Py P((x,yx,y)) = “Everyone has someone )) = “Everyone has someone

whom they like.”whom they like.”(A __________ with ___ free variables.)(A __________ with ___ free variables.)

Page 19: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

19

Order of Quantifiers Is Important!!

If If PP((xx,,yy)=“)=“xx relies upon relies upon yy,” express the ,” express the following in unambiguous English:following in unambiguous English:

xx((y Py P((x,yx,y))=))=

yy((xx PP((x,yx,y))=))=

xx((y Py P((x,yx,y))=))=

yy((x Px P((x,yx,y))=))=

xx((y Py P((x,yx,y))=))=

Everyone has someone to rely on.

There’s a poor overworked soul whom everyone relies upon (including himself)!There’s some needy person who relies upon everybody (including himself).

Everyone has someone who relies upon them.

Everyone relies upon everybody, (including themselves)!

Page 20: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

20

Natural language is ambiguous!

• ““Everybody likes somebody.”Everybody likes somebody.”° For everybody, there is somebody they like,For everybody, there is somebody they like,

xx yy LikesLikes((xx,,yy))

° or, there is somebody (a popular person) whom or, there is somebody (a popular person) whom everyone likes?everyone likes?yy xx LikesLikes((xx,,yy))

[Probably more likely.]

Page 21: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

21

Notational Conventions

• Consecutive quantifiers of the same type can be Consecutive quantifiers of the same type can be combined: combined: x x y y z Pz P((xx,,yy,,zz) ) x,y,z Px,y,z P((xx,,yy,,zz) or even ) or even xyz Pxyz P((xx,,yy,,zz))

• Sometimes the universe of discourse is restricted Sometimes the universe of discourse is restricted within the quantification, within the quantification, e.g.e.g.,, x>x>0 0 PP((xx) is shorthand for) is shorthand for

“For all “For all xx that are greater than zero, that are greater than zero, PP((xx).”).” x>x>0 0 PP((xx) is shorthand for) is shorthand for

“There is an “There is an x x greater than zero such that greater than zero such that PP((xx).”).”

Page 22: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

22

Defining New Quantifiers

As per their name, quantifiers can be used to As per their name, quantifiers can be used to express that a predicate is true of any given express that a predicate is true of any given quantityquantity (number) of objects. (number) of objects.

Define Define !!xx PP((xx) to mean “) to mean “PP((xx) is true of ) is true of exactly oneexactly one xx in the universe of discourse.” in the universe of discourse.”

!!xx PP((xx) ) x x ((PP((xx) ) y y ((PP((yy) ) y y x x))))“There is an “There is an xx such that such that PP((xx), where there is ), where there is no no yy such that P( such that P(yy) and ) and yy is other than is other than xx.”.”

Page 23: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

23

Some Number Theory Examples

• Let u.d. = the Let u.d. = the natural numbersnatural numbers 0, 1, 2, … 0, 1, 2, …

• ““A number A number xx is is eveneven, , EE((xx), if and only if it ), if and only if it is equal to 2 times some other number.”is equal to 2 times some other number.”x x ((EE((xx) ) ( (y x=y x=22yy))))

• ““A number is A number is primeprime, , PP((xx), iff it isn’t the ), iff it isn’t the product of two non-unity numbers.”product of two non-unity numbers.”

x x ((PP((xx) ) ((y,z xy,z x==yzyz yy1 1 zz11))))

Page 24: 1 Predicate Logic Rosen 6 th ed., § 1.3-1.4 2 Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning.

24

Calculus Example

• Precisely defining the concept of a limit Precisely defining the concept of a limit using quantifiers:using quantifiers:

|)(|||

::0:0

)(lim

Lxfax

x

Lxfax