root/trunk/examples/metainterpreters/SCRIPT.txt

Revision 4662, 1.8 KB (checked in by pmoura, 6 days ago)

Updated copyright notice.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1================================================================
2Logtalk - Open source object-oriented logic programming language
3Release 2.35.0
4
5Copyright (c) 1998-2009 Paulo Moura.        All Rights Reserved.
6Logtalk is free software.  You can redistribute it and/or modify
7it under the terms of the "Artistic License 2.0" as published by
8The Perl Foundation. Consult the "LICENSE.txt" file for details.
9================================================================
10
11
12% start by loading the example:
13
14| ?- logtalk_load(metainterpreters(loader)).
15...
16
17
18% direct call of p/1:
19
20| ?- database::p(X).
21
22X = 1 ;
23X = 2
24yes
25
26
27% solver - a simple meta-interpreter for pure Prolog:
28
29| ?- database::solve(p(X)).
30
31X = 1 ;
32X = 2
33yes
34
35| ?- database::proof_tree(p(X), Tree).
36
37X = 1
38Tree = p(1):- (q(1, a):- (s(1):-true), (t(1, a):-true)), (r(a):-true) ;
39X = 2
40Tree = p(2):- (q(2, b):- (s(2):-true), (t(2, b):-true)), (r(b):-true)
41yes
42
43
44% tracer - a simple meta-interpreter for tracing goal proofs using pure Prolog:
45
46| ?- database::trace(p(X)).
471 call: p(_G180)
482 call: q(_G180, _G316)
493 call: s(_G180)
503 exit: s(1)
513 call: t(1, _G316)
523 exit: t(1, a)
532 exit: q(1, a)
542 call: r(a)
552 exit: r(a)
561 exit: p(1)
57
58X = 1 ;
591 redo: p(1)
602 redo: r(a)
612 fail: r(a)
622 redo: q(1, a)
633 redo: t(1, a)
643 fail: t(1, _G316)
653 redo: s(1)
663 exit: s(2)
673 call: t(2, _G316)
683 exit: t(2, b)
692 exit: q(2, b)
702 call: r(b)
712 exit: r(b)
721 exit: p(2)
73
74X = 2 ;
751 redo: p(2)
762 redo: r(b)
772 fail: r(b)
782 redo: q(2, b)
793 redo: t(2, b)
803 fail: t(2, _G316)
813 redo: s(2)
823 exit: s(3)
833 call: t(3, _G316)
843 fail: t(3, _G316)
853 redo: s(3)
863 fail: s(_G180)
872 fail: q(_G180, _G316)
881 fail: p(_G180)
89
90no
91
92
93% another example: expert system rules:
94
95| ?- rules::prove(weather(Wheather)).
96
97Wheather = raining
98yes
99
100| ?- rules::prove(goto(Where)).
101
102Where = cinema
103yes
Note: See TracBrowser for help on using the browser.