Inference in first-order logic CE417: Introduction to Artificial Intelligence Sharif University of Technology Spring 2017 Soleymani “ Artificial Intelligence: A Modern Approach ” , 3 rd Edition, Chapter 9
Outline Reducing first-order inference to propositional inference Potentially great expense Lifting inference (direct inference in FOL) Unification Generalized Modus Ponens KB of Horn clauses Forward chaining Backward chaining General KB Resolution 2
FOL to PL FOL to PL conversion First order inference by converting the knowledge base to PL and using propositional inference. How to remove universal and existential quantifiers? Universel Instantiation Existential Instantiation 3
Universal instantiation (UI) Every instantiation of a universally quantified sentence is entailed by it: ∀𝑤 𝛽 𝑇𝑣𝑐𝑡𝑢( 𝑤 , 𝛽) 𝑦 𝐿𝑗𝑜(𝑦) ∧ 𝐻𝑠𝑓𝑓𝑒𝑧(𝑦) ⇒ 𝐹𝑤𝑗𝑚(𝑦) Example, 𝛽 : 𝑇𝑣𝑐𝑡𝑢 𝑦 𝐾𝑝ℎ𝑜 , 𝛽 𝐿𝑗𝑜(𝐾𝑝ℎ𝑜) ∧ 𝐻𝑠𝑓𝑓𝑒𝑧(𝐾𝑝ℎ𝑜) ⇒ 𝐹𝑤𝑗𝑚(𝐾𝑝ℎ𝑜) 𝑇𝑣𝑐𝑡𝑢( 𝑦 𝑆𝑗𝑑ℎ𝑏𝑠𝑒 , 𝛽) 𝐿𝑗𝑜(𝑆𝑗𝑑ℎ𝑏𝑠𝑒) ∧ 𝐻𝑠𝑓𝑓𝑒𝑧(𝑆𝑗𝑑ℎ𝑏𝑠𝑒) ⇒ 𝐹𝑤𝑗𝑚(𝑆𝑗𝑑ℎ𝑏𝑠𝑒) 𝑇𝑣𝑐𝑡𝑢( 𝑦 𝐺𝑏𝑢ℎ𝑓𝑠(𝐾𝑝ℎ𝑜) , 𝛽) 𝐿𝑗𝑜(𝐺𝑏𝑢ℎ𝑓𝑠(𝐾𝑝ℎ𝑜)) ∧ 𝐻𝑠𝑓𝑓𝑒𝑧(𝐺𝑏𝑢ℎ𝑓𝑠(𝐾𝑝ℎ𝑜)) ⇒ 𝐹𝑤𝑗𝑚(𝐺𝑏𝑢ℎ𝑓𝑠(𝐾𝑝ℎ𝑜)) 4
Existential instantiation (EI) For any sentence 𝛽 , variable 𝑤 , and a new constant symbol 𝑙 : ∃𝑤 𝛽 𝑇𝑣𝑐𝑡𝑢( 𝑤 𝑙 , 𝛽) Example, 𝛽 : 𝑦 𝐷𝑠𝑝𝑥𝑜(𝑦) ∧ 𝑃𝑜𝐼𝑓𝑏𝑒(𝑦, 𝐾𝑝ℎ𝑜) 𝑇𝑣𝑐𝑡𝑢 𝑦 𝐷 1 , 𝛽 𝐷𝑠𝑝𝑥𝑜(𝐷 1 ) ∧ 𝑃𝑜𝐼𝑓𝑏𝑒(𝐷 1 , 𝐾𝑝ℎ𝑜) 𝐷 1 is a new constant symbol, called a Skolem constant EI can be applied one time (existentially quantified sentence can be discarded after it) 5
Reduction to propositional inference: Example KB of FOL sentences: 𝑦 𝐿𝑗𝑜 𝑦 𝐻𝑠𝑓𝑓𝑒𝑧 𝑦 𝐹𝑤𝑗𝑚 𝑦 𝐿𝑗𝑜 𝐾𝑝ℎ𝑜 𝐻𝑠𝑓𝑓𝑒𝑧 𝐾𝑝ℎ𝑜 𝐶𝑠𝑝𝑢ℎ𝑓𝑠 𝑆𝑗𝑑ℎ𝑏𝑠𝑒, 𝐾𝑝ℎ𝑜 𝑦 𝐷𝑠𝑝𝑥𝑜(𝑦) ∧ 𝑃𝑜𝐼𝑓𝑏𝑒(𝑦, 𝐾𝑝ℎ𝑜) A universally quantified sentence is replaced by all possible instantiations & an existentially quantified sentence by one instantiation: 𝐿𝑗𝑜(𝐾𝑝ℎ𝑜) 𝐻𝑠𝑓𝑓𝑒𝑧(𝐾𝑝ℎ𝑜) ⇒ 𝐹𝑤𝑗𝑚(𝐾𝑝ℎ𝑜) 𝐿𝑗𝑜(𝑆𝑗𝑑ℎ𝑏𝑠𝑒) 𝐻𝑠𝑓𝑓𝑒𝑧(𝑆𝑗𝑑ℎ𝑏𝑠𝑒) ⇒ 𝐹𝑤𝑗𝑚(𝑆𝑗𝑑ℎ𝑏𝑠𝑒) 𝐿𝑗𝑜(𝐾𝑝ℎ𝑜) 𝐻𝑠𝑓𝑓𝑒𝑧(𝐾𝑝ℎ𝑜) 𝐶𝑠𝑝𝑢ℎ𝑓𝑠(𝑆𝑗𝑑ℎ𝑏𝑠𝑒, 𝐾𝑝ℎ𝑜) 𝐷𝑠𝑝𝑥𝑜 𝐷 1 𝑃𝑜𝐼𝑓𝑏𝑒 𝐷 1 , 𝐾𝑝ℎ𝑜 6
Propositionalization Every FOL KB and query can be propositionalized Algorithms for deciding PL entailment can be used Problem: infinitely large set of sentences Infinite set of possible ground-term substitution due to function symbols e.g., 𝐺𝑏𝑢ℎ𝑓𝑠(… 𝐺𝑏𝑢ℎ𝑓𝑠(𝐺𝑏𝑢ℎ𝑓𝑠(𝐾𝑝ℎ𝑜))) Solution: Theorem (Herbrand, 1930): If a sentence 𝛽 is entailed by an FOL KB, it can be entailed by a finite subset of its propositionalized KB for 𝑜 = 0 to ∞ do Generate all instantiations with depth 𝑜 nested symbols if 𝛽 is entailed by this 𝐿𝐶 then return 𝑢𝑠𝑣𝑓 7
Propositionalization (Cont.) Problem: When procedure go on and on, we will not know whether it is stuck in a loop or the proof is just about to pop out Theorem (Turing-1936, Church-1936): Deciding entailment for FOL is semidecidable Algorithms exist that say yes to every entailed sentence, but no algorithm exists that also says no to every non-entailed sentence. 8
Propositionalization is inefficient Generates lots of irrelevant sentences Example: 𝐿𝑗𝑜 𝑆𝑗𝑑ℎ𝑏𝑠𝑒 𝐻𝑠𝑓𝑓𝑒𝑧 𝑆𝑗𝑑ℎ𝑏𝑠𝑒 𝐹𝑤𝑗𝑚 𝑆𝑗𝑑ℎ𝑏𝑠𝑒 is irrelevant. KB Query 𝑦 𝐿𝑗𝑜 𝑦 𝐻𝑠𝑓𝑓𝑒𝑧 𝑦 𝐹𝑤𝑗𝑚 𝑦 𝐹𝑤𝑗𝑚(𝑦) 𝐿𝑗𝑜 𝐾𝑝ℎ𝑜 𝐻𝑠𝑓𝑓𝑒𝑧 𝐾𝑝ℎ𝑜 𝐶𝑠𝑝𝑢ℎ𝑓𝑠 𝑆𝑗𝑑ℎ𝑏𝑠𝑒, 𝐾𝑝ℎ𝑜 𝑞 𝑙 -ary predicates and 𝑜 constants 𝑞 × 𝑜 𝑙 instantiations 9
Lifting & Unification Lifting: raising inference rules or algorithms from ground (variable-free) PL to FOL. E.g., generalized Modus Ponens Unification: Lifted inference rules require finding substitutions that make different expressions looks identical. Instantiating variables only as far as necessary for the proof . All variables are assumed universally quantified. 10
Unification: Simple example Example: Infer immediately when finding a substitution θ such that 𝐿𝑗𝑜(𝑦) and 𝐻𝑠𝑓𝑓𝑒𝑧(𝑦) match 𝐿𝑗𝑜(𝐾𝑝ℎ𝑜) and 𝐻𝑠𝑓𝑓𝑒𝑧(𝑧) KB Query 𝑦 𝐿𝑗𝑜 𝑦 𝐻𝑠𝑓𝑓𝑒𝑧 𝑦 𝐹𝑤𝑗𝑚 𝑦 𝐹𝑤𝑗𝑚(𝑦) 𝐿𝑗𝑜 𝐾𝑝ℎ𝑜 ∀𝑧 𝐻𝑠𝑓𝑓𝑒𝑧 𝑧 𝐶𝑠𝑝𝑢ℎ𝑓𝑠 𝑆𝑗𝑑ℎ𝑏𝑠𝑒, 𝐾𝑝ℎ𝑜 11
Unification: examples 𝑉𝑂𝐽𝐺𝑍 𝑞, 𝑟 = 𝜄 where 𝑇𝑣𝑐𝑡𝑢 𝜄, 𝑞 = 𝑇𝑣𝑐𝑡𝑢(𝜄, 𝑟) 𝑞 𝑟 𝜄 𝐿𝑜𝑝𝑥𝑡(𝐾𝑝ℎ𝑜, 𝑦) 𝐿𝑜𝑝𝑥𝑡(𝐾𝑝ℎ𝑜, 𝐾𝑏𝑜𝑓) {𝑦/𝐾𝑏𝑜𝑓} { 𝐿𝑜𝑝𝑥𝑡(𝐾𝑝ℎ𝑜, 𝑦) 𝐿𝑜𝑝𝑥𝑡(𝑧, 𝐶𝑗𝑚𝑚) 𝑦 𝐶𝑗𝑚𝑚, 𝑧/𝐾𝑝ℎ𝑜} 𝐿𝑜𝑝𝑥𝑡(𝐾𝑝ℎ𝑜, 𝑦) 𝐿𝑜𝑝𝑥𝑡(𝑧, 𝑁𝑝𝑢ℎ𝑓𝑠(𝑧)) { 𝑦 𝑁𝑝𝑢ℎ𝑓𝑠(𝐾𝑝ℎ𝑜), 𝑧/𝐾𝑝ℎ𝑜} 𝐿𝑜𝑝𝑥𝑡(𝐾𝑝ℎ𝑜, 𝑦) 𝐿𝑜𝑝𝑥𝑡(𝑦, 𝐹𝑚𝑗𝑨𝑏𝑐𝑓𝑢ℎ) 𝑔𝑏𝑗𝑚 12
Unification: examples 𝑉𝑂𝐽𝐺𝑍 𝑞, 𝑟 = 𝜄 where 𝑇𝑣𝑐𝑡𝑢 𝜄, 𝑞 = 𝑇𝑣𝑐𝑡𝑢(𝜄, 𝑟) 𝑞 𝑟 𝜄 𝐿𝑜𝑝𝑥𝑡(𝐾𝑝ℎ𝑜, 𝑦) 𝐿𝑜𝑝𝑥𝑡(𝐾𝑝ℎ𝑜, 𝐾𝑏𝑜𝑓) {𝑦/𝐾𝑏𝑜𝑓} { 𝐿𝑜𝑝𝑥𝑡(𝐾𝑝ℎ𝑜, 𝑦) 𝐿𝑜𝑝𝑥𝑡(𝑧, 𝐶𝑗𝑚𝑚) 𝑦 𝐶𝑗𝑚𝑚, 𝑧/𝐾𝑝ℎ𝑜} 𝐿𝑜𝑝𝑥𝑡(𝐾𝑝ℎ𝑜, 𝑦) 𝐿𝑜𝑝𝑥𝑡(𝑧, 𝑁𝑝𝑢ℎ𝑓𝑠(𝑧)) { 𝑦 𝑁𝑝𝑢ℎ𝑓𝑠(𝐾𝑝ℎ𝑜), 𝑧/𝐾𝑝ℎ𝑜} 𝐿𝑜𝑝𝑥𝑡(𝐾𝑝ℎ𝑜, 𝑦) 𝐿𝑜𝑝𝑥𝑡(𝑦, 𝐹𝑚𝑗𝑨𝑏𝑐𝑓𝑢ℎ) 𝑔𝑏𝑗𝑚 13
Unification: complications Complications T wo sentences using the same variable name Standardizing apart: renaming the variables causing name clashes in one of sentences More than one unifier Most General Unifier (MGU) 𝑞 𝑟 𝜄 𝐿𝑜𝑝𝑥𝑡(𝐾𝑝ℎ𝑜, 𝑦) 𝐿𝑜𝑝𝑥𝑡(𝑦, 𝐹𝑚𝑗𝑨𝑏𝑐𝑓𝑢ℎ) 𝑔𝑏𝑗𝑚 { 𝐿𝑜𝑝𝑥𝑡(𝐾𝑝ℎ𝑜, 𝑦) 𝐿𝑜𝑝𝑥𝑡(𝑦 2 , 𝐹𝑚𝑗𝑨𝑏𝑐𝑓𝑢ℎ) 𝑦 𝐹𝑚𝑗𝑨𝑏𝑐𝑓𝑢ℎ, 𝑦 2 /𝐾𝑝ℎ𝑜} 14
Unification (MGU) 𝑉𝑂𝐽𝐺𝑍( 𝐿𝑜𝑝𝑥𝑡 𝐾𝑝ℎ𝑜, 𝑦 , 𝐿𝑜𝑝𝑥𝑡 𝑧, 𝑨 ) 𝜄 1 = {𝑧/𝐾𝑝ℎ𝑜, 𝑦/𝑨 } 𝜄 2 = {𝑧/𝐾𝑝ℎ𝑜, 𝑦/𝐾𝑝ℎ𝑜, 𝑨/𝐾𝑝ℎ𝑜} 𝜄 1 is more general There is a single most general unifier (MGU) that is unique up to renaming of variables. 15
Generalized Modus Ponens (GMP) ′ = 𝑇𝑣𝑐𝑡𝑢 𝜄, 𝑞 𝑗 ′ , 𝑟 & 𝑇𝑣𝑐𝑡𝑢 𝜄, 𝑞 𝑗 For atomic sentences 𝑞 𝑗 , 𝑞 𝑗 for all 𝑗 ′ , … , 𝑞 𝑜 ′ , ′ , 𝑞 2 𝑞 1 (𝑞 1 ∧ 𝑞 2 ∧ … ∧ 𝑞 𝑜 ⇒ 𝑟) 𝑇𝑣𝑐𝑡𝑢(𝜄, 𝑟) KB ′ : 𝐿𝑗𝑜(𝐾𝑝ℎ𝑜) 𝑞 1 𝑞 1 : 𝐿𝑗𝑜(𝑦) 𝐿𝑗𝑜 𝑦 𝐻𝑠𝑓𝑓𝑒𝑧 𝑦 𝐹𝑤𝑗𝑚 𝑦 ′ : 𝐻𝑠𝑓𝑓𝑒𝑧(𝑧) 𝑞 2 𝑞 2 : 𝐻𝑠𝑓𝑓𝑒𝑧(𝑦) 𝐿𝑗𝑜 𝐾𝑝ℎ𝑜 𝑟 : 𝐹𝑤𝑗𝑚(𝑦) 𝐻𝑠𝑓𝑓𝑒𝑧 𝑧 … 𝜄 = {𝑦/𝐾𝑝ℎ𝑜, 𝑧/𝐾𝑝ℎ𝑜} Query 𝑇𝑣𝑐𝑡𝑢(𝜄, 𝑟) is 𝐹𝑤𝑗𝑚(𝐾𝑝ℎ𝑜) 𝐹𝑤𝑗𝑚(𝑦) 16
Recommend
More recommend