Certified contiguous output partitions #
This module proves the general array theorem used by task-parallel einsum output generation. A partition may contain any number of adjacent chunks. Folding their arrays together in source order reconstructs the original finite function exactly.
One named physical output buffer together with its complete finite-function semantics.
Generated sequential kernels name this record as one auxiliary definition.
Executable code projects produce, while certificates project
toArray_produce; neither side needs to unfold the complete native loop.
- produce : Unit → Storage.Buffer α
Produce the complete physical output buffer.
Observing the produced buffer gives the complete finite function.
Instances For
Select a contiguous subrange of a finite function.
The range proof is erased. At runtime this adds start to the local index and
reads the corresponding value.
Instances For
One named parallel chunk together with its exact finite-function semantics.
Generated code names this record as one auxiliary definition. Executable code
projects produce, while certificates project toArray_produce; neither side
needs to unfold the named chunk body.
- produce : Unit → Storage.Buffer α
Produce the physical buffer for this contiguous range.
- toArray_produce : Storage.toArray (self.produce ()) = Array.ofFn (flatRange total start length hRange values)
Observing the produced buffer gives exactly the selected range.
Instances For
An ordered list of chunk producers covering the interval from start through
total.
Each producer returns exactly one contiguous physical-buffer range, and the
recursive index ensures that adjacent ranges have no gap or overlap. The final
constructor requires the accumulated start to equal total, so the partition
is complete.
- done
{α : Type u}
[storage : Storage α]
{total : ℕ}
{values : Fin total → α}
: OrderedFlatPartition total values total []
The empty suffix completes a partition once its start reaches
total. - next
{α : Type u}
[storage : Storage α]
{total : ℕ}
{values : Fin total → α}
{start length : ℕ}
{parts : List (Unit → Storage.Buffer α)}
(part : Unit → Storage.Buffer α)
(hRange : start + length ≤ total)
(hPart : Storage.toArray (part ()) = Array.ofFn (flatRange total start length hRange values))
(tail : OrderedFlatPartition total values (start + length) parts)
: OrderedFlatPartition total values start (part :: parts)
Prepend one certified contiguous producer to a partition of the remaining interval.
Instances For
Append a complete physical source buffer to a physical output buffer.
Instances For
Observing a complete physical-buffer append gives ordinary array append.
Appending to a fresh empty physical buffer returns the source buffer.
Appending every producer in an ordered partition after an existing prefix reconstructs the complete finite-function array.