1 package DX::Step::ResolveProposition;
3 use DX::Step::EnterRecheck;
4 use DX::Step::Backtrack;
6 use DX::Utils qw(expand_deps);
10 with 'DX::Role::Step';
12 has resolves => (is => 'lazy', init_arg => undef, builder => sub {
14 $self->resolution_space->proposition;
17 has resolution_space => (is => 'ro', isa => ResolutionSpace);
19 has current_resolution => (is => 'lazy', init_arg => undef, builder => sub {
21 $self->resolution_space->next_resolution;
24 has actions => (is => 'lazy', init_arg => undef, builder => sub {
26 $self->current_resolution->actions;
29 has depends_on => (is => 'lazy', init_arg => undef, builder => sub {
31 expand_deps($self->current_resolution->veracity_depends_on);
34 has alternative_step => (is => 'lazy', init_arg => undef, builder => sub {
36 my $rspace = $self->resolution_space->remaining_resolution_space;
37 return undef unless @{$rspace->members};
38 return $rspace->next_step;
42 my ($self, @actions) = @_;
43 $self->but(actions => [ @actions, @{$self->actions} ]);
46 sub but_with_dependencies_on {
47 my ($self, @deps) = @_;
48 $self->but(depends_on => [ @{$self->depends_on}, @deps ]);
52 my ($self, $old_ss) = @_;
53 trace resolve => [ statement => [
54 [ symbol => 'resolve' ],
57 [ symbol => 'proposition' ],
58 @{$self->resolves->for_deparse->[1]},
62 [ symbol => 'actions' ],
63 [ block => $self->actions ],
67 [ symbol => 'depends_on' ],
70 [ symbol => (split '::', ${$_->[0]})[-1] ],
71 [ value_path => [ @{$_}[1..$#$_] ] ]
72 ] ], @{$self->depends_on}
78 if (my $prop = $old_ss->next_proposition) {
79 DX::Step::ConsiderProposition->new(
83 $old_ss->on_solution_step
86 my $ss = $old_ss->but(
89 [ $self->resolution_space, $old_ss ],
90 @{$old_ss->decisions_taken}
93 my $new_ss = $self->_apply_to_ss($ss);
94 return $ss->but(next_step => DX::Step::Backtrack->new) unless $new_ss;
99 my ($self, $old_ss) = @_;
100 my $old_hyp = $old_ss->current_hypothesis;
101 (my $hyp, my @recheck) = $old_hyp->with_resolution(
102 $self->resolves, $self->depends_on, $self->actions
104 return undef unless $hyp;
105 return $self->_recheck_for(
106 $old_ss->but(current_hypothesis => $hyp),
112 my ($self, $old_ss, @recheck) = @_;
114 return $old_ss unless @recheck;
116 my $ss = $old_ss->but(
117 next_step => DX::Step::EnterRecheck->new(
118 proposition_list => \@recheck,
119 on_completion_step => $old_ss->next_step,
120 on_failure_step => DX::Step::Backtrack->new,