+ All Categories
Home > Documents > First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional...

First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional...

Date post: 20-Jun-2020
Category:
Upload: others
View: 7 times
Download: 0 times
Share this document with a friend
34
First Order Logic Propositional logic represented states of the world Raining, Sunny, a cookie being sweet FOL adds objects, relations, and functions Objects - kim, my car, the duration of time between 1pm and 2pm today Relations – Kim and I are Friends, 1pm-2pm is before 3pm Functions – Kim’s father → some dog Many to 1 mapping from Objects to Objects
Transcript
Page 1: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

First Order Logic

● Propositional logic represented states of the world– Raining, Sunny, a cookie being sweet

● FOL adds objects, relations, and functions– Objects - kim, my car, the duration of time between

1pm and 2pm today

– Relations – Kim and I are Friends, 1pm-2pm is before 3pm

– Functions – Kim’s father → some dog● Many to 1 mapping from Objects to Objects

Page 2: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

FOL Syntax

● Constant Symbols – represent Objects– kim01, truck32, timeSpan7

● N-ary predicate - represent relations/states– 0-ary – states (propositional logic)

– 1-ary – properties (Red(marker1)

– 2-ary – binary relationship (Ate(kim0, apple56))

– n-ary - Buy(kim0,truck45,odie2)

● n-ary functions – some object based on its arguments– Owner(truck45) = kim0

– SteeringWheel(truck32) returns steeringWheel98

Page 3: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Syntax

● Terms – refer to objects– Constants – kim0,

house45

– Variables - ∀ x happy(x)

– Functions - motherOf(kim0)

● Atoms – Single Predicates– Raining

– Dog(kim0)

– kim0 = zorri41

● Universal Quantifier– ∀ x P(x)

– For all x it is true P(x)

● Existential Quantifier– ∃ x Q(x)

– There exists an assignment of x to an object such that Q(x)

Page 4: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Syntax

Page 5: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Semantics

● Domain – The (non empty) set of objects we are trying to model

● Interpretation of a domain, d, )– links (�constants, predicates, and functions to the possible world the model represents– c C | (C): C→ D∈ �– f Functions | (f) D x D...x D → D∈ � ∈– p Predicates | (p) D x D...x D→ {true, false}∈ � ∈

Page 6: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Semantics

Page 7: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Quantifier

● ∀ x P(x):– For every assignment of x to an object in our

domain it is true P(x)

– P(a) P(b) … P(z)∧ ∧

● ∃ x P(x):– For some assignment of x to an object in our

domain it is true P(x)

– P(a) P(b) … P(z)∨ ∨

Page 8: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

FOL De Morgan

Page 9: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Knowledge Representation

● Types and properties– dog(kim0)

– red(ball56)

● Relationships– friendOf(kim0,odie2)

● Functions– birthMotherOf(kim0)

● Quantification– Everything that has a property also has some other property

● ∀ x. dog(x) → animal(x)

– Something has a property● ∃ x. dog(x) red(x)∧

– Be careful of mixing existential with implications● ∃ x. dog(x) → red(x) ≡ x. ¬dog(x) red(x)∃ ∨

Page 10: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Knowledge Representation

● All Cookies are Sweet● All Fudge cookies are Yummy● All Dark Cookies are either Burnt or Fudge● Sweet Cookies are not Burnt● Bread is either sweet or savory● Onion Bread is savory● There is no such thing as a bread that is both sweet and savory.● This Bread is Burnt.● The Baker of this Bread is bad at their job.

Page 11: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Knowledge Representation

● Kim is both a Golden Retriever and a Labrador Retriever● Kim’s birth mother is either a Golden or Lab● Kim and Odie are friends● Some dogs have a ball● All dogs have a tail● Kim is a black dog with a brown tail● All Golden Retrievers are red except for Kim.● All dogs love some person● Every person who owns a dog loves it● Kim has two toys

Page 12: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Resolution in FOL

Similar to propositional logic but we have to account for Terms and Quantifiers– Constants – kim0, house45

– Variables - ∀ x happy(x)

– Functions - motherOf(kim0)

● Skolemization● Unification

Page 13: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

FOL CNF

● Start just like Propositional CNF– Eliminate bi-conditionals, implication, move negation

inward, distribute over ∨ ∧

● Treat universally quantified variables as free variables – Give variables unique names and remove the quantifier, :∀– [ x. p(x) ] [ x. f(x) , ¬p(x)]∀ ∧ ∀– [ x∀ 1. p(x1) ] [ x∧ ∀ 2. f(x2), ¬p(x2) ]

– [ p(x1) ] [ f(x∧ 2), ¬p(x2) ]

● Handle with Skolemize∃

Page 14: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Unification

● θ is a set of variable substitutions <variable>/<term>– e.g. θ = {v/w, x/Kim01, y/motherOf(z)}

– Combined with a sentence they create a new sentence

– f(x,y) Substituted with {y/Kim} = f(x,Kim)

● Two sentences unify if we can find a substitution of variables that make both look syntactically identical to each other– Unify( f(x,y), f(Kim,Kim) )?

– Unify( f(x,y), f(Kelly,z) )?

– Unify( f(Kim,y), f(Kelly,x) )?

Page 15: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Skolemization

● Remove Existential Instantiation∃– Introduce a single new literal – Skolem constant

– ∃ y. q(y) {y/sk1}

– We name that y sk1

– q(sk1)

Page 16: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Nested ∃

● Introduce a function that points to a new literal ● Arguments contextualize the literal

– ∀ x y. r1(x, y)∃

● r1(x, skF1(x))– ∀ x,z y q(y)∃

● q(skF2(x,z))

Page 17: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Unification

● Unify( f(w,x), f(y,z)) – {w/y,z/x} or {w/x, y/x, z/x} or {w/y, x/Kim, z/Kim} or {w/Kim,

x/Kelley, y/Kim,z/Kelley}?

● Among a set of valid unifiers for two sentences, a Most General Unifier produces a sentence that can unify with every other sentence produced by the other possible substitutions– f(y,x): {w/y,z/x}

– f(y,Kim): {w/y, x/Kim, z/Kim}

– f(Kim,Kelley): {w/Kim, x/Kelley, y/Kim,z/Kelley}

Page 18: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

“An angry man bought a truck”

∃ x, y Man(x) Angry(x) Truck(y) Buy(x,y)∧ ∧ ∧

CNF

Page 19: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

FOL Resolution

KB:Buy(x1,y1) → Acquire(x1,y1)

Woman(x2) → Person(x2)

Man(x3) → Person(x3)

Truck(x4) → Vehicle(x4)

Man(SK1)

Angry(SK1)

Truck(SK2)

Buy(SK1,SK2)

● Did a person buy a vehicle?

● Prove:

KB ¬( x y ∧ ∃Person(x) ∧Vehicle(y) Buy(x,y)) ∧

is unsatisfiable

Page 20: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

FOL Resolution

KB:Buy(x,y) → Acquire(x,y)

Man(x) → Person(x)

Man(Mike)

Truck(SK1)

Buy(Mike,SK1)

Person(Kelly)

Truck(SK2)

Buy(Kelly,SK2)

● What person bought a truck?

● Prove:

KB ¬( x y Person(x) ∧ ∃ ∧Truck(y) Buy(x,y)) ∧is unsatisfiable

● Add ANS(x) to query clause

● Resolution stops when ANS(x) is the only literal left

Page 21: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

FOL Resolution

KB:Buy(x1,y1) → Acquire(x1,y1)

Woman(x2) → Person(x2)

Man(x3) → Person(x3)

Truck(x4) → Vehicle(x4)

Man(SK1)

Angry(SK1)

Truck(SK2)

Buy(SK1,SK2)

● Did every person buy a truck?

● Prove:

KB ¬( x y ∧ ∀ ∃Person(x) → Truck(y)

Buy(x,y)) ∧is unsatisfiable

See R&N p 350 for a discussion on the completeness of FOL resolution

Page 22: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

FOL Resolution

KB:Ancestor(mom(Kim),Kim)

∀ x Ancestor(x, Kim) →Ancestor(mom(x),Kim)

See R&N p 350 for a discussion on the completeness of FOL resolution

Page 23: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Representing Situations

● Often in natural language understanding we are faced with designing predicates to represent situations– “Kim bought a car”

– “Kim bought a car from Odie for $100”

● Verbs are predicates, roles related to those verbs are arguments– Buy(<buyer>,<item>)

– bought(kim0, car3)

● Naively, we creating a predicate dealing with with every conceivable combination of arguments– bought(kim0, car3, odie2, $100)

Page 24: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Representing Situations

● In linguistics we can characterize situations compositionally – e.g. VerbNet or Framenet

● Reify situations into objects with role relations instead of arguments

● Represent situations more concisely and deal with composition more elegantly

● Instead we can represent every event as an object and treat each role as a relationship

buy(e1) ∧buyer(e1,kim0) seller(e1,odie2) ∧ ∧ money(e1, $100)

Page 25: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Special Assumptions

● Unique name– Literals map to objects 1:1 (not many:1)– e.g. we cannot say: kim0 = zori41

● Closed-world– Any atomic sentences not known (i.e. an axiom or proven to be entailed) to be true

are false– Proof by failure – a sentence is false if we fail to prove it

– KB = {Dog(kim), Cat(kelly)} ¬Cat(kim), ¬Dog(kelly), kim != kelley⊢

● Domain closure– The only objects in the Domain are those named by constant symbols (much easier

to talk about than what we’ve been doing)

Database Semantics: closed-world, unique-names, domain closure

Page 26: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Horn Clauses

● Horn Clause - disjunction of literals; at most 1 literal is positive

● Definite Clause – exactly 1 is positive● Fact – a definite clause with 0 negative literals● Goal Clause – none are positive

Page 27: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Horn Clauses

● P ¬Q∨

P ← Q

P :- Q● Head ← Body● Head - positive literal● Body – clause of negative literals

Page 28: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Horn Clauses

● If it’s raining then the grass is wet – W ← R (Definite Clause)

● It is raining– R (Fact)

● Prove that the grass is wet– Prove KB W⊨– Prove KB ¬W is unsatisfiable∧– ¬W (Goal Clause)

Page 29: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Logic Programming

● Prolog – a declarative programming language based on logic– Describe a problem in horn logic

– Control flow is handled by resolution

● Uses an efficient resolution refutation algorithm– SLD resolution

Page 30: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Blocks World

● Assume we are using Database Semantics – Closed-world, unique-names, domain closure

● n blocks, 1 table● A block can be on top of another block or on the

table● At most 1 block can be on top of another● A block can only be picked up iff there isn’t a

another block on top of it

Page 31: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Blocks World with Actions

● n blocks ● A block can be on top of another block or on a

table

● A block can only be picked up iff there isn’t a another block on top of it

● If a block can be picked up and moved to the table or on top of another block

Page 32: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Actions and Time

● Fluent – predicates who’s truth value depends on time– on(b1,b2,t1) : b1 is on b2 at time t1

● In a simple case, time is treated as discrete steps that occur one after the other.– on(greenB,blueB, 1) on(∧ greenB,blueB, 2)

● Actions:– Action(t) → Precondition(t) PostCondition(t+1)∧– ∀b1,b2,t. move(b1,b2, table, t) →

( ¬ On(b1,table,t+1) On(∧ b1,b2, t) ) ∧ ( On(b1,table,t+1) ¬On(∧ b1,b2, t+1) )

– Don’t forget to say what doesn’t change! ● ∀b1,b2,t. move(b1,b2, table, t) →

On(b1,table,t+1) ¬On(∧ b1,b2, t+1) ∧ x,y. x !=∀ b1 →( On(x,y,t) ↔ On(x,y,t+1) )● Dog(kim,t+1) ?

Page 33: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Planning with Logic

● PDDL – Planning Domain Definition Language● Database Semantics – Closed-world, unique-names,Domain

closure● Each state is a set of logical statements (factored representation)

– No need for temporal arguments – time is signified by our current state in the graph

● Actions change states ● Preconditions tell us what must be true to perform an action● Effects tell us what changed

– Everything else remains the same

– Circumvents the frame problem

Page 34: First Order Logic - RITjro/courses/intelSys/notes/week06.pdf · First Order Logic Propositional logic represented states of the world – Raining, Sunny, a cookie being sweet FOL

Recommended