First-Order Deduction: Universal Elimination
First-Order Deduction: Universal Elimination
1 2
•Let SUBST(θ, α) denote the result of applying a substitution 1) ∀x,y(Parent(x,y) ∧ Male(x) ⇒ Father(x,y))
or binding list θ to the sentence α. 2) Parent(Tom,John)
-SUBST({x/Tom, y,/Fred}, Uncle(x,y)) = Uncle(Tom, Fred) 3) Male(Tom)
3 4
Generalized Modus Ponens Canonical Form
•In order to utilize generalized Modus Ponens, all sentences
•Combines three steps of “natural deduction” (Universal in the KB must be in the form of Horn sentences:
Elimination, And Introduction, Modus Ponens) into one.
∀v1,v2,...vn p1 ∧ p2 ∧...∧pm ⇒ q
where θ is a substitution such that for all i If θ is the constant False, this simplifies to
SUBST(θ,pi´)=SUBST(θ,pi)
∀v1,v2,...vn ¬p1 ∨ ¬p2∨ ... ∨ ¬ pn
•1) ∀x,y(Parent(x,y) ∧ Male(x) ⇒ Father(x,y)) Otherwise the sentence is called a definite clause (exactly
2) Parent(Tom,John) one non-negated literal).
3) Male(Tom)
Single positive literals (facts) are Horn clauses with no
θ={x/Tom, y/John) antecedent.
5 6
Unification Unification
(cont.)
•In order to match antecedents to existing literals in the KB, •Exact variable names used in sentences in the KB should not
need a pattern matching routine. matter.
•UNIFY(p,q) takes two atomic sentences and returns a •But if Likes(x,FOPC) is a formula in the KB, it does not unify
substitution that makes them equivalent. with Likes(John,x) but does unify with Likes(John,y).
UNIFY(Parent(Tom,x), Parent(Tom, John)) = {x/John}) •There are many possible unifiers for some atomic sentences.
UNIFY(Likes(x,y), Likes(z,FOPC)) = {x/z, y/FOPC} UNIFY(Likes(x,y),Likes(z,FOPC)) = {x/z, y/FOPC}
{x/John, z/John, y/FOPC}
UNIFY(Likes(Tom,y), Likes(z,FOPC)) = {z/Tom, y/FOPC} {x/Fred, z/Fred, y/FOPC}
......
UNIFY(Likes(Tom,y), Likes(y,FOPC)) = fail UNIFY should return the most general unifier which makes
the least commitment to variable values.
UNIFY(Likes(Tom,Tom), Likes(x,x)) = {x/Tom}
7 8
Forward Chaining Forward Chaining Algorithm
•Use modus ponens to always deriving all consequences •A sentence is a renaming of another if it is the same except for a
from new information. renaming of the variables.
SUBST(COMPOSE(θ1,θ2),p) = SUBST(θ2,SUBST(θ1,p))
procedure FORWARD-CHAIN(KB, p)
9 10
•Start from query or atomic sentence to be proven and look •Given a conjunction of queries, first get all possible answers to
for ways to prove it. the first conjunct and then for each resulting substitution try to
prove all of the remaining conjuncts.
•Query can contain variables which are assumed to be •Assume variables in rules are renamed (standardized apart)
existentially quantified. before each use of a rule.
Sibling(x,John) ?
Father(x,y) ? function BACK-CHAIN(KB, q) returns a set of substitutions
Inference process should return all sets of variable bindings BACK-CHAIN-LIST(KB, [q], fg)
that satisfy the query. function BACK-CHAIN-LIST(KB, qlist, ) returns a set of substitutions
inputs: KB, a knowledge base
qlist, a list of conjuncts forming a query ( already applied)
, the current substitution
•First try to answer query by unifying it to all possible facts in static: answers, a set of substitutions, initially empty
the KB.
if qlist is empty then return fg
q FIRST(qlist)
for each q0i in KB such that i UNIFY(q, q0i ) succeeds do
•Next try to prove it using a rule whose consequent unifies Add COMPOSE(, i ) to answers
^ ^ )
with the query and then try to recursively prove all of it’s end
q0i ) in KB such that i UNIFY(q, q0i ) succeeds do
[
for each sentence ( p1 ... pn
antecedents. answers BACK-CHAIN-LIST(KB, SUBST(i , [ p1 . . . pn ]), COMPOSE(, i )) answers
2
end
return the union of BACK-CHAIN-LIST(KB, REST(qlist), ) for each answers
13 14
Backchaining Examples
Backchaining Examples (cont)
KB: Query: Father(f,s)
1) Parent(x,y) ∧ Male(x) ⇒ Father(x,y) Subgoal: Parent(f,s) ∧ Male(f)
2) Father(x,y) ∧ Father(x,z) ⇒ Sibling(y,z) {f/Tom, s/John}
3) Parent(Tom,John) Subgoal: Male(Tom)
4) Male(Tom) Answer: {f/Tom, s/John}
7) Parent(Tom,Fred) {f/Tom, s/Fred}
Subgoal: Male(Tom)
Answer: {f/Tom, s/Fred}
Query: Parent(Tom,x) Answers: ({f/Tom,s/John}, {f/Tom,s/Fred})
Answers: ( {x/John}, {x/Fred})
Query: Sibling(a,b)
Subgoal: Father(f,a) ∧ Father(f,b)
{f/Tom, a/John}
Query: Father(Tom,s) Subgoal: Father(Tom,b)
Subgoal: Parent(Tom,s) ∧ Male(Tom) {b/John}
{s/John} Answer: {f/Tom, a/John, b/John}
Subgoal: Male(Tom) {b/Fred}
Answer: {s/John} Answer: {f/Tom, a/John, b/Fred}
{s/Fred} {f/Tom, a/Fred}
Subgoal: Male(Tom) Subgoal: Father(Tom,b)
Answer: {s/Fred} {b/John}
Answers: ({s/John}, {s/Fred}) Answer: {f/Tom, a/Fred, b/John}
{b/Fred}
Answer: {f/Tom, a/Fred, b/Fred}
Answers: ({f/Tom, a/John, b/John},{f/Tom, a/John, b/Fred}
{f/Tom, a/Fred, b/John}, {f/Tom, a/Fred, b/Fred})
15 16
Incompleteness Completeness
•Rule-based inference is not complete, but is reasonably •In 1930 GÖdel showed that a complete inference
efficient and useful in many circumstances. procedure for FOPC existed, but did not demonstrate one
(non-constructive proof).
17 18
p1∧... ∧ pm ⇒ q1 ∨ ...∨ qn
19 20
Resolution Proofs Refutation Proofs
•INF (CNF) is more expressive than Horn clauses. •Unfortunately, resolution proofs in this form are still
incomplete.
•Resolution is simply a generalization of modus ponens. •For example, it cannot prove any tautology (e.g. P∨¬P)
from the empty KB since there are no clauses to resolve.
•As with modus ponens, chains of resolution steps can be •Therefore, use proof by contradiction (refutation,
used to construct proofs. reductio ad absurdum). Assume the negation of the
theorem P and try to derive a contradiction (False, the
empty clause).
P(w) => Q(w) Q(y) => S(y)
(KB ∧ ¬P ⇒ False) ⇔ KB ⇒ P
{y/w}
P(w) => S(w) True => P(x) R(x) P(w) => Q(w) Q(y) => S(y)
>
{y/w}
{w/x}
P(w) => S(w) True => P(x) R(x)
>
True => S(x) R(x) R(z) => S(z)
>
{w/x}
{x/A, z/A}
True => S(x) R(x) R(z) => S(z)
>
True => S(A) {z/x}
21 22
23 24
Conversion to Clausal Form Conversion to Clausal Form
(cont) (cont)
•Skolemize: Remove existential quantifiers by replacing •Distribute ∧ over ∨ to convert to conjunctions of clauses
each existentially quantified variable with a Skolem
constant or Skolem function as appropriate. (a ∧ b) ∨ c −> (a ∨ c) ∧ (b ∨ c)
(a ∧ b) ∨ (c ∧ d) −> (a ∨ c) ∧ (b ∨ c) ∧ (a ∨ d) ∧ (b ∨ d)
-If an existential variable is not within the scope of any
universally quantified variable, then replace every
Can exponentially expand size of sentence.
instance of the variable with the same unique constant
that does not appear anywhere else.
∀x1∃x2 (P(x1) ∨ P(x2)) −> ∀x1(P(x1) ∨ P(f1(x1))) •Convert clauses to implications if desired for readability
∀x(Person(x) ⇒ ∃y(Heart(y) ∧ Has(x,y))) −> (¬a ∨ ¬b ∨ c ∨ d) −> a ∧ b ⇒ c ∨ d
∀x(Person(x) ⇒ Heart(HeartOf(x)) ∧
Has(x,HeartOf(x)))
25 26
27 28
Resolution Proof Answer Extraction
>
>
{y/D}
{x/Jack} {x/Tuna} •If you compose the substitutions from all unifications made
AnimalLover(Jack) Animal(Tuna)
in the course of a proof, you obtain an answer substitution
{y/Tuna} that gives a binding for the query variables.
Kills(Jack,Tuna} Kills(Curiosity,Tuna) AnimalLover(x) Kills(x,Tuna) => False
>
>
{x/Jack}
•To find all answers, must find all distinct resolution proofs
Kills(Curiosity,Tuna) => False Kills(Jack,Tuna) => False since each one may provide a different answer.
{}
Kills(Jack,Tuna)
{}
False
29 30
31 32
GÖdel’s Incompleteness Theorem Logicist Program
•If FOPC is extended to allow for the use of mathematical •Encode general knowledge about the world and/or any
induction for showing that statements are true for all natural given domain as a set of sentences in first-order logic.
numbers, there are true statements that can never be
proven.
•Use general logical inference to solve problems and answer
questions.
•The logical theory of numbers starts with a single constant
0, the function S (successor) for generating the natural
numbers, and axioms defining functions for multiplication, •Focus on epistemological problems of what and how to
addition, and exponentiation. represent knowledge rather than the heuristic problems of
how to efficiently conduct search.
33 34