Data enumerator
Formal definition
Let denote the set of all values that data expression
can attain.
Definition (Enumerable sort)
A sort is enumerable iff there exists a function
that maps an arbitrary data expression
of
sort
to a finite set of closed data expressions
such that
By applying repeatedly to the non-closed sub-results,
a tree expansion is obtained whose leaves form a finite representation of
. For sorts that are finite (see Finiteness of sorts), this tree is always finite.
Algorithm
Given an expression of type
and a list of data
variables
, the enumerator algorithm iteratively reports expressions
that can be obtained from
by assigning constant values to the variables in
.
Let be a rewriter on expressions of type
,
a
rewriter on data expressions, and
a substitution on data
variables applied during rewriting with
. Let
be a queue of
pairs
, with
a non-empty list of
variables and
an expression. The function
is a user-supplied callback; whenever it
returns true the while loop is interrupted. The predicate
discards an expression so that it does not enter the
queue
. The predicate
accepts an expression
as a solution even when it still has a non-empty variable list. By default
both
and
always return false.
The
predicate is not merely cosmetic: termination of
the enumeration may depend on it. Enumeration is often used to find solutions
of boolean predicates; in that case
typically rejects
and
accepts
,
or vice versa.
The
case in the algorithm applies to finite function
sorts and finite sets; all elements of such sorts can be obtained via the
function . For each sort
a non-empty set of
constructor functions
is assumed to be defined.
Remarks
The algorithm works both for data expressions and PBES expressions.
In the case of data expressions,
and
may coincide.
The algorithm can be extended to also return the assignments corresponding to a solution.