NAME
Logic::Relational::Query - Manages the execution and backtracking search of a query.
SYNOPSIS
use Logic::Relational::Query;
my $query = Logic::Relational::Query->new(
program => $program,
goals => [$goal],
predicates => $predicates_snapshot,
);
while (my $solution = $query->next) {
...
}
DESCRIPTION
Logic::Relational::Query executes the logical goals using a depth-first search and an explicit agenda of execution states. This design avoids deep recursion or complex mutable call stacks, while supporting ancestor cycle pruning and subgoal memoization.
METHODS
new
Constructor. Takes program (Program), goals (arrayref), and predicates (snapshot of the predicates hash).
trace
Sets or returns the trace event callback coderef.
next
Performs the search step. Returns the next Logic::Relational::Solution object, or undef if all solutions have been exhausted.
reify_solution
Constructs a Logic::Relational::Solution object from a successful execution state.
is_true
Returns 1 if the query succeeds at least once, 0 otherwise.
is_success
Alias for is_true.
all
Returns all solutions (up to limit, default 10,000).
all_values
Returns all bindings for the given variable across all solutions.
distinct_values
Returns unique bindings for the given variable in discovery order.
all_tuples
Extracts arrayref tuples for an arrayref of variables across all solutions, deduplicating tuples by default (pass distinct => 0 to keep duplicates).
first_value
Returns the variable's value from the first solution, or undef.
value
Alias for first_value.