Title: The CHR-based Implementation of the SCIFF Abductive System
1The CHR-based Implementation of the
SCIFFAbductive System
- Marco Gavanelli Università di Ferrara, Italy
- Marco Alberti Universidade nova de Lisboa,
Portugal - Evelina Lamma Università di Ferrara, Italy
2Abductive Logic Programming
- ALP lt KB, A, IC gt
- KB logic program (set of clauses)
- A atoms without definitions, can be assumed
- IC Integrity constraints (usually,
implications) - KB ? ? - G KB ? ? - IC
- Reasoning from effects to causes
3Diagnosis
- headache- flu.
- headache- period.
- headache- hangover.
- flu, vaccine -gt false.
- hangover -gt drank.
- period, sex(male) -gt false.
- ?- headache.
- Yes, flu More?
- Yes, period
4Event Calculus
- holdsat(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), T1ltTltT2. - initially(f1). initially(f2).
happens(c,7)
happens(a,2)
happens(b,4)
5Abductive Event Calculus
- holdsat(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), T1ltTltT2. - initially(f1). initially(f2).
happens(c,7)
happens(a,2)
happens(b,4)
?
6Sound negation
- p(1).
- p(f(X))- q(X).
- q(2).
- ?- not(p(Y)).
- yes, Y\1, Y\f(2)
7Abduction constraint solvingKowalski, Toni,
Wetzel 98
- headache - flu.
- headache - hangover.
- flu, vaccine -gt false
Constraint Store
?- , headache.
vaccine
Constraint Solver
flu
fail
8Abduction constraint solvingKowalski, Toni,
Wetzel 98
- headache - flu.
- headache - hangover.
- headache - period.
- flu, vaccine -gt false.
- hangover -gt drank.
- period, sex(male) -gt false.
Constraint Store
Constraint Solver
?- , headache.
vaccine
fail
flu
9Constraint Handling Rules (CHR)
- Declarative language for defining constraint
solvers - Simplification rules
- c1, c2, ..., cn ltgt guard body
- activated 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 gt guard body
- activated if some constraints in the store match
with c1, c2, ..., cn and guard is true - executes body
10Example leq (less or equal)
- reflexivity_at_ leq(X,X) ltgt true.
- antisymmetry_at_ leq(X,Y), leq(Y,X) ltgt XY.
- transitivity_at_ leq(X,Y), leq(Y,Z) gt leq(X,Z).
leq(A,B), leq(B,C), leq(C,A)
leq(A,B), leq(B,C), leq(C,A), leq(A,C)
leq(A,B), leq(B,A), AC
AB, AC
11Abduction in CHR Abdennadher, Christiansen,
Dahl
- Abducibles mapped to CHR constraints
- headache - flu.
- headache - hangover.
- flu, vaccine -gt false
12Abduction in CHR
- headache - flu.
- headache - ...
- flu, vaccine gt false
Constraint Store
?- , headache.
vaccine
fail
flu
13Abduction in CHR
- headache - hangover.
- headache - ...
- drank.
- hangover gt drank
Constraint Store
?- headache.
hangover
drank
success
14Abduction in CHR
- headache - period.
- headache - ...
- sex(male).
Constraint Store
- period, sex(male) gt false
! CHR invalid syntax "sex(male)" ! Undeclared
constraint sex/1 in head of rule
15Problem
16Operational semantics
- Propagation
- a(X) a(Y), b -gt c (XY, b) -gt c
- Case analysis
- (XY, b) -gt c XY, (b -gt c) \/ X\Y
- Equality rewriting
- p(A,B,C)p(D,E,F) AD, BE, CF
- Unfolding
- p(X) -gt Goal p(X)- a. p(X)-b.
- a -gt Goal. b -gt Goal
- ...
- Constraint solving
17Abduction in CHR (SCIFF)
Constraint Store
- headache - flu.
- headache - ...
ic( )
vaccine, flu -gt false
?- , headache.
vaccine
fail
flu
18Abduction in CHR (SCIFF)
Constraint Store
- headache - flu.
- headache - ...
ic( flu -gt false)
ic( )
vaccine, flu -gt false
?- , headache.
vaccine
fail
flu
19Transitions
- Propagation transition ( case analysis)
- abd(X), ic(abd(Y)Rest-gt Head)
- gt
- copy(ic(abd(Y) Rest -gt Head) ,
- ic(abd(Y)Rest-gt Head)),
- reif_unify(X,Y,Boolean),
- ( Boolean1, ic(Rest-gtHead)
- Boolean0).
20Transitions
- Propagation transition ( case analysis)
- abd(X), ic(abd(Y)Rest-gt Head)
- gt
- copy(ic(abd(Y) Rest -gt Head) ,
- ic(abd(Y)Rest-gt Head)),
- reif_unify(X,Y,Boolean),
- ( Boolean1, ic(Rest-gtHead)
- Boolean0).
ic(abd(vaccine),abd(flu)-gt false)
ic(abd(period),sex(male)-gt false)
ic(abd(hangover)-gt drank)
abd(hangover)
21No hashing
- Does not use CHRs hashing
- Solution 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 contains - abd(mother, 2, mother(X,john))
22Hashing
- Propagation transition ( case analysis)
- abd(F,A,X), ic(abd(F,A,Y)Rest-gt Head)
- gt
- copy(ic(abd(Y) Rest -gt Head) ,
- ic(abd(Y)Rest-gt Head)),
- reif_unify(X,Y,Boolean),
- ( Boolean1, ic(Rest-gtHead)
- Boolean0).
Requires the first two arguments identical
23Hashing
- Propagation transition ( case analysis)
- abd(F,A,X), ic(abd(F,A,Y)Rest-gt Head)
- gt
- copy(ic(abd(Y) Rest -gt Head) ,
- ic(abd(Y)Rest-gt Head)),
- reif_unify(X,Y,Boolean),
- ( Boolean1, ic(Rest-gtHead)
- Boolean0).
ic(abd(vaccine,1,vaccine),abd(flu,1,flu)-gt
false)
ic(abd(period,1,period),sex(male)-gt false)
ic(abd(hangover,1,hangover)-gt drank)
abd(hangover,1,hangover)
24Postpone choices
- new 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 executed - phase(nondeterministic) exactly ONE
nondeterministic goal can be executed - switch2det _at_ phase(nondeterministic),
nondeterministic(G) ltgt - call(G), phase(deterministic).
- switch2nondet _at_ phase(deterministic) ltgt
phase(nondeterministic)
25Postponing nondet.
- Propagation transition ( case analysis)
- abd(F,A,X), ic(abd(F,A,Y)Rest-gt Head)
- gt
- copy(ic(abd(Y) Rest -gt Head) ,
- ic(abd(Y)Rest-gt Head)),
- reif_unify(X,Y,B),
- ( B1, ic(Rest-gtHead)
- B0).
26Postponing nondet.
- Propagation transition ( case analysis)
- abd(F,A,X), ic(abd(F,A,Y)Rest-gt Head)
- gt
- copy(ic(abd(Y) Rest -gt Head) ,
- ic(abd(Y)Rest-gt Head)),
- reif_unify(X,Y,B),
- (B 1 -gt ic(Rest, Head)
- B 0 -gt true
- nondeterministic((B1,ic(Rest,Head))
B0)) - ).
27Results
Experiment SCIFF 2005 SCIFF 2011
Auction protocol 2.27 s 0.37 s
Block world 45.0 s 15.7 s
AlLoWS Feeble Conformance 84.4 s 36.8 s
AlLoWS non-conformant 3.7 s 3.3 s
28Conclusions
- CHR implementation of an abductive
proof-procedure - Sound, complete, sound treatment of negation
- Well 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)
29Thank you for your attention!