All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class prolog.Prolog

java.lang.Object
   |
   +----prolog.Prolog

public final class Prolog
extends Object
The Prolog engine. This class implements the process of evaluating a goal list.


Variable Index

 o db
The database of clauses.
 o input_stream
The current input stream.
 o obj
An application-specific object (whatever it is).
 o parser
The parser for this Prolog engine.
 o sys_lex
Lexer for stdin, for interactive mode.
 o threshold
The threshold at which we compile a predicate.
 o time
Enable a crude benchmark - display the time taken to answer a query and collect the resultant garbage.
 o types
Contains all user- and system-defined types.

Constructor Index

 o Prolog(boolean)
Creates a new Prolog engine with default parameters.
 o Prolog(boolean, int)
Creates a new Prolog engine with the specified initial database type and size.
 o Prolog(Database)
Creates a new Prolog engine with a pre-initialised database (e.g.

Method Index

 o allocate_ar(Term[], Goal)
Allocates an ActivationRecord for the body of a clause.
 o allocate_cp(ClauseList, Binding)
Allocates a ChoicePoint.
 o backtrack()
Backtrack to the last OR-choice we made.
 o consult(String)
Reads a file into the database.
 o cut()
Prunes the cp_stack to remove pending non-deterministic goals.
 o find(Goal)
Finds the first solution to the given goal.
 o get_trail_top()
Gets the top of the trail, so it can be reset at a later point.
 o once(Goal)
Executes the given goal once only, and resets the execution environment after doing so.
 o push(Binding)
Saves a reference to a Variable binding so that it can be undone on backtracking.
 o push(Binding, Term)
 o set_pending_goal(Goal)
 o toGoal(Compound)
Convert a list of conjunctions/disjunctions/if-then/if-then-else into a Goal.
 o toString()
FIXME: helper function for compiled code.
 o unwind_trail(Binding)
Unwinds the trail back to where the argument indicates.
 o use_pending_goal()

Variables

 o sys_lex
 public static final Yylex sys_lex
Lexer for stdin, for interactive mode.

 o types
 public final TypeDictionary types
Contains all user- and system-defined types.

 o input_stream
 public Yylex input_stream
The current input stream.

 o parser
 public Parser parser
The parser for this Prolog engine.

 o db
 public Database db
The database of clauses.

 o obj
 public Object obj
An application-specific object (whatever it is).

 o time
 public boolean time
Enable a crude benchmark - display the time taken to answer a query and collect the resultant garbage. Highly dependent on system load.

 o threshold
 public final int threshold
The threshold at which we compile a predicate.

Constructors

 o Prolog
 public Prolog(boolean jit)
Creates a new Prolog engine with default parameters.

 o Prolog
 public Prolog(boolean jit,
               int dbsize)
Creates a new Prolog engine with the specified initial database type and size.

 o Prolog
 public Prolog(Database dbin)
Creates a new Prolog engine with a pre-initialised database (e.g. recovered by deserialization).

Methods

 o consult
 public void consult(String filename) throws IOException, PrologException
Reads a file into the database.

Parameters:
filename - file to read
Throws: PrologException
Generated upon a parser error.
See Also:
Parser
 o find
 public boolean find(Goal goal) throws PrologException
Finds the first solution to the given goal. If the goal is null, we backtrack and look for another solution.

 o once
 public boolean once(Goal goal) throws PrologException
Executes the given goal once only, and resets the execution environment after doing so.

 o allocate_cp
 public ChoicePoint allocate_cp(ClauseList next_clause,
                                Binding trail_top)
Allocates a ChoicePoint.

 o allocate_ar
 public void allocate_ar(Term insts[],
                         Goal body)
Allocates an ActivationRecord for the body of a clause.

Parameters:
new_cut_scope - Adjust the cut_ptr so that this Goal is treated as the body of a unifier of the parent goal, i.e. introduce a new cut scope.
 o push
 public void push(Binding b)
Saves a reference to a Variable binding so that it can be undone on backtracking.

 o push
 public void push(Binding b,
                  Term t)
 o get_trail_top
 public Binding get_trail_top()
Gets the top of the trail, so it can be reset at a later point.

 o unwind_trail
 public void unwind_trail(Binding trail_top)
Unwinds the trail back to where the argument indicates.

 o backtrack
 ChoicePoint backtrack()
Backtrack to the last OR-choice we made.

 o cut
 public void cut()
Prunes the cp_stack to remove pending non-deterministic goals. Note that the runtime_stack is pruned by the find method as part of its post-unification cleanup.

 o set_pending_goal
 public void set_pending_goal(Goal pending_goal)
 o use_pending_goal
 public void use_pending_goal()
 o toGoal
 public Goal toGoal(Compound c)
Convert a list of conjunctions/disjunctions/if-then/if-then-else into a Goal.

e.g. ','(g1, ','(g2, g3)) -> [g1, g2, g3], where the latter is a tree constructed of objects from subclasses of Goal.

Also, each Goal node is linked to the Predicate record of the potential unifier for this goal.

Parameters:
c - a list of conjunctions.
Returns:
a Goal representation of the conjunctions.
 o toString
 public String toString()
FIXME: helper function for compiled code.

Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index