At 13:19 +0200 02/5/28, Candide Kemmler wrote:
...
First: I have read that prolog systems are generally backward-chaining systems. I would like to do forward-chaining so I can deal with notification of particular events to the users.
...
Though the Prolog interpreter uses backward-chaining you can use Prolog to write meta-interpreters to perform any kind of proof strategy including forward-chaining. Here is a very simple forward-chaining meta-interpeter:
chain_forward(Facts, NewFacts) :- % to find new facts derive_facts(Facts, Facts1), % perform one forward-chaining step chain_forward(Facts1, NewFacts). % and recurse chain_forward(Facts, Facts). % no more facts
derive_facts(Facts, [Fact|Facts]) :- % for a new fact rule(Conditions, Fact), % find a rule forall(member(Condition, Conditions), member(Condition, Facts)), % whose preconditions are true and + member(Fact, Facts). % whose consequence is new
forall(Element, Condition) :- + (Element, + Condition).
With a trivial set of rules
rule(['The sun is shining.'], 'I am hot.'). rule(['I am hot.'], 'I get myself an ice-cream.').
we get
?- chain_forward(['The sun is shining.'], NewFacts). NewFacts = ['I get myself an ice-cream.','I am hot.','The sun is shining.'] ?
Regards.
Norbert E. Fuchs
Department of Information Technology University of Zurich CH-8057 Zurich Switzerland
Telephone +41-1-635 43 13 Fax +41-1-635 68 09 Email fuchs(a)ifi.unizh.ch WWW http://www.ifi.unizh.ch/~fuchs/ ============================================================================== Message: Address: Action: help majordomo(a)clip.dia.fi.upm.es Info. on useful commands subscribe ciao-users-request(a)clip.dia.fi.upm.es Subscribe to this list unsubscribe ciao-users-request(a)clip.dia.fi.upm.es Unsubscribe from this list <whatever> ciao-users(a)clip.dia.fi.upm.es Send message to list ----------------------------------------------------------------------------- Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/ -----------------------------------------------------------------------------