SlideShare a Scribd company logo
INFERENCE IN FIRST-ORDER LOGIC
Artificial Intelligence, A Modern Approach, CH.9
2017.04.28(Fri)
Junya Tanaka (M1)
Definition
Sound
• Inference derives true conclusions given true premises
Complete
• Inference derives all true conclusions from a set of premises
Substitution(SUBST({var_name / value}, sentence))
• EX.
oP = Animal(X)
oSUBST({X/Panda},P}) = Animal(Panda)
Introduction
• Chapter 7 showed how a knowledge-based agent could
represent the world in which it operates and deduce what
actions to take.
• Chapter 8 examine first-order logic, which is sufficiently
expressive to represent a good deal of our common-sense
knowledge.
effective procedures for answering questions posed
in first-order logic.
Goal of this chapter is …
Agenda
•9.1 Propositional VS. First-Oder Interference
•9.2 Unification and Lifting
•9.3 Forward Chaining
•9.4 Backward Chaining
•9.5 Resolution
•9.6 Summery
9.1 Propositional VS. First-Oder Inference
• This section and the next introduce the ideas underlying
modern logical inference systems
• some simple inference rules that can be applied to
sentences with quantifiers to obtain sentences without
quantifiers
• Inference rules for quantifiers
oUniversal Quantifiers
 a type of quantifier a logical constant which is interpreted as "given
any" or "for all”
oExistential Quantifiers
 a type of quantifier, a logical constant which is interpreted as "there
exists", "there is at least one", or "for some"
∀
∃
Universal Instantiation(UI:∀)
• we can infer any sentence obtained by substituting a ground
term (a term without variables) for the variable.
• Example
oIf ∀x Person(x) (every x is a person)
othen Person(John), Person(Jack)…so on are true.
oSo substitute x with anything(ground term) is legal.
• 𝑆𝑈𝐵𝑆𝑇(𝜃, 𝛼) denote the result of applying the substitution 𝜃
to the sentence 𝛼 . Then the rule is written
∀𝑣 𝛼
𝑆𝑈𝐵𝑆𝑇(
𝑣
𝑔
, 𝛼)
for any variable v and ground term g
Example
• Suppose our knowledge base contains the standard
folkloric axiom stating that all greedy kings are evil:
∀𝑥 𝐾𝑖𝑛𝑔 𝑥 ∧ 𝐺𝑟𝑒𝑒𝑑𝑦 𝑥 ⇒ 𝐸𝑣𝑖𝑙(𝑥)
• Then it seems quite permissible to infer any of the
following sentences:
𝐾𝑖𝑛𝑔 𝐽𝑜ℎ𝑛 ∧ 𝐺𝑟𝑒𝑒𝑑𝑦 𝐽𝑜ℎ𝑛 ⇒ 𝐸𝑣𝑖𝑙 𝐽𝑜ℎ𝑛
𝐾𝑖𝑛𝑔 𝑅𝑖𝑐ℎ𝑎𝑟𝑑 ∧ 𝐺𝑟𝑒𝑒𝑑𝑦 𝑅𝑖𝑐ℎ𝑎𝑟𝑑 ⇒ 𝐸𝑣𝑖𝑙 𝑅𝑖𝑐ℎ𝑎𝑟𝑑
𝐾𝑖𝑛𝑔(𝐹𝑎𝑡ℎ𝑒𝑟(𝐽𝑜ℎ𝑛)) ∧ 𝐺𝑟𝑒𝑒𝑑𝑦(𝐹𝑎𝑡ℎ𝑒𝑟(𝐽𝑜ℎ𝑛)) ⇒ 𝐸𝑣𝑖𝑙(𝐹𝑎𝑡ℎ𝑒𝑟(𝐽𝑜ℎ𝑛))
Existential Instantiation
• The existential sentence says there is some object satisfying
a condition, and applying the existential instantiation rule just
gives a name to that object
• For any sentence α, variable v, and constant symbol k that
does not appear elsewhere in the knowledge base,
∃𝑣 𝛼
𝑆𝑈𝐵𝑆𝑇(
𝑣
𝑘
, 𝛼)
• Intuition
oThere is “some” object satisfying a condition.
oWe cannot randomly substitute the variable.
oInstead, we use a constant “C” which we assume that C
satisfies the condition.
Example
• From the sentence
∃x Crown(x) ∧ OnHead(x, John)
• we can infer the sentence
Crown(C1) ∧ OnHead(C1, John)
as long as C1 does not appear in knowledge base.
• Provided C1 is a new constant symbol, called a Skolem
constant
• Existential Instantiation is a special case of a more general
process called Skolemization
UI and EI
• UI can be applied several times to add new sentences; the
new KB is logically equivalent to the old.
oGiven everything is valid, instantiating anything is also valid.
• EI can be applied only once to replace the existential
sentence; the new KB is not equivalent to the old, but is
satisfiable iff the old KB was satisfiable.
oE.g. ∃x Killer(x, Victim)
 After substituting this sentence, we get Killer(Murderer, Victim) and
the original sentence with ∃ is discarded.
 The new KB is not equivalent to the old one since the original
sentence was replaced.
 These two KB are not logically equivalent yet inferentially
equivalent
Reduction to propositional inference
• We have rules for inferring nonquantified sentences from
quantified sentences
• It becomes possible to reduce first-order inference to
propositional inference
• The first idea is that, just as an existentially quantified
sentence can be replaced by one instantiation, a universally
quantified sentence can be replaced by the set of all possible
instantiations
Example
• Suppose the KB contains just the following:
o∀ x King(x) ∧ Greedy(x) ⇒ Evil(x)
oKing(John)
oGreedy(John)
oBrother(Richard, John)
• Instantiating the universal sentence in all possible ways, we
have
oKing(John) ∧ Greedy(John) ⇒ Evil(John)
oKing(Richard) ∧ Greedy(Richard) ⇒ Evil(Richard)
oKing(John)
oGreedy(John)
oBrother(Richard, John)
• The new KB is propositionalized: proposition symbols are
oKing(John), Greedy(John), Evil(John), King(Richard) etc.
Problems
• Problem1:
oWith function symbols, there are infinitely many ground terms,
Father(Father(Father(John)))
• Problem2:
oWe can check the entailment of a sentence. (Modus Ponens,
Resolution, etc.)
oHowever, unable to check the “non-entailment” of the sentence.
(Infinitely nested statement → infinite loop)
9.2 Unification and Lifting
• The propositionalization approach is rather inefficient
• Example
othe inference of Evil(John) from the sentences
∀x King(x)∧Greedy(x) ⇒ Evil(x)
King (John )
Greedy (John )
This seems completely obvious to a human being
First-order inference rule
• Generalized Modus Ponens
oIt can be summarized as "P implies Q and P is asserted to be
true, so therefore Q must be true
oFor atomic sentences p , p ′, and q, where there is a
substitution θ such that SUBST(θ, pi′) = SUBST(θ, pi), for all i,
p1′, p2′, ..., pn′, (p1 ∧p2 ∧...∧pn ⇒q)
𝑆𝑈𝐵𝑆𝑇(𝜃, 𝑞)
Example of Generalized Modus Ponens
• Example
oUse the rule that greedy kings are evil, find some x such that x
is a king and x is greedy, and then infer that this x is evil
oThe substitution {x/John,y/John} to the implication premises
King(x) and Greedy(x) and the knowledge-base sentences
King(John) and Greedy(y) will make them identical
• p1′ is King(John)
p2′ is Greedy(y)
θ is {x/John, y/John} SUBST(θ, q) is Evil(John) .
• p1 is King(x) p2 is Greedy(x) q is Evil(x)
Unification
• We can get the inference immediately if we can find a
substitution θ such that King(x) and Greedy(x) match
King(John) and Greedy(y)
oθ = {x/John,y/John} works
• Unification finds substitutions that make different logical
expressions look identical
oUNIFY takes two sentences and returns a unifier for them, if one
exists
oUNIFY(p,q) =  where SUBST(,p) = SUBST (,q)
 Basically, find a  that makes the two clauses look alike
