25#ifndef PL_SEARCH_ENGINE_HPP_
26#define PL_SEARCH_ENGINE_HPP_
100 friend class ::EngineTest;
150 return p->apply_choice() &&
call_predicate(p->get_continuation());
Represents a disjunction of predicates.
Definition pred.hpp:215
The Engine class manages the execution of predicates and backtracking.
Definition engine.hpp:69
bool call_predicate(PredPtr p)
Call a predicate.
Definition engine.cpp:172
bool unify(TermPtr t1, TermPtr t2)
Unifies two terms.
Definition engine.cpp:76
void clear_stacks()
Clears the environment and trail stacks.
Definition engine.cpp:248
bool execute(PredPtr p, bool unbind)
Executes a predicate.
Definition engine.cpp:268
bool make_choice_and_continue(PredPtr p)
Makes the current choice, checks it, and continues execution (using the predicates continuation) if t...
Definition engine.hpp:149
int stack_size() const
Definition engine.hpp:102
std::stack< std::shared_ptr< env_entry > > env_stack
Stack for environment entries.
Definition engine.hpp:105
void trail(PVarPtr v)
Trails a variable.
Definition engine.cpp:49
std::stack< std::shared_ptr< trail_entry > > trail_stack
Stack for trail entries.
Definition engine.hpp:104
void pop_pred_call()
Pops the top predicate call from the environment stack.
Definition engine.cpp:215
bool retry_predicate(PredPtr p)
Retries the call on a predicate.
Definition engine.cpp:202
void backtrack()
Performs backtracking.
Definition engine.cpp:59
void push(PredPtr p)
Pushes a predicate onto the environment stack.
Definition engine.cpp:155
Engine()
Initialize the environment stack with a dummy entry.
Definition engine.hpp:71
friend class Cut
Definition engine.hpp:91
void print_env_stack() const
Definition engine.cpp:285
void cut_to_choice_point(int env_index)
Cuts the environment stack to the choice point at the given index.
Definition engine.cpp:239
void pop_to_pred(PredPtr p)
Pops predicate calls from the environment stack until the specified predicate is reached.
Definition engine.cpp:226
Represents the equivalent of Prolog if-then-else i.e. (G1 -> G2; G3) - similar to (G1,...
Definition pred.hpp:350
Intended for internal use by NotNot which injects this call directly after the predicate supplied to ...
Definition pred.hpp:302
Represents an equivalent of the Prolog call \+\+Call. The aim is to determine if Call succeeds withou...
Definition pred.hpp:328
Represents the equivalent of Prolog's once(Call). The aim is to remove any choicepoints produced by C...
Definition pred.hpp:280
Definition of the CList class.
Definition choice_iterator.hpp:16
std::shared_ptr< Pred > PredPtr
Typedef for a shared pointer to a Pred object.
Definition typedefs.hpp:34
std::shared_ptr< PVar > PVarPtr
Definition typedefs.hpp:45
std::shared_ptr< Term > TermPtr
Typedefs for shared pointers to Terms and subclasses.
Definition typedefs.hpp:44
Definition of the Pred class and its derived classes.
Definition of the PVar class.
Represents an environment entry for predicates.
Definition engine.hpp:57
int trail_index
The index in the trail stack.
Definition engine.hpp:59
PredPtr pred
The predicate being executed.
Definition engine.hpp:58
Represents a trail entry for backtracking.
Definition engine.hpp:49
PVarPtr var
The variable being trailed.
Definition engine.hpp:50
TermPtr value
The value of the variable.
Definition engine.hpp:51
Definition of the Term class.
Definition of common typedefs used in the pl_search library.