follow alternative rspace entries without backtracking, explicitly resolve
[scpubgit/DX.git] / lib / DX / Proposition.pm
index d67e2de..c32354d 100644 (file)
@@ -1,10 +1,28 @@
 package DX::Proposition;
 
+use DX::Step::ConsiderProposition;
+
 use DX::Class;
 
-has predicate => (is => 'ro', required => 1);
+has predicate => (is => 'ro', isa => Str, required => 1);
+
+has args => (is => 'ro', isa => ArrayRef[Str|Value], required => 1);
 
-has args => (is => 'ro', required => 1);
+has introduced_names => (is => 'ro', isa => HashRef[One], required => 1);
+
+has required_names => (is => 'ro', isa => HashRef[One], required => 1);
+
+sub for_deparse {
+  my ($self) = @_;
+  [ statement => [
+    [ symbol => $self->predicate ],
+    map {
+      ref($_)
+        ? $_
+        : [ symbol => $self->introduced_names->{$_} ? "?$_" : $_ ]
+    } @{$self->args}
+  ] ];
+}
 
 sub resolve_for {
   my ($self, $scope) = @_;
@@ -13,7 +31,12 @@ sub resolve_for {
   #if (my $step = $scope->known_facts->resolution_step_for($predicate, @args)) {
   #  return $step;
   #}
-  return $predicate->resolution_step_for(@args);
+  return $predicate->resolution_step_for($self, @args);
+}
+
+sub consider_step {
+  my ($self) = @_;
+  DX::Step::ConsiderProposition->new(proposition => $self);
 }
 
 1;