07 Fol
07 Fol
Kalev Kask
• New Ontology
– The world consists of OBJECTS.
– OBJECTS have PROPERTIES, RELATIONS, and FUNCTIONS.
• New Syntax
– Constants, Variables, Predicates, Functions, Quantifiers.
• New Semantics
– Meaning of new syntax.
• Variables x, y, a, b,...
• Quantifiers ,
• Connectives , , , , (standard)
• Note: Functions refer to objects, do not state facts, and form no sentence:
– Brother(Pete) refers to John (his brother) and is neither true nor false.
– Plus(2, 3) refers to the number 5 and is neither true nor false.
• BrotherOf( Pete, Brother(Pete) ) is True.
• King(Richard) King(John)
x y Loves(x,y)
– For everyone (“all x”) there is someone (“exists y”) whom they love.
– There might be a different y for each x (y is inside the scope of x)
y x Loves(x,y)
– There is someone (“exists y”) whom everyone loves (“all x”).
– Every x loves the same y (x is inside the scope of y)
Clearer with parentheses: y ( x Loves(x,y) )
In effect:
- is a conjunction over the universe of objects
- is a disjunction over the universe of objects
Thus, DeMorgan’s rules can be applied
De Morgan’s Law for Quantifiers
De Morgan’s Rule Generalized De Morgan’s Rule
P Q (P Q ) x P x (P )
P Q (P Q ) x P x (P )
(P Q ) P Q x P x (P )
(P Q ) P Q x P x (P )
x,y Sibling(x,y)
[(x = y)
m,f (m = f) Parent(m,x) Parent(f,x)
Parent(m,y) Parent(f,y)]
• PARTIAL SOLUTION:
– An upon-agreed ontology that settles these questions
– Ontology = what exists in the world & how it is represented
– The Knowledge Engineering teams agrees upon an ontology
BEFORE they begin encoding knowledge
Making Sentences
More fun with sentences
• “All persons are mortal.”
• [Use: Person(x), Mortal (x) ]
More fun with sentences
• “All persons are mortal.”
[Use: Person(x), Mortal (x) ]
• ∀x Person(x) Mortal(x)
• Equivalent Forms:
• ∀x ¬Person(x) ˅ Mortal(x)
• Common Mistakes:
• ∀x Person(x) Mortal(x)
More fun with sentences
• “Fifi has a sister who is a cat.”
• [Use: Sister(Fifi, x), Cat(x) ]
More fun with sentences
• “Fifi has a sister who is a cat.”
• [Use: Sister(Fifi, x), Cat(x) ]
• ∃x Sister(Fifi, x) Cat(x)
• Common Mistakes:
• ∃x Sister(Fifi, x) Cat(x)
More fun with sentences
• “For every food, there is a person who eats
that food.”
[Use: Food(x), Person(y), Eats(y, x) ]
More fun with sentences
• “For every food, there is a person who eats that food.”
[Use: Food(x), Person(y), Eats(y, x) ]
• Equivalent Forms:
• ∀x Food(x) ∃y [ Person(y) Eats(y, x) ]
• ∀x ∃y ¬Food(x) ˅ [ Person(y) Eats(y, x) ]
• ∀x ∃y [ ¬Food(x) ˅ Person(y) ] [¬ Food(x) ˅ Eats(y, x) ]
• ∀x ∃y [ Food(x) Person(y) ] [ Food(x) Eats(y, x) ]
• Common Mistakes:
• ∀x ∃y [ Food(x) Person(y) ] Eats(y, x)
• ∀x ∃y Food(x) Person(y) Eats(y, x)
More fun with sentences
• “Every person eats every food.”
[Use: Person (x), Food (y), Eats(x, y) ]
More fun with sentences
• “Every person eats every food.”
[Use: Person (x), Food (y), Eats(x, y) ]
• Equivalent Forms:
• ∀x ∀y ¬Person(x) ˅ ¬Food(y) ˅ Eats(x, y)
• ∀x ∀y Person(x) [ Food(y) Eats(x, y) ]
• ∀x ∀y Person(x) [ ¬Food(y) ˅ Eats(x, y) ]
• ∀x ∀y ¬Person(x) ˅ [ Food(y) Eats(x, y) ]
• Common Mistakes:
• ∀x ∀y Person(x) [Food(y) Eats(x, y) ]
• ∀x ∀y Person(x) Food(y) Eats(x, y)
More fun with sentences
• “All greedy kings are evil.”
[Use: King(x), Greedy(x), Evil(x) ]
More fun with sentences
• “All greedy kings are evil.”
[Use: King(x), Greedy(x), Evil(x) ]
• Equivalent Forms:
• ∀x ¬Greedy(x) ˅ ¬King(x) ˅ Evil(x)
• ∀x Greedy(x) [ King(x) Evil(x) ]
• Common Mistakes:
• ∀x Greedy(x) King(x) Evil(x)
More fun with sentences
• “Everyone has a favorite food.”
[Use: Person(x), Food(y), Favorite(y, x) ]
More fun with sentences
• “Everyone has a favorite food.”
[Use: Person(x), Food(y), Favorite(y, x) ]
• Equivalent Forms:
• ∀x Person(x) ∃y [ Food(y) Favorite(y, x) ]
• ∀x ∃y ¬Person(x) ˅ [ Food(y) Favorite(y, x) ]
• ∀x ∃y [ ¬Person(x) ˅ Food(y) ] [ ¬Person(x) ˅ Favorite(y, x) ]
• ∀x ∃y [Person(x) Food(y) ] [ Person(x) Favorite(y, x) ]
• Common Mistakes:
• ∀x ∃y [ Person(x) Food(y) ] Favorite(y, x)
• ∀x ∃y Person(x) Food(y) Favorite(y, x)
More fun with sentences
• “There is someone at UCI who is smart.”
[Use: Person(x), At(x, UCI), Smart(x) ]
More fun with sentences
• “There is someone at UCI who is smart.”
[Use: Person(x), At(x, UCI), Smart(x) ]
• Common Mistakes:
• ∃x [ Person(x) At(x, UCI) ] Smart(x)
More fun with sentences
• “Everyone at UCI is smart.”
[Use: Person(x), At(x, UCI), Smart(x) ]
More fun with sentences
• “Everyone at UCI is smart.”
[Use: Person(x), At(x, UCI), Smart(x) ]
• Equivalent Forms:
• ∀x ¬[Person(x) At(x, UCI) ] ˅ Smart(x)
• ∀x ¬Person(x) ˅ ¬At(x, UCI) ˅ Smart(x)
• Common Mistakes:
• ∀x Person(x) At(x, UCI) Smart(x)
• ∀x Person(x) [At(x, UCI) Smart(x) ]
•
More fun with sentences
• “Every person eats some food.”
[Use: Person (x), Food (y), Eats(x, y) ]
More fun with sentences
• “Every person eats some food.”
[Use: Person (x), Food (y), Eats(x, y) ]
• Common Mistakes:
• ∀x ∃y [ Person(x) Food(y) ] Eats(x, y)
• ∀x ∃y Person(x) Food(y) Eats(x, y)
•
More fun with sentences
• “Some person eats some food.”
[Use: Person (x), Food (y), Eats(x, y) ]
More fun with sentences
• “Some person eats some food.”
[Use: Person (x), Food (y), Eats(x, y) ]
• Common Mistakes:
• ∃x ∃y [ Person(x) Food(y) ] Eats(x, y)
Semantics
Semantics: Worlds
• The world consists of objects that have properties; there are
relations and functions between these objects
• Truth of more complex sentence (using logical connectives) is determined the usual
way; quantifiers means “for all, exists (some)”…
• The wff is true if and only if (iff) its assertion holds among the
objects in the world under the mapping by the interpretation.
Semantics: an
KB : CNF over interpretation maps
prop symbols prop symbols to
{true,false}
Semantics: an interpretation
KB : CNF over has obj’s and maps :
predicates over terms (fn const symbols to const’s,
+ var + const) fn symbols to fn’s,
Note : pred symbols to pred’s
const, fn, pred symbols Note :
const’s, fn’s, pred’s
Note : var’s not mapped!
Reduction of FOL inference to PL
inference
Review : Propositionalisation
• x Cat(x) Mammal(x)
– Cat(Spot) Mammal(Spot)
Cat(Rebecca) Mammal(Rebecca)
Cat(LAX) Mammal(LAX)
Cat(Shayama) Mammal(Shayama)
Cat(France) Mammal(France)
Cat(Felix) Mammal(Felix)
…
• x Sister(x, Spot) Cat(x)
– Sister(Spot, Spot) Cat(Spot)
Sister(Rebecca, Spot) Cat(Rebecca)
Sister(LAX, Spot) Cat(LAX)
Sister(Shayama, Spot) Cat(Shayama)
Sister(France, Spot) Cat(France)
Sister(Felix, Spot) Cat(Felix)
…
Reduction of FOL to PL
• Every FOL KB can be propositionalized so as to preserve
entailment
Idea: For n = 0 to ∞ do
create a propositional KB by instantiating with depth=n terms
see if α is entailed by this KB
• E.g., from:
6. Distribute over :
[Animal(F(x)) Loves(G(x),x)] [Loves(x,F(x)) Loves(G(x),x)]
A note on Skolem functions
Consider the statement: x y P(x, y)
P(x,C) for some C is wrong! This is equivalent to saying y x P(x, y)
The statement asserts that, for all x, there is (at least) one y such that P(x,y).
Recall that each x may have a different y, and so y depends on x.
So, at least abstractly, there is a list that pairs each x to a y that satisfies P(x,y):
{ (x1, y1), (x2, y2), (x3, y3), (x4, y4) … } where P(x1, y1) = TRUE; P(x2, y2) =
TRUE; P(x3, y3) = TRUE; and so on.
So, at least abstractly, there is a function that maps xi to yi. Call that function
F(), where F(x1) = y1; F(x2) = y2; F(x3) = y3; and so on. (We don’t know what
that function is, but we do know that it must exist --- even if we can’t write it
down.)
So P(x1, F(x1) ) = TRUE; P(x2, F(x2) ) = TRUE; P(x3, F(x3) ) = TRUE; and so on.
• Example:
p = Knows(John,x)
q = Knows(John, Jane)
Unify(p,q) = {x/Jane}
Unification examples
• simple example: query = Knows(John,x), i.e., who does John know?
p q θ
• Last unification fails: only because x can’t take values John and OJ at the same time
– But we know that if John knows x, and everyone (x) knows OJ, we should be able to infer
that John knows OJ
If a predicate/function,
unify the arguments.
Unification Algorithm
If unifying arguments,
unify the remaining
arguments.
Unification Algorithm
Otherwise, fail.
Hard matching example
Diff(wa,nt) Diff(wa,sa) Diff(nt,q)
Diff(nt,sa) Diff(q,nsw) Diff(q,sa)
Diff(nsw,v) Diff(nsw,sa) Diff(v,sa)
Colorable()
• The two clauses are assumed to be standardized apart so that they share
no variables.
• For example,
Rich(x) Unhappy(x) Rich(Ken)
Unhappy(Ken)
with θ = {x/Ken}
~
Forward Chaining
Backward Chaining
Forward chaining proof: (Horn clauses)
Forward chaining proof (Horn clauses)
Enemy(x,America) Hostile(x)
Missile(x) Owns(Nono,x) Sells(West,x,Nono)
Missile(x) Weapon(x)
Forward chaining proof (Horn clauses)
• PARTIAL SOLUTION:
– An upon-agreed ontology that settles these questions
– Ontology = what exists in the world & how it is represented
– The Knowledge Engineering teams agrees upon an ontology
BEFORE they begin encoding knowledge
Using FOL
• We want to TELL things to the KB, e.g.
TELL(KB, x King(x) PersonX) )
TELL(KB, King(John) )
The KB should return the list of x’s for which Person(x) is true:
{x/John, x/Richard,...}
FOL Version of Wumpus World
• Typical percept sentence:
Percept([Stench,Breeze,Glitter,None,None],5)
• Actions:
Turn(Right), Turn(Left), Forward, Shoot, Grab, Release, Climb
• Reflex action
– t Glitter(t) BestAction(Grab,t)
Properties of locations:
s,t At(Agent,s,t) Breeze(t) Breezy(s)
Possible queries:
- does the circuit function properly?
- what gates are connected to the first input terminal?
- what would happen if one of the gates is broken?
and so on
The electronic circuits domain
1. Identify the task
– Does the circuit actually add properly?
3. Decide on a vocabulary
– Many alternative ways to say X1 is an OR gate:
–
– Type(X1) = XOR (function)
Type(X1, XOR) (binary predicate)
XOR(X1) (unary predicate)
etc.
The electronic circuits domain
4. Encode general knowledge of the domain
– t1,t2 Connected(t1, t2) Signal(t1) = Signal(t2)
– t Signal(t) = 1 Signal(t) = 0
– 1≠0
Connected(Out(1,X1),In(1,X2)) Connected(In(1,C1),In(1,X1))
Connected(Out(1,X1),In(2,A2)) Connected(In(1,C1),In(1,A1))
Connected(Out(1,A2),In(1,O1)) Connected(In(2,C1),In(2,X1))
Connected(Out(1,A1),In(2,O1)) Connected(In(2,C1),In(2,A1))
Connected(Out(1,X2),Out(1,C1)) Connected(In(3,C1),In(2,X2))
Connected(Out(1,O1),Out(2,C1)) Connected(In(3,C1),In(1,A2))
The electronic circuits domain
6. Pose queries to the inference procedure:
What are the possible sets of values of all the terminals for the adder circuit?
• Nested quantifiers
– Order of unlike quantifiers matters (the outer scopes the inner)
• Like nested ANDs and ORs
– Order of like quantifiers does not matter
• like nested ANDS and ANDs
⊥ ⊥
S1,S2[,B]