Todays Topics Predicate Logic aka FirstOrder Predicate Calculus

  • Slides: 39
Download presentation
Today’s Topics • Predicate Logic (aka First-Order Predicate Calculus, FOPC; also First-Order Logic, FOL)

Today’s Topics • Predicate Logic (aka First-Order Predicate Calculus, FOPC; also First-Order Logic, FOL) • We’ll covert to logic more complex English sentences here than for prop logic debugging tips situation calculus for rep’ing time • Next lecture will cover inference in FOPC 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 1

FOPC’s Extensions to Propositional Logic TERMS refer to objects in the ‘world’ eg John,

FOPC’s Extensions to Propositional Logic TERMS refer to objects in the ‘world’ eg John, Mary, CS 540, Democracy Predicates (aka relations) are propositions with arguments eg siblings(John, Mary), location(Madison, Wisconsin) Can quantify over variables x valuable(x) // “Everything is valuable. ” x valuable(x) // “Something is valuable. ” Functions take arguments (so look just like predicates), but refer to other terms eg mother. Of(Sue) is another name for Mary 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 2

Three Types of Terms can be constants such as John and Mary variables such

Three Types of Terms can be constants such as John and Mary variables such as x or ? x functions such as mother. Of(? x) All refer to objects in the ‘domain of discourse’ (ie, the world we are representing) We cannot use connectives with terms eg, the following is not a wff: John ˄ Mary 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 3

First vs Second Order Logic • In FOPC, we can only quantify over terms

First vs Second Order Logic • In FOPC, we can only quantify over terms (ie, objects in the world) x human(x) → mortal(x) • In second order logic, we could quantify over predicates p p(Sue) // All properties apply to Sue. However, 2 nd order logic is incomplete (Gödel) 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 4

Some ‘Syntactic Sugar’ For convenience, we will use Jon = Jonathan and ? x

Some ‘Syntactic Sugar’ For convenience, we will use Jon = Jonathan and ? x Mary As ‘infix’ (rather than ‘prefix’) shorthand for equals(John, Jonathan) equals(? x, Mary) Note: = ‘takes’ TERMs (‘same object’) and ↔ ‘takes’ PREDICATES (‘same truth value’) 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 5

WFF? Expression Mary Well Formed? NO, WFF’s are TRUTH VALUED Could be, but presumably

WFF? Expression Mary Well Formed? NO, WFF’s are TRUTH VALUED Could be, but presumably a FUNCTION, which is not a wff mother. Of(John) mother(John, Mary) friends(John ˄ Mary) NO, arguments must be TERMs father. Of(Sue) = brother. Of(Mary) 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 6

Some Examples of Converting English to FOPC (multiple acceptable answers in these examples) “John

Some Examples of Converting English to FOPC (multiple acceptable answers in these examples) “John and Mary live in Madison. ” “Alice has a brother. ” “Mary has two sisters, Sue and Ellen. ” “Fred is the brother of Al’s mother’s father. ” 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 7

Some Examples of Converting English to FOPC “John and Mary live in Madison. ”

Some Examples of Converting English to FOPC “John and Mary live in Madison. ” lives(John, Madison) lives(Mary, Madison) “Alice has a brother. ” x human(x) x = brother. Of(Alice) “Mary has two sisters, Sue and Ellen. ” sisters(Mary, Sue) sisters(Mary, Ellen) “Fred is the brother of Al’s mother’s father. ” brothers(Fred, father. Of(mother. Of(Al))) 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 8

Scoping Rules (use paren’s, braces, or brackets to clarify if confusing) We’ll assume 1.

Scoping Rules (use paren’s, braces, or brackets to clarify if confusing) We’ll assume 1. Implications and equivalences ‘grab’ all items to the left and right p(1) q(2) r(3) is [p(1) q(2)] r(3) rather than p(1) [ q(2) r(3) ] 2. NOTs grab the next wff p(1) q(2) is [ p(1) ] q(2) rather than [ p(1) q(2) ] 3. Quantified variables contain all the following items where the variable appears x p(x) q(x) is x [ p(x) q(x) ] rather than [ x p(x) ] q(x) 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 9

Some Examples of Converting English to FOPC (2) “There is a prime larger than

