PrologExecutionContext
One frame of the :solve-prolog execution-context stack: a substitution, the streams of remaining goals, candidate Rules and candidate primitive responses, plus a parent link. Frames chain into their parent rather than living in a separate stack container, so the parent chain (see pathToRoot) is the call stack -- ordinary heap-allocated data rather than native JVM/JS stack frames, which is what lets Prolog resolution of arbitrarily deep recursive programs run as an explicit, non-recursive it.unibo.tuprolog.argumentation.core.engine.fsm.State loop instead of unbounded host-language recursion.
Resolving a sub-goal (a primitive call or a rule body) pushes a new context whose parent is the current one (see it.unibo.tuprolog.argumentation.core.engine.fsm.createChild); finishing a context's goals pops back to its parent in it.unibo.tuprolog.argumentation.core.engine.fsm.StateGoalSelection. Every instance also threads through choicePoints, the sibling data structure (see ChoicePointContext) recording still-open backtracking alternatives.
Most fields mirror it.unibo.tuprolog.solve.ExecutionContext; the ones specific to the prolog engine are:
query/goals: the original query, and the cursor over the goals still to be proven in this frame.
rules/primitives: the still-untried candidate clauses/primitive responses for the current goal, i.e. the frame's own view of the choicePoints entry recorded for it (if any).
choicePoints: the head of the choice-point queue as seen from this frame -- see ChoicePointContext.
parent/depth: the enclosing frame and this frame's distance from the root (
depth == 0, isRoot).step: a monotonically increasing counter of state-machine transitions, used to keep PrologSolver's
currentContextin sync with resolution progress and to detect it.unibo.tuprolog.solve.exception.TimeOutExceptions.relevantGoals: the goals selected so far in this frame, whose variables are still of interest, used to trim substitutions of variables local to a finished sub-goal when popping back to parent (see isVariableInteresting); trimmedSize is the size of the substitution when it was last trimmed.
inlined: whether this frame solves the goal of an Inlining, against libraries of its own; scoped: whether this frame or one above does (so that its libraries are not the ones of the whole resolution).
theoryIndexes: the indexes of the immutable theories, kept by the solver and shared with the solvers the resolution creates (see TheoryIndexes).
Throws
if depth and parent are inconsistent (depth == 0 iff parent == null), or if startTime or maxDuration are negative.
Constructors
Properties
The current goals entry with substitution already applied, or null if there is none left to prove.
Whether choicePoints (or any of its ancestors) still has an alternative to backtrack into.
This frame and all its ancestors, from here up to (and including) the root, in that order (arg2p: built when needed, rather than for each of the contexts, one or more per resolution step).
Functions
Records a it.unibo.tuprolog.argumentation.core.engine.ChoicePointContext.Rules onto PrologExecutionContext.choicePoints whose alternatives resolve the current goal of this context on backtracking (arg2p): for the frames whose first alternative is not a clause (see ControlConstruct)
Solve.Response analogue of appendRulesAndChoicePoints, recording a it.unibo.tuprolog.argumentation.core.engine.ChoicePointContext.Primitives instead.
Attaches rules as this context's PrologExecutionContext.rules cursor and records a matching it.unibo.tuprolog.argumentation.core.engine.ChoicePointContext.Rules onto PrologExecutionContext.choicePoints, so the remaining candidates (if any) can be retried later on backtracking.
Pushes a new child frame onto the execution-context stack for the current goal, becoming its own PrologExecutionContext.goals (arg2p: currentGoal is the current goal with the substitution applied, when the caller already has it)
Combines createChild and appendRulesAndChoicePoints: the usual way StateRuleSelection moves into a non-tail rule call.
Whether variable is still relevant to this frame or any of its ancestors (i.e. occurs in relevantGoals, in the goals left of this frame or of an ancestor, or in the query). Used when popping a finished frame back to its parent (in it.unibo.tuprolog.argumentation.core.engine.fsm.StateGoalSelection) to filter the substitution handed up, discarding bindings for variables local to the finished sub-goal.
Last-call-optimization counterpart of createChild: reuses the current frame for the current goal (incrementing PrologExecutionContext.depth without growing the PrologExecutionContext.parent chain), used by StateRuleSelection for tail calls to avoid an unbounded execution-context stack.
Combines replaceWithChild and appendRulesAndChoicePoints: how StateRuleSelection moves into a last-call-optimized (tail) rule call.
The context an error raised in this one is reported in: the nearest one that is not throw/1