Example of Unification
•Examples
UNIFY(Knows(John,x), Knows(John,Jane)) = {x/Jane}
UNIFY(Knows(John,x), Knows(y,Bill)) = {x/Bill, y/John}
UNIFY(Knows(John,x), Knows(y,Mother(y))= {y/John, x/Mother(John)
UNIFY(Knows(John,x), Knows(x,Elizabeth)) = fail
o Last example fails because x would have to be both John and Elizabeth
o We can avoid this problem by standardizing:
 The two statements now read
UNIFY(Knows(John,x), Knows(z,Elizabeth))
 This is solvable:
UNIFY(Knows(John,x), Knows(z,Elizabeth)) = {x/Elizabeth,z/John}
Unification
•To unify Knows(John,x) and Knows(y,z)
oCan use θ = {y/John, x/z }
oOr θ = {y/John, x/John, z/John}
•The first unifier is more general than the second.
•There is a single most general unifier (MGU) that is
unique up to renaming of variables.
MGU = { y/John, x/z }
Unification Algorithm
Storage and Retrieval
•Use TELL and ASK to interact with Inference Engine
oImplemented with STORE and FETCH
 STORE(s) stores sentence s
 FETCH(q) returns all unifiers that the query q unifies with some
sentence in Knowledge Base
•Example:
oq = Knows(John,x)
oKB is:
 Knows(John,Jane), Knows(y,Bill), Knows(y,Mother(y))
oResult is
 1={x/Jane}, 2=, 3= {John/y,x/Mother(y)}
Storage and Retrieval
• First approach:
 Create a long list of all propositions in Knowledge Base
 Attempt unification with all propositions in Knowledge Base
oWorks, but is inefficient
• Need to restrict unification attempts to sentences that have
some chance of unifying
oIndex facts in Knowledge Base
 Predicate Indexing
Index predicates:
• All “Knows” sentences in one bucket
• All “Loves” sentences in another
 Use Subsumption Lattice (see below)
Storage and Retrieval
• Subsumption Lattice
oChild is obtained from parent through a single substitution
oLattice contains all possible queries that can be unified with it.
 Works well for small lattices
 Predicate with n arguments has a 2n lattice
oStructure of lattice depends on whether the base contains repeated
variables
9.3 Forward Chaining
• Forward Chaining
oone of the two main methods of reasoning when using
an inference engine and can be described logically as repeated
application
oIdea:
 Start with atomic sentences in the KB
 Apply Modus Ponens
Add new atomic sentences until no further inferences can be made
oWorks well for a KB consisting of Situation  Response
clauses when processing newly arrived data
First-Order definite clauses
• They are disjunctions of literals of which exactly one is
positive
• First Order Definite Clauses
oDisjunctions of literals of which exactly one is positive:
oExample:
 King(x)  Greedy(x)  Evil(x)
 King(John)
 Greedy(y)
oFirst Order Definite Clauses can include variables
 Variables are assumed to be universally quantified
Greedy(y) means y Greedy(y)
oNot every KB can be converted into first definite clauses
Example(1/2)
• Consider the following problem:
oThe law says that it is a crime for an American to sell weapons
to hostile nations. The country Nono, an enemy of America,
has some missiles, and all of its missiles were sold to it by
Colonel West, who is American
• Prove
oWest is a criminal
Example(2/2)
• it is a crime for an American to sell weapons to hostile
nations:
American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x)
• Nono … has some missiles, i.e., x Owns(Nono,x) 
Missile(x):
Owns(Nono,M1) and Missile(M1)
• … all of its missiles were sold to it by Colonel West
Missile(x)  Owns(Nono,x)  Sells(West,x,Nono)
• Missiles are weapons:
Missile(x)  Weapon(x)
• An enemy of America counts as "hostile“:
Enemy(x,America)  Hostile(x)
• West, who is American …
American(West)
• The country Nono, an enemy of America …
Enemy(Nono,America)
Simple Forward-chaining algorithm
Proof of Forward Chaining
Proof of Forward Chaining
Proof of Forward Chaining
Properties of forward chaining
•Sound and complete for first-order definite clauses
•Datalog = first-order definite clauses + no functions
•FC terminates for Datalog in finite number of
iterations
•May not terminate in general if α is not entailed
oThis is unavoidable: entailment with definite clauses is
semidecidable
Efficiency of forward chaining
• Incremental forward chaining: no need to match a rule on
iteration k if a premise wasn't added on iteration k-1
 match each rule whose premise contains a newly added positive
literal
• Matching itself can be expensive:
• Database indexing allows O(1) retrieval of known facts
oe.g., query Missile(x) retrieves Missile(M1)
• Forward chaining is widely used in deductive databases
• There are two major possible sources of complexity.
oPattern matching
oIncremental forward chaining
Pattern matching
• Finding all possible unifiers consumes large amount of time.
• For example,
oMissile(x) ∧ Owns(Nono, x) → Sells(West, x, Nono)
oAssume that Nono owns 1000 objects but only 3 are missile.
oIf we sequentially find substitution of x in KB from objects
owned by Nono, it would take lots of time to find a missile.
oOn the other hand, if we started with finding from x that is
missile, we would check only 3 times and that reduce great
amount of computational time.
• This is called “conjunct ordering” problem:
ofind a good order to solve the conjuncts of the rule premise
oNP-hard problem (but good heuristic available)
Example : Map-coloring problem
• Given a map, find a way to paint the color on each city(node)
so that the adjacent cities do not share the same color.
• Colorable() means the constraints are satisfiable.
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()
Diff(Red,Blue) Diff (Red,Green)
Diff(Green,Red) Diff(Green,Blue)
Diff(Blue,Red) Diff(Blue,Green)
Incremental forward chaining
• On each iteration, Forward Chaining matches every rule in
Knowledge Base.
 (But didn’t show in the previous slide)
 E.g. Missile(x) → Weapon(x) is matched with Missile(M1) resulting
in “Weapon(M1)”, which is already in KB, in every iteration.
• Observation :
oFacts obtained from iteration t must use some facts from the
iteration t-1 to derive.
oIt’s true, if the fact in iteration t could be derived with new fact
from iteration t-1, we would get that iteration t fact sooner.
• Solution :
oAt iteration t, we take a rule only if its premise contains a
conjunct pi that unifies with a newly derived fact pi
′
at iteration
t-1.
oNote: The premise just needs to contain, doesn’t have to be
whole.
Example of Incremental forward chaining
• Example
oWe were able to derive the fact P(John) at 5th iteration.
oThere are these following sentences in KB
 (1) P(x) ∧ Q(Jane) → AA
 (2) K(x) ∧ M(x, y) ∧ N(x) ∧ O(x, z) → BB
 (3) P(Jack) ∧ N(Jake) → CC
oAt the 6th iteration, there is no point in checking the second and
third sentences
 (2) does not contain P
 (3) cannot unify with P(John) since P was already substituted as
Jack.
oAnd at the 7th iteration, we don’t match P(John) with (1)
because we will keep deriving AA.
9.4 Backward Chaining
• Backward Chaining is a “generator”
oGenerates all possible substitutions to the goal.
• Backward Chaining is depth-first.
• Idea
oStarts from the goal
oMatches each literal in goal’s premise from left to right with
facts in Knowledge Base
oCreates new recursive call, if the call succeed, the proof in that
branch is completed.
oIf the current goal is completed, continue with new sentence
that can lead to goal.
 Be reminded : goal might be able to reached from one or more
rules.
Backward chaining
Backward chaining
Backward chaining
Backward chaining
Backward chaining
Backward chaining
Backward chaining
Backward Chaining
• Properties of Backward chaining
oDepth-first recursive proof search
oIncomplete due to infinite loops
 Fixed by checking current goal against every goal
oInefficient due to repeated subgoals
 Fixed by caching previous results
oHowever, Backward Chaining is widely used “without”
improvements.
Backward Chaining
• Logic programming
oAlgorithm = Logic + Control (Robert Kowalski’s equation)
oDeclare problem in logical symbol form
oQuery desired statement
oThe program will find the solution to the query based on
Knowledge Base.
• Prolog
oLogic programming language
oUse Backward Chaining as an inference algorithm
oClose world assumption
Prolog
• Redundant inference and infinite loops
oProlog is trapped in infinite loops easily because of its depth-
first style search.
oLet
 path(x, y) refers to “an existence of path between point x and z.”
 link(x, y) refers to “x is directly connected to y.” (adjacent node)
oTo see if a path between two distant nodes exist, we use
path(n1, n2)
oWe model the rules in recursive style with prolog syntax as…
 path(n1, n2) :- link(n1, n2)
 path(n1, n2) :- path(n1, n), path(n, n2)
Prolog
• Redundant inference and infinite loops
• path(n1, n2) :- link(n1, n2)
oCase 1: two nodes are directly connected.
• path(n1, n2) :- path(n1, n), link(n, n2)
oCase 2:two nodes are connected by some path between n1
and n while n is adjacent to n2.
• This can be written in FOL style as…
o[link(n1, n2)] ∨ [path(n1, n) ∧ link(n, n2)] → path(n1, n2)
Prolog
• If implemented badly, prolog will keep on delving itself to find
the path as the right picture
Constraint logic programming(CLP)
• Normally logic program(e.g. prolog) can answer only 1 or
finite number of answers at time.
• What if there are infinitely many answers?
• Example
x>=0 ∧ y>=0 ∧ z>=0 ∧ x+y>=z ∧ y+z>=x ∧ x+z>=y
→ Triangle(x, y, z)
oFor Prolog
 Triangle(3,4,5) is True.
 But Triangle(3,4,z) causes an error because prolog cannot handle z>= 0
constraint.
oCLP can handle this.
 Triangle(3,4,z) results in 1<= z <= 7
• CLP was invented for constraint problem solving.
• The answer is correct as long as it meets the constraints
9.5 Resolution
• Conjunctive normal form for First-order logic
oAs in propositional logic, resolution algorithm works with
sentences in Conjunctive normal form.
oEvery First-order logic sentence can be converted into an
inferentially equivalent Conjunctive normal form sentence.
Resolution
• Conversion to Conjunctive normal form
• Everyone who loves all animals is loved by someone:
∀x [∀y Animal(y) → Loves(x, y)] → [∃y Loves(y, x)]
• 1. Eliminate implications and biconditionals (if any)
∀x [¬(∀y ¬Animal(y) ∨ Loves(x, y))] ∨ [∃y Loves(y, x)]
• 2. Move ¬ inwards: (¬∀x p ≡ ∃x ¬p , ¬ ∃x p ≡ ∀x ¬p)
∀x [∃y ¬(¬ Animal(y) ∨ Loves(x, y))] ∨ [∃y Loves(y, x)]
∀x [∃y ¬¬ Animal(y) ∧ ¬Loves(x, y))] ∨ [∃y Loves(y, x)]
∀x [∃y Animal(y) ∧ ¬Loves(x, y))] ∨ [∃y Loves(y, x)]
• 3. Standardize variables:
∀x [∃y Animal(y) ∧ ¬Loves(x, y))] ∨ [∃y Loves(y, x)]
oNotice that there are two y in the sentence.
oHowever, these y refer to different objects
 The first one is animal, the second one is the person who loves x.
