Seyed Hashem Davarpanah [email protected] University of Science and Culture Expert systems CLIPS.
Artificial Intelligence First-Order Logic Seyed Hashem Davarpanah [email protected] University of...
-
Upload
hayden-poole -
Category
Documents
-
view
213 -
download
1
Transcript of Artificial Intelligence First-Order Logic Seyed Hashem Davarpanah [email protected] University of...
Artificial Artificial IntelligenceIntelligence
First-Order LogicFirst-Order LogicSeyed Hashem DavarpanahSeyed Hashem Davarpanah
University of Science and University of Science and CultureCulture
Limitations of propositional Limitations of propositional logiclogic
So far we studied propositional logicSo far we studied propositional logic Some English statements are hard to model Some English statements are hard to model
in propositional logic:in propositional logic: ““If your roommate is wet because of rain, If your roommate is wet because of rain,
your roommate must not be carrying your roommate must not be carrying anyany umbrella”umbrella”
Pathetic attempt at modeling this:Pathetic attempt at modeling this: RoommateWetBecauseOfRain => RoommateWetBecauseOfRain =>
(NOT(RoommateCarryingUmbrella0) AND (NOT(RoommateCarryingUmbrella0) AND NOT(RoommateCarryingUmbrella1) AND NOT(RoommateCarryingUmbrella1) AND NOT(RoommateCarryingUmbrella2) AND …)NOT(RoommateCarryingUmbrella2) AND …)
Problems with propositional Problems with propositional logiclogic
No notion of No notion of objectsobjects No notion of No notion of relations among objectsrelations among objects RoommateCarryingUmbrella0 is instructive RoommateCarryingUmbrella0 is instructive
to usto us, suggesting , suggesting there is an object we call Roommate,there is an object we call Roommate, there is an object we call Umbrella0,there is an object we call Umbrella0, there is a relationship Carrying between these two there is a relationship Carrying between these two
objectsobjects
Formally, none of this meaning is thereFormally, none of this meaning is there Might as well have replaced Might as well have replaced
RoommateCarryingUmbrella0 by PRoommateCarryingUmbrella0 by P
Elements of first-order logicElements of first-order logic Objects:Objects: can give these names such as can give these names such as
Umbrella0, Person0, John, Earth, …Umbrella0, Person0, John, Earth, … Relations:Relations: Carrying(., .), IsAnUmbrella(.)Carrying(., .), IsAnUmbrella(.)
Carrying(Person0, Umbrella0), Carrying(Person0, Umbrella0), IsUmbrella(Umbrella0)IsUmbrella(Umbrella0)
Relations with one object = Relations with one object = unary unary relationsrelations = = propertiesproperties
Functions:Functions: Roommate(.) Roommate(.) Roommate(Person0)Roommate(Person0)
EqualityEquality: Roommate(Person0) = Person1: Roommate(Person0) = Person1
Reasoning about many objects at Reasoning about many objects at onceonce
VariablesVariables: x, y, z, … can refer to multiple : x, y, z, … can refer to multiple objectsobjects
New operators “for all” and “there exists”New operators “for all” and “there exists” Universal quantifierUniversal quantifier and and existential quantifierexistential quantifier
for all x: CompletelyWhite(x) => for all x: CompletelyWhite(x) => NOT(PartiallyBlack(x))NOT(PartiallyBlack(x)) Completely white objects are never partially blackCompletely white objects are never partially black
there exists x: PartiallyWhite(x) AND there exists x: PartiallyWhite(x) AND PartiallyBlack(x)PartiallyBlack(x) There exists some object in the world that is There exists some object in the world that is
partially white and partially blackpartially white and partially black
Practice converting Practice converting English to first-order English to first-order
logiclogic ““John has an umbrella”John has an umbrella” there exists y: (Has(John, y) AND there exists y: (Has(John, y) AND
IsUmbrella(y))IsUmbrella(y)) ““Anything that has an umbrella is not wet”Anything that has an umbrella is not wet” for all x: ((there exists y: (Has(x, y) AND for all x: ((there exists y: (Has(x, y) AND
IsUmbrella(y))) => NOT(IsWet(x)))IsUmbrella(y))) => NOT(IsWet(x))) ““Any person who has an umbrella is not wet”Any person who has an umbrella is not wet” for all x: (IsPerson(x) => ((there exists y: for all x: (IsPerson(x) => ((there exists y:
(Has(x, y) AND IsUmbrella(y))) => (Has(x, y) AND IsUmbrella(y))) => NOT(IsWet(x))))NOT(IsWet(x))))
More practice converting More practice converting English to first-order English to first-order
logiclogic ““John has at least two umbrellas”John has at least two umbrellas” there exists x: (there exists y: (Has(John, x) there exists x: (there exists y: (Has(John, x)
AND IsUmbrella(x) AND Has(John, y) AND AND IsUmbrella(x) AND Has(John, y) AND IsUmbrella(y) AND NOT(x=y))IsUmbrella(y) AND NOT(x=y))
““John has at most two umbrellas”John has at most two umbrellas” for all x, y, z: ((Has(John, x) AND for all x, y, z: ((Has(John, x) AND
IsUmbrella(x) AND Has(John, y) AND IsUmbrella(x) AND Has(John, y) AND IsUmbrella(y) AND Has(John, z) AND IsUmbrella(y) AND Has(John, z) AND IsUmbrella(z)) => (x=y OR x=z OR y=z))IsUmbrella(z)) => (x=y OR x=z OR y=z))
Even more practice Even more practice converting English to converting English to
first-order logic…first-order logic… ““Duke’s basketball team defeats any Duke’s basketball team defeats any
other basketball team”other basketball team” for all x: ((IsBasketballTeam(x) AND for all x: ((IsBasketballTeam(x) AND
NOT(x=BasketballTeamOf(Duke))) => NOT(x=BasketballTeamOf(Duke))) => Defeats(BasketballTeamOf(Duke), x))Defeats(BasketballTeamOf(Duke), x))
““Every team defeats some other team”Every team defeats some other team” for all x: (IsTeam(x) => (there exists y: for all x: (IsTeam(x) => (there exists y:
(IsTeam(y) AND NOT(x=y) AND (IsTeam(y) AND NOT(x=y) AND Defeats(x,y))))Defeats(x,y))))
Is this a tautology?Is this a tautology? ““Property P implies property Q, or Property P implies property Q, or
propery P implies property Q (or both)”propery P implies property Q (or both)” for all x: ((P(x) => Q(x)) OR (Q(x) => for all x: ((P(x) => Q(x)) OR (Q(x) =>
P(x)))P(x))) (for all x: (P(x) => Q(x)) OR (for all x: (for all x: (P(x) => Q(x)) OR (for all x:
(Q(x) => P(x)))(Q(x) => P(x)))
Relationship between Relationship between universal and existentialuniversal and existential
for all x: afor all x: a is equivalent tois equivalent to NOT(there exists x: NOT(a))NOT(there exists x: NOT(a))
Something we cannot do Something we cannot do in first-order logicin first-order logic
We are We are notnot allowed to reason in general about relations allowed to reason in general about relations and functionsand functions
The following would correspond to The following would correspond to higher-order logichigher-order logic (which is more powerful):(which is more powerful):
““If John is Jack’s roommate, then any property of John is If John is Jack’s roommate, then any property of John is also a property of Jack’s roommate”also a property of Jack’s roommate”
(John=Roommate(Jack)) => for all p: (p(John) => (John=Roommate(Jack)) => for all p: (p(John) => p(Roommate(Jack)))p(Roommate(Jack)))
““If a property is inherited by children, then for any thing, if If a property is inherited by children, then for any thing, if that property is true of it, it must also be true for any child that property is true of it, it must also be true for any child of it”of it”
for all p: (IsInheritedByChildren(p) => (for all x, y: for all p: (IsInheritedByChildren(p) => (for all x, y: ((IsChildOf(x,y) AND p(y)) => p(x))))((IsChildOf(x,y) AND p(y)) => p(x))))
Axioms and theoremsAxioms and theorems
AxiomsAxioms: basic facts about the domain, : basic facts about the domain, our “initial” knowledge baseour “initial” knowledge base
TheoremsTheorems: statements that are logically : statements that are logically derived from axiomsderived from axioms
SUBSTSUBST
SUBST replaces one or more variables with SUBST replaces one or more variables with something elsesomething else
For example: For example: SUBST({x/John}, IsHealthy(x) => SUBST({x/John}, IsHealthy(x) =>
NOT(HasACold(x))) gives usNOT(HasACold(x))) gives us IsHealthy(John) => NOT(HasACold(John))IsHealthy(John) => NOT(HasACold(John))
Instantiating quantifiersInstantiating quantifiers FromFrom for all x: afor all x: a we can obtainwe can obtain SUBST({x/g}, a)SUBST({x/g}, a)
FromFrom there exists x: athere exists x: a we can obtainwe can obtain SUBST({x/k}, a)SUBST({x/k}, a) where k is a constant that does not appear where k is a constant that does not appear
elsewhere in the knowledge base (elsewhere in the knowledge base (SkolemSkolem constantconstant))
Don’t need original sentence anymoreDon’t need original sentence anymore
Instantiating Instantiating existentials after existentials after
universalsuniversals for all x: there exists y: IsParentOf(y,x)for all x: there exists y: IsParentOf(y,x) WRONG: for all x: IsParentOf(k, x)WRONG: for all x: IsParentOf(k, x) RIGHT: for all x: IsParentOf(k(x), x)RIGHT: for all x: IsParentOf(k(x), x) Introduces a new function (Introduces a new function (Skolem Skolem
functionfunction)) … … again, assuming k has not been used again, assuming k has not been used
previouslypreviously
Generalized modus Generalized modus ponensponens
for all x: Loves(John, x)for all x: Loves(John, x) John loves every thingJohn loves every thing
for all y: (Loves(y, Jane) => for all y: (Loves(y, Jane) => FeelsAppreciatedBy(Jane, y))FeelsAppreciatedBy(Jane, y)) Jane feels appreciated by every thing that loves herJane feels appreciated by every thing that loves her
Can infer from this:Can infer from this: FeelsAppreciatedBy(Jane, John)FeelsAppreciatedBy(Jane, John)
Here, we used the substitution {x/Jane, y/John}Here, we used the substitution {x/Jane, y/John} Note we used different variables for the different Note we used different variables for the different
sentencessentences
General UNIFY algorithms for finding a good General UNIFY algorithms for finding a good substitutionsubstitution
Keeping things as general Keeping things as general as possible in unificationas possible in unification
Consider EdibleByWith Consider EdibleByWith e.g., EdibleByWith(Soup, John, Spoon) – John can eat soup with a spoone.g., EdibleByWith(Soup, John, Spoon) – John can eat soup with a spoon
for all x: for all y: EdibleByWith(Bread, x, y)for all x: for all y: EdibleByWith(Bread, x, y) Anything can eat bread with anythingAnything can eat bread with anything
for all u: for all v: (EdibleByWith(u, v, Spoon) => for all u: for all v: (EdibleByWith(u, v, Spoon) => CanBeServedInBowlTo(u,v))CanBeServedInBowlTo(u,v)) Anything that is edible with a spoon by something can be served in Anything that is edible with a spoon by something can be served in
a bowl to that somethinga bowl to that something
Substitution: {x/z, y/Spoon, u/Bread, v/z}Substitution: {x/z, y/Spoon, u/Bread, v/z} Gives: for all z: CanBeServedInBowlTo(Bread, z)Gives: for all z: CanBeServedInBowlTo(Bread, z) Alternative substitution {x/John, y/Spoon, u/Bread, Alternative substitution {x/John, y/Spoon, u/Bread,
v/John} would only have given v/John} would only have given CanBeServedInBowlTo(Bread, John), which is not as CanBeServedInBowlTo(Bread, John), which is not as generalgeneral
Resolution for first-order Resolution for first-order logiclogic for all x: (NOT(Knows(John, x)) OR IsMean(x) OR for all x: (NOT(Knows(John, x)) OR IsMean(x) OR
Loves(John, x))Loves(John, x)) John loves everything he knows, with the possible John loves everything he knows, with the possible
exception of mean thingsexception of mean things
for all y: (Loves(Jane, y) OR Knows(y, Jane))for all y: (Loves(Jane, y) OR Knows(y, Jane)) Jane loves everything that does not know herJane loves everything that does not know her
What can we unify? What can we conclude?What can we unify? What can we conclude? Use the substitution: {x/Jane, y/John}Use the substitution: {x/Jane, y/John} Get: IsMean(Jane) OR Loves(John, Jane) OR Get: IsMean(Jane) OR Loves(John, Jane) OR
Loves(Jane, John)Loves(Jane, John) Complete (i.e., if not satisfiable, will find a proof of Complete (i.e., if not satisfiable, will find a proof of
this), this), ifif we can remove literals that are duplicates we can remove literals that are duplicates after unificationafter unification Also need to put everything in Also need to put everything in canonical formcanonical form first first