Knowledge Engineering: Quang Nhat NGUYEN
Knowledge Engineering: 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
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
Knowledge Engineering
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, Resolution, And-introduction And-elimination ponens Resolution And-introduction, And-elimination, Or-introduction, Negation elimination
Additional inference rules are needed for sentences with quantifiers ( ) tifi (, We need to handle variables
Must involve variable substitutions
Knowledge Engineering
5
Variable substitutions
Variables in FOL sentences can be substituted with ground terms Ground terms = {constants, variables, functions} A variable substitution is a mapping from variables to ground terms {x1 /t1, x2/t2,} Application of the substitution to FOL sentences
SUBST({x/Tuan, y/Hai}, Likes(x, y)) = Likes(Tuan,Hai) SUBST ({x/z, y/fatherOf(Vu)}, Likes(x, y)) = Likes (z, fatherOf(Vu))
Knowledge Engineering
Example
x: Likes(x, IceCream) Likes(Tuan, IceCream) By the substitution of the variable x with the constant Tuan Denoted as: SUBST({x/a}, x: (x)) = (a)
Universal Instantiation can be applied many times to produce many different consequences
Knowledge Engineering
7
Example
x: Kill(x Victim) Kill(Murderer Victim) Kill(x, Kill(Murderer, By the substitution of the variable x with the constant Murderer Denoted as: SUBST({x/a} x: (x)) = (a) SUBST({x/a},
Unification (1)
Problem in inference: Universal instantiation gives many opportunities for substituting variables with ground terms
x: (x) (a) ; a is a ground term
Unification (2)
A unification takes two similar sentences and computes the substitution that makes them look the same if it same, exists
UNIFY(p,q) = such that SUBST(,p) = SUBST(,q)
Examples
UNIFY(Knows(John, x), Knows(John, Jane)) = {x/Jane} UNIFY(Knows(John, x), Knows(y, Bill)) = {x/Bill, y/John} UNIFY(Knows(John, x), Knows(y, MotherOf(y))) = {x/MotherOf(John), /J h } { /M th Of(J h ) y/John} UNIFY(Knows(John, x), Knows(x, Elizabeth )) = fail Because no
substitution can make the two sentence are the same (i.e., x cannot take on the values John and Elizabeth at the same time)
Knowledge Engineering
10
In the above example, the f first unifier is more general f than the second For every unifiable pair of expressions, there is a single expressions most general unifier (MGU) that is unique up to renaming of variables
In the above example: MGU = {y/John, x/z}
Knowledge Engineering
11
Knowledge Engineering
12
Knowledge Engineering
13
Resolution-based proving
Proof by refutation: To prove KB , we need to prove that { , {KB, } is unsatisfiable } Main steps of the resolution-based proving procedure
1. Convert {KB, } to CNF with ground terms and universal
variables only i bl l 2. Apply repeatedly the resolution rule while keeping track and consistency of substitutions 3. 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, clause (equivalent to false) is derived
p, p {}
Knowledge Engineering
16
17
( x: p(x))
( x: q(x)) ( x: p(x))
Knowledge Engineering
( y: q(y))
18
If no universal quantifier () occurs before an existential quantifier (x), drop the existential quantifier and replace all occurrences of the existential quantifier variable x by a new constant (called a Skolem constant) E.g., ( x: p(A) q(x)) (p(A) q(B)) If universal quantifiers y1,, yn precede an existential q y, , y p quantifier (x), drop the existential quantifier and replace all occurrences of the existential quantifier variable x by the term f(y1, , yn) where f is a new function symbol (called a Skolem function) E.g., ( x, y: p(x) q(y)) ( x: p(x) q(f(x)) where f(x) is a Skolem function
Knowledge Engineering
19
Knowledge Engineering
20
Knowledge Engineering
21
p(x, f1( )) ( ( f2( )) r(x, f2( ))) ( (x)) (q(x, (x)) ( (x)))
6. Distribute over
Knowledge Engineering
23
Knowledge Engineering
24
25
Example: Proof
Knowledge Engineering
27
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
Knowledge Engineering
29
Forward reasoning
Problem: Given a set of premises (i.e., rules and facts) stored in the knowledge base 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, add its conclusion clause to KB ,
Knowledge Engineering
30
Knowledge Engineering
31
Knowledge Engineering
32
Knowledge Engineering
33
Knowledge Engineering
34
Knowledge Engineering
35
Knowledge Engineering
36
Knowledge Engineering
37
Backward reasoning
Idea: the backward reasoning process starts from the conclusion Q To prove Q by using the set of premises (i.e., rules and facts) in KB
Check if Q has been proved (in KB) If not yet, 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, dont add it again!
Knowledge Engineering
39
Knowledge Engineering
40
Knowledge Engineering
41
Knowledge Engineering
42
Knowledge Engineering
43
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.g., How do I get into a PhD program?
Knowledge Engineering
44