oTo avoid confusion, we rename(standardize) the second y.
∀x [∃y Animal(y) ∧ ¬Loves(x, y))] ∨ [∃z Loves(z, x)]
Resolution
• 4. Skolemization
oAs in the previous slide, skolemization is done so as to drop the
EQ.
oHowever, we cannot use skolem variable as before.
o∀x [Animal(A) ∧ ¬Loves(x, A))] ∨ [Loves(B, x)]
 Everyone either
fails to love a “particular” animal A.
Is loved by a “particular” person B.
oThe meaning of the sentence has changed.
oIn this case, we have to use “skolem function” which its value
depends on x.
o∀x [Animal(F(x)) ∧ ¬Loves(x, F(x)))] ∨ [Loves(G(x), x)]
oSkolem function are all the “universally quantified variable” in a
“scope of existential quantifier”.
oSo… skolem funtion behaves like a universal quantifier
Resolution
• 5. Drop universal quantifiers
oSince everything up to this point is universally quantified,
dropping the sign is a legal action.
o[Animal(F(x)) ∧ ¬Loves(x, F(x))] ∨ [Loves(G(x), x)]
• 6. Rewrite into Conjunctive form (Distribute ∧ over ∨)
o(L1 ∨ … ∨ Ln) ∧ (M1 ∨ … ∨ Mm) ∧ … ∧ (Z1 ∨ … ∨ Zz)
o[Animal(F(x)) ∨ Loves(G(x), x)] ∧ [¬Loves(x, F(x)) ∨ Loves(G(x),
x)]
Resolution
• Properties of resolution
oComplete for FOL
oRefutation-complete
 If a set of sentences is unsatisfiable, resolution will always be able
to derive a contradiction.
oHowever, resolution can produce nonconstructive proofs.
 A proof which indirectly shows a mathematical object exists without
providing a specific example or algorithm for producing an
example.
 To avoid that, answer literal is added to the negated goal.
 CNF(KB ∧ ¬(a ∧ answerLiteral))
Resolution strategies
• Unit preference
oMake use of “unit clause” : a sentence which has exactly one
literal.
oIdea : use unit clause to produce shorter sentence.
 Since we want to reach empty clause as soon as possible, having
a heuristic that could reduce the sentence’s length is worth trying
Resolution strategies
• Set of support(SoS)
oA special set that in every step of resolution, the resolvent
comes from a member of that set.
oIdea :
 We get a problem with a set of conditions.
 To solve the problem, we have to use every condition indicated in
the problem.
If we could solve without using every condition????
Something must be off!
 That set of conditions is an analogy to the set of support.
• Drawback
oIf we define bad SoS, problem becomes unsolvable.
Summary
• A first approach uses inference rules for instantiating
quantifiers in order to propositionalize the inference problem.
However, it’s very slow.
• Lifted Modus Ponens, called generalized Modus Ponens,
can be applied to FOL. FC and BC also use this rule.
• FC is a bottom-up process. Starting from scattered facts,
assembling them to get the desired conclusion.
• BC is a top-down process. Starting from desired goal, then
try to find the facts that can prove the goal true.
• Resolution also has its lifted version which works in the
same manner, CNF and proof by contradiction, as the
propositional version.

More Related Content

PPT
Logical Agents
Yasir Khan
 
PPTX
Unification and Lifting
Megha Sharma
 
PPTX
Artificial Intelligence Notes Unit 4
DigiGurukul
 
PDF
Ch 7 Knowledge Representation.pdf
KrishnaMadala1
 
PPTX
Knowledge Representation & Reasoning AI UNIT 3
Dr. SURBHI SAROHA
 
PPT
Propositional And First-Order Logic
ankush_kumar
 
PPTX
Frames
amitp26
 
PPTX
Knowledge Engineering in FOL.
Megha Sharma
 
