|
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 | ================================================================ |
|---|
| 2 | Logtalk - Open source object-oriented logic programming language |
|---|
| 3 | Release 2.35.0 |
|---|
| 4 | |
|---|
| 5 | Copyright (c) 1998-2009 Paulo Moura. All Rights Reserved. |
|---|
| 6 | Logtalk is free software. You can redistribute it and/or modify |
|---|
| 7 | it under the terms of the "Artistic License 2.0" as published by |
|---|
| 8 | The 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 | |
|---|
| 22 | X = 1 ; |
|---|
| 23 | X = 2 |
|---|
| 24 | yes |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | % solver - a simple meta-interpreter for pure Prolog: |
|---|
| 28 | |
|---|
| 29 | | ?- database::solve(p(X)). |
|---|
| 30 | |
|---|
| 31 | X = 1 ; |
|---|
| 32 | X = 2 |
|---|
| 33 | yes |
|---|
| 34 | |
|---|
| 35 | | ?- database::proof_tree(p(X), Tree). |
|---|
| 36 | |
|---|
| 37 | X = 1 |
|---|
| 38 | Tree = p(1):- (q(1, a):- (s(1):-true), (t(1, a):-true)), (r(a):-true) ; |
|---|
| 39 | X = 2 |
|---|
| 40 | Tree = p(2):- (q(2, b):- (s(2):-true), (t(2, b):-true)), (r(b):-true) |
|---|
| 41 | yes |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | % tracer - a simple meta-interpreter for tracing goal proofs using pure Prolog: |
|---|
| 45 | |
|---|
| 46 | | ?- database::trace(p(X)). |
|---|
| 47 | 1 call: p(_G180) |
|---|
| 48 | 2 call: q(_G180, _G316) |
|---|
| 49 | 3 call: s(_G180) |
|---|
| 50 | 3 exit: s(1) |
|---|
| 51 | 3 call: t(1, _G316) |
|---|
| 52 | 3 exit: t(1, a) |
|---|
| 53 | 2 exit: q(1, a) |
|---|
| 54 | 2 call: r(a) |
|---|
| 55 | 2 exit: r(a) |
|---|
| 56 | 1 exit: p(1) |
|---|
| 57 | |
|---|
| 58 | X = 1 ; |
|---|
| 59 | 1 redo: p(1) |
|---|
| 60 | 2 redo: r(a) |
|---|
| 61 | 2 fail: r(a) |
|---|
| 62 | 2 redo: q(1, a) |
|---|
| 63 | 3 redo: t(1, a) |
|---|
| 64 | 3 fail: t(1, _G316) |
|---|
| 65 | 3 redo: s(1) |
|---|
| 66 | 3 exit: s(2) |
|---|
| 67 | 3 call: t(2, _G316) |
|---|
| 68 | 3 exit: t(2, b) |
|---|
| 69 | 2 exit: q(2, b) |
|---|
| 70 | 2 call: r(b) |
|---|
| 71 | 2 exit: r(b) |
|---|
| 72 | 1 exit: p(2) |
|---|
| 73 | |
|---|
| 74 | X = 2 ; |
|---|
| 75 | 1 redo: p(2) |
|---|
| 76 | 2 redo: r(b) |
|---|
| 77 | 2 fail: r(b) |
|---|
| 78 | 2 redo: q(2, b) |
|---|
| 79 | 3 redo: t(2, b) |
|---|
| 80 | 3 fail: t(2, _G316) |
|---|
| 81 | 3 redo: s(2) |
|---|
| 82 | 3 exit: s(3) |
|---|
| 83 | 3 call: t(3, _G316) |
|---|
| 84 | 3 fail: t(3, _G316) |
|---|
| 85 | 3 redo: s(3) |
|---|
| 86 | 3 fail: s(_G180) |
|---|
| 87 | 2 fail: q(_G180, _G316) |
|---|
| 88 | 1 fail: p(_G180) |
|---|
| 89 | |
|---|
| 90 | no |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | % another example: expert system rules: |
|---|
| 94 | |
|---|
| 95 | | ?- rules::prove(weather(Wheather)). |
|---|
| 96 | |
|---|
| 97 | Wheather = raining |
|---|
| 98 | yes |
|---|
| 99 | |
|---|
| 100 | | ?- rules::prove(goto(Where)). |
|---|
| 101 | |
|---|
| 102 | Where = cinema |
|---|
| 103 | yes |
|---|