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/SCRIPT.txt
pmoura 46c8cfbeff Logtalk 2.29.4 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1799 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2007-02-19 18:58:28 +00:00

101 lines
1.6 KiB
Plaintext

=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.29.4
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
=================================================================
% start by loading the example:
| ?- logtalk_load(metainterpreters(loader)).
...
% direct call of p/1:
| ?- database::p(X).
X = 1 ;
X = 2
yes
% solver - a simple meta-interpreter for pure Prolog:
| ?- database::solve(p(X)).
X = 1 ;
X = 2
yes
| ?- database::proof_tree(p(X), Tree).
X = 1
Tree = p(1):- (q(1, a):- (s(1):-true), (t(1, a):-true)), (r(a):-true) ;
X = 2
Tree = p(2):- (q(2, b):- (s(2):-true), (t(2, b):-true)), (r(b):-true)
yes
% tracer - a simple meta-interpreter for tracing goal proofs using pure Prolog:
| ?- database::trace(p(X)).
1 call: p(_G180)
2 call: q(_G180, _G316)
3 call: s(_G180)
3 exit: s(1)
3 call: t(1, _G316)
3 exit: t(1, a)
2 exit: q(1, a)
2 call: r(a)
2 exit: r(a)
1 exit: p(1)
X = 1 ;
1 redo: p(1)
2 redo: r(a)
2 fail: r(a)
2 redo: q(1, a)
3 redo: t(1, a)
3 fail: t(1, _G316)
3 redo: s(1)
3 exit: s(2)
3 call: t(2, _G316)
3 exit: t(2, b)
2 exit: q(2, b)
2 call: r(b)
2 exit: r(b)
1 exit: p(2)
X = 2 ;
1 redo: p(2)
2 redo: r(b)
2 fail: r(b)
2 redo: q(2, b)
3 redo: t(2, b)
3 fail: t(2, _G316)
3 redo: s(2)
3 exit: s(3)
3 call: t(3, _G316)
3 fail: t(3, _G316)
3 redo: s(3)
3 fail: s(_G180)
2 fail: q(_G180, _G316)
1 fail: p(_G180)
no
% another example: expert system rules:
| ?- rules::prove(weather(Wheather)).
Wheather = raining
yes
| ?- rules::prove(goto(Where)).
Where = cinema
yes