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.
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).
Example
Since functional and relational propositions are actually the same
thing, either has()
or get()
can be used with any proposition.
In a solution with propositions of the form node _
, edge _ _
, and
color _ is _
, the implied Typescript types for has()
and get()
are as follows:
These can be used like this:
Explore this example on StackBlitz
Enumerating all facts
facts
getter
The facts
getter provides an iterator over all the facts
in a solution.
Explore this example on StackBlitz
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 StackBlitz
This will print the following:
Given the first argument 'path'
and the second argument 2n
, lookup
will
return an iterator over all the second arguments B
such that there is a fact
path 2 B
.
Explore this example on StackBlitz
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: