Documentation

LeanPool.PointwiseComposition.CategoricalRiceShapiro.ArithmeticCode.EncodedList

Supporting results for pointwise provable equality.

Codes acting on an encoded list #

A list of natural numbers is represented by its Encodable code, in which the empty list is 0 and a cons cell is the successor of a Cantor pair of head and tail. codeListHead? and codeListTail invert that representation, and codeListDrop iterates the tail by primitive recursion, so that codeListGet? reads the entry at an index as an encoded Option. codeListLength minimizes the number of entries that must be dropped to reach the empty list, and codeOptionBind is the bind of the encoded option monad.

Only the code constructions are given here. The standard computation theorems over the natural numbers are not part of this migration.

The head of an encoded list, as an encoded Option.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    The tail of an encoded list.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Iterated tail of an encoded list, as a code in the index and the list.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        The entry of the encoded list dlist at index didx, as an encoded Option.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          The length of an encoded list: the least index at which dropping that many entries leaves the empty list.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            Bind on an encoded Option: run dk on the payload when dopt encodes some, and return the encoding of none otherwise.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              codeListDrop applies one fixed arity-two code to its two arguments.

              A context that changes only those arguments is therefore a composition context, to which eval_comp_congr applies. The arity-two code is an implementation detail and stays private; a proof reaches it by rewriting with this equation.

              One-layer view of an encoded list #

              The pinned encoding of List ℕ satisfies encode [] = 0 and encode (x :: xs) = Nat.pair x (encode xs) + 1. The two constructors below name that layer as codes; no arithmetic property of the encoding is asserted here.

              The encoded list with head dx and tail dt.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                The recursion that rebuilds an encoded list with one entry appended: at recursion argument i the entry at index length - (i + 1) is consed onto the list built so far, starting from the singleton [dx].

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Append dx to the end of the encoded list dlist.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    codeListSnoc binds the length of its list argument as the recursion argument of one fixed arity-r + 1 code.

                    The recursion is an implementation detail and stays private; a proof reaches it by rewriting with this equation.