Logical Agents
Yasir Khan
 
Unification and Lifting
Megha Sharma
 
Artificial Intelligence Notes Unit 4
DigiGurukul
 
Ch 7 Knowledge Representation.pdf
KrishnaMadala1
 
Knowledge Representation & Reasoning AI UNIT 3
Dr. SURBHI SAROHA
 
Propositional And First-Order Logic
ankush_kumar
 
Frames
amitp26
 
Knowledge Engineering in FOL.
Megha Sharma
 

What's hot (20)

PPTX
Knowledge representation and Predicate logic
Amey Kerkar
 
PPTX
Forward Backward Chaining
QAU ISLAMABAD,PAKISTAN
 
PPTX
First order logic
Megha Sharma
 
PPT
predicate logic example
SHUBHAM KUMAR GUPTA
 
PPT
Knowledge Representation & Reasoning
Sajid Marwat
 
PPTX
Dempster shafer theory
Dr. C.V. Suresh Babu
 
PPTX
Artificial Intelligence (AI) | Prepositional logic (PL)and first order predic...
Ashish Duggal
 
PPTX
Semantic nets in artificial intelligence
harshita virwani
 
PPTX
Planning
Amar Jukuntla
 
PPTX
Forward and Backward chaining in AI
Megha Sharma
 
PPTX
Knowledge representation
Md. Tanvir Masud
 
PPTX
Knowledge representation in AI
Vishal Singh
 
PPT
First order logic in knowledge representation
Sabaragamuwa University
 
PPT
Planning
ahmad bassiouny
 
PPTX
Artificial intelligence- Logic Agents
Nuruzzaman Milon
 
PPTX
Knowledge representation In Artificial Intelligence
Ramla Sheikh
 
PPTX
The Wumpus World in Artificial intelligence.pptx
JenishaR1
 
PDF
First order logic
Chinmay Patel
 
PPT
Knowledge Representation in Artificial intelligence
Yasir Khan
 
PPTX
AI_Session 20 Horn clause.pptx
Guru Nanak Technical Institutions
 
Knowledge representation and Predicate logic
Amey Kerkar
 
Forward Backward Chaining
QAU ISLAMABAD,PAKISTAN
 
First order logic
Megha Sharma
 
predicate logic example
SHUBHAM KUMAR GUPTA
 
Knowledge Representation & Reasoning
Sajid Marwat
 
Dempster shafer theory
Dr. C.V. Suresh Babu
 
Artificial Intelligence (AI) | Prepositional logic (PL)and first order predic...
Ashish Duggal
 
Semantic nets in artificial intelligence
harshita virwani
 
Planning
Amar Jukuntla
 
Forward and Backward chaining in AI
Megha Sharma
 
Knowledge representation
Md. Tanvir Masud
 
Knowledge representation in AI
Vishal Singh
 
First order logic in knowledge representation
Sabaragamuwa University
 
Planning
ahmad bassiouny
 
Artificial intelligence- Logic Agents
Nuruzzaman Milon
 
Knowledge representation In Artificial Intelligence
Ramla Sheikh
 
The Wumpus World in Artificial intelligence.pptx
JenishaR1
 
First order logic
Chinmay Patel
 
Knowledge Representation in Artificial intelligence
Yasir Khan
 
AI_Session 20 Horn clause.pptx
Guru Nanak Technical Institutions
 
Ad

Similar to Inference in First-Order Logic (20)

PPTX
Knowledge Representation and Reasoning.pptx
MohanKumarP34
 
PPTX
Jarrar: First Order Logic- Inference Methods
Mustafa Jarrar
 
PPTX
lecture-inference-in-first-order-logic.pptx
RaghavendraPrasad179187
 
PPT
Jarrar.lecture notes.aai.2011s.ch9.fol.inference
PalGov
 
PPT
Jarrar.lecture notes.aai.2011s.ch9.fol.inference
PalGov
 
PPT
9.class-notesr9.ppt
Pabitha Chidambaram
 
PDF
lecture-inference-in-first-order-logic.pdf
angerfist1
 
PDF
Ai lecture 10(unit03)
vikas dhakane
 
PPT
Inference in first-order logic Reducing first-order
erasmuskratos
 
PDF
First Order Logic resolution
Amar Jukuntla
 
PPT
Unit III Knowledge Representation in AI K.Sundar,AP/CSE,VEC
sundarKanagaraj1
 
PDF
16_FirstOrderLogic.p_4_moduleModuleNotespdf
ShylaBg1
 
PPT
chapter9.ppt
Praveen Kumar
 
PPTX
Theory of first order logic
Devaddd
 
PPTX
Logic in Predicate and Propositional Logic
ArchanaT32
 
PPTX
Propositional logic(part 2)
Dr. SURBHI SAROHA
 
PPTX
First order logic
Faiz Zeya
 
PPT
Propositional and first-order logic different chapters
ines396023
 
PPTX
Module4_AI 4th semester engineering.pptx
nithudgowda3
 
PPT
firstorder_predicate_logic_resolution.ppt
ssuserc108ce1
 
Knowledge Representation and Reasoning.pptx
MohanKumarP34
 
Jarrar: First Order Logic- Inference Methods
Mustafa Jarrar
 
lecture-inference-in-first-order-logic.pptx
RaghavendraPrasad179187
 
Jarrar.lecture notes.aai.2011s.ch9.fol.inference
PalGov
 
Jarrar.lecture notes.aai.2011s.ch9.fol.inference
PalGov
 
9.class-notesr9.ppt
Pabitha Chidambaram
 
lecture-inference-in-first-order-logic.pdf
angerfist1
 
Ai lecture 10(unit03)
vikas dhakane
 
Inference in first-order logic Reducing first-order
erasmuskratos
 
First Order Logic resolution
Amar Jukuntla
 
Unit III Knowledge Representation in AI K.Sundar,AP/CSE,VEC
sundarKanagaraj1
 
16_FirstOrderLogic.p_4_moduleModuleNotespdf
ShylaBg1
 
chapter9.ppt
Praveen Kumar
 
Theory of first order logic
Devaddd
 
Logic in Predicate and Propositional Logic
ArchanaT32
 
Propositional logic(part 2)
Dr. SURBHI SAROHA
 
First order logic
Faiz Zeya
 
Propositional and first-order logic different chapters
ines396023
 
Module4_AI 4th semester engineering.pptx
nithudgowda3
 
firstorder_predicate_logic_resolution.ppt
ssuserc108ce1
 
Ad

Recently uploaded (20)

PDF
The Cosmic Symphony: How Photons Shape the Universe and Our Place Within It
kutatomoshi
 
PPTX
Modifications in RuBisCO system to enhance photosynthesis .pptx
raghumolbiotech
 
PDF
Migrating Katalon Studio Tests to Playwright with Model Driven Engineering
ESUG
 
PPTX
Embark on a journey of cell division and it's stages
sakyierhianmontero
 
PDF
Evaluating Benchmark Quality: a Mutation-Testing- Based Methodology
ESUG
 
PPTX
Q1_Science 8_Week4-Day 5.pptx science re
AizaRazonado
 
PPTX
METABOLIC_SYNDROME Dr Shadab- kgmu lucknow pptx
ShadabAlam169087
 
PPTX
Hericium erinaceus, also known as lion's mane mushroom
TinaDadkhah1
 
PPTX
Limbic system_components_connections_ functions.pptx
muralinath2
 
PPTX
Sleep_pysilogy_types_REM_NREM_duration_Sleep center
muralinath2
 
PPT
1a. Basic Principles of Medical Microbiology Part 2 [Autosaved].ppt
separatedwalk
 
PPTX
Role of GIS in precision farming.pptx
BikramjitDeuri
 
PPTX
The Obesity Paradox. Friend or Foe ?pptx
drdgd1972
 
PPTX
Internal Capsule_Divisions_fibres_lesions
muralinath2
 
PPTX
INTERNATIONAL CLASSIFICATION OF DISEASES ji.pptx
46JaybhayAshwiniHari
 
PPTX
first COT (MATH).pptxCSAsCNKHPHCouAGSCAUO:GC/ZKVHxsacba
DitaSIdnay
 
PPTX
Nanofertilizer: Its potential benefits and associated challenges.pptx
BikramjitDeuri
 
PPTX
fghvqwhfugqaifbiqufbiquvbfuqvfuqyvfqvfouiqvfq
PERMISONJERWIN
 
PDF
Multiwavelength Study of a Hyperluminous X-Ray Source near NGC6099: A Strong ...
Sérgio Sacani
 
PDF
Renewable Energy Resources (Solar, Wind, Nuclear, Geothermal) Presentation
RimshaNaeem23
 
The Cosmic Symphony: How Photons Shape the Universe and Our Place Within It
kutatomoshi
 
Modifications in RuBisCO system to enhance photosynthesis .pptx
raghumolbiotech
 
Migrating Katalon Studio Tests to Playwright with Model Driven Engineering
ESUG
 
Embark on a journey of cell division and it's stages
sakyierhianmontero
 
Evaluating Benchmark Quality: a Mutation-Testing- Based Methodology
ESUG
 
Q1_Science 8_Week4-Day 5.pptx science re
AizaRazonado
 
METABOLIC_SYNDROME Dr Shadab- kgmu lucknow pptx
ShadabAlam169087
 
Hericium erinaceus, also known as lion's mane mushroom
TinaDadkhah1
 
Limbic system_components_connections_ functions.pptx
muralinath2
 
Sleep_pysilogy_types_REM_NREM_duration_Sleep center
muralinath2
 
1a. Basic Principles of Medical Microbiology Part 2 [Autosaved].ppt
separatedwalk
 
Role of GIS in precision farming.pptx
BikramjitDeuri
 
The Obesity Paradox. Friend or Foe ?pptx
drdgd1972
 
Internal Capsule_Divisions_fibres_lesions
muralinath2
 
INTERNATIONAL CLASSIFICATION OF DISEASES ji.pptx
46JaybhayAshwiniHari
 
first COT (MATH).pptxCSAsCNKHPHCouAGSCAUO:GC/ZKVHxsacba
DitaSIdnay
 
Nanofertilizer: Its potential benefits and associated challenges.pptx
BikramjitDeuri
 
fghvqwhfugqaifbiqufbiquvbfuqvfuqyvfqvfouiqvfq
PERMISONJERWIN
 
Multiwavelength Study of a Hyperluminous X-Ray Source near NGC6099: A Strong ...
Sérgio Sacani
 
Renewable Energy Resources (Solar, Wind, Nuclear, Geothermal) Presentation
RimshaNaeem23
 

