Marco Gavanelli – Università di Ferrara, ItalyMarco Alberti – Universidade nova de Lisboa,
PortugalEvelina Lamma – Università di Ferrara, Italy
Abductive Logic ProgrammingALP = < KB, A, IC >
KB = logic program (set of clauses)A = atoms without definitions, can be
assumedIC = Integrity constraints (usually,
implications)
KB ╞═ G KB ╞═ ICReasoning from effects to causes
Diagnosisheadache:- flu.headache:- period.headache:- hangover.flu, vaccine -> false.
hangover -> drank.
period, sex(male) -> false.
?- headache.Yes, flu More? ;Yes, period
Event Calculusholdsat(Fluent,Time):- initially(Fluent),
not(clipped(0,Fluent,Time)).holdsat(Fluent,Time):- initiates(Action,Fluent),
happens(Action,T1), not(clipped(T1,Fluent,Time)).clipped(T1,Fluent,T2):- terminates(Action),
happens(Action,T), T1<T<T2.initially(f1). initially(f2).
happens(a,2) happens(b,4) happens(c,7)
Abductive Event Calculusholdsat(Fluent,Time):- initially(Fluent),
not(clipped(0,Fluent,Time)).holdsat(Fluent,Time):- initiates(Action,Fluent),
happens(Action,T1), not(clipped(T1,Fluent,Time)).clipped(T1,Fluent,T2):- terminates(Action),
happens(Action,T), T1<T<T2.initially(f1). initially(f2).
happens(a,2) happens(b,4) happens(c,7)={ }
Sound negationp(1).
p(f(X)):- q(X).
q(2).
?- not(p(Y)).
yes, Y\=1, Y\=f(2)
Abduction = constraint solving[Kowalski, Toni, Wetzel 98]headache :- flu.headache :- hangover.
flu, vaccine -> false
Constraint Store
?- , headache.vaccine
fluConstraint Solver
fail
Abduction = constraint solving[Kowalski, Toni, Wetzel 98]headache :- flu.headache :- hangover.headache :- period.
flu, vaccine -> false.hangover -> drank.period, sex(male) -> false.
Constraint Store
?- , headache.vaccine
flu
Constraint Solver
fail
Constraint Handling Rules (CHR)Declarative language for defining constraint solversSimplification rules:
c1, c2, ..., cn <=> guard | bodyactivated if some constraints in the store match with c1, c2, ..., cn and guard is true
removes c1, c2, ..., cn from the store and executes body
Propagation rules:c1, c2, ..., cn ==> guard | body
activated if some constraints in the store match with c1, c2, ..., cn and guard is true
executes body
Example: leq (less or equal)reflexivity@ leq(X,X) <=> true.
antisymmetry@ leq(X,Y), leq(Y,X) <=> X=Y.
transitivity@ leq(X,Y), leq(Y,Z) ==> leq(X,Z).
leqleq(A,B), (A,B), leqleq(B,C), (B,C), leqleq(C,A)(C,A)
leqleq(A,B), (A,B), leqleq(B,C), (B,C), leqleq(C,A), (C,A), leqleq(A,C)(A,C)
leqleq(A,B), (A,B), leqleq(B,A), A=C(B,A), A=C
A=B, A=CA=B, A=C
Abduction in CHR [Abdennadher, Christiansen, Dahl]Abducibles mapped to CHR constraintsheadache :- flu.headache :- hangover.
flu, vaccine -> false
Abduction in CHRheadache :- flu.headache :- ...
flu, vaccine ==> false
Constraint Store
?- , headache.vaccine
flufail
Abduction in CHRheadache :- hangover.headache :- ...drank.hangover ==> drank
Constraint Store
?- headache.
hangover
success
drank
Abduction in CHRheadache :- period.headache :- ...sex(male).
Constraint Store
period, sex(male) ==> false
! CHR: invalid syntax "sex(male)"! Undeclared constraint sex/1 in head of rule
Problem:
Operational semanticsPropagation
a(X) a(Y), b -> c (X=Y, b) -> cCase analysis
(X=Y, b) -> c X=Y, (b -> c) \/ X\=Y
Equality rewriting p(A,B,C)=p(D,E,F) A=D, B=E, C=F
Unfoldingp(X) -> Goal p(X):- a. p(X):-b.a -> Goal. b -> Goal
...Constraint solving
Abduction in CHR (SCIFF)headache :- flu.headache :- ...
Constraint Store
?- , headache.vaccine
flufail
ic( )vaccine, flu -> false
ic( flu -> false)
TransitionsPropagation transition (+ case analysis):abd(X), ic([abd(Y)|Rest]-> Head)
==>
copy(ic([abd(Y) |Rest ]-> Head) ,
ic([abd(Y’)|Rest’]-> Head’)),
reif_unify(X,Y’,Boolean),
( Boolean=1, ic(Rest’->Head’)
; Boolean=0).
TransitionsPropagation transition (+ case analysis):abd(X), ic([abd(Y)|Rest]-> Head)
==>
copy(ic([abd(Y) |Rest ]-> Head) ,
ic([abd(Y’)|Rest’]-> Head’)),
reif_unify(X,Y’,Boolean),
( Boolean=1, ic(Rest’->Head’)
; Boolean=0).
ic([abd(vaccine),abd(flu)]-> false)
ic([abd(period),sex(male)]-> false)
ic([abd(hangover)]-> drank)
abd(hangover)
No hashingDoes not use CHR’s hashingSolution: abducibles are represented with
redundant information:abd(Functor, Arity, Atom)
So to abduce atom X:abd(X):- functor(F, A, X),
abd(F, A, X).E.g., if I abduce atom mother(X,john), the
constraint store containsabd(mother, 2, mother(X,john))
HashingPropagation transition (+ case analysis):abd(F,A,X), ic([abd(F,A,Y)|Rest]-> Head)
==>
copy(ic([abd(Y) |Rest ]-> Head) ,
ic([abd(Y’)|Rest’]-> Head’)),
reif_unify(X,Y’,Boolean),
( Boolean=1, ic(Rest’->Head’)
; Boolean=0).
Requires the first two
arguments identical
HashingPropagation transition (+ case analysis):abd(F,A,X), ic([abd(F,A,Y)|Rest]-> Head)
==>
copy(ic([abd(Y) |Rest ]-> Head) ,
ic([abd(Y’)|Rest’]-> Head’)),
reif_unify(X,Y’,Boolean),
( Boolean=1, ic(Rest’->Head’)
; Boolean=0).
ic([abd(vaccine,1,vaccine),abd(flu,1,flu)]-> false)
ic([abd(period,1,period),sex(male)]-> false)
ic([abd(hangover,1,hangover)]-> drank)
abd(hangover,1,hangover)
Postpone choicesnew CHR constraint
nondeterministic(Goal)says that Goal can open a choice point, so should be called as late as possible.
Two phases, declared by a CHR constraint phase/1:phase(deterministic): only deterministic goals are executedphase(nondeterministic): exactly ONE nondeterministic goal
can be executed
switch2det @ phase(nondeterministic), nondeterministic(G) <=>
call(G), phase(deterministic).
switch2nondet @ phase(deterministic) <=> phase(nondeterministic)
Postponing nondet.Propagation transition (+ case analysis):abd(F,A,X), ic([abd(F,A,Y)|Rest]-> Head)
==>
copy(ic([abd(Y) |Rest ]-> Head) ,
ic([abd(Y’)|Rest’]-> Head’)),
reif_unify(X,Y’,B),
( B=1, ic(Rest’->Head’)
; B=0).
Postponing nondet.Propagation transition (+ case analysis):abd(F,A,X), ic([abd(F,A,Y)|Rest]-> Head)
==>
copy(ic([abd(Y) |Rest ]-> Head) ,
ic([abd(Y’)|Rest’]-> Head’)),
reif_unify(X,Y’,B),
(B == 1 -> ic(Rest’, Head’) ;
B == 0 -> true ;
nondeterministic((B#=1,ic(Rest’,Head’)) ; B#=0))
).
ResultsExperiment SCIFF
2005SCIFF 2011
Auction protocol 2.27 s 0.37 sBlock world 45.0 s 15.7 sAlLoWS Feeble Conformance
84.4 s 36.8 s
AlLoWS non-conformant
3.7 s 3.3 s
ConclusionsCHR implementation of an abductive proof-
procedureSound, complete, sound treatment of
negationWell integrated with constraint solving,
CLP(FD), CLP(R), universally quantified variables, quantifier restrictions, etc.
Easy to extend for other features (see other talk after coffee break)
Thank you for your attention!
Questions?