Descriptions as bit strings: the postorder serialization of data #
Blueprint rem:compression-abstract, item 1: the strings of the compressibility criterion are
descriptions, pairs (λ, decider) of a parameter and a decider program. This file fixes how
such a pair travels as a bit string.
A pair is data (cons (encode λ) (encode decider)), and data is serialized in postorder:
nil ↦ 0, cons a b ↦ a · b · 1 (Data.toBitsPost). Postorder, rather than the preorder
Data.toBits, because it is read back by a stack machine (Data.stackStep): a 0 pushes
nil, a 1 pops two entries and pushes their pair. A loop of the ambient model can run a stack
machine on a bit string, whereas a recursive-descent reader would need recursion; the ambient
program is in Halting/Lists.lean, this file has the mathematics and the primitive recursive
versions.
Data.toBitsPost,Data.stackRun,Data.parse: the serialization, the stack machine and the total reader (the top of the final stack,nilfor an empty stack), with the round tripData.parse_toBitsPost.Data.normBin: a total normalization of the parameter, the identity on canonical binary numerals (encode nforn : ℕ) andnil(encode 0) elsewhere;Data.natOfreads it. Every string thereby names a parameter and a decider (descLam,descDecD), and the wrapper decider ofHalting/Wrapper.leaninterprets the raw data the same way, so that no validity condition on strings is needed anywhere.
Each of these is also given in primitive recursive form, Data.parse and Data.natOf among
them, together with Data.primrec_size: the level at which the halting reduction runs is
2 ^ (K + 1 + esize e), so the size of an encoding has to be computable.
Postorder serialization #
Postorder serialization of data: nil ↦ 0, cons a b ↦ a · b · 1.
Equations
Instances For
One step of the stack machine: a 0 pushes nil; a 1 pops b then a and pushes
cons a b, and does nothing on a stack with fewer than two entries.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Running the stack machine over a bit string from a stack.
Equations
Instances For
The total reader: the top of the final stack, nil for an empty stack.
Equations
Instances For
Primitive recursiveness #
The parameter: canonical binary numerals #
A datum is a bit: nil or cons nil nil.
Equations
Instances For
A datum is a canonical binary numeral: a list of bits, empty or ending in true.
Equations
- d.isCanonBin = match MIPRE.Cost.decode d with | some l => decide (l = [] ∨ List.getLast? l = some true) | none => false
Instances For
A canonical bit string is the binary expansion of the number it denotes.
Total normalization of a parameter: canonical binary numerals are kept, everything else
reads as 0.
Equations
- d.normBin = if d.isCanonBin = true then d else MIPRE.Cost.Data.nil
Instances For
The parameter a datum denotes, after normalization.
Equations
- d.natOf = (MIPRE.Cost.decode d.normBin).getD 0
Instances For
How large a parameter a short string can denote #
The bound a string of length L places on the number it denotes. Obligation O4 of the
halting reduction needs it: the answer budget the classes are read with at level n grows
with the described string's own compression parameter (MIPRE.Halting.ansBound), while the
compression theorem's completeness clause supplies strategies at a budget fixed by the
compressor's output, so the two can only be related through a bound on that parameter.
A datum denotes a number smaller than 2 to its size. Through
encode_natOf, the normalized datum is the binary encoding of the number it denotes, so
the number has at most d.size binary digits.
What a string of length L can parse to: a datum of size at most L, or nil when
the run leaves the stack empty.
The size of data #
The size of data is primitive recursive, hence so is esize of anything whose encoding
is: Cost.esize a = (encode a).size. The halting reduction needs it for the level
2 ^ (K + 1 + esize e) at which the recursion runs.