Inference in First-Order Logic

  • 1. INFERENCE IN FIRST-ORDER LOGIC Artificial Intelligence, A Modern Approach, CH.9 2017.04.28(Fri) Junya Tanaka (M1)
  • 2. Definition Sound • Inference derives true conclusions given true premises Complete • Inference derives all true conclusions from a set of premises Substitution(SUBST({var_name / value}, sentence)) • EX. oP = Animal(X) oSUBST({X/Panda},P}) = Animal(Panda)
  • 3. Introduction • Chapter 7 showed how a knowledge-based agent could represent the world in which it operates and deduce what actions to take. • Chapter 8 examine first-order logic, which is sufficiently expressive to represent a good deal of our common-sense knowledge. effective procedures for answering questions posed in first-order logic. Goal of this chapter is …
  • 4. Agenda •9.1 Propositional VS. First-Oder Interference •9.2 Unification and Lifting •9.3 Forward Chaining •9.4 Backward Chaining •9.5 Resolution •9.6 Summery
  • 5. 9.1 Propositional VS. First-Oder Inference • This section and the next introduce the ideas underlying modern logical inference systems • some simple inference rules that can be applied to sentences with quantifiers to obtain sentences without quantifiers • Inference rules for quantifiers oUniversal Quantifiers  a type of quantifier a logical constant which is interpreted as "given any" or "for all” oExistential Quantifiers  a type of quantifier, a logical constant which is interpreted as "there exists", "there is at least one", or "for some" ∀ ∃
  • 6. Universal Instantiation(UI:∀) • we can infer any sentence obtained by substituting a ground term (a term without variables) for the variable. • Example oIf ∀x Person(x) (every x is a person) othen Person(John), Person(Jack)…so on are true. oSo substitute x with anything(ground term) is legal. • 𝑆𝑈𝐵𝑆𝑇(𝜃, 𝛼) denote the result of applying the substitution 𝜃 to the sentence 𝛼 . Then the rule is written ∀𝑣 𝛼 𝑆𝑈𝐵𝑆𝑇( 𝑣 𝑔 , 𝛼) for any variable v and ground term g
  • 7. Example • Suppose our knowledge base contains the standard folkloric axiom stating that all greedy kings are evil: ∀𝑥 𝐾𝑖𝑛𝑔 𝑥 ∧ 𝐺𝑟𝑒𝑒𝑑𝑦 𝑥 ⇒ 𝐸𝑣𝑖𝑙(𝑥) • Then it seems quite permissible to infer any of the following sentences: 𝐾𝑖𝑛𝑔 𝐽𝑜ℎ𝑛 ∧ 𝐺𝑟𝑒𝑒𝑑𝑦 𝐽𝑜ℎ𝑛 ⇒ 𝐸𝑣𝑖𝑙 𝐽𝑜ℎ𝑛 𝐾𝑖𝑛𝑔 𝑅𝑖𝑐ℎ𝑎𝑟𝑑 ∧ 𝐺𝑟𝑒𝑒𝑑𝑦 𝑅𝑖𝑐ℎ𝑎𝑟𝑑 ⇒ 𝐸𝑣𝑖𝑙 𝑅𝑖𝑐ℎ𝑎𝑟𝑑 𝐾𝑖𝑛𝑔(𝐹𝑎𝑡ℎ𝑒𝑟(𝐽𝑜ℎ𝑛)) ∧ 𝐺𝑟𝑒𝑒𝑑𝑦(𝐹𝑎𝑡ℎ𝑒𝑟(𝐽𝑜ℎ𝑛)) ⇒ 𝐸𝑣𝑖𝑙(𝐹𝑎𝑡ℎ𝑒𝑟(𝐽𝑜ℎ𝑛))
  • 8. Existential Instantiation • The existential sentence says there is some object satisfying a condition, and applying the existential instantiation rule just gives a name to that object • For any sentence α, variable v, and constant symbol k that does not appear elsewhere in the knowledge base, ∃𝑣 𝛼 𝑆𝑈𝐵𝑆𝑇( 𝑣 𝑘 , 𝛼) • Intuition oThere is “some” object satisfying a condition. oWe cannot randomly substitute the variable. oInstead, we use a constant “C” which we assume that C satisfies the condition.
  • 9. Example • From the sentence ∃x Crown(x) ∧ OnHead(x, John) • we can infer the sentence Crown(C1) ∧ OnHead(C1, John) as long as C1 does not appear in knowledge base. • Provided C1 is a new constant symbol, called a Skolem constant • Existential Instantiation is a special case of a more general process called Skolemization
  • 10. UI and EI • UI can be applied several times to add new sentences; the new KB is logically equivalent to the old. oGiven everything is valid, instantiating anything is also valid. • EI can be applied only once to replace the existential sentence; the new KB is not equivalent to the old, but is satisfiable iff the old KB was satisfiable. oE.g. ∃x Killer(x, Victim)  After substituting this sentence, we get Killer(Murderer, Victim) and the original sentence with ∃ is discarded.  The new KB is not equivalent to the old one since the original sentence was replaced.  These two KB are not logically equivalent yet inferentially equivalent
  • 11. Reduction to propositional inference • We have rules for inferring nonquantified sentences from quantified sentences • It becomes possible to reduce first-order inference to propositional inference • The first idea is that, just as an existentially quantified sentence can be replaced by one instantiation, a universally quantified sentence can be replaced by the set of all possible instantiations
  • 12. Example • Suppose the KB contains just the following: o∀ x King(x) ∧ Greedy(x) ⇒ Evil(x) oKing(John) oGreedy(John) oBrother(Richard, John) • Instantiating the universal sentence in all possible ways, we have oKing(John) ∧ Greedy(John) ⇒ Evil(John) oKing(Richard) ∧ Greedy(Richard) ⇒ Evil(Richard) oKing(John) oGreedy(John) oBrother(Richard, John) • The new KB is propositionalized: proposition symbols are oKing(John), Greedy(John), Evil(John), King(Richard) etc.
  • 13. Problems • Problem1: oWith function symbols, there are infinitely many ground terms, Father(Father(Father(John))) • Problem2: oWe can check the entailment of a sentence. (Modus Ponens, Resolution, etc.) oHowever, unable to check the “non-entailment” of the sentence. (Infinitely nested statement → infinite loop)
  • 14. 9.2 Unification and Lifting • The propositionalization approach is rather inefficient • Example othe inference of Evil(John) from the sentences ∀x King(x)∧Greedy(x) ⇒ Evil(x) King (John ) Greedy (John ) This seems completely obvious to a human being
  • 15. First-order inference rule • Generalized Modus Ponens oIt can be summarized as "P implies Q and P is asserted to be true, so therefore Q must be true oFor atomic sentences p , p ′, and q, where there is a substitution θ such that SUBST(θ, pi′) = SUBST(θ, pi), for all i, p1′, p2′, ..., pn′, (p1 ∧p2 ∧...∧pn ⇒q) 𝑆𝑈𝐵𝑆𝑇(𝜃, 𝑞)
  • 16. Example of Generalized Modus Ponens • Example oUse the rule that greedy kings are evil, find some x such that x is a king and x is greedy, and then infer that this x is evil oThe substitution {x/John,y/John} to the implication premises King(x) and Greedy(x) and the knowledge-base sentences King(John) and Greedy(y) will make them identical • p1′ is King(John) p2′ is Greedy(y) θ is {x/John, y/John} SUBST(θ, q) is Evil(John) . • p1 is King(x) p2 is Greedy(x) q is Evil(x)
  • 17. Unification • We can get the inference immediately if we can find a substitution θ such that King(x) and Greedy(x) match King(John) and Greedy(y) oθ = {x/John,y/John} works • Unification finds substitutions that make different logical expressions look identical oUNIFY takes two sentences and returns a unifier for them, if one exists oUNIFY(p,q) =  where SUBST(,p) = SUBST (,q)  Basically, find a  that makes the two clauses look alike
  • 18. Example of Unification •Examples UNIFY(Knows(John,x), Knows(John,Jane)) = {x/Jane} UNIFY(Knows(John,x), Knows(y,Bill)) = {x/Bill, y/John} UNIFY(Knows(John,x), Knows(y,Mother(y))= {y/John, x/Mother(John) UNIFY(Knows(John,x), Knows(x,Elizabeth)) = fail o Last example fails because x would have to be both John and Elizabeth o We can avoid this problem by standardizing:  The two statements now read UNIFY(Knows(John,x), Knows(z,Elizabeth))  This is solvable: UNIFY(Knows(John,x), Knows(z,Elizabeth)) = {x/Elizabeth,z/John}
  • 19. Unification •To unify Knows(John,x) and Knows(y,z) oCan use θ = {y/John, x/z } oOr θ = {y/John, x/John, z/John} •The first unifier is more general than the second. •There is a single most general unifier (MGU) that is unique up to renaming of variables. MGU = { y/John, x/z }
  • 21. Storage and Retrieval •Use TELL and ASK to interact with Inference Engine oImplemented with STORE and FETCH  STORE(s) stores sentence s  FETCH(q) returns all unifiers that the query q unifies with some sentence in Knowledge Base •Example: oq = Knows(John,x) oKB is:  Knows(John,Jane), Knows(y,Bill), Knows(y,Mother(y)) oResult is  1={x/Jane}, 2=, 3= {John/y,x/Mother(y)}
  • 22. Storage and Retrieval • First approach:  Create a long list of all propositions in Knowledge Base  Attempt unification with all propositions in Knowledge Base oWorks, but is inefficient • Need to restrict unification attempts to sentences that have some chance of unifying oIndex facts in Knowledge Base  Predicate Indexing Index predicates: • All “Knows” sentences in one bucket • All “Loves” sentences in another  Use Subsumption Lattice (see below)
  • 23. Storage and Retrieval • Subsumption Lattice oChild is obtained from parent through a single substitution oLattice contains all possible queries that can be unified with it.  Works well for small lattices  Predicate with n arguments has a 2n lattice oStructure of lattice depends on whether the base contains repeated variables
  • 24. 9.3 Forward Chaining • Forward Chaining oone of the two main methods of reasoning when using an inference engine and can be described logically as repeated application oIdea:  Start with atomic sentences in the KB  Apply Modus Ponens Add new atomic sentences until no further inferences can be made oWorks well for a KB consisting of Situation  Response clauses when processing newly arrived data
  • 25. First-Order definite clauses • They are disjunctions of literals of which exactly one is positive • First Order Definite Clauses oDisjunctions of literals of which exactly one is positive: oExample:  King(x)  Greedy(x)  Evil(x)  King(John)  Greedy(y) oFirst Order Definite Clauses can include variables  Variables are assumed to be universally quantified Greedy(y) means y Greedy(y) oNot every KB can be converted into first definite clauses
  • 26. Example(1/2) • Consider the following problem: oThe law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American • Prove oWest is a criminal
  • 27. Example(2/2) • it is a crime for an American to sell weapons to hostile nations: American(x)  Weapon(y)  Sells(x,y,z)  Hostile(z)  Criminal(x) • Nono … has some missiles, i.e., x Owns(Nono,x)  Missile(x): Owns(Nono,M1) and Missile(M1) • … all of its missiles were sold to it by Colonel West Missile(x)  Owns(Nono,x)  Sells(West,x,Nono) • Missiles are weapons: Missile(x)  Weapon(x) • An enemy of America counts as "hostile“: Enemy(x,America)  Hostile(x) • West, who is American … American(West) • The country Nono, an enemy of America … Enemy(Nono,America)
  • 29. Proof of Forward Chaining
  • 30. Proof of Forward Chaining
  • 31. Proof of Forward Chaining
  • 32. Properties of forward chaining •Sound and complete for first-order definite clauses •Datalog = first-order definite clauses + no functions •FC terminates for Datalog in finite number of iterations •May not terminate in general if α is not entailed oThis is unavoidable: entailment with definite clauses is semidecidable
  • 33. Efficiency of forward chaining • Incremental forward chaining: no need to match a rule on iteration k if a premise wasn't added on iteration k-1  match each rule whose premise contains a newly added positive literal • Matching itself can be expensive: • Database indexing allows O(1) retrieval of known facts oe.g., query Missile(x) retrieves Missile(M1) • Forward chaining is widely used in deductive databases • There are two major possible sources of complexity. oPattern matching oIncremental forward chaining
  • 34. Pattern matching • Finding all possible unifiers consumes large amount of time. • For example, oMissile(x) ∧ Owns(Nono, x) → Sells(West, x, Nono) oAssume that Nono owns 1000 objects but only 3 are missile. oIf we sequentially find substitution of x in KB from objects owned by Nono, it would take lots of time to find a missile. oOn the other hand, if we started with finding from x that is missile, we would check only 3 times and that reduce great amount of computational time. • This is called “conjunct ordering” problem: ofind a good order to solve the conjuncts of the rule premise oNP-hard problem (but good heuristic available)
  • 35. Example : Map-coloring problem • Given a map, find a way to paint the color on each city(node) so that the adjacent cities do not share the same color. • Colorable() means the constraints are satisfiable. 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() Diff(Red,Blue) Diff (Red,Green) Diff(Green,Red) Diff(Green,Blue) Diff(Blue,Red) Diff(Blue,Green)
  • 36. Incremental forward chaining • On each iteration, Forward Chaining matches every rule in Knowledge Base.  (But didn’t show in the previous slide)  E.g. Missile(x) → Weapon(x) is matched with Missile(M1) resulting in “Weapon(M1)”, which is already in KB, in every iteration. • Observation : oFacts obtained from iteration t must use some facts from the iteration t-1 to derive. oIt’s true, if the fact in iteration t could be derived with new fact from iteration t-1, we would get that iteration t fact sooner. • Solution : oAt iteration t, we take a rule only if its premise contains a conjunct pi that unifies with a newly derived fact pi ′ at iteration t-1. oNote: The premise just needs to contain, doesn’t have to be whole.
  • 37. Example of Incremental forward chaining • Example oWe were able to derive the fact P(John) at 5th iteration. oThere are these following sentences in KB  (1) P(x) ∧ Q(Jane) → AA  (2) K(x) ∧ M(x, y) ∧ N(x) ∧ O(x, z) → BB  (3) P(Jack) ∧ N(Jake) → CC oAt the 6th iteration, there is no point in checking the second and third sentences  (2) does not contain P  (3) cannot unify with P(John) since P was already substituted as Jack. oAnd at the 7th iteration, we don’t match P(John) with (1) because we will keep deriving AA.
  • 38. 9.4 Backward Chaining • Backward Chaining is a “generator” oGenerates all possible substitutions to the goal. • Backward Chaining is depth-first. • Idea oStarts from the goal oMatches each literal in goal’s premise from left to right with facts in Knowledge Base oCreates new recursive call, if the call succeed, the proof in that branch is completed. oIf the current goal is completed, continue with new sentence that can lead to goal.  Be reminded : goal might be able to reached from one or more rules.
  • 46. Backward Chaining • Properties of Backward chaining oDepth-first recursive proof search oIncomplete due to infinite loops  Fixed by checking current goal against every goal oInefficient due to repeated subgoals  Fixed by caching previous results oHowever, Backward Chaining is widely used “without” improvements.
  • 47. Backward Chaining • Logic programming oAlgorithm = Logic + Control (Robert Kowalski’s equation) oDeclare problem in logical symbol form oQuery desired statement oThe program will find the solution to the query based on Knowledge Base. • Prolog oLogic programming language oUse Backward Chaining as an inference algorithm oClose world assumption
  • 48. Prolog • Redundant inference and infinite loops oProlog is trapped in infinite loops easily because of its depth- first style search. oLet  path(x, y) refers to “an existence of path between point x and z.”  link(x, y) refers to “x is directly connected to y.” (adjacent node) oTo see if a path between two distant nodes exist, we use path(n1, n2) oWe model the rules in recursive style with prolog syntax as…  path(n1, n2) :- link(n1, n2)  path(n1, n2) :- path(n1, n), path(n, n2)
  • 49. Prolog • Redundant inference and infinite loops • path(n1, n2) :- link(n1, n2) oCase 1: two nodes are directly connected. • path(n1, n2) :- path(n1, n), link(n, n2) oCase 2:two nodes are connected by some path between n1 and n while n is adjacent to n2. • This can be written in FOL style as… o[link(n1, n2)] ∨ [path(n1, n) ∧ link(n, n2)] → path(n1, n2)
  • 50. Prolog • If implemented badly, prolog will keep on delving itself to find the path as the right picture
  • 51. Constraint logic programming(CLP) • Normally logic program(e.g. prolog) can answer only 1 or finite number of answers at time. • What if there are infinitely many answers? • Example x>=0 ∧ y>=0 ∧ z>=0 ∧ x+y>=z ∧ y+z>=x ∧ x+z>=y → Triangle(x, y, z) oFor Prolog  Triangle(3,4,5) is True.  But Triangle(3,4,z) causes an error because prolog cannot handle z>= 0 constraint. oCLP can handle this.  Triangle(3,4,z) results in 1<= z <= 7 • CLP was invented for constraint problem solving. • The answer is correct as long as it meets the constraints
  • 52. 9.5 Resolution • Conjunctive normal form for First-order logic oAs in propositional logic, resolution algorithm works with sentences in Conjunctive normal form. oEvery First-order logic sentence can be converted into an inferentially equivalent Conjunctive normal form sentence.
  • 53. Resolution • Conversion to Conjunctive normal form • Everyone who loves all animals is loved by someone: ∀x [∀y Animal(y) → Loves(x, y)] → [∃y Loves(y, x)] • 1. Eliminate implications and biconditionals (if any) ∀x [¬(∀y ¬Animal(y) ∨ Loves(x, y))] ∨ [∃y Loves(y, x)] • 2. Move ¬ inwards: (¬∀x p ≡ ∃x ¬p , ¬ ∃x p ≡ ∀x ¬p) ∀x [∃y ¬(¬ Animal(y) ∨ Loves(x, y))] ∨ [∃y Loves(y, x)] ∀x [∃y ¬¬ Animal(y) ∧ ¬Loves(x, y))] ∨ [∃y Loves(y, x)] ∀x [∃y Animal(y) ∧ ¬Loves(x, y))] ∨ [∃y Loves(y, x)] • 3. Standardize variables: ∀x [∃y Animal(y) ∧ ¬Loves(x, y))] ∨ [∃y Loves(y, x)] oNotice that there are two y in the sentence. oHowever, these y refer to different objects  The first one is animal, the second one is the person who loves x. oTo avoid confusion, we rename(standardize) the second y. ∀x [∃y Animal(y) ∧ ¬Loves(x, y))] ∨ [∃z Loves(z, x)]
  • 54. Resolution • 4. Skolemization oAs in the previous slide, skolemization is done so as to drop the EQ. oHowever, we cannot use skolem variable as before. o∀x [Animal(A) ∧ ¬Loves(x, A))] ∨ [Loves(B, x)]  Everyone either fails to love a “particular” animal A. Is loved by a “particular” person B. oThe meaning of the sentence has changed. oIn this case, we have to use “skolem function” which its value depends on x. o∀x [Animal(F(x)) ∧ ¬Loves(x, F(x)))] ∨ [Loves(G(x), x)] oSkolem function are all the “universally quantified variable” in a “scope of existential quantifier”. oSo… skolem funtion behaves like a universal quantifier
  • 55. Resolution • 5. Drop universal quantifiers oSince everything up to this point is universally quantified, dropping the sign is a legal action. o[Animal(F(x)) ∧ ¬Loves(x, F(x))] ∨ [Loves(G(x), x)] • 6. Rewrite into Conjunctive form (Distribute ∧ over ∨) o(L1 ∨ … ∨ Ln) ∧ (M1 ∨ … ∨ Mm) ∧ … ∧ (Z1 ∨ … ∨ Zz) o[Animal(F(x)) ∨ Loves(G(x), x)] ∧ [¬Loves(x, F(x)) ∨ Loves(G(x), x)]
  • 56. Resolution • Properties of resolution oComplete for FOL oRefutation-complete  If a set of sentences is unsatisfiable, resolution will always be able to derive a contradiction. oHowever, resolution can produce nonconstructive proofs.  A proof which indirectly shows a mathematical object exists without providing a specific example or algorithm for producing an example.  To avoid that, answer literal is added to the negated goal.  CNF(KB ∧ ¬(a ∧ answerLiteral))
  • 57. Resolution strategies • Unit preference oMake use of “unit clause” : a sentence which has exactly one literal. oIdea : use unit clause to produce shorter sentence.  Since we want to reach empty clause as soon as possible, having a heuristic that could reduce the sentence’s length is worth trying
  • 58. Resolution strategies • Set of support(SoS) oA special set that in every step of resolution, the resolvent comes from a member of that set. oIdea :  We get a problem with a set of conditions.  To solve the problem, we have to use every condition indicated in the problem. If we could solve without using every condition???? Something must be off!  That set of conditions is an analogy to the set of support. • Drawback oIf we define bad SoS, problem becomes unsolvable.
  • 59. Summary • A first approach uses inference rules for instantiating quantifiers in order to propositionalize the inference problem. However, it’s very slow. • Lifted Modus Ponens, called generalized Modus Ponens, can be applied to FOL. FC and BC also use this rule. • FC is a bottom-up process. Starting from scattered facts, assembling them to get the desired conclusion. • BC is a top-down process. Starting from desired goal, then try to find the facts that can prove the goal true. • Resolution also has its lifted version which works in the same manner, CNF and proof by contradiction, as the propositional version.

