Fw: simple forward chaining

Thorsten Brunklaus brunklaus at ps.uni-sb.de
Mon Sep 23 09:03:27 CEST 2002


----- Original Message ----- 
From: "Wendelin Reich" <wreich at gmx.net>
To: <owner-oz-users at ps.uni-sb.de>
Sent: Sunday, September 22, 2002 10:34 PM
Subject: simple forward chaining


> Dear all,
> 
> I am still in the process of figuring out how to do logic programming in
> Oz. Unfortunately, the tutorial is incomplete here, the references only
> for people who already know what constructs like "choice", "or", "cond"
> and "dis" are for, and Peter Van Roy's really wonderful new book covers
> only the "choice"-statement. There are some older threads in
> owner-oz-users on the "or" statement, but the difference between
> "choice", "or" and "dis" as well as the purpose of the "cond" construct
> are still mysteries to me. Could anybody give me or point me to a
> summary and examples? That would be very kind.
> 
> To get started nonetheless, I have been trying to translate a very
> simple forward-chaining reasoner to Oz, but I haven't come very far. Can
> anyone tell me whether Oz's choice constructs and search engines can
> implement behavior similar to the following Prolog forward-chainer
> (taken from Bratko)?
> 
> Given Prolog facts of the form ("if", "else", "and" and "or" being
> defined as operators)...
> 
> if Condition then Conclusion.
> if Condition1 and Condition2 then Conclusion.
> if Condition1 or Condition2 then Conclusion.
> 
> ... the following snippet will spit out all derivable conclusions:
> ------8<------
> forward  :-
>    new_derived_fact( P),             % A new fact   
>    !,
>    write( 'Derived: '), write( P), nl,
>    assert( fact( P)),
>    forward                           % Continue   
>    ;
>    write( 'No more facts').          % All facts derived
> 
> new_derived_fact( Concl)  :-
>    if Cond then Concl,               % A rule   
>    not fact( Concl),                 % Rule's conclusion not yet a fact
>    composed_fact( Cond).             % Condition true? 
> 
> composed_fact( Cond)  :-
>    fact( Cond).                      % Simple fact 
> 
> composed_fact( Cond1 and Cond2)  :-
>    composed_fact( Cond1),
>    composed_fact( Cond2).            % Both conjuncts true 
> 
> composed_fact( Cond1 or Cond2)  :-
>    composed_fact( Cond1)
>    ;
>    composed_fact( Cond2).
> ------>8------
> 
> This code seems to summarize all the reasons why we should prefer Oz to
> Prolog :-) but it does its work. I guess such facts would simply be
> implemented as entries in an Oz-dictionary, then there would also be a
> loop construct, but would it also be possible (or good Oz-style, for
> that matter) to tie the facts together into "choice" constructs
> (how?????) and let Oz do search?
> 
> Thanks for any suggestions, Wendelin
> 
-
Please send submissions to users at mozart-oz.org
and administriva mail to users-request at mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.





More information about the mozart-users mailing list