Reading and writing descriptions, in the ambient model #
The two programs that move between a datum and its postorder serialization
(Data.toBitsPost, Halting/Descriptions.lean):
Prog.parseProg: the stack machineData.stackRunon a bit string, returning the top of the final stack (Data.parse). The compressor's decider reads the description it was handed with it (Halting/Compressor.lean).Prog.serProg: the postorder serialization of a datum, by a loop over a list of pending items — a datum still to be written, or a marker for the closing1of a pair — accumulating the bits in reverse and reversing at the end. The compressor writes its output with it.
Both run in time quadratic in the size of their input: each step copies the remainder of the work list and the accumulator.
A pending item of the serializer: a datum to write (some d, as cons nil d) or the
closing 1 of a pair (none, as nil).
Equations
Instances For
The bits still to be written for a list of pending items.
Equations
Instances For
The measure of a list of pending items, decreasing along the serializer's loop.
Equations
- MIPRE.Cost.Data.serMeasure [] = 0
- MIPRE.Cost.Data.serMeasure (some d :: r) = 3 * d.size + 1 + MIPRE.Cost.Data.serMeasure r
- MIPRE.Cost.Data.serMeasure (none :: r) = 1 + MIPRE.Cost.Data.serMeasure r
Instances For
The same measure, on the data of the pending list (for the loop invariant).
Equations
- MIPRE.Cost.Data.nil.serMeasureD = 0
- (MIPRE.Cost.Data.nil.cons r).serMeasureD = 1 + r.serMeasureD
- ((a.cons d).cons r).serMeasureD = 3 * d.size + 1 + r.serMeasureD
Instances For
Close a cost bound after the run has been built, unfolding list encodings.
Equations
- MIPRE.Cost.Prog.tacticCost_omega₂ = Lean.ParserDescr.node `MIPRE.Cost.Prog.tacticCost_omega₂ 1024 (Lean.ParserDescr.nonReservedSymbol "cost_omega₂" false)
Instances For
The parser #
Body of parseProg, on the state cons bits stack: at the end, stop with the top of the
stack (nil if empty); on a 0, push nil; on a 1, pop two entries and push their pair,
leaving a stack with fewer than two entries alone.
Equations
- One or more equations did not get rendered due to their size.
Instances For
parseProg reads a serialization back.
The serializer #
Body of serProg, on the state cons pending acc: at the end, stop with acc; a marker
writes a 1; the datum nil writes a 0; a pair cons a b schedules a, b and a marker.
Equations
- One or more equations did not get rendered due to their size.
Instances For
serProg on d computes encode d.toBitsPost.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The serializer's loop, by the invariant "acc.reverse ++ serItems items is the target",
with the measure serMeasure and the size bound S₀.