This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/Logtalk/examples/metainterpreters/rules.lgt
pmoura d79dd807e6 Logtalk 2.29.1 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1744 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2006-12-28 13:03:34 +00:00

51 lines
846 B
Plaintext

:- category(engine).
:- public(prove/1).
:- public(if/1).
:- dynamic(if/1).
:- op(200, fx, if).
:- op(100, xfx, then).
prove(true) :-
!.
prove([]) :-
!.
prove([Cond| Conds]) :-
!,
prove(Cond),
prove(Conds).
prove(Fact) :-
::clause(Fact, true).
prove(Conclusion) :-
::clause(if Conds then Conclusion, true),
prove(Conds).
:- end_category.
:- object(rules,
imports(engine)).
:- public([weather/1, weekday/1, time/1, goto/1]).
:- dynamic([weather/1, weekday/1, time/1, goto/1]).
:- dynamic(if/1).
:- op(200, fx, if).
:- op(100, xfx, then).
if [weather(sunny), weekday(weekend), time(day)] then goto(beach).
if [weather(raining), weekday(weekend), time(night)] then goto(cinema).
if [weekday(workday), time(day)] then goto(work).
weather(raining).
weekday(weekend).
time(night).
:- end_object.