Title: INDUCTIVE LOGIC PROGRAMMING
1INDUCTIVE LOGIC PROGRAMMING
- Jiangbo Dang
- Vincent Ellerby
- Bingyu Zhu
2Machine Learning
- What can you use it for
- Pattern recognition
- faces, digits, speech
- Bioinformatics
- gene finding
- Internet
- spam filtering, search engines
- Prediction
- stock market
3Machine Learning
- Things learn when they change their behavior in a
way that makes them perform better in the future - A system capable of the autonomous acquisition
and integration of knowledge
4Machine Learning
- A computer program is said to learn from
experience E with respect to some class of tasks
T and performance measure P, if its performance
at tasks in T, as measured by P, improves with
experience E. - Learn E(T, P) if T(P) ? E
5ML contd
- Hypothesis Space
- This box represents the set of all instances X
- Each point is an instance, i.e, performance
measure - The circles are hypothesis
- The points inside a circle correspond to the
instances that hypothesis classifies as positive.
6Inductive Logic Programming
- Approach to machine learning where definitions of
relations are induced from positive and negatives
examples. - Logic used a hypothesis language
- Result is Prolog program
- Hypothesis is made and refined to find target
hypothesis
7ILP contd
- Given
- Set of positive examples E and negative examples
E- - Background knowledge BK, such that E cannot be
derived from BK alone - Find hypothesis H
- All examples in E can be derived from BK and H
- No examples in E- can be derived from BK and H
8ILP contd
- Complete hypothesis
- Covers all positive examples
- Consistent hypothesis
- Does not cover any negative examples
- H must be complete and consistent
9ILP Example
- Task Find a definition of predicate
has_daughter( X), known as target predicate -
- In terms of
- Predicates parent, male, and female
- Such that
- It is true for all given positive examples
- Not true for all given negative examples
10ILP Example contd
- Background knowledge is provided by the
programmer - Ex., parent( X, Y), male( X), female( X) defining
a family relation, given as backliteral( male(
X), X) in Prolog - Positive example
- ex( has_daughter( tom))
- Negative example
- neg( has_daughter( pam))
11Refinement
- Start with overly general hypothesis that is
complete but inconsistent - Refinement takes hypothesis H1 and produces more
specific hypothesis H2 - H2 must cover a subset of cases covered by H1
12Refinement Graph
Figure 19.2 Prolog Programming for Artificial
Intelligence by Ivan Bratko
13Two types of refinements in graph
- Matching two variables in the clause
- Example
- has_daughter( X) - parent( Y, Z)
- refined to
- has_daughter( X) - parent( X, Z)
- This is done by matching X Y
14Two types of refinements in graph
- Adding a background literal to the body of the
clause - Example
- has_daughter( X).
- refined to
- has_daughter( X) - parent( Y, Z).
15MINIHYPER PROGRAM
16MINIHYPER
- HypothesisClause1,Clause2,
- ClauseHead,BodyLiteral1,BodyLiteral2,/Var1,Va
r2, - Example
- pred(X,Y) - parent(X,Y).
- pred(X,Z) - parent(X,Y),pred(Y,Z).
- pred(X1,Y1),parent(X1,Y1)/X1,Y1,
- pred(X2,Z2),parent(X2,Y2),pred(Y2,Z2)/X2,Y2,Z
2
17BACKGROUND KNOWLEDGE
- BackGround Knowledge
- backliteral(parent(X,Y), X,Y). A background
literal with vars. X,Y - backliteral(male(X), X).
- backliteral(female(X), X).
- prolog_predicate( parent(_,_)). Goal
executed directly by Prolog - prolog_predicate( male(_)).
- prolog_predicate( female(_)).
18BACKGROUND KNOWLEDGE
- parent( pam, bob).
- parent( tom, bob).
- parent( tom, liz).
- parent( bob, ann).
- parent( bob, pat).
- parent( pat, jim).
- parent( pat, eve).
- male( tom).
- male( bob).
- male( jim).
- female( pam).
- female( liz).
- female( ann).
- female( pat).
- female( eve).
19TRAINING EXAMPLES
- Positive examples
- ex( has_daughter(tom)). Tom has a daughter
- ex( has_daughter(bob)).
- ex( has_daughter(pat)).
- Negative examples
- nex( has_daughter(pam)). Pam doen't have a
daughter - nex( has_daughter(jim)).
20- start_hyp( has_daughter(X) / X ).
Starting hypothesis
21A interpreter for Hypotheses
- prove( Goal, Hypo, Answer)
- Answer yes, if Goal derivable from Hypo in at
most D steps - Answer no, if Goal not derivable
- Answer maybe, if search terminated after D
steps inconclusively
22What Answermaybe means
- Answer maybe, if search terminated after D
steps inconclusively - A. The interpreter would get into infinite loop
if without proof length limit - B. The interpreter would find a proof with proof
length greater than D - C. The interpreter would fails with proof length
greater than D then backtrack
23A loop-avoiding interpreter
- prove( Goal, Hypo, Answer) -
- max_proof_length( D),
- prove( Goal, Hypo, D, RestD),
- (RestD gt 0, Answer yes Proved
-
- RestD lt 0, !, Answer maybe Maybe, but
it looks like inf. loop - ).
-
- prove( Goal, _, no). Otherwise Goal
definitely cannot be proved - prove( Goal, Hyp, MaxD, RestD)
- MaxD allowed proof length, RestD 'remaining
length' after proof - Count only proof steps using Hyp
- prove( G, H, D, D) -
- D lt 0, !. Proof length
overstepped - prove( , _, D, D) - !.
24A loop-avoiding interpreter(cont.)
- prove( G1 Gs, Hypo, D0, D) - !,
- prove( G1, Hypo, D0, D1),
- prove( Gs, Hypo, D1, D).
- prove( G, _, D, D) -
- prolog_predicate( G), Background
predicate in Prolog? - call( G).
Call of background predicate - prove( G, Hyp, D0, D) -
- D0 lt 0, !, D is D0-1 Proof too
long -
- D1 is D0-1, Remaining
proof length - member( Clause/Vars, Hyp), A clause
in Hyp - copy_term( Clause, Head Body ), Rename
variables in clause - G Head, Match
clause's head with goal - prove( Body, Hyp, D1, D). Prove G
using Clause
25MINIHYPER
Start Hypothesis
No
Complete?
Yes
Refine_hyp
Reach MaxD?
Consistent?
No
No
Yes
Output Hypothesis
MaxDMaxD1
26MINIHYPER
- induce( Hyp) -
- iter_deep( Hyp, 0,).
- Iterative deepening starting with max. depth 0
- iter_deep( Hyp, MaxD,Depthreshold) -
- write( 'MaxD '), write( MaxD), nl,
- start_hyp( Hyp0),
- complete( Hyp0), Hyp0 covers
all positive examples - depth_first( Hyp0, Hyp, MaxD)
- Depth-limited depth-first search
-
- NewMaxD is MaxD 1,
- (NewMaxD gt Depthreshold,!,fail
-
- iter_deep( Hyp, NewMaxD,Depthreshold)).
27MINIHYPER
- depth_first( Hyp0, Hyp, MaxD)
- refine Hyp0 into consistent and complete Hyp
in at most MaxD steps - depth_first( Hyp, Hyp, _) -
- consistent( Hyp).
- depth_first( Hyp0, Hyp, MaxD0) -
- MaxD0 gt 0,
- MaxD1 is MaxD0 - 1,
- refine_hyp( Hyp0, Hyp1),
- complete( Hyp1), Hyp1 covers all
positive examples - depth_first( Hyp1, Hyp, MaxD1).
28MINIHYPER
- complete( Hyp) - Hyp covers all
positive examples - not(ex( E), A
positive example - once( prove( E, Hyp, Answer)), Prove
it with Hyp - Answer \ yes).
Possibly not proved - consistent( Hyp) -
- Hypothesis does not possibly cover any negative
example - not(nex( E), A
negative example - once( prove( E, Hyp, Answer)), Prove
it with Hyp - Answer \ no).
Possibly provable
29MINIHYPER
- refine_hyp( Hyp0, Hyp)
- refine hypothesis Hyp0 into Hyp
- refine_hyp( Hyp0, Hyp) -
- conc( Clauses1, Clause0/Vars0 Clauses2,
Hyp0), - Choose Clause0 from Hyp0
- conc( Clauses1, Clause/Vars Clauses2, Hyp),
- New hypothesis
- refine( Clause0, Vars0, Clause, Vars).
- Refine the Clause
30MINIHYPER
- refine( Clause, Args, NewClause, NewArgs)
- refine Clause with arguments Args giving
NewClause with NewArgs - 1. Refine by unifying arguments
- refine( Clause, Args, Clause, NewArgs) -
- conc( Args1, A Args2, Args),
Select a variable A - member( A, Args2),
Match it with another one -
- conc( Args1, Args2, NewArgs).
- 2. Refine by adding a literal
- refine( Clause, Args, NewClause, NewArgs) -
- length( Clause, L),
- max_clause_length( MaxL),
- L lt MaxL,
- backliteral( Lit, Vars),
Background knowledge literal - conc( Clause, Lit, NewClause), Add
literal to body of clause
31MINIHYPER
- Default parameter settings
- max_proof_length( 6).
- Max. proof length, counting calls to
'non-prolog' pred. - max_clause_length( 3).
- Max. number of literals in a clause
32RESULTS
33Experiments with MINIHYPER
- has_daughter(A) - parent(A, B), female(B).
- predecessor(A, B) - parent(A, C), predecessor(C,
B). - predecessor(A, B) - parent(A, B).
- predecessor(A,B) with the guard literal atom(X)
in the background literals.
34First example
- Target predicate
- has_daughter(A) - parent(A, B),
female(B). - BK (Background knowledge)
- parent(X, Y).
- male(X).
- female(X).
35Positive and negative examples
- ex( has_daughter(tom)). Tom has a
daughter - ex( has_daughter(bob)).
- ex( has_daughter(pat)).
- nex( has_daughter(pam)). Pam doesn't
have - nex( has_daughter(jim)). daughter
36has_daughter(A) - parent(A, B), female(B).
- ?- induce(H).
- MaxD 0
- MaxD 1
- MaxD 2
- MaxD 3
- MaxD 4
- H has_daughter(_G258), parent(_G258, _G290),
female(_G290)/_G258, _G290
37Refinement graph
38less one negative example nex(has_daughter(pam)).
- ?- induce(H).
- MaxD 0
- MaxD 1
- MaxD 2
- Â
- H has_daughter(_G252), parent(_G252,
_G284)/_G252, _G284
39less the other negative example
nex(has_daughter(jim)).
- ?- induce(H).
- MaxD 0
- MaxD 1
- MaxD 2
- MaxD 3
- MaxD 4
- Â
- H has_daughter(_G261), parent(_G261, _G293),
female(_G293)/_G261, _G293
40Second example
- predecessor(A, B) - parent(A,
B).predecessor(A, B) - parent(A, C),
predecessor(C, B).
41Results
- ?- induce(H,8).
- MaxD 0
- MaxD 1
- MaxD 2
- MaxD 3
- MaxD 4
- MaxD 5
- MaxD 6
- MaxD 7
- MaxD 8
42Continue
- H predecessor(_G313, _G314), parent(_G313,
_G381), predecessor(_G381, _G314)/_G313,
_G381, _G314, predecessor(_G331, _G332),
parent(_G331, _G332)/_G331, _G332 - Execution time more than 3 hours
43Last example Add atom(X).
- Execution time about 20 mins
- Definition of predecessor
- Hpredecessor(A, B), atom(A), parent(A, C),
atom(C), predecessor(C, B)/A, C, B,
predecessor(D, E), atom(D), parent(D, E)/D,
E - Â
44Results
- ?- induce(H,8).
- MaxD 0
- MaxD 1
- MaxD 2
- MaxD 3
- MaxD 4
- MaxD 5
- MaxD 6
- MaxD 7
- MaxD 8
45Continue
- H predecessor(_G313, _G314), atom(_G313),
parent(_G313, _G381), atom(_G381),
predecessor(_G381, _G314)/_G313, _G381,
_G314, predecessor(_G331, _G332), atom(_G331),
parent(_G331, _G332)/_G331, _G332
46Refinement graph
47Continue
48Experiments with HYPER
- predecessor(A, B)-
- parent(A, B).
- predecessor(A, C)-
- parent(A, B),
- predecessor(B, C).
49Results
- Hypotheses generated 35404
- Hypotheses refined 5907
- To be refined 2710
50Continue
- H predecessor(_G480383, _G480384),
parent(_G480383, _G480384) - /_G480383item, _G480384item,
predecessor(_G480416, _G480417),
parent(_G480416, _G480426), predecessor(_G48042
6,_G480417) - /_G480416item, _G480426item,_G480417item
51Comparison for the second relation
52Summary
53QUESTIONS?