FirstOrder Logic Representation Chapter 8 1 8 2

  • Slides: 33
Download presentation
First-Order Logic Representation Chapter 8. 1 & 8. 2 • FOL Syntax • FOL

First-Order Logic Representation Chapter 8. 1 & 8. 2 • FOL Syntax • FOL Semantics • Thinking in FOL 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 1

FOL n Logics are characterized by what they commit to as "primitives". Logic Propositional

FOL n Logics are characterized by what they commit to as "primitives". Logic Propositional First-Order What Exists in World Knowledge States facts true/false/unknown facts, objects, true/false/unknown relations Temporal facts, objects, relations, times facts true/false/unknown degree of truth degree of belief 0. . 1 Probability Theory Fuzzy 11/22/2020 degree of belief 0. . 1 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 2

FOL Syntax FWhat does the following FOL sentence mean? $x [Person(x) Ù "t (Time(t)

FOL Syntax FWhat does the following FOL sentence mean? $x [Person(x) Ù "t (Time(t) Þ Fool(x, t))] Ù $t [Time(t) Ù "x (Person(x) Þ Fool(x, t))] Ù Ø"t, x [Time(t) Ù Person(x) Þ Fool(x, t)] n Abraham Lincoln: "If you once forfeit the confidence of your fellow citizens, you can never regain their respect and esteem. It is true that you may fool some of the people all of the time; you can even fool all of the people some of the time, but you can’t fool all of the people all of the time. " 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 3

FOL Syntax n FOL fixes problems with PL: q q q n PL doesn’t

FOL Syntax n FOL fixes problems with PL: q q q n PL doesn’t have variables. FOL does. Identifying individuals in PL is hard. FOL it’s easy. PL can't directly express properties of individuals or relations between individuals. FOL can. Inferencing in PL is fairly easy. In FOL it is more complicated. 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 4

FOL Syntax n A term denotes an object in the world. q q q

FOL Syntax n A term denotes an object in the world. q q q Constant: Bob. Smith, 2, Madison, Green, … Variable: x, y, a, b, c, … Function(Term 1, …, Termn): n n n Sqrt(9), Distance(Madison, Milwaukee) is a relation for which there is one answer maps one or more objects to another single object can refer to an unnamed object: e. g. Left. Leg. Of(John) represents a user defined functional relation cannot be used with logical connectives A ground term is a term with no variables. 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 5

FOL Syntax n An atom/literal is smallest expression to which a truth value can

FOL Syntax n An atom/literal is smallest expression to which a truth value can be assigned. q Predicate(Term 1, …, Termn): Teacher(John, Deb), <=(Sqrt(2), Sqrt(7)) n is a relation for which there is more than one answer n maps one or more objects to a truth value n represents a user defined truth relation q Term 1 = Term 2: Income(John) = 20 K, 1 = 2 n represents the equality relation when two terms refer to the same object n is a predicate in prefix form: =(Term 1, Term 2) 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 6

FOL Syntax n A sentence represents a fact in the world that is assigned

FOL Syntax n A sentence represents a fact in the world that is assigned a truth value. q q atom complex sentence using connectives: Ù Ú Ø Þ Û Friend(Deb, Jim) Þ Friend(Jim, Deb) >(11, 22) Ù <(22, 33) q complex sentence using quantified variables: " $ more in a bit… 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 7

FOL Syntax: Assigning Truth Þ Sentences are assigned a truth value with respect to

FOL Syntax: Assigning Truth Þ Sentences are assigned a truth value with respect to a model and an interpretation. n The model contains the objects and the relations among them. q n the domain of a model is the set of objects it contains The interpretation specifies what the symbols refer to: q q q constants symbols refer to objects predicate symbols refer to truth relations functional symbols refer to functional relations 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 8

FOL Semantics: Assigning Truth Þ The atom Predicate(Term 1, …, Termn) is true iff

FOL Semantics: Assigning Truth Þ The atom Predicate(Term 1, …, Termn) is true iff the objects referred to by Term 1, …, Termn are in the relation referred to by the predicate. n What is the truth value for F(D, J)? q model objects: relation: q Deb, Jim, Sue, Bob Friend {<Deb, Sue>, <Sue, Deb>} interpretation D means Deb, J means Jim, S means Sue, B means Bob F(Term 1, Term 2) means Term 1 is friend of Term 2 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 9

FOL Syntax: Quantifiers Universal quantifier: "<variables> <sentence> Þ n Means the sentence holds true

FOL Syntax: Quantifiers Universal quantifier: "<variables> <sentence> Þ n Means the sentence holds true for all values of x in the domain of variable x. Main connective typically Þ forming if-then rules q All humans are mammals. Becomes what in FOL? Mammals must have fur. Becomes what in FOL? "x Human(x) Þ Mammal(x) for all x if x is a human then x is a mammal q "x Mammal(x) Þ Has. Fur(x) for all x if x is a mammal then x has fur 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 10

FOL Syntax: Quantifiers "x Human(x) Þ Mammal(x) n Equivalent to conjunction of instantiations of

FOL Syntax: Quantifiers "x Human(x) Þ Mammal(x) n Equivalent to conjunction of instantiations of x: (Human(Jim) Þ Mammal(Jim)) Ù (Human(Deb) Þ Mammal(Deb)) Ù (Human(22) Þ Mammal(22) ) Ù … n Common mistake is to use Ù as main connective. q n results in a blanket statement about everything Bad example "x Human(x) Ù Mammal(x)means? q everything is human and a mammal (Human(Jim) Ù Mammal(Jim)) Ù (Human(Deb) Ù Mammal(Deb)) Ù (Human(22) Ù Mammal(22) ) Ù … 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 11

FOL Syntax: Quantifiers Existential quantifier: $<variables> <sentence> Þ n Means the sentence holds true

FOL Syntax: Quantifiers Existential quantifier: $<variables> <sentence> Þ n Means the sentence holds true for some value of x in the domain of variable x. Main connective typically Ù q Some humans are old. Becomes what in FOL? Mammals may have arms. Becomes what in FOL? $x Human(x) Ù Old(x) there exist an x such that x is a human and x is old q $x Mammal(x) Ù Has. Arms(x) there exist an x such that x is a mammal and x has arms 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 12

FOL Syntax: Quantifiers $x Human(x) Ù Old(x) n Equivalent to disjunction of instantiations of

FOL Syntax: Quantifiers $x Human(x) Ù Old(x) n Equivalent to disjunction of instantiations of x: (Human(Jim) Ù Old(Jim)) Ú (Human(Deb) Ù Old(Deb)) Ú (Human(22) Ù Old(22) ) Ú … n Common mistake is to use Þ as main connective. q n results in a weak statement Bad example $x Human(x) Þ Old(x) means? q true if there is anything that isn't human (Human(Jim) Þ Old(Jim)) Ú (Human(Deb) Þ Old(Deb)) Ú (Human(22) Þ Old(22) ) Ú … 11/22/2020 22 not human! © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 13

FOL Syntax: Quantifiers n n "x "y Likes(x, y) is what in English? Everyone

FOL Syntax: Quantifiers n n "x "y Likes(x, y) is what in English? Everyone likes everyone. It’s the active voice. "y "x Likes(x, y) is what in English? Everyone is liked by everyone. It’s the passive voice. FDo these mean the same thing? n Property of quantifiers: q q q "x "y is the same as "y "x $x $y is the same as $y $x note: $x $y can be written as $x, y, likewise with " 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 14

FOL Syntax: Quantifiers n n "x $y Likes(x, y) is what in English? Everyone

FOL Syntax: Quantifiers n n "x $y Likes(x, y) is what in English? Everyone likes someone. again the active voice $y "x Likes(x, y) is what in English? Someone is liked by everyone. again the passive voice FDo these mean the same thing? n Property of quantifiers: q q "x $y is not the same as $y "x $x "y is not the same as "y $x 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 15

FOL Syntax: Quantifiers n "x Likes(x, Ice. Cream) is what in English? Everyone likes

FOL Syntax: Quantifiers n "x Likes(x, Ice. Cream) is what in English? Everyone likes ice cream. n Ø$x ØLikes(x, Ice. Cream) is what in English? No one doesn't like ice cream. It's a double negative! FDo these mean the same thing? n Properties of quantifiers: q q q "x P(x) is the same as Ø$x ØP(x) $x P(x) is the same as Ø"x ØP(x) This is the negation of the application of de Morgan's law to the fully instantiated sentence. 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 16

FOL Syntax: Quantifiers n "x Likes(x, Ice. Cream) is what in English? Everyone likes

FOL Syntax: Quantifiers n "x Likes(x, Ice. Cream) is what in English? Everyone likes ice cream. FWhat is the logical negation of this sentence? Not everyone likes ice cream. which is the same as… $x ØLikes(x, Ice. Cream) is what in English? Someone doesn't like ice cream. n Properties of quantifiers: q q q "x P(x) when negated is $x ØP(x) $x P(x) when negated is "x ØP(x) This is from the application of de Morgan's law to the fully instantiated sentence. 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 17

FOL Syntax: Basics n A free variable is a variable that isn't bound by

FOL Syntax: Basics n A free variable is a variable that isn't bound by a quantifier. q n $y Likes(x, y) x is free, y is bound A well-formed formula is a sentence where all variables are quantified. 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 18

Thinking in FOL FConvert the following English sentences to FOL. n Bob is a

Thinking in FOL FConvert the following English sentences to FOL. n Bob is a fish. q q n n n What are the objects? Bob look for nouns and noun phrases What are the relations? is a fish look for verbs and verb phrases Answer: Fish(Bob) a unary relation or property Deb and Sue are women. Deb and Sue aren't plants. Deb and Sue aren’t friends. we'll be casual about plurals 11/22/2020 ambiguous? use a function? predicate? © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 19

Thinking in FOL FConvert the following English sentences to FOL. n America bought Alaska

Thinking in FOL FConvert the following English sentences to FOL. n America bought Alaska from Russia. q q What are the objects? America, Alaska, Russia What are the relations? bought(who, what, from) an n-ary relation where n is 3 Answer: Bought(America, Alaska, Russia) Þ The model must include the ordering and meaning of a predicate’s terms. n Warm is between cold and hot. Deb, Lynn, Jim, and Steve went together to APT. n 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 20

Thinking in FOL FNow lets think about quantifying variables. n Jim collects everything. q

Thinking in FOL FNow lets think about quantifying variables. n Jim collects everything. q q What are the objects? Jim What are the variables and how are they quantified? everything x, all - universal Answer: "x Collects(Jim, x) Collects(Jim, Pencil) Ù Collects(Jim, Deb) Ù … n n Jim collects something. Somebody collects Jim. 11/22/2020 How do you handle "body"? © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 21

Thinking in FOL When to restrict the domain, e. g. people: n All: q

Thinking in FOL When to restrict the domain, e. g. people: n All: q q n things: anything, everything, whatever people: anybody, anyone, everybody, everyone, whoever Some (at least one): $x Person(x)Ù. . . q q n "x Person(x)Ù. . . Þ. . . things: something people: somebody, someone None: q q Ø$x Person(x)Ù. . . things: nothing people: nobody, no one 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 22

Thinking in FOL FHow about sentences with multiple variables? n Somebody collects something. q

Thinking in FOL FHow about sentences with multiple variables? n Somebody collects something. q q What are the objects? none! What are the variables and how are they quantified? somebody x and something y, some - existential Answer: $ x, y Person(x) Ù Collects(x, y) n n n Everybody collects everything. Everybody collects something. Something is collected by everybody. 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 23

Thinking in FOL FConvert the following English sentences to FOL. n Nothing collects anything.

Thinking in FOL FConvert the following English sentences to FOL. n Nothing collects anything. q q What are the variables? nothing x and anything y How are they quantified? not one (i. e. not existential) and all (universal) Answer: Ø$x "y Collects(x, y) FWhat’s the “double-negative” equivalent? Everything does not collect anything. Answer: "x, y ØCollects(x, y) n Everything collects nothing. 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 24

Thinking in FOL FAnd more complex quantified sentences: n All hoarders collect everything. q

Thinking in FOL FAnd more complex quantified sentences: n All hoarders collect everything. q How are ideas connected? being a hoarder implies collecting everything Answer: "x, y Horder(x) Þ Collects(x, y) n Hoarders collect valuable things. q q Is ambiguous! Some hoarders collect all valuable things. Some hoarders collect some valuable things. All hoarders collect all valuable things. 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 25

Thinking in FOL FAnd more complex quantified sentences: n All stinky shoes are allowed.

Thinking in FOL FAnd more complex quantified sentences: n All stinky shoes are allowed. (1 st) How are ideas connected? being any shoe and stinky implies it is allowed Answer: "x Shoe(x) Ù Stinky(x) Þ Allowed(x) q n No stinky shoes are allowed. (2 nd) Answer: Ø$x Shoe(x) Ù Stinky(x) Ù Allowed(x) FWhat is the equivalent of the 2 nd sentence? (All) Stinky shoes are not allowed. Answer: "x Shoe(x) Ù Stinky(x) Þ ØAllowed(x) FIs the 2 nd sentence the logical negative of 1 st? 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 26

Thinking in FOL FAnd even more complex quantified sentences: n Any good amateur can

Thinking in FOL FAnd even more complex quantified sentences: n Any good amateur can beat some professional. q q q break into components "x [ (x is a good amateur) Þ (x can beat some professional) ] (x can beat some professional) becomes $y [ (y is a professional) Ù (x can beat y) ] Answer: "x [(Amateur(x) Ù Good. Player(x)) Þ $y (Professional(y) Ù Beat(x, y))] n Some professionals can beat all amateurs. 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 27

Thinking in FOL FAnd now for functional relations and equalities: n John's income is

Thinking in FOL FAnd now for functional relations and equalities: n John's income is 20 K. q q Are functional relations specified? Are equalities specified? Answer: Income(John) = 20 K n There are exactly two shoes. q q Are quantities specified? Are equalities implied? Answer: $x, y Shoe(x) Ù Shoe(y) Ù Ø(x=y) Ù "z (Shoe(z) Þ (x=z) Ú (y=z)) 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 28

Thinking in FOL n Interesting words: always, sometimes, never q Good people always have

Thinking in FOL n Interesting words: always, sometimes, never q Good people always have friends. could mean: All good people have friends. "x Person(x) Ù Good(x) Þ $y(Friend(x, y)) q Busy people sometimes have friends. could mean: Some busy people have friends. $x Person(x) Ù Busy(x) Ù $y(Friend(x, y)) q Bad people never have friends. could mean: Bad people have no friends. "x Person(x) Ù Bad(x) Þ Ø$y(Friend(x, y)) or equivalently: No bad people have friends. Ø$x Person(x) Ù Bad(x) Ù $y(Friend(x, y)) 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 29

Thinking in FOL n The "interesting words" are ambiguous in that they can quantify

Thinking in FOL n The "interesting words" are ambiguous in that they can quantify a variable as in the last slide or they may refer to units of time. n Temporal indicators: while, whenever, … q q help determine when "interesting words“ refer to time rather than quantifying a variable Jo always writes home when she is away from home. "x Time(x)Ù Away(Jo, Home, x)Þ Writes(Jo, Home, x) 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 30

Thinking in FOL FDefinitions can be self referencing: n X is above Y if

Thinking in FOL FDefinitions can be self referencing: n X is above Y if X is directly on the top of Y or else there is a pile of one or more other objects directly on top of another starting with X and ending with Y. Answer: "x "y Above(x, y) Û [On. Top(x, y) Ú $z(On. Top(x, z) Ù Above(z, y))] 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 31

Summary of FOL Representation n Constants: Bob, 2, Madison, … n Functions: Income, Address,

Summary of FOL Representation n Constants: Bob, 2, Madison, … n Functions: Income, Address, Sqrt, … n Predicates: Sister, Teacher, <=, … n Variables: x, y, a, b, c, … n Connectives: Ø Ù Ú Þ Û n Equality: = n Quantifiers: "$ 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 32

Summary of FOL Representation n Term: q q q n Atom/Literal: q q n

Summary of FOL Representation n Term: q q q n Atom/Literal: q q n Predicate(Term 1, … Termn), Term 1 = Term 2 is smallest expression assigned a truth value Sentence: q q n Constant, variable, Function(Term 1, …Termn) denotes an object in the world Ground Term has no variables atom, quantified sentence with variables or complex sentence using connectives is assigned a truth value Well-Formed Formula: q sentence where all variables are quantified 11/22/2020 © 2001 -2004 James D. Skrentny from notes by C. Dyer, et. al. 33