Enumerating the distinct values of a sequence of partial outputs #
A sequence f : ℕ → Option β lists, possibly with repetitions and gaps, the elements of its range
{b | ∃ n, f n = some b}. Typically f n decodes n as a program and a time bound and reports
the output of the program if it halts in time, so the range is a computably enumerable set.
Nat.distinctValues f n lists the distinct values among f 0, …, f (n - 1) in order of first
appearance, and Nat.nthDistinctValue f i is the i-th distinct value of the whole sequence,
found by an unbounded search over n. When the range is finite, every element has an index below
the size of the range. When f depends primitive recursively on a parameter, both are
computable in the parameter: this is the enumeration step in counting arguments of Kolmogorov
complexity, which describe an element of a computably enumerable set by its index.
Main definitions #
Nat.distinctValues: the distinct values of a sequence up to a bound, in order of first appearance.Nat.nthDistinctValue: thei-th distinct value of a sequence, if there is one.
Main results #
Nat.mem_distinctValues,Nat.nodup_distinctValues,Nat.distinctValues_prefix: the lists contain exactly the values seen so far, without repetitions, and grow by extension.Nat.length_distinctValues_le_ncard,Nat.exists_length_distinctValues_eq_ncard: for a finite range, the lists are no longer than the range and eventually as long as it.Nat.mem_nthDistinctValue_iff,Nat.exists_eq_some_of_mem_nthDistinctValue,Nat.exists_mem_nthDistinctValue_of_finite: thei-th distinct value is in the range, and, for a finite range, every element of it is thei-th distinct value for someibelow its size.Primrec.distinctValues,Partrec.nthDistinctValue: computability in a parameter.
The distinct values among f 0, …, f (n - 1), in order of first appearance. The body is
exposed so that concrete lists can be evaluated by decide.
The lists of distinct values grow by extension.
The distinct values up to n are the values f j = some b with j < n.
The i-th distinct value of the sequence f, in order of first appearance: the search for a
bound n such that distinctValues f n has an i-th entry.
The distinct values of f are in its range.
The distinct values of a sequence depending primitive recursively on a parameter are primitive recursive in the parameter and the bound.
The i-th distinct value of a sequence depending primitive recursively on a parameter is
partial recursive in the parameter and i.