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.
-
db
- The database of clauses.
-
input_stream
- The current input stream.
-
obj
- An application-specific object (whatever it is).
-
parser
- The parser for this Prolog engine.
-
sys_lex
- Lexer for stdin, for interactive mode.
-
threshold
- The threshold at which we compile a predicate.
-
time
- Enable a crude benchmark - display the time taken to answer a query
and collect the resultant garbage.
-
types
- Contains all user- and system-defined types.
-
Prolog(boolean)
- Creates a new Prolog engine with default parameters.
-
Prolog(boolean, int)
- Creates a new Prolog engine with the specified initial database type
and size.
-
Prolog(Database)
- Creates a new Prolog engine with a pre-initialised database
(e.g.
-
allocate_ar(Term[], Goal)
- Allocates an ActivationRecord for the body of a clause.
-
allocate_cp(ClauseList, Binding)
- Allocates a ChoicePoint.
-
backtrack()
- Backtrack to the last OR-choice we made.
-
consult(String)
- Reads a file into the database.
-
cut()
- Prunes the cp_stack to remove pending non-deterministic
goals.
-
find(Goal)
- Finds the first solution to the given goal.
-
get_trail_top()
- Gets the top of the trail, so it can be reset at a later point.
-
once(Goal)
- Executes the given goal once only, and resets the execution
environment after doing so.
-
push(Binding)
- Saves a reference to a Variable binding so that it can be undone on
backtracking.
-
push(Binding, Term)
-
-
set_pending_goal(Goal)
-
-
toGoal(Compound)
- Convert a list of conjunctions/disjunctions/if-then/if-then-else into
a Goal.
-
toString()
- FIXME: helper function for compiled code.
-
unwind_trail(Binding)
- Unwinds the trail back to where the argument indicates.
-
use_pending_goal()
-
sys_lex
public static final Yylex sys_lex
- Lexer for stdin, for interactive mode.
types
public final TypeDictionary types
- Contains all user- and system-defined types.
input_stream
public Yylex input_stream
- The current input stream.
parser
public Parser parser
- The parser for this Prolog engine.
db
public Database db
- The database of clauses.
obj
public Object obj
- An application-specific object (whatever it is).
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.
threshold
public final int threshold
- The threshold at which we compile a predicate.
Prolog
public Prolog(boolean jit)
- Creates a new Prolog engine with default parameters.
Prolog
public Prolog(boolean jit,
int dbsize)
- Creates a new Prolog engine with the specified initial database type
and size.
Prolog
public Prolog(Database dbin)
- Creates a new Prolog engine with a pre-initialised database
(e.g. recovered by deserialization).
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
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.
once
public boolean once(Goal goal) throws PrologException
- Executes the given goal once only, and resets the execution
environment after doing so.
allocate_cp
public ChoicePoint allocate_cp(ClauseList next_clause,
Binding trail_top)
- Allocates a ChoicePoint.
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.
push
public void push(Binding b)
- Saves a reference to a Variable binding so that it can be undone on
backtracking.
push
public void push(Binding b,
Term t)
get_trail_top
public Binding get_trail_top()
- Gets the top of the trail, so it can be reset at a later point.
unwind_trail
public void unwind_trail(Binding trail_top)
- Unwinds the trail back to where the argument indicates.
backtrack
ChoicePoint backtrack()
- Backtrack to the last OR-choice we made.
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.
set_pending_goal
public void set_pending_goal(Goal pending_goal)
use_pending_goal
public void use_pending_goal()
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.
toString
public String toString()
- FIXME: helper function for compiled code.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index