Documentation

MIPRE.Foundations.Repeat.MapLoop

The block loop of the repeated sampler #

The repeated sampler of thm:parallel-repetition answers a marginal, linear or factor query on ๐”ฝโ‚‚^{k s} by cutting the vectors of the query into k blocks of s coordinates, asking the input sampler about each block, and concatenating the answers (planning/repetition-verifier.md, R3(b)). This module is that loop:

The loop is uniform in the query kind: the blocks of an absent vector are empty, which is the encoding of the empty bit string, so a marginal or factor query โ€” whose last component is empty โ€” goes through the same code as a linear one. The answers are a parameter f of the run lemma, known only on the pairs of blocks that occur: on well-formed queries they are the input sampler's answers, on arbitrary ones whatever it halts with.

Cutting a block off two lists #

On cons us (cons remU remY) with us the unary numeral s: the pair of remainders and the pair of blocks, cons remU' (cons remY' (cons blockU blockY)).

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

    The cost of pairTakeProg on a numeral s and lists of sizes U, Y.

    Equations
    Instances For
      theorem MIPRE.Cost.Prog.pairTakeProg_runs (s : โ„•) (remU remY : List Data) :
      โˆƒ t โ‰ค pairTakeCost s (Data.list remU).size (Data.list remY).size, pairTakeProg.Runs ((Data.ofNat s).cons ((Data.list remU).cons (Data.list remY))) ((Data.list (List.drop s remU)).cons ((Data.list (List.drop s remY)).cons ((Data.list (List.take s remU)).cons (Data.list (List.take s remY))))) t

      The loop body #

      def MIPRE.Cost.Prog.mapCtx (sD nD kD wD jD : Data) :

      The context of the loop: the input sampler Sฬ„ and the fixed part (n, kind, w, j) of the query.

      Equations
      Instances For
        def MIPRE.Cost.Prog.mapQuery (sD nD kD wD jD cU cY : Data) :

        The input of the universal machine for one block: (Sฬ„, (n, kind, w, j, blockU, blockY)).

        Equations
        Instances For
          def MIPRE.Cost.Prog.mapState (s : โ„•) (remU remY : List Data) (ctx : Data) (acc : List Data) :

          The state of the loop.

          Equations
          Instances For

            The body of the block loop, with univ the universal machine.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem MIPRE.Cost.Prog.mapBody_stop (univ : Prog) (s : โ„•) (remY : List Data) (ctx : Data) (acc : List Data) :
              โˆƒ t โ‰ค (Data.list acc).size + 8, Eval [mapState s [] remY ctx acc] univ.mapBody (Data.nil.cons (Data.list acc)) t

              The cost of one iteration, in the numeral s, the sizes U, Y of the remainders, C of the context, A of the accumulator, and the cost Tu of the call.

              Equations
              Instances For
                theorem MIPRE.Cost.Prog.mapBody_step {univ : Prog} (hU : WellScoped 1 univ) (s : โ„•) (h : Data) (l remY : List Data) (sD nD kD wD jD : Data) (acc : List Data) {r : Data} {tu : โ„•} (hr : Eval [mapQuery sD nD kD wD jD (Data.list (List.take s (h :: l))) (Data.list (List.take s remY))] univ r tu) :
                โˆƒ t โ‰ค mapStepCost s (Data.list (h :: l)).size (Data.list remY).size (mapCtx sD nD kD wD jD).size (Data.list acc).size tu, Eval [mapState s (h :: l) remY (mapCtx sD nD kD wD jD) acc] univ.mapBody ((Data.nil.cons Data.nil).cons (mapState s (List.drop s (h :: l)) (List.drop s remY) (mapCtx sD nD kD wD jD) (r.toList.reverse ++ acc))) t

                One iteration: the block is cut, the call made, its answer pushed reversed onto acc.

                def MIPRE.Cost.Prog.mapAcc (f : List Data โ†’ List Data โ†’ Data) (pairs : List (List Data ร— List Data)) (acc : List Data) :

                The output of the loop from the pairs of blocks: the answers, each reversed, in reverse order, in front of acc.

                Equations
                Instances For
                  theorem MIPRE.Cost.Prog.mapAcc_reverse (f : List Data โ†’ List Data โ†’ Data) (pairs : List (List Data ร— List Data)) :
                  (mapAcc f pairs []).reverse = (List.map (fun (p : List Data ร— List Data) => (f p.1 p.2).toList) pairs).flatten

                  Reversing the output with acc = [] gives the concatenation of the answers.

                  theorem MIPRE.Cost.Prog.mapAcc_cons (f : List Data โ†’ List Data โ†’ Data) (p : List Data ร— List Data) (pairs : List (List Data ร— List Data)) (acc : List Data) :
                  mapAcc f (p :: pairs) acc = mapAcc f pairs ((f p.1 p.2).toList.reverse ++ acc)

                  The per-iteration budget of the loop, in a bound Z on the sizes in play.

                  Equations
                  Instances For
                    theorem MIPRE.Cost.Prog.pairTakeCost_le {s U Y Z : โ„•} (h : s + U + Y โ‰ค Z) :
                    pairTakeCost s U Y โ‰ค 17 * (Z + 30) ^ 2
                    theorem MIPRE.Cost.Prog.mapStepCost_le {s U Y C A Tu Z : โ„•} (h : s + U + Y + C + A + Tu โ‰ค Z) :
                    mapStepCost s U Y C A Tu + 1 โ‰ค mapIter Z
                    theorem MIPRE.Cost.Prog.mapLoop_runs {univ : Prog} (hU : WellScoped 1 univ) {s : โ„•} (hs : 0 < s) (sD nD kD wD jD : Data) (f : List Data โ†’ List Data โ†’ Data) (Tu Z : โ„•) (remU remY acc : List Data) (env : Env) :
                    (โˆ€ p โˆˆ Data.chunkPairs s hs remU remY, โˆƒ t โ‰ค Tu, Eval [mapQuery sD nD kD wD jD (Data.list p.1) (Data.list p.2)] univ (f p.1 p.2) t) โ†’ s + (Data.list remU).size + (Data.list remY).size + (mapCtx sD nD kD wD jD).size + (Data.list acc).size + remU.length * (Tu + 1) + Tu โ‰ค Z โ†’ โˆƒ t โ‰ค (remU.length + 1) * mapIter Z, Eval (mapState s remU remY (mapCtx sD nD kD wD jD) acc :: env) univ.mapBody.loop (Data.list (mapAcc f (Data.chunkPairs s hs remU remY) acc)) t

                    The block loop. With f the answer of the universal machine on each pair of blocks that occurs, at cost at most Tu, and Z a bound on the sizes in play, the loop from (s, remU, remY, ctx, acc) outputs mapAcc f (chunkPairs s remU remY) acc in time (|remU| + 1) ยท mapIter Z.