Documentation

MIPRE.Foundations.Halting.Compressor

The compressor's decider: the program #

Obligation O4 of blueprint rem:compression-abstract, the program half. The compressor of the halting reduction takes a succinct description (c, n) of a string x and returns a string denoting the compressed verifier of the verifier of x frozen at index 2n + 1: its parameter is λ(n), and its decider — the datum a string carries — is the program haltProg below with (c, n, λ(n)) hardcoded. This module is that program and its acceptance agreement, CompressorSpec.accepts_compr; the accounting is separate.

The decider is the paper's machine 𝓕 (recursive.tex, fig:halt_f) with the recursion removed: the paper's 𝓕 hardcodes its own description and compresses the verifier it is the decider of, while here the string to compress is read from the description c by bit queries — the reading is what the compressibility criterion's succinct descriptions make possible — and the verifier compressed is the string's own, frozen. The paper's Step 2, running 𝓜 for n steps, is the criterion's business and does not appear.

The program prepProg G U does everything but the last step, and always halts on a succinct description:

  1. readProg U.univ: read x from c by bit queries 0, 1, 2, … through the universal machine, stopping at the out-of-range marker of bitQueryAnswer;
  2. parseProg, then the two projections and normBinProg: the parameter encode (descLam x) and the decider datum descDecD x;
  3. G.samplerProg.code: the encoded sampler program sampData G x;
  4. wrapBuildProg U.univ: the encoded wrapped decider decProgData G U x, which is encode (Vof G U x).decider.prog;
  5. freezeBuildProg twice at index 2n + 1: the encoded programs of the frozen verifier;
  6. G.compress.code on ((frozen sampler, frozen decider), λ(n)): the encoded compressed decider.

Then haltProg G U runs it through the universal machine on the decider's own input, and returns what the universal machine does. Forward runs of each stage compose to a forward run of haltProg; the inversion (haltProg_runs_inv) is three cases and determinism, the preparation being a single closed program with an unconditional run, and gives the acceptance agreement haltProg_accepts_iff.

Every stage carries an explicit cost, in the sizes of what it is handed, so that the accounting can be done from these lemmas alone.

Reading a string from its succinct description #

readProg univ on encode c: loop over i = 0, 1, 2, …, running univ on cons (encode c) (encode i), until the answer is the out-of-range marker ofNat 2; the bits answered are accumulated in reverse and reversed at the end. On a succinct description of x the answers are bitQueryAnswer x i, so the result is encode x.

The loop state is cons cD (cons iD acc): the description, the index in binary, and the bits read so far, most recent first.

