class DusaSolution
A DusaSolution
is a queryable solution to a Dusa program returned by
solving a Dusa
instance.
Checking facts
has()
method
The has()
method is intended to check whether a relational proposition
exists in a solution.
An error will be raised if the number of args
is not equal to the number of
arguments that the proposition has.
get()
method
The get()
method is intended to check the value assigned to a functional
proposition. It returns the term associated with the
attribute.
An error will be raised if the number of args
is not equal to the number of
arguments that the proposition has (not counting the value), or if the
predicate name
is a Datalog predicate that does not have an is
value.
Querying solutions
lookup()
method
The lookup()
method on solutions is a powerful query mechanism. If your
program has a relational proposition path _ _
, then given only the first
argument 'path'
, lookup()
will return an iterator over all the paths.
Explore this example on val.town
This will print the following in some order:
Given the first argument 'path'
and the second argument 2
, lookup
will
return an iterator over all the second arguments B
such that there is a fact
path 2 B
.
Explore this example on val.town
This will print the following:
In Typescript terms, the lookup()
method has the following type:
For a functional proposition like name _ is _
, the effective type of the
lookup()
method is:
Enumerating all facts
facts()
The facts
method provides a list of all the
facts in a solution. The lookup()
method
is generally going to be preferable.