Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!udel!gatech!swrinde!pipex!sunic!sunic.sunet.se!news.chalmers.se!news.gu.se!mac17.ling.gu.se!user
From: lager@ling.gu.se (Torbjrn Lager)
Subject: Re: Abduction for semantic reconciliation in heterogeneous databases
Message-ID: <lager-2703950848340001@mac17.ling.gu.se>
Sender: news@news.gu.se (USENET News System)
Nntp-Posting-Host: mac17.ling.gu.se
Organization: Department of Linguistics, Gteborg University
References: <3knad2$cc1@senator-bedfellow.MIT.EDU>
Date: Mon, 27 Mar 1995 07:52:12 GMT
Lines: 132

Here's a very simple abductive prover that I have found useful for 
experimenting with abduction. It is built as an extension of a vanilla 
meta-interpreter, and it uses a 'backtrackable' assert to keep track 
of assumptions.

Since it uses assert/2 to a great extent, and since consistency 
checking is performed globally, it might not be very efficient. Passing
the assumptions around in a difference list would be cleaner and faster, 
but, as far as I can see, consistency checking then becomes more 
difficult.

I too would be very interested in other, more efficient ways of 
implementing abduction. So please let me know if you learn about other
implementations, etc.


Best regards,
Torbjorn Lager

Department of Linguistics
University of Goteborg
sweden

********************************************/


% abductively_prove(Goal) succeeds if Goal is provable given 
% certain assumptions.  


abductively_prove(true) :- !.
abductively_prove((A,B)) :- !,
   abductively_prove(A),
   abductively_prove(B). 
abductively_prove(A) :- 
   clause(A,B),
   abductively_prove(B). 
abductively_prove(A) :-
   assumable(A),
%  we may want to check for groundness
%  ground(A),
   assume(A),
   \+ inconsistent.



% assume/1 implements a backtrackable assert that keeps track
% of assumptions (so that they can be listed, abolished, etc. later)
% Assumptions are stored as unit clauses, and their DB-references 
% are stored in clauses of the form '$ass_ref'(Ref)

assume(A) :-
   assert(A,Ref), 
   assert('$ass_ref'(Ref),RefRef),
   (   true 
   ;   erase(Ref),
       erase(RefRef),
       !,
       fail
   ).


% list_assumptions/0

list_assumptions :-
   (   '$ass_ref'(Ref),
        instance(Ref,Clause),
        write(Clause), put(.),
        nl,
        fail
   ;    true
   ).


% abolish_assumptions/0

abolish_assumptions :-
    (    retract('$ass_ref'(Ref)),
         erase(Ref),
         fail
    ;    true
    ).



% a simple UI loop

main :-
   nl,
   % clean up, if needed
   abolish_assumptions,
   write('Goal: '),
   read(Goal),
   (   abductively_prove(Goal),
       write('The goal '),
       write(Goal),
       write(' is proved, assuming:'), nl,
       list_assumptions,
       nl,
       fail
   ;   true
   ),
   main.



% Bicycle Expert System Example from (Kowalski,1990).

wobbly_wheel :- flat_tyre.
wobbly_wheel :- broken_spokes.
flat_tyre :- punctured_tube.
flat_tyre :- leaky_valve.
tyre_holds_air.
inconsistent :- flat_tyre, tyre_holds_air.

% declare everything as assumable
assumable(_).



/*  TEST RUN

?- main.
Goal: wobbly_wheel.

The goal wobbly_wheel is proved, assuming:
broken_spokes.

The goal wobbly_wheel is proved, assuming:
wobbly_wheel.

*/
