nmr98 - logic programming1 learning with extended logic programs evelina lamma (1), fabrizio riguzzi...
TRANSCRIPT
NMR98 - Logic Programming 1
Learning withExtended Logic Programs
Evelina Lamma(1), Fabrizio Riguzzi (1),
Luís Moniz Pereira (2)
(1)DEIS, University of Bologna, Italy
(2)CENTRIA, Departamento de Informática
Universidade Nova de Lisboa, Portugal
NMR98 - Logic Programming 2
Summary
• Concept learning in a 3-valued setting
• Consider positive and negative examples as instances of two disjoint classes
• Learn a definition for both the target concept and its opposite
• Extended Logic Programs under WSFX
• Default negation to handle exceptions, and inconsistencies
NMR98 - Logic Programming 3
2-valued vs 3-valued setting
• Explicit definition of the negated concept (De Raedt, Bruynooghe 1990)
• Requires the adoption of a more expressible class of programs
+++
+ +++ +
- - ---- --
+++
+ +++ +
- - ---- --
+++
+ +++ +
- - ---- --
a cb
NMR98 - Logic Programming 4
Learning ELP
• Useful in partially known domains
• Extend Inductive Logic Programming framework to the case of ELP
• Learn a definition for concept p using E+, E-
as training set
• Learn a definition for concept p using E-, E+ as training set
NMR98 - Logic Programming 5
The new ILP problem
Given– a set P of possible ELP programs (bias)– a set E+ of positive examples– a set E- of negative examples– a consistent extended logic program (the
background knowledge)
Find an ELP, PP such thatPE+, E- (completeness)
P E-, E+ (consistency)
NMR98 - Logic Programming 6
Intersection of definitions
E+ E-
p-p+
Exceptions to thepositive definition:negative atoms
Exceptions to thenegative definition:positive atoms
Unseen atoms
NMR98 - Logic Programming 7
Unseen atoms
• Unseen atoms are classified as unknown
p(X)p+(X), not p(X).
p(X)p-(X), not p(X).
• unless the concept is true and its opposite undefined:
p(X)p+(X), undefined(p(X)).
p(X)p-(X), undefined(p(X)).
NMR98 - Logic Programming 8
Training set atoms
• They must be classified according to the training set
• Default literals, representing non-abnormality conditions, added to rules
p(X) p+(X), not abp (X), not p(X).
p(X) p-(X), not abp (X), not p(X).
NMR98 - Logic Programming 9
ExampleB: bird(a). has_wings(a).
jet(b). has_wings(b).
angel(c). has_wings(c).has_limbs(c).
penguin(d). has_wings(d).
has_limbs(d).
dog(e). has_limbs(e).
cat(f). has_limbs(f).
E+={flies(a)} E-={flies(d), flies(e)}
NMR98 - Logic Programming 10
flies+ E+
a b c fd e
flies-E-
NMR98 - Logic Programming 11
flies+(X)has_wings(X).
flies-(X)has_limbs(X).
flies(X)flies+(X),not abflies+(X),not flies(X).
flies(X)flies-(X), not flies(X).
abflies+(d).
flies(X) flies+(X), undefined(flies(X)).
flies(X) flies-(X), undefined(flies(X)).
• Generalizing exceptions, we obtain:abflies+(X)penguin(X).
NMR98 - Logic Programming 12
The Learning Algorithm• Input: E+, E-, B
• Output: H, learned theory– LearnHierarchy(E+, E-, B; Hp )
LearnHierarchy(E-, E+, B; Hp )
– Obtain H by transforming Hp and Hp into non-deterministic rules and adding clauses for undefined case
• Coverage of examples through SLX interpreter (Alferes, Damásio, Pereira, 1994)
NMR98 - Logic Programming 13
LearnHierarchy
• Input: E+, E-, B
• Output: H, learned theory– Learn (E+, E-, B; Hp )
– H= Hp
– For each r Hp :• if some negative example p(t) is covered, specialize
r through a default literal not abr(t)
• Learn a definition for abr (LearnHierarchy) and add it to H
NMR98 - Logic Programming 14
ExampleB: penguin(1). penguin(2).
bird(3). bird(4). bird(5).
bird(X)penguin(X).
animal(6). animal(7). animal(8).
animal(9). animal(10). animal(11).
animal(12).
animal(X)bird(X).
E+= {flies(3),flies(4),flies(5)}
E-= {flies(1), flies(2), flies(6), flies(7), flies(8), flies(9),flies(10),flies(11),flies(12)}
NMR98 - Logic Programming 15
• Procedure Learn generates:
(1) flies(X)bird(X). covers E-1={flies(1),flies(2)}
(2) flies(X)bird(X), not ab2(X).
• Learning a definition for exceptions:
E+= {ab2 (1),ab2 (2)}
E-= {ab2(3), ab2(4), ab2(5)}
(3) ab2(X) penguin(X). (consistent)
NMR98 - Logic Programming 16
• Learning the negative concept:
(4) flies(X)animal(X). covers E-4={flies(3),flies(4),flies(5)}
(5) flies(X)animal(X),not ab5(X).
• Learning a definition for exceptions:
E+= {ab5(3),ab5(4),ab5(5)}
E-= {ab5(1),ab5(2),ab5(6),ab5(7),ab5(8),ab5(9),ab5(10),
ab5(11),ab5(12)}
(6) ab5(X)bird(X). covers E-7={ab5(1),ab5(2)}
NMR98 - Logic Programming 17
(7) ab5(X)bird(X), not ab7(X).
• Learning a definition for exceptions:
E+= {ab7(1),ab7(2)}
E-= {ab7(3),ab7(4),ab7(5)}
(8) ab7(X) penguin(X).
• The algorithm terminates by making the clauses for flies and flies non-deterministic and by adding the clauses for the undefined case
NMR98 - Logic Programming 18
Related work
• LELP (Inoue, Kudoh, 1997) relies on answer-set semantics– bottom-up approach, only– redundant clauses, in some cases
• We can choose whether to learn Least General Solution or Most General Solution for a concept
NMR98 - Logic Programming 19
Least General vs Most General Solutions
• Bottom-up methods search the space of clauses specific to general– RLGG, Inverse Resolution, Inverse Entailment– GOLEM
• Top-down methods search the space of clauses general to specific– FOIL, Progol
NMR98 - Logic Programming 20
LGS, MGS: Example
B: bird(a). animal(a).cat(b). animal(b).
E+= {flies(a)} E-= {flies(b)}
flies+MGS(X) bird(X).
flies+LGS(X) bird(X),animal(X).
flies-MGS(X) cat(X).
flies-LGS(X) cat(X),animal(X).
NMR98 - Logic Programming 21
Example: Mixing LGS, MGS
• Concept about who is likely to attack one person, (maximize the concept and minimize its opposite)
attacker1(X)attacker+MGS(X), not attacker1(X).
attacker1(X)attacker-LGS(X), not attacker1(X).
• Concept about beggars (one wants to give money strictly to those appearing to need it - minimize the concept and maximize its opposite)
beggar1(X)beggar+LGS(X), not beggar1(X).
beggar1(X)beggar-MGS(X), not beggar1(X).
NMR98 - Logic Programming 22
• However, rejected beggars, may turn into attackers (maximize the concept and minimize its opposite)
beggar2(X)beggar+MGS(X), not beggar2(X).
beggar2(X)beggar-LGS(X), not beggar2(X).
• Concepts can be used in order to minimize the risk when carrying a lot of money
runlot_of_money, attacker1(X), not beggar2(X).
rungive_money.
give_money beggar1(X).
give_money attacker1(X), not beggar2(X).
NMR98 - Logic Programming 23
n disjoint classes
p1(X)p1+(X),not abp1+(X),not p2(X),…, not pn(X).
p2(X)p2+(X),not abp2+(X),not p1(X),…, not pn(X). …
pn(X)pn+(X),not abpn+(X),not p1(X),…,not pn-1(X).
p1(X)p1+(X), undef(p2(X)),…, undef(pn(X)).
…
pn(X)pn+(X), undef(p1(X)),…, undef(pn-1(X)).
NMR98 - Logic Programming 24
Future Work
• System able to learn ELP, with various approaches in learning
• Implementation under development • Integration with abductive reasoning in order to
guess new examples and cope with exceptions (Lamma, Mello,Milano, Riguzzi, 1997)
• Extension to the case of multi-predicate learning• Revision of theories in form of ELP