Documentation

MIPRE.Foundations.Halting.Descriptions

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.

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
      @[simp]

      Running the stack machine over a bit string from a stack.

      Equations
      Instances For
        @[simp]
        theorem MIPRE.Cost.Data.stackRun_cons (bit : Bool) (x : BitStr) (s : List Data) :
        stackRun (bit :: x) s = stackRun x (stackStep s bit)
        theorem MIPRE.Cost.Data.stackRun_toBitsPost (d : Data) (rest : BitStr) (s : List Data) :
        stackRun (d.toBitsPost ++ rest) s = stackRun rest (d :: s)

        The stack machine reads a serialization by pushing the datum.

        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
            theorem MIPRE.Cost.Data.isBit_iff (d : Data) :
            d.isBit = true ↔ ∃ (b : Bool), d = ofBool b

            A datum is a canonical binary numeral: a list of bits, empty or ending in true.

            Equations
            Instances For

              Decoding a bit string succeeds only on its encoding.

              Nat.bits is canonical: empty or ending in true.

              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
              Instances For

                The parameter a datum denotes, after normalization.

                Equations
                Instances For
                  @[simp]

                  The normalized parameter is the encoding of the number it denotes.

                  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.

                  Normalization does not grow a datum: it is either the datum or nil.

                  theorem MIPRE.Cost.Data.natOf_lt (d : Data) :
                  d.natOf < 2 ^ d.size

                  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.

                  One step of the stack machine adds at most one to the total size on the stack: a 0 pushes nil, and a 1 replaces two entries by one node above them.

                  So the whole run adds at most the length of the string.

                  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 #

                  theorem MIPRE.Cost.Data.size_eq_recD (d : Data) :
                  d.size = recD 1 (fun (x x_1 : Data) (ra rb : ℕ) => ra + rb + 1) d

                  The size of data is a tree recursion.

                  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.