Editor's Notes

  • #7: This is formal definition
  • #21: The unification algorithm. The algorithm works by comparing the structures of the inputs, element by element. The substitution θ that is the argument to UNIFY is built up along the way and is used to make sure that later comparisons are consistent with bindings that were established earlier. In a compound expression such as F (A, B), the OP field picks out the function symbol F and the ARGS field picks out the argument list (A, B).
  • #25: 推論規則を使う時の二種類の主要な推論手法のひとつである。もう一方は後向き連鎖である。 前向き連鎖は使用可能なデータからスタートし、推論規則を使って最適解に達するまでさらにデータを(例えばエンドユーザーから)引き出していく。前向き連鎖を使う推論エンジンは、推論規則を検索し、条件部(IF節)が真であることが分かっている規則を探し出す。見つけた規則の帰結部(THEN節)は、データセットへの新たな情報として追加される。 Forward chaining (or forward reasoning) is one of the two main methods of reasoning when using an inference engine and can be described logically as repeated application of modus ponens. Forward chaining is a popular implementation strategy for expert systems, business and production rule systems. The opposite of forward chaining is backward chaining.
  • #30: The proof tree generated by forward chaining on the crime example. The initial facts appear at the bottom level, facts inferred on the first iteration in the middle level, and facts inferred on the second iteration at the top level.
  • #31: The proof tree generated by forward chaining on the crime example. The initial facts appear at the bottom level, facts inferred on the first iteration in the middle level, and facts inferred on the second iteration at the top level.
  • #32: The proof tree generated by forward chaining on the crime example. The initial facts appear at the bottom level, facts inferred on the first iteration in the middle level, and facts inferred on the second iteration at the top level.
  • #39: 後向き連鎖はゴール(または仮説)のリストによって起動して後向きに作業し、いずれかのゴールが正しいことを補強するのに使用可能なデータがあるかどうかを確かめる後向き連鎖を使う。 推論エンジンは推論規則を検索し、帰結部(THEN節)がゴールにマッチする規則を探す。その規則の条件部(IF節)が真かどうか不明な場合、それもゴールのリストに追加され(つまり、仮説の一部とされ)、それを立証するデータをさらに提供しなければならない Backward chaining (or backward reasoning) is an inference method that can be described (in lay terms) as working backward from the goal(s). It is used in automated theorem provers, inference engines, proof assistants and other artificial intelligence applications
  • #40: Proof tree constructed by backward chaining to prove that West is a criminal. The tree should be read depth first, left to right. To prove Criminal (West ), we have to prove the four conjuncts below it. Some of these are in the knowledge base, and others require further backward chaining. Bindings for each successful unification are shown next to the corresponding subgoal. Note that once one subgoal in a conjunction succeeds, its substitution is applied to subsequent subgoals. Thus, by the time FOL-BC-ASK gets to the last conjunct, originally Hostile(z), z is already bound to Nono.
  • #41: Proof tree constructed by backward chaining to prove that West is a criminal. The tree should be read depth first, left to right. To prove Criminal (West ), we have to prove the four conjuncts below it. Some of these are in the knowledge base, and others require further backward chaining. Bindings for each successful unification are shown next to the corresponding subgoal. Note that once one subgoal in a conjunction succeeds, its substitution is applied to subsequent subgoals. Thus, by the time FOL-BC-ASK gets to the last conjunct, originally Hostile(z), z is already bound to Nono.
  • #42: Proof tree constructed by backward chaining to prove that West is a criminal. The tree should be read depth first, left to right. To prove Criminal (West ), we have to prove the four conjuncts below it. Some of these are in the knowledge base, and others require further backward chaining. Bindings for each successful unification are shown next to the corresponding subgoal. Note that once one subgoal in a conjunction succeeds, its substitution is applied to subsequent subgoals. Thus, by the time FOL-BC-ASK gets to the last conjunct, originally Hostile(z), z is already bound to Nono.
  • #43: Proof tree constructed by backward chaining to prove that West is a criminal. The tree should be read depth first, left to right. To prove Criminal (West ), we have to prove the four conjuncts below it. Some of these are in the knowledge base, and others require further backward chaining. Bindings for each successful unification are shown next to the corresponding subgoal. Note that once one subgoal in a conjunction succeeds, its substitution is applied to subsequent subgoals. Thus, by the time FOL-BC-ASK gets to the last conjunct, originally Hostile(z), z is already bound to Nono.
  • #44: Proof tree constructed by backward chaining to prove that West is a criminal. The tree should be read depth first, left to right. To prove Criminal (West ), we have to prove the four conjuncts below it. Some of these are in the knowledge base, and others require further backward chaining. Bindings for each successful unification are shown next to the corresponding subgoal. Note that once one subgoal in a conjunction succeeds, its substitution is applied to subsequent subgoals. Thus, by the time FOL-BC-ASK gets to the last conjunct, originally Hostile(z), z is already bound to Nono.
  • #45: Proof tree constructed by backward chaining to prove that West is a criminal. The tree should be read depth first, left to right. To prove Criminal (West ), we have to prove the four conjuncts below it. Some of these are in the knowledge base, and others require further backward chaining. Bindings for each successful unification are shown next to the corresponding subgoal. Note that once one subgoal in a conjunction succeeds, its substitution is applied to subsequent subgoals. Thus, by the time FOL-BC-ASK gets to the last conjunct, originally Hostile(z), z is already bound to Nono.
  • #46: Proof tree constructed by backward chaining to prove that West is a criminal. The tree should be read depth first, left to right. To prove Criminal (West ), we have to prove the four conjuncts below it. Some of these are in the knowledge base, and others require further backward chaining. Bindings for each successful unification are shown next to the corresponding subgoal. Note that once one subgoal in a conjunction succeeds, its substitution is applied to subsequent subgoals. Thus, by the time FOL-BC-ASK gets to the last conjunct, originally Hostile(z), z is already bound to Nono.
  • #50: (a)Finding a path from A to C can lead Prolog into an infinite loop. (b) A graph in which each node is connected to two random successors in the next layer. Finding a path from A1 to J4 requires 877 inferences.