First-Order Logic: CS472 - Fall 2007 Thorsten Joachims
First-Order Logic: CS472 - Fall 2007 Thorsten Joachims
• Idea:
Foundations of Artificial Intelligence – Don’t treat propositions as “atomic” entities.
• First-Order Logic:
– Objects: cs472, fred, ph219, emptylist …
First-Order Logic – Relations/Predicates: is_Man(fred), Located(cs472, ph219) …
• Note: Relations typically correspond to verbs
CS472 – Fall 2007 – Functions: Pair(search,Pair(learning,Pair(kbsystems, emptylist)))
Thorsten Joachims – Connectives: ∧, ∨ , ¬, ⇒, ⇔
– Quantifiers:
• Universal: ∀ x: ( is_Man(x) ⇒ is_Mortal(x) )
• Existential: ∃ y: ( is_Father(y, fred) )
Example:
Representing Facts in First-Order Logic
Example: Proof
Knowledge base:
1. Lucy* is a professor
• is-prof(lucy)
2. All professors are people. • ∀ x ( is-prof(x) → is-person(x) )
• is-dean(fuchs)
3. Fuchs is the dean.
• ∀ x (is-dean(x) Æ is-prof(x))
4. Deans are professors. • ∀ x (∀ y ( is-prof(x) ∧ is-dean(y) → is-friend-of(y,x) ∨ ¬ knows(x, y) ) )
5. All professors consider the dean a friend or don’t know him. • ∀ x (∃ y ( is-friend-of (y, x) ) )
• ∀ x (Vy (is-person(x) ∧ is-person(y) ∧ criticize (x,y) → ¬ is-friend-of (y,x)))
6. Everyone is a friend of someone. • criticize(lucy,fuchs)
7. People only criticize people that are not their friends. Question: Is Fuchs no friend of Lucy?
8. Lucy criticized Fuchs. ¬ is-friend-of(fuchs,lucy)
1
Algorithm: Resolution Proof
Resolution Rule of Inference
• Negate the theorem to be proved, and add the result to the
General Rule: knowledge base.
• Bring knowledge base into conjunctive normal form (CNF)
– CNF: conjunctions of disjunctions
– Each disjunction is called a clause.
2
Unification - Purpose Unification (example)
Who does John hate?
Given: ∃ x: Hates (John, x)
Knowledge base (in clause form):
¬ Knows (John, x) ∨ Hates (John, x) 1. ¬ Knows (John, v) ∨ Hates (John, v)
Knows (John, Jim) 2. Knows (John, Jim)
Derive: 3. Knows (y, Leo)
4. Knows (z, Mother(z))
Hates (John, Jim) 5. ¬ Hates (John, x) (since ¬ ∃ x: Hates (John, x) Ù∀ x: ¬Hates(John,x))
Resolution with 5 and 1:
Unification: unify(Hates(John, x), Hates(John, v)) = {x/v}
6. ¬ Knows (John, v)
Resolution with 6 and 2:
Need unifier {x/Jim} for resolution to work. unify(Knows(John, v), Knows(John, Jim))= {v/Jim}
or resolution with 6 and 3:
Add to knowledge base: unify(Knows (John, v), Knows (y, Leo)) = {y/John, v/Leo}
or Resolution with 6 and 4:
unify(Knows (John, v), Knows (z, Mother(z))) = {z/John, v/Mother(z)}
Answers:
1. Hates(John,x) with {x/v, v/Jim} (i.e. John hates Jim)
2. Hates(John,x) with {x/v, y/John, v/Leo} (i.e. John hates Leo)
3. Hates(John,x) with {x/v, v/Mother(z), z/John} (i.e. John hates his mother)
Result:
3
3. Eliminate Existential Quantifiers: 4. Rename variables as necessary
Skolemization
We want no two variables of the same name.
Harder cases:
Easy case:
5. Move the universal quantifiers to the left 6. Move disjunctions down to the literals
4
Algorithm: Putting Axioms into Clausal Form
1. Eliminate the implications.
9. Eliminate the universal quantifiers
2. Move the negations down to the atomic formulas.
3. Eliminate the existential quantifiers.
4. Rename the variables, if necessary.
5. Move the universal quantifiers to the left.
6. Move the disjunctions down to the literals.
7. Eliminate the conjunctions.
8. Rename the variables, if necessary.
9. Eliminate the universal quantifiers.
Example
Jack owns a dog.
Every dog owner is an animal lover.
No animal lover kills an animal.
Either Jack or Curiosity killed the cat, who is named Tuna.
Did Curiosity kill the cat?
5
Proof by Resolution
Conjunctive Normal Form ¬ kills(Curiosity,Tuna) kills(Jack,Tuna) ∨ kills(Curiosity,Tuna)
{}
(D is a placeholder for the dogs unknown name
(i.e. Skolem symbol/function). Think of D like kills(Jack,Tuna) ¬ AnimalLover(w) ∨ ¬ Animal(y) ∨ ¬ kills(w,y)
“JohnDoe”)
{w/Jack, y/Tuna}
{z/Tuna}
As a consequence, many practical Knowledge Representation formalisms • MYCIN (Feigenbaum, Buchanan, Shortliffe)
in AI use a restricted form and specialized inference.
• PROSPECTOR (Duda et al., 1979)
– Logic programming (Prolog)
– Description logics
6
Successes in Rule-Based Reasoning Cognitive Modeling with Rule-Based Systems
• PROSPECTOR (Duda et al., 1979) SOAR is a general architecture for building intelligent
– Correctly recommended exploratory drilling at geological site systems.
– Rule-based system founded on probability theory – Long term memory consists of rules
– Working memory describes current state
• R1 (McDermott, 1982)
– All problem solving, including deciding what rule to
– Designs configurations of computer components
execute, is state space search
– About 10,000 rules
– Successful rule sequences are chunked into new rules
– Uses meta-rules to change context
– Control strategy embodied in terms of meta-rules
7
Programming in Prolog Programming in Prolog
• Towers of Hanoi: move N disks from pin a to pin b • 8-Queens:
using pin c. solve(P) :-
hanoi(N):-hanoi(N, a, b, c). perm([1,2,3,4,5,6,7,8],P),
combine([1,2,3,4,5,6,7,8],P,S,D),
hanoi(0,A,B,C). all_diff(S),
hanoi(N,FromPin,ToPin,UsingPin):- all_diff(D).
M is N-1, combine([X1|X],[Y1|Y],[S1|S],[D1|D]) :-
hanoi(M,FromPin,UsingPin,ToPin), S1 is X1 +Y1,
move(FromPin,ToPin), D1 is X1 - Y1,
hanoi(M,UsingPin,ToPin,FromPin). combine(X,Y,S,D).
move(From,To):- combine([],[],[],[]).
write([move, disk from, pin, From, to, pin,
ToPin]),nl. all_diff([X|Y]) :- \+member(X,Y), all_diff(Y).
all_diff([X]).