The body of the reading loop. After taking the state apart (cD at 2, iD at 0, acc at 1), it runs univ on cons cD iD. The answer nil is the bit false, cons nil nil the bit true, and anything else — the marker ofNat 2 = cons nil (cons nil nil) — stops the loop with the accumulator. On a bit, the index is incremented with incProg and the bit pushed onto the accumulator.

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

      readProg univ on encode c: the loop from the state cons (encode c) (cons nil nil) — index 0, nothing read — followed by the reversal of the accumulator.

      Equations
      Instances For
        def MIPRE.Cost.Prog.readState (cD : Data) (x : BitStr) (i : ℕ) :

        The state of the reading loop after i bits of x have been read.

        Equations
        Instances For
          def MIPRE.Cost.Prog.readEnv (cD iD acc ans : Data) :

          The environment after the body has taken the state apart and queried the description.

          Equations
          Instances For
            theorem MIPRE.Cost.Prog.readBody_pre {univ : Prog} (cD : Data) (hU : WellScoped 1 univ) {iD acc ans : Data} {t : ℕ} (h : univ.Runs (cD.cons iD) ans t) {r : Data} {t' : ℕ} (hc : Eval (readEnv cD iD acc ans) readTail r t') :
            Eval [cD.cons (iD.cons acc)] univ.readBody r (t' + t + 2 * cD.size + 2 * iD.size + 10)
            theorem MIPRE.Cost.Prog.readBody_bit {univ : Prog} (cD : Data) (hU : WellScoped 1 univ) {iD acc : Data} {i : ℕ} (hi : iD = encode i) (b : Bool) {t : ℕ} (h : univ.Runs (cD.cons iD) (encode b) t) :
            ∃ t' ≤ t + 3 * cD.size + 4 * iD.size + acc.size + 2 * ((i.size + 2) * (8 * esize i + 8 * i.size + 60)) + 30, Eval [cD.cons (iD.cons acc)] univ.readBody ((Data.nil.cons Data.nil).cons (cD.cons ((encode (i + 1)).cons ((encode b).cons acc)))) t'

            The body on a bit answer: continue with the next index and the bit pushed.

            theorem MIPRE.Cost.Prog.readBody_stop {univ : Prog} (cD : Data) (hU : WellScoped 1 univ) {iD acc : Data} {t : ℕ} (h : univ.Runs (cD.cons iD) (Data.ofNat 2) t) :
            Eval [cD.cons (iD.cons acc)] univ.readBody (Data.nil.cons acc) (t + 2 * cD.size + 2 * iD.size + acc.size + 15)

            The body on the marker: stop with the accumulator.

            noncomputable def MIPRE.Cost.Prog.readIter (U : UniversalMachine) (s n L : ℕ) :

            The cost of one iteration of the reading loop on a succinct description at parameter n of a string of length at most L, with the description of size s: the universal machine's overhead on a bit query, plus the bookkeeping.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem MIPRE.Cost.Prog.readLoop_runs (U : UniversalMachine) {c : Prog} {n : ℕ} {x : BitStr} (hsd : IsSuccinctDesc c n x) (env : Env) :
              ∃ t ≤ (List.length x + 1) * (readIter U (esize c) n (List.length x) + 1), Eval (readState (encode c) x 0 :: env) U.univ.readBody.loop (encode (List.reverse x)) t

              The reading loop reads the string. On a succinct description (c, n) of x, from the initial state, the loop of readBody U.univ stops with encode x.reverse.

              theorem MIPRE.Cost.Prog.readProg_runs (U : UniversalMachine) {c : Prog} {n : ℕ} {x : BitStr} (hsd : IsSuccinctDesc c n x) :
              ∃ t ≤ (List.length x + 1) * (readIter U (esize c) n (List.length x) + 1) + (List.length x + 2) * (4 * List.length x + 14) + esize c + 7, U.univ.readProg.Runs (encode c) (encode x) t

              readProg reads the string. On a succinct description (c, n) of x, readProg U.univ on encode c computes encode x.

              Building descriptions of programs #

              The compressor's decider has to assemble the descriptions of the wrapped decider and of the two frozen programs: Prog.ProgD.dWrapCore and dFreeze below, at the level of data, with the sampler program and the string's decider as holes. The programs that build them are the same trees with cons/const in place of the constructors — pK, pC, pL, pE mirror ProgD.dK, dC, dL, dE — and their cost is the size of what they build plus one per hole read.

              The description of the frozen program freezeProg k p, at the level of data.

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

                The sizes of the constructors' descriptions.

                theorem MIPRE.Cost.Prog.ProgD.size_dL (a b : Data) :
                (dL a b).size = a.size + b.size + 11
                theorem MIPRE.Cost.Prog.ProgD.size_dE (i : ℕ) (a b : Data) :
                (dE i a b).size = a.size + b.size + 2 * i + 11

                The size of the wrapper's description: the two holes, the universal machine twice, and a fixed number of nodes.

                Instances For
                  theorem MIPRE.Cost.Prog.ProgD.size_dWrapCore (univD sampD decD : Data) :
                  (dWrapCore univD sampD decD).size = sampD.size + decD.size + 2 * univD.size + wrapNodes

                  cons (const 6) e: builds dK.

                  Equations
                  Instances For

                    Builds dC.

                    Equations
                    Instances For

                      Builds dL.

                      Equations
                      Instances For
                        theorem MIPRE.Cost.Prog.pK_eval {env : Env} {e : Prog} {v : Data} {s : ℕ} (h : Eval env e v s) :
                        Eval env e.pK (ProgD.dK v) (s + 14)
                        theorem MIPRE.Cost.Prog.pC_eval {env : Env} {h t : Prog} {a b : Data} {s u : ℕ} (h₁ : Eval env h a s) (h₂ : Eval env t b u) :
                        Eval env (h.pC t) (ProgD.dC a b) (s + u + 7)
                        theorem MIPRE.Cost.Prog.pL_eval {env : Env} {e b : Prog} {a c : Data} {s u : ℕ} (h₁ : Eval env e a s) (h₂ : Eval env b c u) :
                        Eval env (e.pL b) (ProgD.dL a c) (s + u + 11)
                        theorem MIPRE.Cost.Prog.pE_eval {env : Env} (i : ℕ) {n c : Prog} {a b : Data} {s u : ℕ} (h₁ : Eval env n a s) (h₂ : Eval env c b u) :
                        Eval env (pE i n c) (ProgD.dE i a b) (s + u + 2 * i + 11)
                        theorem MIPRE.Cost.Prog.pC_wellScoped {n : ℕ} {h t : Prog} (h₁ : WellScoped n h) (h₂ : WellScoped n t) :
                        WellScoped n (h.pC t)
                        theorem MIPRE.Cost.Prog.pL_wellScoped {n : ℕ} {e b : Prog} (h₁ : WellScoped n e) (h₂ : WellScoped n b) :
                        WellScoped n (e.pL b)
                        theorem MIPRE.Cost.Prog.pE_wellScoped {n i : ℕ} {e b : Prog} (h₁ : WellScoped n e) (h₂ : WellScoped n b) :
                        WellScoped n (pE i e b)
                        def MIPRE.Cost.Prog.pCheck (i j : ℕ) (c : Prog) :

                        One length check of the wrapper, as a builder with the continuation as a hole.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          theorem MIPRE.Cost.Prog.pCheck_eval {env : Env} (i j : ℕ) {c : Prog} {v : Data} {s : ℕ} (h : Eval env c v s) :
                          theorem MIPRE.Cost.Prog.pCheck_wellScoped {n i j : ℕ} {c : Prog} (h : WellScoped n c) :
                          WellScoped n (pCheck i j c)

                          The wrapper's description, built. On cons sampD decD, the description dWrapCore univD sampD decD of the wrapped decider.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            theorem MIPRE.Cost.Prog.wrapBuildProg_runs (univD sampD decD : Data) :
                            ∃ t ≤ sampD.size + decD.size + 2 * univD.size + ProgD.wrapNodes + 3, (wrapBuildProg univD).Runs (sampD.cons decD) (ProgD.dWrapCore univD sampD decD) t

                            The builder builds the wrapper's description, at a cost linear in the sizes involved.

                            The frozen program's description, built. On cons kD p, the description dFreeze kD p.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              theorem MIPRE.Cost.Prog.freezeBuildProg_runs (kD p : Data) :
                              ∃ t ≤ p.size + kD.size + 56, freezeBuildProg.Runs (kD.cons p) (ProgD.dFreeze kD p) t

                              Small pieces #

                              theorem MIPRE.Cost.Prog.fstProg_runs' (d : Data) :
                              ∃ t ≤ d.left.size + 2, fstProg.Runs d d.left t

                              The left projection on any datum (nil on nil).

                              theorem MIPRE.Cost.Prog.sndProg_runs' (d : Data) :
                              ∃ t ≤ d.right.size + 2, sndProg.Runs d d.right t

                              The right projection on any datum (nil on nil).

                              def MIPRE.Cost.Prog.call2 (i j : ℕ) (q : Prog) :

                              A pair of two variables, then a closed program on it.

                              Equations
                              Instances For
                                theorem MIPRE.Cost.Prog.call2_wellScoped {n i j : ℕ} (hi : i < n) (hj : j < n) {q : Prog} (hq : WellScoped 1 q) :
                                WellScoped n (call2 i j q)
                                theorem MIPRE.Cost.Prog.call2_eval {env : Env} {i j : ℕ} {q : Prog} (hq : WellScoped 1 q) {a b r : Data} {t : ℕ} (ha : env.get i = a) (hb : env.get j = b) (h : Eval [a.cons b] q r t) :
                                Eval env (call2 i j q) r (a.size + b.size + t + 4)

                                The preparation: from (c, n, λ) to the compressed decider's description #

                                Everything the compressor's decider does before running the compressed decider: on encode (c, n, λ), the description of Compress applied to the verifier of the string c describes, frozen at 2n + 1, and to λ. The stages are those of the module docstring; the comments give the environment after each.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  @[reducible, inline]

                                  The frozen verifier of the string x, at index 2n + 1.

                                  Equations
                                  Instances For

                                    The description of the compressed decider the preparation produces.

                                    Equations
                                    Instances For
                                      @[reducible, inline]

                                      The values of the stages, named. sampD is sampData G x, wD is decProgData G U x and kD n is encode (2n + 1) (Cost.encode_two_mul_add_one); they are abbrevs so that the environment bookkeeping below sees through them.

                                      Equations
                                      Instances For

                                        The sizes of the stages' values, bounded in the length L of the described string and the level n: the sampler program (sampBound, by its own time bound at a parameter of size at most L + 1), the wrapped decider (wBound), the frozen index (kBound) and the two frozen programs together (fBound).

                                        noncomputable def MIPRE.Halting.sampBound (G : GapCompression) (L : ℕ) :

                                        The size of the sampler program at a parameter of size at most L + 1.

                                        Equations
                                        Instances For
                                          noncomputable def MIPRE.Halting.wBound (G : GapCompression) (U : Cost.UniversalMachine) (L : ℕ) :

                                          The size of the wrapped decider's description.

                                          Equations
                                          Instances For

                                            The size of encode (2n + 1).

                                            Equations
                                            Instances For
                                              noncomputable def MIPRE.Halting.fBound (G : GapCompression) (U : Cost.UniversalMachine) (L n : ℕ) :

                                              The sizes of the two frozen programs, summed.

                                              Equations
                                              Instances For

                                                The parameter a string of length L denotes has an encoding of size at most L + 1.

                                                The sizes of the stages' values, against their bounds.

                                                The two frozen programs fit under fBound.

                                                noncomputable def MIPRE.Halting.prepBound (G : GapCompression) (U : Cost.UniversalMachine) (s n L l : ℕ) :

                                                The cost of the preparation, in the description's size s, the level n, a bound L on the described string's length, and the size l of the parameter.

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For
                                                  theorem MIPRE.Halting.prepProg_runs (G : GapCompression) (U : Cost.UniversalMachine) {c : Cost.Prog} {x : Cost.BitStr} {n : ℕ} (hsd : Cost.IsSuccinctDesc c n x) (lam : ℕ) :
                                                  ∃ t ≤ prepBound G U (Cost.esize c) n (List.length x) (Cost.esize lam), (prepProg G U).Runs (Cost.encode (c, n, lam)) (compressedD G U x n lam) t

                                                  The preparation computes the compressed decider's description, on a succinct description (c, n) of x.

                                                  The decider #

                                                  The compressor's decider, before hardcoding. On cons P d with P = encode (c, n, λ) and d the decider's own input encode (m, x', y', a, b): prepare the description of the compressed decider, and run it on d through the universal machine; the result is the universal machine's.

                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For
                                                    theorem MIPRE.Halting.prep_call (G : GapCompression) (U : Cost.UniversalMachine) {c : Cost.Prog} {x : Cost.BitStr} {n : ℕ} (hsd : Cost.IsSuccinctDesc c n x) (lam : ℕ) (d : Cost.Data) :
                                                    ∃ t ≤ prepBound G U (Cost.esize c) n (List.length x) (Cost.esize lam), (compressedD G U x n lam).size ≤ t ∧ Cost.Eval [Cost.encode (c, n, lam), d, (Cost.encode (c, n, lam)).cons d] (Cost.Prog.callVar 0 (prepProg G U)) (compressedD G U x n lam) ((Cost.encode (c, n, lam)).size + 1 + t + 1)

                                                    The run of the preparation, as the decider calls it, with the size of what it produces.

                                                    theorem MIPRE.Halting.pair_step (P d cmpD : Cost.Data) :
                                                    Cost.Eval [cmpD, P, d, P.cons d] ((Cost.Prog.var 0).cons (Cost.Prog.var 2)) (cmpD.cons d) (cmpD.size + 1 + (d.size + 1) + 1)

                                                    The pairing step of the decider.

                                                    theorem MIPRE.Halting.haltProg_runs (G : GapCompression) (U : Cost.UniversalMachine) {c : Cost.Prog} {x : Cost.BitStr} {n : ℕ} (hsd : Cost.IsSuccinctDesc c n x) (lam : ℕ) {d r : Cost.Data} {t : ℕ} (h : U.univ.Runs ((compressedD G U x n lam).cons d) r t) :
                                                    ∃ t' ≤ 3 * prepBound G U (Cost.esize c) n (List.length x) (Cost.esize lam) + Cost.esize (c, n, lam) + 2 * d.size + t + 12, (haltProg G U).Runs ((Cost.encode (c, n, lam)).cons d) r t'

                                                    Forward run. A run of the universal machine on the compressed decider's description and the input is a run of the decider, at the cost of the preparation and the copies.

                                                    theorem MIPRE.Halting.haltProg_runs_inv (G : GapCompression) (U : Cost.UniversalMachine) {c : Cost.Prog} {x : Cost.BitStr} {n : ℕ} (hsd : Cost.IsSuccinctDesc c n x) (lam : ℕ) {d r : Cost.Data} {t : ℕ} (h : (haltProg G U).Runs ((Cost.encode (c, n, lam)).cons d) r t) :
                                                    ∃ (t' : ℕ), U.univ.Runs ((compressedD G U x n lam).cons d) r t'

                                                    Inversion. The decider halts only if the universal machine does on the compressed decider's description and the input, with the same result.

                                                    theorem MIPRE.Halting.haltProg_accepts_iff (G : GapCompression) (U : Cost.UniversalMachine) {c : Cost.Prog} {x : Cost.BitStr} {n : ℕ} (hsd : Cost.IsSuccinctDesc c n x) (lam m : ℕ) (x' y' a b : Cost.BitStr) :
                                                    (∃ (t : ℕ), (haltProg G U).Runs ((Cost.encode (c, n, lam)).cons (Cost.encode (m, x', y', a, b))) (Cost.encode true) t) ↔ (G.output ((frozen G U x n).sampler.prog, (frozen G U x n).decider.prog) lam).decider.Accepts m x' y' a b

                                                    Acceptance agreement of the decider. On a succinct description (c, n) of x, the decider with (c, n, λ) in front accepts (m, x', y', a, b) exactly when the compressed decider of the verifier of x frozen at 2n + 1, at parameter λ, accepts it.

                                                    The compressor's output, as a string #

                                                    The string the compressor outputs on (c, n) at parameter λ: it denotes λ and the decider haltProg with (c, n, λ) hardcoded.

                                                    Equations
                                                    Instances For
                                                      @[simp]
                                                      theorem MIPRE.Halting.descLam_comprStr (G : GapCompression) (U : Cost.UniversalMachine) (c : Cost.Prog) (n lam : ℕ) :
                                                      descLam (comprStr G U c n lam) = lam

                                                      The verifier the output denotes: the compressed sampler at λ, and the hardcoded decider as a program.

                                                      theorem MIPRE.Halting.comprStr_accepts (G : GapCompression) (U : Cost.UniversalMachine) {c : Cost.Prog} {x : Cost.BitStr} {n : ℕ} (hsd : Cost.IsSuccinctDesc c n x) (lam m : ℕ) (x' y' a b : Cost.BitStr) :
                                                      (Vof G U (comprStr G U c n lam)).decider.Accepts m x' y' a b ↔ (G.output (((Vof G U x).freeze (2 * n + 1)).sampler.prog, ((Vof G U x).freeze (2 * n + 1)).decider.prog) lam).decider.Accepts m x' y' a b

                                                      The acceptance agreement of the output (the field CompressorSpec.accepts_compr): on a succinct description (c, n) of x, the decider of the verifier the output denotes accepts, at every index, exactly what the compressed decider of the verifier of x frozen at 2n + 1 accepts.