artificial intelligence – lecture 9
TRANSCRIPT
Artificial Intelligence – Lecture 9
2
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Lecture plan
• 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
3
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Conjunctive Normal Form (CNF)
4
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Resolution
• Requires all expression in CNF
• Only one rule required for all reasoning
A1 ∨ ... ∨A
i ∨ C ∨ A
i+1 ∨ ... ∨ A
N
B1 ∨ ... ∨ B
j ∨ ¬C ∨ B
j+1 ∨ ... ∨ B
M
⇒
A1 ∨ .... ∨ A
N ∨ B
1 ∨ ... ∨ B
M
Example: X ∨ ¬Y Y ∨ Z⇒X ∨ Z
5
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Resolution in propositional logic
• 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
6
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Examples
• 1.Given X (Y (¬X ⇒ ⇒ ∧ Z) and Y, prove ¬X
• 2. Given A (B⇒ ∨C) and C ¬A, prove ¬A⇒ ∨B
A1 ∨ ... ∨ A
i ∨ C ∨ A
i+1 ∨ ... ∨ A
N
B1 ∨ ... ∨ B
j ∨ ¬C ∨ B
j+1 ∨ ... ∨ B
M
⇒
A1 ∨ .... ∨ A
N ∨ B
1 ∨ ... ∨ B
M
7
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Limitations of propositional logic
• 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?”
8
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Predicate logic
• More expressive logic
• Predicates
• Functions
• Quantifiers
• No complete inference mechanism
• Terms
• Constants and variables are terms
• f(t1, ..., t
N) is a term iff f is a function and t
1 .., t
N are terms
• Atomic sentence
• p(t1, ..., t
N) is an atomic sentence iff p is a predicate and t
1 .., t
N are
terms
9
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Predicate logic – well formed formulas
10
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Quantifiers
• 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
11
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Example: english to predicate logic
• 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.
12
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Semantics
13
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Semantics
14
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Predicate logic – inference mechanism
• 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
15
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Predicate logic – CNF
16
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Predicate logic – resolution
• 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
A1 ∨ ... ∨ A
i ∨ C ∨ A
i+1 ∨ ... ∨ A
N
B1 ∨ ... ∨ B
j ∨ ¬C ∨ B
j+1 ∨ ... ∨ B
M
⇒A
1 ∨ .... ∨ A
N ∨ B
1 ∨ ... ∨ B
M
17
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Unification
• Find most general substitution so that two formulas become syntactically equivalent
The substitution algorithm for L1, L2
1. Set SUBST to nil2. 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
18
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Predicate logic example
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?
19
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Computational properties
• 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. Hornclauses
20
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Prolog
• Programming language based on pred. logics
• Statements given in implication normal form
• Version of resolution for solving questions
ancestor(X,Y) : father(X,Y).ancestor(X,Y) : father(X,Z), ancestor(Z,Y).father(kalle, erik).father(erik, lars).
ancestor(A, lars)? gives A=erik or A=kalleancestor(kalle, B)? gives B=erik or B=lars
21
● Prolog
● Other Logics
● Expert Systems
● Probabilities
Other logics
• 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
• ...