Some Examples of Converting English to FOPC (2) “There is a prime larger than 100. ” “There is no largest prime. ” “Every rational number is also real. ” 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 10

Some Examples of Converting English to FOPC (2) “There is a prime larger than

Some Examples of Converting English to FOPC (2) “There is a prime larger than 100. ” x prime(x) greater. Than(x, 100) “There is no largest prime. ” x prime(x) ( y prime(y) (y > x) ) “Every rational number is also real. ” x number(x) rational(x) real(x) 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 11

What about … “Every rational number is also real. ” x number(x) rational(x) real(x)

What about … “Every rational number is also real. ” x number(x) rational(x) real(x) what about irrational numbers? what about non-numbers, etc? x number(x) rational(x) real(x) loses info (ALL became SOME), plus what if NO #’s in our world? x ¬ number(x) ˅ ¬ rational(x) ˅ real(x) this one is correct, equiv to (Numb ˄ Rat)→Real 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 12

Can AND Mean OR? ? “Tell me all the sales people in NYC and

Can AND Mean OR? ? “Tell me all the sales people in NYC and LA who had sales of at least $1 M. ” “None, because we have no one who works in both LA and NYC. ” This answer seems wrong. What was meant: “Tell me all the sales people in NYC or LA who had sales of at least $1 M. ” 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 13

Good Rules-of-Thumb For. All’s usually involve implications x some. Test. That. Selects. Subset. Of.

Good Rules-of-Thumb For. All’s usually involve implications x some. Test. That. Selects. Subset. Of. World. Objects(x) → some. Additional. Facts. We. Can. Infer. About. That. Subset(x) There. Exist’s never involve implications x p(x) → q(x) is equivalent to x p(x) q(x) 11/29/16 // So true if p(x) ever false! CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 14

Recall: P → Q as a Venn Diagram If we know P is true

Recall: P → Q as a Venn Diagram If we know P is true we can also infer Q is true Knowing Q is false also tells us that P is false But if P is false, we can’t infer anything about Q Q 11/29/16 P CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 15

Some Examples of Converting English to FOPC (3) “Everyone likes a dog. ” x

Some Examples of Converting English to FOPC (3) “Everyone likes a dog. ” x human(x) ( y dog(y) likes(x, y) ) “There is one dog that every one likes. ” y [ dog(y) ( x human(x) likes(x, y) ) ] “Everyone likes a different dog. ” x human(x) [ y dog(y) likes(x, y) ( z human(z) likes(z, y) z = x ) ] 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 16

Debugging English-to-FOPC We can show faulty translations by finding models (ie, ‘worlds’) where our

Debugging English-to-FOPC We can show faulty translations by finding models (ie, ‘worlds’) where our ‘gut feeling’ understanding of the English sentence does not match the mechanical calculation of the ‘truth value’ of the sentence 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 17

Interpretations in FOPC • In prop calc, we provided the truth value of each

Interpretations in FOPC • In prop calc, we provided the truth value of each proposition • Now we need – List of objects in the world – Truth value for each grounded predicate (grounding means replace variables with constants in all possible ways) – Map for each grounded function to an object 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 18

Interpretations in FOPC: Example Assume we have predicate related, function mother. Of and objects

Interpretations in FOPC: Example Assume we have predicate related, function mother. Of and objects Al, Eve, No. One An interpretation: related(Al, Al)=T related(Al, Eve)=T related(Al, No. One)=F related(Eve, Al)=T related(Eve, Eve)=T related(Eve, No. One)=F related(No. One, Al)=F related(No. One, Eve)=F mother. Of(Al) = Eve mother. Of(Eve) = No. One related(No. One, No. One)=T mother. Of(No. One) = No. One 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 19

Mechanically Determining the Truth Value of a Compound Sentence: One Method (‘inference’ is another)

Mechanically Determining the Truth Value of a Compound Sentence: One Method (‘inference’ is another) • Assume we have a non-zero, finite number of objects in our world (we won’t worry about empty sets in cs 540: is For. All true in empty sets? ) • Replace variables by constants in all possible ways – Convert FOR ALL’s to a big AND – Convert THERE EXIST’s to a big OR • Use truth tables like with prop logic 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 20

