This action might not be possible to undo. Are you sure you want to continue?

Quang Nhat NGUYEN

(Academic year 2010-2011) Hanoi University of Science and Technology School of Information and Communication Technology

Content

Introduction First-order logic Knowledge representation Semantic Web Logic L i programming i

Resolution Forward reasoning g Backward reasoning

**Uncertain reasoning Expert systems Knowledge discovery by Machine learning Knowledge discovery by Data mining
**

Knowledge Engineering

2

**Logical inference in First-order logic (1)
**

Logical inference problem

Given a knowledge base KB (a set of sentences) and a sentence α, does the KB semantically entail α?

KB╞ α ?

In all interpretations in which sentences in the KB are true, α is also true?

Question: Is there a procedure that can decide the entailment for all possible input sentences in a finite number of steps For the propositional logic: Yes However, the logical inference problem in the first-order logic is undecidable

Knowledge Engineering

3

**Logical inference in First-order logic (2)
**

Is the Truth-table approach a viable approach for the first order first-order logic? No! Why not? It would require us to enumerate and list all possible interpretations I I = (assignments of symbols to objects, predicates to relations and functions to relational mappings) There are t many possible i t Th too ibl interpretations! t ti !

Knowledge Engineering

4

Negation elimination Additional inference rules are needed for sentences with quantifiers (∀ ∃) tifi (∀.Logical inference in First-order logic (3) Is the Inference-rule approach a viable approach for the first order logic? first-order-logic? Yes The inference rules represent sound inference patterns that one can apply to sentences in the KB Reuse inference rules from the propositional logic Modus ponens. We need to handle variables Must involve variable substitutions Knowledge Engineering 5 . Or-introduction. And-elimination. And-introduction And-elimination ponens Resolution And-introduction. Resolution.

…} Application of the substitution to FOL sentences SUBST({x/Tuan.Hai) SUBST ({x/z. fatherOf(Vu)) Knowledge Engineering 6 . y/Hai}. y)) = Likes (z. Likes(x.Variable substitutions Variables in FOL sentences can be substituted with ground terms Ground terms = {constants. y)) = Likes(Tuan. variables. y/fatherOf(Vu)}. Likes(x. functions} A variable substitution is a mapping from variables to ground terms {x1 /t1. x2/t2.

∀x: φ(x)) = φ(a) Universal Instantiation can be applied many times to produce many different consequences Knowledge Engineering 7 .Inference rules for quantifiers (1) Universal instantiation (elimination) To b tit t T substitute a variable with a ground term i bl ith dt ∀x: φ(x) φ( ) φ(a) . a is a ground term Example x: Likes(x. IceCream) → Likes(Tuan. IceCream) By the substitution of the variable x with the constant Tuan Denoted as: SUBST({x/a}.

Existential Instantiation can be applied once Then the existentially quantified sentence can be discarded Knowledge Engineering 8 . By the substitution of the variable x with the constant Murderer Denoted as: SUBST({x/a} ∃x: φ(x)) = φ(a) SUBST({x/a}. Kill(Murderer. a does not appear in KB Example ∃x: Kill(x Victim) → Kill(Murderer Victim) Kill(x.Inference rules for quantifiers (2) Existential instantiation (elimination) To substitute a variable with a ground term that does not appear elsewhere in the KB ∃x: φ(x) φ(a) .

Unification (1) Problem in inference: Universal instantiation gives many opportunities for substituting variables with ground terms ∀x: φ(x) φ(a) .y/John}. a is a ground term Solution: Try substitutions of “similar” sentences in KB Example Let’s assume we have KB containing the 3 following sentences x: King(x) Greedy(x) → Evil(x) King(John) y: Greedy(y) If we use a substitution σ = {x/John. then we can infer Evil(John) Knowledge Engineering 9 .

MotherOf(y))) = {x/MotherOf(John). Jane)) = {x/Jane} UNIFY(Knows(John. Bill)) = {x/Bill. Knows(y. x).p) = SUBST(σ.. /J h } { /M th Of(J h ) y/John} UNIFY(Knows(John. x cannot take on the values John and Elizabeth at the same time) Knowledge Engineering 10 . exists UNIFY(p. x). Knows(John.Unification (2) A unification takes two similar sentences and computes the substitution that makes them look the same if it same. x).q) Examples UNIFY(Knows(John. Knows(y. Elizabeth )) = fail – Because no substitution can make the two sentence are the same (i.e. x). Knows(x.q) = σ such that SUBST(σ. y/John} UNIFY(Knows(John.

to unify Knows(John.z) p y ( ) (y ) σ1 = {y/John. there is a single expressions most general unifier (MGU) that is unique up to renaming of variables In the above example: MGU = {y/John.Most general unifier UNIFY should return a substitution that makes the two arguments look the same – But there could be more But. x/John. the f first unifier is more general f than the second For every unifiable pair of expressions. x/z} Knowledge Engineering 11 . than one such unifier For example.x) and Knows(y. z/John} In the above example. x/z } σ2 = {y/John.

β → γ ¬α → γ Knowledge Engineering 12 .Resolution inference rule (1) Basic propositional version α ∨ β ¬β ∨ γ β. β α∨γ Equivalent to ¬α → β.

Resolution inference rule (2) FOL version: p1 ∨ … ∨ pj ∨ … ∨ pm. (p1 ∨ … ∨ pj-1 ∨ pj+1 ∨ … ∨ pm ∨ q1 ∨… ∨ qk-1 ∨ qk+1 ∨ … ∨ qn)) where qk = ¬q’k and UNIFY(pj. q’k) = σ q q σ is the most general unifier (MGU) of pj and qk The literals pj and qk are called complementary literals Because each one unifies with the negation of the other The resulting disjunction is called a resolvent Knowledge Engineering 13 . q1 ∨ ∨ qk ∨ … ∨ qn ∨… SUBST (σ.

Resolution inference rule – Examples (1) Example 1 ¬Rich(x) ∨ Unhappy(x) Rich(Me) Unhappy(x). Unhappy(Me) by the most general unifier σ = {x/Me} Example 2 Let’s assume that KB contains the following sentences PhD(x) → HighlyQualified(x) ¬PhD(x) → EarlyEarnings(x) HighlyQualified(x) → Rich(x) EarlyEarnings(x) → Rich(x) Try resolution to infer Rich(Me) y ( ) Knowledge Engineering 14 .

Resolution inference rule – Examples (2) Convert KB to the equivalent sentences ¬PhD(x) ∨ HighlyQualified(x) ( ) g yQ ( ) PhD(x) ∨ EarlyEarnings(x) ¬HighlyQualified(x) ∨ Rich(x) ¬EarlyEarnings(x) ∨ Rich(x) EarlyEarnings(x) From ¬PhD(x) ∨ HighlyQualified(x) and PhD(x) ∨ EarlyEarnings(x) and using the MGU σ = {x/Me}. we infer Rich(Me) {x/Me} Knowledge Engineering 15 . Rich(Me) ∨ EarlyEarnings(Me) From Rich(Me) ∨ EarlyEarnings(Me) and ¬EarlyEarnings(x) ∨ Rich(x) and using the MGU σ = {x/Me}. we infer HighlyQualified(Me) ∨ EarlyEarnings(Me) From ¬HighlyQualified(x) ∨ Rich(x) and HighlyQualified(Me) ∨ EarlyEarnings(Me) and using the MGU σ = {x/Me}. we infer y g ( ) g { }.

¬ α} to CNF with ground terms and universal variables only i bl l 2. ¬p {} Knowledge Engineering 16 .Resolution-based proving Proof by refutation: To prove KB╞ α. we need to prove that { . Stop when either an empty set (contradiction) is derived or no more new resolvents (conclusions) follow At a resolution step a contradiction occurs if an empty step. Convert {KB. Apply repeatedly the resolution rule while keeping track and consistency of substitutions 3. ¬ α} is unsatisfiable } Main steps of the resolution-based proving procedure 1. clause (equivalent to false) is derived p. {KB.

the given formulas have to be in conjunctive normal form (CNF) A literal is an atomic formula or the negation of an atomic formula An atomic formula is also called a positive literal The negation of an atomic formula is called a negative literal A clause is a disjunction of literals f A special clause called the empty clause – equivalent to false A FOL formula is in conjunctive normal form (CNF) if it is a conjunction of disjunctions of literals Equivalently.Conjunctive normal form To be able to do resolution. if it is a set of clauses Knowledge Engineering 17 .

Conversion to CNF (1) 1. Rename variables so that each quantifier has a unique variable ( x: p(x)) ( x: q(x)) ≡ ( x: p(x)) Knowledge Engineering ( y: q(y)) 18 . Eliminate implications and equivalences using the laws (p → q) ≡ (¬p ∨ q) (p ↔ q) ≡ ((p → q) ∧ (q → p)) ≡ ((¬p ∨ q) ∧ (¬q ∨ p)) 2. 2 Move negations inwards using the laws ¬(p q) ≡ (¬p ¬q) ¬(p q) ≡ (¬p ¬q) ¬( x: p(x)) ≡ ( x: ¬p(x)) ¬( x: p(x)) ≡ ( x: ¬p(x)) ¬¬p ≡ p p 3.

( x.….g. …. ( x: p(A) q(x)) ≡ (p(A) q(B)) If universal quantifiers ∀y1.g.Conversion to CNF (2) 4. ∀yn precede an existential q y. drop the existential quantifier and replace all occurrences of the existential quantifier variable x by the term f(y1.. Eliminate existential quantifiers (∃) If no universal quantifier (∀) occurs before an existential quantifier (∃x).. y p quantifier (∃x). y: p(x) q(y)) ≡ ( x: p(x) q(f(x)) – where f(x) is a Skolem function Knowledge Engineering 19 . . yn) where f is a new function symbol (called a Skolem function) E. drop the existential quantifier and replace all occurrences of the existential quantifier variable x by a new constant (called a Skolem constant) E.

E g ( x: p(x) q(f(x))) ≡ (p(x) q(f(x))) 6. E.. Then write each disjunction on a separate line Knowledge Engineering 20 . constants. Drop all universal quantifiers (∀) E. Convert to CNF by using the distributive law of ∧ over ∨ The result is a CNF with variables constants functions variables. (p (q r)) ≡ (p q) (p r) 7.g. Flatten nested conjunctions or disjunctions..g.Conversion to CNF (3) 5.

z) ∧ ¬r(x. y) ∧ ¬r(x.Conversion to CNF – Example (1) Problem: Convert to CNF the following sentence: ∀x: (∀y: p(x y) → ¬(∀y: q(x y) → r(x y))) p(x. Move ¬ inwards ∀x: ((∃y: ¬p(x. r(x. y)))) )) (∀ (¬q(x. y)) ∨ (∃z: (q(x. y)) ∨ (∃y: (q(x. Rename variables ∀x: ((∃y: ¬p(x. ) ( )))) 2. Eliminate implications ∀x: (¬(∀y: ( ∀ ( (∀ p(x. y)))) 3. (∀y: q(x. z)))) Knowledge Engineering 21 . y)) ∨ ¬(∀y: ( ( y) ∨ r(x. 1.

f2(x)) ¬p(x.Conversion to CNF – Example (2) 4. eliminate existential quantifiers) ∀x: (¬p(x. f1( )) ∨ ( ( f2( )) ∧ ¬r(x. Write each disjunction on a separate line ¬p(x. f1(x)) ∨ q(x. f1(x)) ∨ q(x. f1(x)) ∨ ¬r(x. f2( ))) ( (x)) (q(x. f1(x)) ∨ (q(x f2(x)) ∧ ¬r(x. Drop universal quantifiers ¬p(x. f2(x)) Knowledge Engineering 22 . Distribute ∧ over ∨ (¬p(x.e. Skolemize (i. f1(x)) ∨ ¬r(x. f2(x))) ∧ (¬p(x. f2(x))) 7. r(x 5. f2(x)))) ( p(x (q(x. (x)) ( (x))) 6..

Resolution-based proving – Example The crime example is described as follows: The 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 y y missiles All of the country Nono’s missiles were sold to it by Colonel West who is an American Use resolution to prove that West is a criminal! Knowledge Engineering 23 .

Nono) Knowledge Engineering 24 . x) ∧ Missile(x) → Sells(West. x) ∧ Missile(x) “All of the country Nono’s missiles were sold to it by Colonel West” ∀x: Owns(Nono..y..Example: Formalization in FOL (1) “.. z) ∧ Hostile(z) → Criminal(x) “Nono . has some missiles” ∃x: Owns(Nono. it is a crime for an American to sell weapons to hostile nations” nations ∀x.z: American(x) ∧ Weapon(y) ∧ Sells(x. y.. x.

America) To be proved that “West is a criminal” Criminal(West) Knowledge Engineering 25 . an enemy of America . who is an American” American(West) “Nono.” Enemy(Nono.. America) → Hostile(x) y( ) ( ) “West.Example: Formalization in FOL (2) Missiles are weapons ∀x: Missile(x) → Weapon(x) An enemy of America is a “hostile nation” ∀x: Enemy(x..

z) ∨ ¬Hostile(z) ∨ Criminal(x) Owns(Nono. y.Example: Convert to CNF form ¬American(x) ∨ ¬Weapon(y) ∨ ¬Sells(x. America) ∨ Hostile(x) American(West) ( ) Enemy(Nono. M1) Missile(M1) ¬Missile(x) ∨ ¬Owns(Nono. x) ∨ Sells(West. x. Nono) ¬Missile(x) ∨ Weapon(x) ¬Enemy(x. America) ¬Criminal(West) ( ) Knowledge Engineering 26 .

Example: Proof Knowledge Engineering 27 .

(p ∨ ¬q) ∧ (¬p ∨ ¬r ∨ s) The k Th knowledge base (KB) can b represented i th H l d b be t d in the Horn norm form Rules (¬p ( p1 ∨ ¬p2 ∨ … ∨ ¬pn ∨ q) p p Equivalent to the rule: (p1 ∧ p2 ∧ … ∧ pn → q) Facts p1. q Integrity constraints (¬p1 ∨ ¬p2 ∨ … ∨ ¬pn) Equivalent to the rule: (p1 ∧ p2 ∧ … ∧ pn → false) ( ) Knowledge Engineering 28 .Horn normal form A formula is in the Horn norm form if: The formula is a conjunction (∧) of clauses Each clause is a disjunction (∨) of literals.g. in which at most 1 (possibly no!) positive literal E..

p1. p2. …. pn q The application of the Generalized Modus Ponens inference rule requires th t all th sentences i KB must i f l i that ll the t in t be in the Horn norm form The Generalized Modus Ponens inference rule can be applied in both reasoning strategies Forward reasoning o a d easo g Backward reasoning Knowledge Engineering 29 .Generalized Modus Ponens inference rule (p1 ∧ p2 ∧ … ∧ pn → q).

. rules and facts) stored in the knowledge base KB. Knowledge Engineering 30 .Forward reasoning Problem: Given a set of premises (i. add its conclusion clause to KB . prove the conclusion Q Idea: Iterate the two following steps until the conclusion is derived Apply rules whose condition clause match KB For each matched rule.e.

Forward reasoning – Example (1) Knowledge Engineering 31 .

Forward reasoning – Example (2) Knowledge Engineering 32 .

Forward reasoning – Example (3) Knowledge Engineering 33 .

Forward reasoning – Example (4) Knowledge Engineering 34 .

Forward reasoning – Example (5) Knowledge Engineering 35 .

Forward reasoning – Example (6) Knowledge Engineering 36 .

Forward reasoning – Example (7) Knowledge Engineering 37 .

don’t add it again! Avoid to repeat the proof of a proved clause The clause has already been proved true The clause has already been proved unsatisfiable (false) in KB Knowledge Engineering 38 ..e.Backward reasoning Idea: the backward reasoning process starts from the conclusion Q To prove Q by using the set of premises (i. prove all the conditions of a rule (in KB) whose conclusion clause is Q Avoid loops Check if the new derived clause has already been in the list of tobe-proved ones? – If already. rules and facts) in KB Check if Q has been proved (in KB) If not yet.

Backward reasoning – Example (1) Knowledge Engineering 39 .

Backward reasoning – Example (2) Knowledge Engineering 40 .

Backward reasoning – Example (3) Knowledge Engineering 41 .

Backward reasoning – Example (4) Knowledge Engineering 42 .

Backward reasoning – Example (5) Knowledge Engineering 43 .

Backward reasoning Forward reasoning is a data-driven inference process E.g.Forward vs..g. Forward reasoning may do some redundant work – inferences that are irrelevant to the goal Backward reasoning is a goal-driven inference process. appropriate for problem-solving problem solving E. E g Object recognition routine decision recognition. How do I get into a PhD program? Knowledge Engineering 44 ..

- A_Logic_Programming_Framework
- Fundamentals of Multi Agent Systems[1]
- Mobile Robot Control on Architecture Occam Pi
- Multi Agent Systems and Physical Distribution Systems
- Multi-Agent Systems in Crisis
- Genetic Algorithims and Rule Based AI
- Algorithims
- Multi Agent Systems
- Logic Programming through Prolog
- rr321902-artificial-intelligence
- mas
- How to Write a Virus Program_begginers
- Inference in First Order Logic
- Robotics (20)
- DeductionI6topage-Logic
- mathpt
- DeductionI-Logic
- Formal Systems
- Inference 1
- Lecture 09
- Project Statistic - Hyphothesis Testing
- PAM Talk AISB-11
- Vic171 Inferences to the Best Explanation
- Prolog Games
- Probabilistic Programming Introduction
- Visualizing Inference in Large Bayesian Networks (UCSD M.Sc. Project)
- Levinson
- Pragmatic Inference, Conversational Implicature
- A Classification Method Based on In Distinguish Abilities
- [Ad Foolen, Frederike Van Der Leek] Constructions (BookZZ.org)
- l6 Logic Programming

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd