Artificial Intelligence Lecture 9
Lecture plan Prolog Probabilities AI in general (ch. 1) Search based AI (ch. 4) search, games, planning, optimization Agents (ch. 8) applied AI techniques in robots, software agents,... Knowledge representation (ch. 2) semantic networks, frames, logic, resolution Expert systems (ch. 3) forward/backward chaining, uncertainty, baysian networks Natural language processing (ch. 5) Machine learning (ch. 7) version spaces, decision trees, classification, neural networks 2
Conjunctive Normal Form (CNF) Prolog Probabilities 3
Resolution Prolog Probabilities Requires all expression in CNF Only one rule required for all reasoning A 1... A i C A i+1... A N B 1... B j C B j+1... B M A 1... A N B 1... B M Example: X Y Y Z X Z 4
Resolution in propositional logic Prolog Probabilities To prove that P holds with respect to axioms F 1. Convert all propositions in F into CNF 2. Negate P and convert into CNF 3. Repeat until a contradiction is found a) Select two clauses b) Resolve these two clauses c) If resolvent is empty, a contradiction have been found Propositional resolution is sound Propositional resolution is complete The algorithm will always terminate, and will find a contraduction if there is one Sooner or later, no more new clauses can be added 5
Examples Prolog Probabilities 1.Given X (Y ( X Z) and Y, prove X 2. Given A (B C) and C A, prove A B A 1... A i C A i+1... A N B 1... B j C B j+1... B M A 1... A N B 1... B M 6
Limitations of propositional logic Prolog Probabilities Can only express statements about specific propositional variables Finite number of propositional variables How do we express a statements like: All birds can fly, Tom is a bird, therefore Tom can fly? 7
Predicate logic Prolog Probabilities More expressive logic Predicates Functions Quantifiers No complete inference mechanism Terms Constants and variables are terms f(t 1,..., t N ) is a term iff f is a function and t 1.., t N are terms Atomic sentence p(t 1,..., t N ) is an atomic sentence iff p is a predicate and t 1.., t N are terms 8
Predicate logic well formed formulas Prolog Probabilities 9
Quantifiers Prolog Probabilities Ground term / formula Scope of quantifiers Closed term / formula Quantification rules x : A is equivalent to x : A x : A is equivalent to x : A 10
Example: english to predicate logic Prolog Probabilities All purple mushrooms are poisonous. No purple mushrooms are poisonous. All mushrooms are purple or poisonous. All mushrooms are either purple or poisonous, but not both. There are exactly two purple mushrooms. All purple mushrooms except one are poisonous. 11
Semantics Prolog Probabilities 12
Semantics Prolog Probabilities 13
Predicate logic inference mechanism Prolog Probabilities Recall resolution To prove that P holds with respect to axioms F 1. Convert all propositions in F into CNF 2. Negate P and convert into CNF 3. Repeat until a contradiction is found a) Select two clauses b) Resolve these two clauses c) If resolvent is empty, a contradiction have been found Only new step is how to convert predicate logic formulas into CNF 14
Predicate logic CNF Prolog Probabilities 15
Predicate logic resolution Prolog Probabilities Recall resolution rule how can we match the two expressions for C? Does father(bill, bob) match father(x,y) Depends on how we substitute values for variables A 1... A i C A i+1... A N B 1... B j C B j+1... B M A 1... A N B 1... B M 16
Unification Prolog Probabilities Find most general substitution so that two formulas become syntactically equivalent The substitution algorithm for L1, L2 1. Set SUBST to nil 2. If L1 or L2 is a variable or a constant, then: 2.1 If L1 and L2 are identical, then return success. 2.2 If L1 is a variable then: 2.2.1 If L1 occurs in L2 return fail, 2.2.2 Otherwise set SUBST to {L2/L1} and return success. 2.3 Equivalent case if L2 is a variable. 2.4 Otheriwise FAIL. 3. If the initial predicate symbol of L1, L2 are not identical then FAIL. 4. If L1, L2 have different number of arguments then FAIL. 5. For i=1 to the artity of L1, do: 5.1 Unify i:th argument of L1 with i:th argument of L2 5.2 If unification fails then FAIL. 5.3 Apply subst. to rest of L1, L2 and concatenate with SUBST. 6. Success 17
Predicate logic example Prolog Probabilities 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? 18
Computational properties Prolog Probabilities Resolution is sound, but not complete Resolution is refutation complete When do we stop the resolution algorithm? We cannot generate all logical consequences there might be infinitly many Example: P(x) P(f(x)), P(a) Predicate calculus is undecidable No effective method deciding if a given formula is a theorem (holds in every interpretation) Some subsets of predicate logic is decidable eg. Horn clauses 19
Prolog Prolog Probabilities Programming language based on pred. logics Statements given in implication normal form ancestor(x,y) : father(x,y). ancestor(x,y) : father(x,z), ancestor(z,y). father(kalle, erik). father(erik, lars). Version of resolution for solving questions ancestor(a, lars)? ancestor(kalle, B)? gives A=erik or A=kalle gives B=erik or B=lars 20
Other logics Prolog Probabilities Precicate logic allows us to express predicates, functions and rules involving quantifiers Defines a static world How can we express changes over time? How can we reason about space? Temporal logic(s) Defines syntax and semantics for reasoning over discrete timesteps. Spatial logic(s)... Reason about space and topologies 21