Artificial Intelligence: Methods and Applications Lecture 3: Review of First-Order Logic (FOL) Juan Carlos Nieves Sánchez November 11, 2014
Outline • Knowledge Engineering. • Reducing first-order inference to propositional inferece. • Unification. • Generalized Modus Pones • Forward and backward chaining • Resolution Review of First-Order Logic 3
The knowledge-engineering process 1. Identify the task (identify the questions of interest). 2. Assemble the relevant knowledge (acquisition). 3. Decide on a vocabulaty of predicates, functions, and constants (the ontology). 4. Encode general knowledge about the domain (write down axioms). 5. Encode a description of the specific problem instance. 6. Pose queries to the inference procedure and get answers (use the system). 7. Debug/maintain the knowleg base. Review of First-Order Logic 4
Relations An n-ary relation R is a subset of the Catetian product 𝑬 𝟐 × ∙∙∙ × 𝑬 𝒐 where each 𝑬 𝒋 𝟐 ≤ 𝒋 ≤ 𝒐 is a set. For example: PR(x) – the set of numbers x which are prime: {2,3,5,7,11, . . . } . SQ(x,y ) – the set of pairs (x,y) such that y is the square of x : 1,1 , 2,4 , 3,9 , . . . . Can you define the relation of sum of two integer numbers? Review of First-Order Logic 6
Predicates A relation can be formalized as a boolean-valued function on n-tuples: Let D be a set. R is an n-ary relation on the domain D if R is a relation on 𝑬 𝒐 . Let R be an n-ary relation on a domain D . The predicate P associated with R is: For example: SQ(2,1) = F SQ(2,2) = F SQ(2,3) = F SQ(2,4) = T Review of First-Order Logic 7
The syntax of FOL 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 → 𝐵𝑢𝑝𝑛𝑗𝑑𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 | 𝐷𝑝𝑛𝑞𝑚𝑓𝑦𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 𝐵𝑢𝑝𝑛𝑗𝑑𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 → 𝑞𝑠𝑓𝑒𝑗𝑑𝑏𝑢𝑓 𝑞𝑠𝑓𝑒𝑗𝑑𝑏𝑢𝑓 𝑈𝑓𝑠𝑛 1,… 𝑈𝑓𝑠𝑛 = 𝑈𝑓𝑠𝑛 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 ¬ 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 | 𝐷𝑝𝑛𝑞𝑚𝑓𝑦𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 → Sentence Sentence | Sentence Sentence | 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 ⇒ 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 | 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 𝑇𝑓𝑜𝑢𝑓𝑜𝑑𝑓 | 𝑅𝑣𝑏𝑜𝑢𝑗𝑔𝑗𝑓𝑠 𝑊𝑏𝑠𝑗𝑏𝑐𝑚𝑓 , . . . 𝑇𝑓𝑜𝑢𝑜𝑑𝑓 𝑈𝑓𝑠𝑛 → 𝐷𝑝𝑜𝑡𝑢𝑏𝑜𝑢 𝑊𝑏𝑠𝑗𝑏𝑐𝑚𝑓 𝐺𝑣𝑜𝑑𝑢𝑗𝑝𝑜 𝑈𝑓𝑠𝑛, … 𝑅𝑣𝑏𝑜𝑢𝑗𝑔𝑗𝑓𝑠 → ∀ | ∃ 𝐷𝑝𝑜𝑡𝑢𝑏𝑜𝑢 → A | X1 | Johm | … 𝑊𝑏𝑠𝑗𝑏𝑐𝑚𝑓 → A | x | s | … 𝑄𝑠𝑓𝑒𝑗𝑑𝑏𝑢𝑓 → After | Loves | .. 𝐺𝑣𝑜𝑑𝑢𝑗𝑝𝑜 → LeftLeg Review of First-Order Logic 8
An example of a FOL Theory We build a knowledge base for natural numbers using the following vocabulary: • The relation name Num • The constant name 0 • The function names + and S Assertions: 𝑂𝑣𝑛(0) • • ∀ 𝑦 𝑂𝑣𝑛 𝑦 ⇒ 𝑂𝑣𝑛 𝑇 𝑦 ∀ 𝑦 𝑇 𝑦 != 0 • ∀ 𝑦, 𝑧 𝑦 ! = 𝑧 ⇒ 𝑇 𝑦 ! = 𝑇 𝑧 • ∀ 𝑦 𝑂𝑣𝑛 𝑦 ⇒ 𝑦 + 0 = 𝑦 • ∧ 𝑂𝑣𝑛 𝑧 ⇒ 𝑇 𝑦 + 𝑧 = 𝑇(𝑦 + 𝑧) • ∀ 𝑦 𝑂𝑣𝑛 𝑦 Review of First-Order Logic 9
Queries Asking our knowledge base whether: ? 𝑇 𝑇 𝑇 0 = 𝑇 𝑇 0 + 𝑇(0) Should now in principle yield the answer true. By the first two assertions , all three objects involved are numbers. By the last assertion, the equality must hold. This means that + 𝑇(0) 𝑇 𝑇 𝑇 0 = 𝑇 𝑇 0 is a theorem of our system. It can be derived from our axioms. Review of First-Order Logic 10
Another example of a knowledge base The law says that is a crime for an American to sell weapons to a hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to by Colonel West, who is American. .. it is a crime for an American to sell weapons to hostile nations: ∀ 𝑦, 𝑧, 𝑨 𝐵𝑛𝑓𝑠𝑗𝑑𝑏𝑜 𝑦 ∧ 𝑋𝑓𝑏𝑞𝑝𝑜 𝑧 ∧ 𝑇𝑓𝑚𝑚𝑡 𝑦, 𝑧, 𝑨 ∧ 𝐼𝑝𝑡𝑢𝑗𝑚𝑓 𝑨 ⇒ 𝐷𝑠𝑗𝑛𝑗𝑜𝑏𝑚(𝑦) Nono … has some missiles: ∃ 𝑦 𝑃𝑥𝑜𝑡 𝑂𝑝𝑜𝑝, 𝑦 ∧ 𝑁𝑗𝑡𝑡𝑗𝑚𝑓 𝑦 . How to solve queries automatically? .. all of its missiles were sold to it by Colonel West: ∀𝑦 𝑁𝑗𝑡𝑡𝑗𝑚𝑓 𝑦 ∧ 𝑃𝑥𝑛𝑡 𝑂𝑝𝑜𝑝, 𝑦 ⇒ 𝑇𝑓𝑚𝑚𝑡(𝑋𝑓𝑡𝑢, 𝑦, 𝑂𝑝𝑜𝑝) An enemy of America counts as “hostile”: ∀ 𝑦 𝐹𝑜𝑓𝑛𝑗𝑧 𝑦, 𝐵𝑛𝑓𝑠𝑗𝑑𝑏 ⇒ 𝐼𝑝𝑡𝑢𝑗𝑚𝑓(𝑦) Missiles are weapons: ∀ 𝑦 𝑁𝑗𝑡𝑡𝑗𝑚𝑓 𝑦 ⇒ 𝑋𝑓𝑏𝑞𝑝𝑜( 𝑦) West, who is American: 𝐵𝑛𝑓𝑠𝑗𝑑𝑏𝑜(𝑋𝑓𝑡𝑢) The country Nono, an enemy of America: 𝐹𝑜𝑓𝑛𝑧(𝑂𝑝𝑜𝑝, 𝐵𝑛𝑓𝑠𝑗𝑑𝑏) Review of First-Order Logic 11
Universal Instantiation (UI) Every instantiation of a universal quantified sentence is entailed by it: ∀ 𝑤 𝛽 𝑇𝑉𝐶𝑇𝑈({𝑤/, 𝛽}) for any variable 𝑤 and ground term . E.g., ∀ 𝑦 𝐿𝑗𝑜 𝑦 ∧ 𝐻𝑠𝑓𝑓𝑒𝑧 𝑦 ⇒ 𝐹𝑤𝑗𝑚(𝑦) yields 𝐿𝑗𝑜 𝐾𝑝ℎ𝑜 ∧ 𝐻𝑠𝑓𝑓𝑒𝑧 𝐾𝑝ℎ𝑜 ⇒ 𝐹𝑤𝑗𝑚(𝐾𝑝ℎ𝑜) 𝐿𝑗𝑜 𝑆𝑗𝑑ℎ𝑏𝑠𝑒 ∧ 𝐻𝑠𝑓𝑓𝑒𝑧 𝑆𝑗𝑑ℎ𝑏𝑠𝑒 ⇒ 𝐹𝑤𝑗𝑚(𝑆𝑗𝑑ℎ𝑏𝑠𝑒) 𝐿𝑗𝑜 𝑔𝑏𝑢ℎ𝑓𝑠 𝐾𝑝ℎ𝑜 ∧ 𝐻𝑠𝑓𝑓𝑒𝑧 𝑔𝑏𝑢ℎ𝑓𝑠 𝑘𝑝ℎ𝑜 ⇒ 𝐹𝑤𝑗𝑚(𝑔𝑏𝑢ℎ𝑓𝑠(𝑘𝑝ℎ𝑜)) …. Review of First-Order Logic 12
Existential instantiation (EI) For any sentence 𝛽 , variable 𝑤 , and constnat symbol 𝑙 that does not appear alsewhere in the knowledge base: ∃ 𝑤 𝛽 𝑇𝑉𝐶𝑇𝑈({𝑤/, 𝐿) E.g. ∃ 𝑦 𝐷𝑠𝑝𝑥𝑜 𝑦 ∧ OnHead x, John yields 𝐷𝑠𝑝𝑥𝑜 𝐷 1 ∧ 𝑃𝑜𝐼𝑓𝑏𝑒 (𝐷 1 , 𝐾𝑝ℎ𝑜) such that 𝐷 1 is a new constant symbol, called Skolen constant. OBSERVATIONS: UI can be applied several times to add new sentences; the new logical theory is logical equivalent to the old. EI can be applied once to replace the existence sentence; the new logical theory is not logical equivalent to the old, but is satisfiable iff the old logical theory was satisfiable. Review of First-Order Logic 13
Reduction to propositional inference Suppose the KB contains just the following: ∀𝑦 𝐿𝑗𝑜 𝑦 ∧ 𝐻𝑠𝑓𝑓𝑒𝑧 𝑦 ⇒ 𝐹𝑤𝑗𝑚 𝑦 𝐿𝑗𝑜𝑒 𝐾𝑝ℎ𝑜 𝐻𝑠𝑓𝑓𝑒𝑧 𝐾𝑝ℎ𝑜 𝐶𝑠𝑝𝑢ℎ𝑓𝑠 𝑆𝑗𝑑ℎ𝑏𝑠𝑒, 𝐾𝑝ℎ𝑜 Instantiating the universal sentence in all possible ways, we have 𝐿𝑗𝑜 𝐾𝑝ℎ𝑜 ∧ 𝐻𝑠𝑓𝑓𝑒𝑧 𝐾𝑝ℎ𝑜 ⇒ 𝐹𝑤𝑗𝑚(𝐾𝑝ℎ𝑜) 𝐿𝑗𝑜 𝑆𝑗𝑑ℎ𝑏𝑠𝑒 ∧ 𝐻𝑠𝑓𝑓𝑒𝑧 𝑆𝑗𝑑ℎ𝑏𝑠𝑒 ⇒ 𝐹𝑤𝑗𝑚(𝑆𝑗𝑑ℎ𝑏𝑠𝑒) 𝐿𝑗𝑜𝑒 𝐾𝑝ℎ𝑜 𝐻𝑠𝑓𝑓𝑒𝑧 𝐾𝑝ℎ𝑜 𝐶𝑠𝑝𝑢ℎ𝑓𝑠 𝑆𝑗𝑑ℎ𝑏𝑠𝑒, 𝐾𝑝ℎ𝑜 The new KB is propositionalized. Some of the proposition symbols are 𝐿𝑗𝑜𝑒 𝐾𝑝ℎ𝑜 , 𝐻𝑠𝑓𝑓𝑒𝑧 𝐾𝑝ℎ𝑜 , 𝐹𝑤𝑗𝑚 𝐾𝑝ℎ𝑜 , … . Review of First-Order Logic 14
Observations of the reduction • Claim: A grounded sentence is entailed by the new knowledge base iff entailed by the original knoledge base. • Claim: Every FOL knowledge base can be propositionalized so as to preserve entailment . • Idea: propositonalize knowledge base and query, apply resolution , return result. • Problem: with functions symbols, there are infinitely many grounded terms. • Theorem: Helbrad (1930), If a sentence 𝛽 is enteilated by an FOL knowledge base, it is entailed by a finite subset of the propositonal knowled base. • Idea: For 𝑜 = 0 to ∞ do create a propositional knowleg base by instatiating with depth- 𝑜 terms see if 𝛽 is entailed by this propositional knowledge base • Problem: works if 𝛽 is entailed, loops if 𝛽 is not entailed • Thoerem: Turing (1936), Church(1936), entailment if FOL is semidecidable Review of First-Order Logic 15
Problems with propositonalization Propositionalization seems to generate lots of irrelevant sentences. E.g., from ∀𝑦 𝐿𝑗𝑜 𝑦 ∧ 𝐻𝑠𝑓𝑓𝑒𝑧 ⇒ 𝐹𝑤𝑗𝑚 𝑦 𝐿𝑗𝑜 𝐾𝑝ℎ𝑜 ∀ 𝑧 𝐻𝑠𝑓𝑓𝑒𝑧(𝑧) 𝐶𝑠𝑝𝑢ℎ𝑓𝑠(𝑆𝑗𝑑ℎ𝑏𝑠𝑒, 𝐾𝑝ℎ𝑜) it seems obvious that 𝐹𝑤𝑗𝑚 𝐾𝑝ℎ𝑜 , but propositionalization produces lots of facts such as 𝐻𝑠𝑓𝑓𝑒𝑧 𝑆𝑗𝑑ℎ𝑏𝑠𝑒 that are inrrelevant. With 𝑞 𝑙 -any predicates and 𝑜 constants, there are 𝑞 𝑜 𝑙 instantiations. With function symbols, it gets much much worse! Review of First-Order Logic 16
Recommend
More recommend