================================================================= Logtalk - Object oriented extension to Prolog Release 2.29.3 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