[prev] [up] [next]

Prolog Interpreter

Overview

These classes implement a simple Prolog interpreter.
To avoid interference with the rest of the system, these classes have been installed under the "Prolog" namespace.

Documentation

See the class documentation of "Prolog::PrologInterpreter", and
Use the source - Luke.

Examples

To open a prolog workspace:
    Prolog::PrologInterpreter open
Evaluate solutions (no user interaction):
    |string prolog result answerSet actionInvokedForResult|

    answerSet := Set new.
    actionInvokedForResult := [:answer | answerSet add:answer. true].

    string := '
	?- remove.        % remove all predicates in PrologDataBase.

	likes(john,mary). % assert fact.
	likes(john,wine). % assert fact.
	likes(mary,wine). % assert fact.
	likes(mary,john). % assert fact.

	?- likes(X,Y).                   % question goal.
	?- likes(john,X), likes(mary,X). % question goal.

	'.

    prolog := Prolog::PrologInterpreter new.
    prolog textCollector: Transcript.
    result := prolog 
		refute:string action:actionInvokedForResult.

    answerSet inspect
With user interation:
    |string prolog result actionInvokedForResult|

    actionInvokedForResult := Prolog::PrologInterpreter exampleActionFor:prolog.

    string := '
	?- remove.        % remove all predicates in PrologDataBase.

	likes(john,mary). % assert fact.
	likes(john,wine). % assert fact.
	likes(mary,wine). % assert fact.
	likes(mary,john). % assert fact.

	?- likes(X,Y).                   % question goal.
	?- likes(john,X), likes(mary,X). % question goal.

	'.

    prolog := Prolog::PrologInterpreter new.
    prolog textCollector: Transcript.
    result := prolog 
		refute:string action:actionInvokedForResult.

Licensing

This addOn package is NOT to be considered part of the base ST/X system. It is provided physically with the ST/X delivery, but only for your convenience.

Legally, it is a freeware or public domain goody, as specified in the goodies copyright notice (see the goodies source).

No Warranty

This goody is provided AS-IS without any warranty whatsoever.

Origin/Authors

Ported from the MEI package as found in the smalltalk archives.
Authors:

Copyright (C) 1995-1997 AOKI Atsushi
Atsushi Aoki,
Software Research Associates, Inc.
1113 Spruce Street, Suite 502
Boulder, Colorado 80302 the U.S.A.


<info@exept.de>

Doc $Revision: 1.6 $