Documentation

MIPRE.Foundations.Repeat.Prims

Primitives of the repeated sampler and decider #

Three loops of the ambient model that the programs of thm:parallel-repetition share (planning/repetition-verifier.md, R3(a)–(b)):

The elements of a datum read as a list: every datum is a cons-chain ending in nil.

Equations
Instances For
    theorem MIPRE.Cost.Data.size_list_append (l₁ l₂ : List Data) :
    (list (l₁ ++ l₂)).size + 1 = (list l₁).size + (list l₂).size
    def MIPRE.Cost.Data.chunk {α : Type u_1} (s i : ℕ) (l : List α) :
    List α

    The i-th piece of s elements of a list.

    Equations
    Instances For
      @[irreducible]

      The pieces of s elements of two lists, in lockstep: as many as the first list has, the second one's possibly shorter or empty.

      Equations
      Instances For
        theorem MIPRE.Cost.Data.chunkPairs_nil (s : ℕ) (hs : 0 < s) (y : List Data) :
        chunkPairs s hs [] y = []
        theorem MIPRE.Cost.Data.chunkPairs_cons (s : ℕ) (hs : 0 < s) (h : Data) (l y : List Data) :
        chunkPairs s hs (h :: l) y = (List.take s (h :: l), List.take s y) :: chunkPairs s hs (List.drop s (h :: l)) (List.drop s y)
        theorem MIPRE.Cost.Data.chunkPairs_of_ne_nil (s : ℕ) (hs : 0 < s) {l : List Data} (hl : l ≠ []) (y : List Data) :
        theorem MIPRE.Cost.Data.chunkPairs_eq_ofFn (s : ℕ) (hs : 0 < s) (k : ℕ) (l y : List Data) :
        l.length = k * s → chunkPairs s hs l y = List.ofFn fun (i : Fin k) => (chunk s (↑i) l, chunk s (↑i) y)

        With the first list of length k · s, the pairs are the k pairs of pieces.

        theorem MIPRE.Cost.Data.size_le_of_mem_chunkPairs (s : ℕ) (hs : 0 < s) (l y : List Data) (p : List Data × List Data) :
        p ∈ chunkPairs s hs l y → (list p.1).size ≤ (list l).size ∧ (list p.2).size ≤ (list y).size

        Every piece is a piece of the list it came from: the sizes are bounded.

        theorem Nat.bits_two_pow_mul (m : ℕ) {s : ℕ} (hs : s ≠ 0) :

        The binary digits of 2^m · s, for s ≠ 0: m zeros then those of s.

        Prepending e · (|bl| + |bn|) copies of nil #

        Body of the power walk: on the state cons u (cons bl (cons bn acc)), stop with acc if the counter u is empty, and otherwise walk bn then bl, prepending a nil to acc per element, and decrement u.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          def MIPRE.Cost.Prog.powState (e : ℕ) (bl bn acc : List Data) :

          The state of the power walk.

          Equations
          Instances For
            theorem MIPRE.Cost.Prog.powBody_stop (bl bn acc : List Data) :
            ∃ t ≤ (Data.list acc).size + 8, Eval [powState 0 bl bn acc] powBody (Data.nil.cons (Data.list acc)) t

            The size of a list of m copies of nil in front of acc.

            theorem MIPRE.Cost.Prog.powBody_step (e : ℕ) (bl bn acc : List Data) :
            ∃ t ≤ (bn.length + 1) * ((Data.list bl).size + (Data.list bn).size + (Data.list acc).size + 2 * bn.length + 13) + (bl.length + 1) * ((Data.list bl).size + (Data.list bn).size + (Data.list acc).size + 2 * bn.length + 2 * bl.length + 13) + 4 * ((Data.list bl).size + (Data.list bn).size + (Data.list acc).size + 2 * e + 2 * bn.length + 2 * bl.length) + 40, Eval [powState (e + 1) bl bn acc] powBody ((Data.nil.cons Data.nil).cons (powState e bl bn (List.replicate (bl.length + bn.length) Data.nil ++ acc))) t

            One iteration of the power walk.

            The cost of the power walk with counter e on lists of total length L and total size Σ: (e + 1) rounds, each polynomial in the sizes.

            Equations
            Instances For
              theorem MIPRE.Cost.Prog.powLoop_runs (e : ℕ) (bl bn acc : List Data) (env : Env) :
              ∃ t ≤ powCost e (bl.length + bn.length) ((Data.list bl).size + (Data.list bn).size + (Data.list acc).size), Eval (powState e bl bn acc :: env) powBody.loop (Data.list (List.replicate (e * (bl.length + bn.length)) Data.nil ++ acc)) t

              The power walk: e rounds, each prepending |bl| + |bn| copies of nil.

              Doubling a unary numeral #

              Body of the doubling loop: on the state cons u acc, stop with acc if the counter u is empty, and otherwise replace acc by acc ++ acc (reversal onto itself, acc being a list of nils) and decrement u.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                theorem MIPRE.Cost.Prog.dblBody_step (m a : ℕ) :
                ∃ t ≤ (a + 1) * (4 * a + 14) + 10 * a + 2 * m + 30, Eval [(Data.ofNat (m + 1)).cons (Data.ofNat a)] dblBody ((Data.nil.cons Data.nil).cons ((Data.ofNat m).cons (Data.ofNat (2 * a)))) t

                The cost of the doubling loop: m rounds from the numeral a, the last on 2^m a.

                Equations
                Instances For
                  theorem MIPRE.Cost.Prog.dblLoop_runs (m a : ℕ) (env : Env) :
                  ∃ t ≤ dblCost m a, Eval ((Data.ofNat m).cons (Data.ofNat a) :: env) dblBody.loop (Data.ofNat (2 ^ m * a)) t

                  The doubling loop: dblBody on (m, a) computes 2^m · a.

                  Taking a prefix of given unary length #

                  Body of the take loop: on the state cons u (cons rem cur), stop with cons rem cur if the counter u is empty or rem is; otherwise move the head of rem onto cur and decrement.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    def MIPRE.Cost.Prog.takeState (c : ℕ) (rem cur : List Data) :

                    The state of the take loop.

                    Equations
                    Instances For
                      theorem MIPRE.Cost.Prog.takeBody_stop_empty (c : ℕ) (cur : List Data) :
                      ∃ t ≤ (Data.list cur).size + 2 * c + 12, Eval [takeState (c + 1) [] cur] takeBody (Data.nil.cons ((Data.list []).cons (Data.list cur))) t
                      theorem MIPRE.Cost.Prog.takeBody_step (c : ℕ) (h : Data) (rem cur : List Data) :
                      ∃ t ≤ (Data.list rem).size + h.size + (Data.list cur).size + 2 * c + 18, Eval [takeState (c + 1) (h :: rem) cur] takeBody ((Data.nil.cons Data.nil).cons (takeState c rem (h :: cur))) t
                      theorem MIPRE.Cost.Prog.takeLoop_runs (c : ℕ) (rem cur : List Data) (env : Env) :
                      ∃ t ≤ (c + 1) * ((Data.list rem).size + (Data.list cur).size + 2 * c + 20), Eval (takeState c rem cur :: env) takeBody.loop ((Data.list (List.drop c rem)).cons (Data.list ((List.take c rem).reverse ++ cur))) t

                      The take loop: c elements moved from rem onto cur, reversed.