Debugging English-to-FOPC: Example Assume we represented “There is valuable vase. ” as x vase(x)

Debugging English-to-FOPC: Example Assume we represented “There is valuable vase. ” as x vase(x) → valuable(x) Consider this interpretation: objects: fido interpretation: vase(fido)=false valuable(fido)=false In this world, the English is FALSE, but the FOPC is TRUE. So buggy! 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 21

Debugging English-to-FOPC: Example (Eval’ing the Logic) Assume we represented “There is valuable vase. ”

Debugging English-to-FOPC: Example (Eval’ing the Logic) Assume we represented “There is valuable vase. ” as x vase(x) → valuable(x) objects: fido interpretation: vase(fido)=false valuable(fido)=false All possible groundings: vase(fido) valuable(fido) Evaluating: false true Some extra notes: http: //pages. cs. wisc. edu/~shavlik/cs 540/debugging. English. To. FOPCtranslations. txt 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 22

What about … “Everyone likes a dog. ” What is wrong with: x y

What about … “Everyone likes a dog. ” What is wrong with: x y [human(x) dog(y)] likes(x, y) Consider this interpretation objects: a, d human(a)=true human(d)=false dog(a)=false dog(d)=true likes(a, a)=true likes(a, d)=false likes(d, a)=false likes(d, d)=true 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 English is FALSE for this interpretation, but is the FOPC also FALSE? 23

What about …(solution) “Everyone likes a dog. ” What is wrong with (plug in

What about …(solution) “Everyone likes a dog. ” What is wrong with (plug in interpret’s values): { [human(a) dog(a)] likes(a, a) OR [human(a) dog(d)] likes(a, d) } AND { [human(d) dog(a)] likes(d, a) OR [human(d) dog(d)] likes(d, d) { [T F] T is T OR [T T] F is F } AND { [F F] F is T OR [F T] T is T } T Consider this interpretation objects: a, d human(a)=true human(d)=false dog(a)=false dog(d)=true likes(a, a)=true likes(a, d)=false likes(d, a)=false likes(d, d)=true 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 24

Dealing with Change (eg, Time) “John gave Mary the book Intro. To. AI. ”

Dealing with Change (eg, Time) “John gave Mary the book Intro. To. AI. ” A weak solution: gave(John, Mary, Intro. To. AI) Would like to represent: The ‘ 711’ is used to represent a specific, physical book “John owned Intro. To. AI_711. ” “Mary now owns Intro. To. AI_711. ” 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 25

Why C++ Drives Me Crazy : -) 12/1/16 CS 540 - Fall 2016 (Shavlik©),

Why C++ Drives Me Crazy : -) 12/1/16 CS 540 - Fall 2016 (Shavlik©), Lecture 26, Week 13 26

Dealing with Change (eg, Time) Another example: “Moving a block to another changes the

Dealing with Change (eg, Time) Another example: “Moving a block to another changes the location of the block moved, but nothing else in the world changes. ” A B C B Table 1 11/29/16 A C Table 1 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 27

One Sol’n: Situation Calculus • TIME STAMP our facts! • Invented by Mc. Carthy

One Sol’n: Situation Calculus • TIME STAMP our facts! • Invented by Mc. Carthy & Hayes, 1969 On(block. A, block. B, s 0) Both facts are true. No need to delete the first after the MOVE! On(block. A, block. C, result(move(block. A, block. C), s 0)) A B A FUNCTION Another function C B Table 1 11/29/16 A C Table 1 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 28

result(move(block. A, block. C), s 0)) • RESULT is a function whose arguments are

result(move(block. A, block. C), s 0)) • RESULT is a function whose arguments are an action and a state; refers to the resulting STATE • MOVE is a function whose arguments are two blocks; refers to an ACTION A B C B Table 1 11/29/16 A C Table 1 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 29

Example A B C Table 1 B A C Table 1 “Moving a block

Example A B C Table 1 B A C Table 1 “Moving a block to another changes the location of the block moved, but nothing else in the world changes. ” x y z s block(x) block(y) block(z) state(s) ? ? ? → state(result(move(x, z), s)) ? ? ? 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 30

