Documentation

MIPRE.Foundations.Halting.Lists

Bounded walks over lists, in the ambient model #

The programs with which the wrapper decider of Halting/Wrapper.lean performs the paper's format checks: the questions must be bit strings of the sampler's length, the answers bit strings within the answer-length budget, and equal questions must carry equal answers. All of them walk their input under a budget, so that their cost is the budget times the size of the input — the shape T · (|input| + 1) of Decider.TimeBoundAt — rather than a power of it.

Every walk copies the remainder of the lists at each step, which is what the ambient model charges; the cost bounds are (budget + 1) · (S + c) for S the size of the input.

The length of the right spine: the length of a list.

Equations
Instances For
    @[simp]
    theorem MIPRE.Cost.Data.spine_cons (a r : Data) :
    (a.cons r).spine = r.spine + 1

    The bit an element denotes: nil is false, anything else true.

    Equations
    Instances For

      Walk l against the budget u, checking that every element passed is a bit: nil on a non-bit, otherwise the pair of the remainders.

      Equations
      Instances For

        On a bit list and a list budget: the walk stops with the remainders.

        Equality of two bit lists, element by element.

        Equations
        Instances For
          theorem MIPRE.Cost.Data.eqBits_ofNat (a b : ℕ) :
          (ofNat a).eqBits (ofNat b) = decide (a = b)

          On unary numerals, eqBits is equality of the numbers: every element is nil, so the walk compares only the lengths.

          The walk of the normalization: last records whether the string so far is empty or ends in true.

          Equations
          Instances For
            theorem MIPRE.Cost.Data.canonWalk_iff (d : Data) (b : Bool) :
            d.canonWalk b = true ↔ ∃ (l : BitStr), d = encode l ∧ (l = [] → b = true) ∧ (l ≠ [] → List.getLast? l = some true)

            The walk computes the normalization test.

            Close a cost bound after the run has been built: unfold the sizes of the small constants and let omega finish.

            Equations
            Instances For

              The bounded bit walk #

              Body of bitWalkProg, on the state cons l u: stop with cons nil u if l is empty, with cons l nil if the budget is exhausted, with nil if the head of l is not a bit, and otherwise continue with the two tails.

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

                The bounded bit walk: on cons l u, compute bitWalk l u.

                Equations
                Instances For
                  theorem MIPRE.Cost.Prog.bitWalkBody_step (h l' c u' : Data) (hb : h.isBit = true) :
                  ∃ t ≤ l'.size + u'.size + 20, Eval [(h.cons l').cons (c.cons u')] bitWalkBody ((Data.nil.cons Data.nil).cons (l'.cons u')) t
                  theorem MIPRE.Cost.Prog.bitWalkBody_fail (h l' c u' : Data) (hb : h.isBit = false) :
                  ∃ t ≤ 20, Eval [(h.cons l').cons (c.cons u')] bitWalkBody (Data.nil.cons Data.nil) t
                  theorem MIPRE.Cost.Prog.bitWalkProg_runs (l u : Data) (env : Env) (S : ℕ) (hS : l.size + u.size ≤ S) :
                  ∃ t ≤ (u.spine + 1) * (S + 21), Eval (l.cons u :: env) bitWalkProg (l.bitWalk u) t

                  The bounded bit walk computes bitWalk l u, in time (|u| + 1) · (S + 21) for S dominating the sizes of l and u: linear in the input, times the budget.

                  Equality of bit lists #

                  Body of eqBitsProg, on the state cons l₁ l₂.

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

                    Equality of two bit lists: on cons l₁ l₂, compute encode (eqBits l₁ l₂).

                    Equations
                    Instances For
                      theorem MIPRE.Cost.Prog.eqBitsBody_cons_cons (h₁ l₁ h₂ l₂ : Data) :
                      ∃ t ≤ l₁.size + l₂.size + 20, Eval [(h₁.cons l₁).cons (h₂.cons l₂)] eqBitsBody (if h₁.bitOf = h₂.bitOf then (Data.nil.cons Data.nil).cons (l₁.cons l₂) else Data.nil.cons (encode false)) t
                      theorem MIPRE.Cost.Prog.eqBitsProg_runs (l₁ l₂ : Data) (env : Env) (S : ℕ) (hS : l₁.size + l₂.size ≤ S) :
                      ∃ t ≤ (l₁.spine + 1) * (S + 21), Eval (l₁.cons l₂ :: env) eqBitsProg (encode (l₁.eqBits l₂)) t

                      eqBitsProg computes eqBits l₁ l₂, in time (|l₁| + 1) · (S + 21) for S dominating the sizes.

                      Normalization of the parameter #

                      Body of the canonicity walk, on the state cons rest last.

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

                        normBinProg on d computes normBin d: the input itself if it is a canonical binary numeral, nil otherwise.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          theorem MIPRE.Cost.Prog.canonBody_nil (last : Data) :
                          ∃ t ≤ last.size + 20, Eval [Data.nil.cons last] canonBody (Data.nil.cons last) t
                          theorem MIPRE.Cost.Prog.canonLoop_runs (d : Data) (last : Bool) (env : Env) (S : ℕ) (hS : d.size + 3 ≤ S) :
                          ∃ t ≤ (d.spine + 1) * (S + 21), Eval (d.cons (encode last) :: env) canonBody.loop (encode (d.canonWalk last)) t

                          The canonicity loop computes canonWalk d last, in time (|d| + 1) · (S + 21).

                          theorem MIPRE.Cost.Prog.normBinProg_runs (d : Data) :
                          ∃ t ≤ (d.spine + 2) * (d.size + 25) + 3 * d.size + 10, normBinProg.Runs d d.normBin t

                          normBinProg computes the normalization, in time (|d| + 2) · (|d| + 25) + 3 |d| + 10.