1 package DX::SearchState;
3 use Types::Standard qw(Maybe);
4 use DX::Step::Backtrack;
5 use DX::Step::InvokeNextPredicate;
8 has current_hypothesis => (is => 'ro', isa => Hypothesis, required => 1);
10 has next_step => (is => 'ro', isa => Maybe[Step]);
12 has propositions => (is => 'ro', isa => PropositionSequence, required => 1);
14 has alternatives => (is => 'ro', isa => AlternativeList, required => 1);
16 has is_solution_state => (is => 'ro', required => 1);
18 sub next_proposition {
19 my ($self, $hyp) = @_;
20 $hyp ||= $self->current_hypothesis;
21 $self->propositions->members->[
22 $hyp->resolved_propositions->resolved_count
27 my ($class, $hyp, $props) = @_;
29 current_hypothesis => $hyp,
31 propositions => $props,
34 next_step => DX::Step::InvokeNextPredicate->new(
35 proposition => $props->members->[0],
37 is_solution_state => 0,
39 : ( is_solution_state => 1 )
46 return undef unless my $step = $self->next_step;
47 return $step->apply_to($self);
52 my ($first_alt, @rest_alt) = @{$self->alternatives};
53 return undef unless $first_alt;
54 trace 'search.backtrack.forced' => $first_alt->[0];
56 next_step => DX::Step::Backtrack->new,