Example A B C B Table 1 A C Table 1 “Moving a block

Example A B C B Table 1 A C Table 1 “Moving a block to another changes the location of the block moved, but nothing else in the world changes. ” x y z s block(x) block(y) block(z) state(s) on(x, y, s) clear. Top(x, s) clear. Top(z, s) x z y z → Could drop clear. Top in the ‘THEN part’ and instead assume state(result(move(x, z), s)) we have this inference rule: on(x, z, result(move(x, z), s)) “Blocks that are not the second on(x, y, result(move(x, z), s)) argument to some ON have the property Clear. Top. ” clear. Top(x, result(move(x, z), s)) (to do by you: convert to FOPC) clear. Top(y, result(move(x, z), s)) What if A was on the table? clear. Top(z, result(move(x, z), s)) Or if A moved to the table? We’d need more inference rules. 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 31

Example A B C D Table 1 A C B Table 1 “Blocks not

Example A B C D Table 1 A C B Table 1 “Blocks not involved in a move stay where they are. ” x y z w u s // We’ll let u be a block or table. block(x) block(y) block(z) block(w) state(s) ? ? ? → state(result(move(x, y), s)) ? ? ? 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 32 D

Example A B C D Table 1 B A C D Table 1 “Blocks

Example A B C D Table 1 B A C D Table 1 “Blocks not involved in a move stay where they are. ” x y z w u s // We’ll let u be a block or table. block(x) block(y) block(z) block(w) state(s) on(w, u, s) Rules like these are called x w y w z w frame axioms. They describe x u y u z u what doesn’t change between world states (like the frames → in a movie) state(result(move(x, z), s)) on(w, u, result(move(x, z), s)) ) 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 33

EX: “Giving a car to another person changes who owns the car, but not

EX: “Giving a car to another person changes who owns the car, but not the company who made the car. ” 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 34

EX: “Giving a car to another person changes who owns the car, but not

EX: “Giving a car to another person changes who owns the car, but not the company who made the car. ” x y z w s human(x) human(y) company(z) car(w) state(s) owns(x, w, s) z = builder. Of(w, s) x y → Note: we could also state( result(give(x, w, y), s) simply not ‘time stamp’ the builder. Of predicate owns(y, w, result(give(x, w, y), s)) owns(x, w, result(give(x, w, y), s)) And the ‘frame axiom’ z = builder. Of(w, result(give(x, w, y), s)) should really be a separate inference rule (good s/w engineering) 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 35

The Qualification Problem Can never list all the preconditions of an action Example: “A

The Qualification Problem Can never list all the preconditions of an action Example: “A car won’t start because its battery is dead or it is out of gas or its starter is broken or Solution: do a reasonable approximation and live with imperfections there is banana in the tailpipe or a meteorite hit it while I was turning the key or I am using the wrong key or …” 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 36

Negation-by-Failure Common shortcut – Assume that facts we cannot prove true are false (called

Negation-by-Failure Common shortcut – Assume that facts we cannot prove true are false (called the closed world assumption) – Not justified logically (failure to prove P is true is not a proof that P is false) – But an effective assumption when using logic to build practical systems (since most groundings of predicates are false) – Example: given even(2), even(4) we cannot prove even(6) but of course it is not false 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 37

More Practice if Time Permits (from old cs 540 finals) “Except for Bill. G,

More Practice if Time Permits (from old cs 540 finals) “Except for Bill. G, for every person there exists someone richer. ” “Borrowing a bicycle doesn’t change who owns it. ” “Only those trees that are tall have long roots. ” “Every election has a winner. ” “All birds can fly except for penguins and ostriches or unless they have a broken wing. ” 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 38

Wrapup on Representation via FOPC • FOPC has constants, variables, predicates & functions with

Wrapup on Representation via FOPC • FOPC has constants, variables, predicates & functions with arguments, and quantifiers • Interpretations tell us the truth values or referents for our atomic symbols (next lecture: logical inference in FOPC) – Help debug English translations into FOPC • Situation calculus deals with time-varying facts – Frame problem (what does not change) – Qualification problem (unbound preconditions) 11/29/16 CS 540 - Fall 2016 (Shavlik©), Lecture 22, Week 13 39