Documentation

MIPRE.Foundations.Halting.Wrapper

Reading a string as a normal form verifier: the wrapper decider #

Blueprint rem:compression-abstract, item 1: a string of the compressibility criterion is a pair (Ξ», π’Ÿ) of a parameter and a decider program, read as the verifier (S^compr_Ξ», wrap π’Ÿ). The wrapper is what makes the pair a normal form verifier: the one structural requirement of def:normal-verifier is Verifier.accepts_length, that the decider accept only questions of the sampler's dimension β€” the paper's step 1, "compute the dimension s(n) of the sampler and check |x| = |y| = s(n); if not, reject".

Nothing else has to be enforced. Synchronicity at an index and the answer-length bound are conditions on membership in the classes (Verifier.InClassA, InClassB), not on well-formedness, so the wrapper leaves them to the class definition; and the paper's timeout counter is likewise not needed here, since a decider that fails to halt simply fails to be n-bounded, and its string then lies in neither class.

The program #

One length check, reusable for both questions: read the length of the bit string at index i, compare it with the unary numeral at index j, and continue with c if they agree, rejecting otherwise.

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

    The environment wrapCheck hands to its continuation.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      def MIPRE.Cost.Prog.wrapTail (univ : Prog) (decD : Data) :

      The last step: run the string's decider β€” the datum decD, which the string carries and which need not be the encoding of any program β€” on the whole input, through univ. At this point the input sits at index 19.

      Equations
      Instances For
        def MIPRE.Cost.Prog.wrapHead (univ sampProg c : Prog) :

        The head: compute the sampler's dimension at the input index, in unary.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          def MIPRE.Cost.Prog.wrapPre (univ sampProg c : Prog) :

          The prefix: the head, then the two questions taken apart.

          Equations
          Instances For
            def MIPRE.Cost.Prog.wrapCore (univ sampProg : Prog) (decD : Data) :

            The wrapper's program. Input: encode (N, x, y, a, b).

            Equations
            Instances For
              theorem MIPRE.Cost.Prog.wrapCheck_wellScoped {i j n : β„•} (hi : i < n) (hj : j < n) {c : Prog} (hc : WellScoped (n + 5) c) :
              theorem MIPRE.Cost.Prog.wrapTail_wellScoped {univ : Prog} (hU : WellScoped 1 univ) (decD : Data) :
              WellScoped 20 (univ.wrapTail decD)
              theorem MIPRE.Cost.Prog.wrapHead_wellScoped {univ : Prog} (hU : WellScoped 1 univ) (sampProg : Prog) {c : Prog} (hc : WellScoped 6 c) :
              WellScoped 1 (univ.wrapHead sampProg c)
              theorem MIPRE.Cost.Prog.wrapPre_wellScoped {univ : Prog} (hU : WellScoped 1 univ) (sampProg : Prog) {c : Prog} (hc : WellScoped 10 c) :
              WellScoped 1 (univ.wrapPre sampProg c)
              theorem MIPRE.Cost.Prog.wrapCore_wellScoped {univ : Prog} (hU : WellScoped 1 univ) (sampProg : Prog) (decD : Data) :
              WellScoped 1 (univ.wrapCore sampProg decD)

              The length check #

              theorem MIPRE.Cost.Prog.eq_run (p q : β„•) :
              βˆƒ (t : β„•), eqBitsProg.Runs ((Data.ofNat p).cons (Data.ofNat q)) (encode (decide (p = q))) t
              theorem MIPRE.Cost.Prog.wrapCheck_runs_of_ne {i j : β„•} {c : Prog} {env : Env} {l : BitStr} {m : β„•} (hi : env.get i = encode l) (hj : env.get j = Data.ofNat m) (hne : List.length l β‰  m) :
              βˆƒ (t : β„•), Eval env (wrapCheck i j c) Data.nil t
              theorem MIPRE.Cost.Prog.wrapCheck_runs_of_eq {i j : β„•} {c : Prog} {env : Env} {l : BitStr} {m : β„•} (hi : env.get i = encode l) (hj : env.get j = Data.ofNat m) (heq : List.length l = m) {r : Data} {t : β„•} (hc : Eval (wrapCheckEnv l m env) c r t) :
              βˆƒ (t' : β„•), Eval env (wrapCheck i j c) r t'
              theorem MIPRE.Cost.Prog.wrapCheck_inv {i j : β„•} {c : Prog} {env : Env} {l : BitStr} {m : β„•} (hi : env.get i = encode l) (hj : env.get j = Data.ofNat m) {r : Data} {t : β„•} (h : Eval env (wrapCheck i j c) r t) :
              List.length l β‰  m ∧ r = Data.nil ∨ List.length l = m ∧ βˆƒ (t' : β„•), Eval (wrapCheckEnv l m env) c r t'

              Inversion. A run of the check either fails the comparison and returns nil, or passes it and is a run of the continuation.

              The whole run #

              def MIPRE.Cost.Prog.wrapPreEnv {β„“ : β„•} (S : CL.Sampler β„“) (n : β„•) (x y a b : BitStr) :

              The environment the prefix hands to the first length check.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                theorem MIPRE.Cost.Prog.dim_run {β„“ : β„•} (U : UniversalMachine) (S : CL.Sampler β„“) (n : β„•) :
                theorem MIPRE.Cost.Prog.input_cons (n : β„•) (x y a b : BitStr) :
                encode (n, x, y, a, b) = (encode n).cons ((encode x).cons ((encode y).cons ((encode a).cons (encode b))))
                theorem MIPRE.Cost.Prog.wrapPre_runs {β„“ : β„•} (U : UniversalMachine) (S : CL.Sampler β„“) (n : β„•) (x y a b : BitStr) {c : Prog} {r : Data} {t : β„•} (hc : Eval (wrapPreEnv S n x y a b) c r t) :
                βˆƒ (t' : β„•), Eval [encode (n, x, y, a, b)] (U.univ.wrapPre S.prog c) r t'

                The prefix runs, whatever the continuation does.

                theorem MIPRE.Cost.Prog.wrapPre_inv {β„“ : β„•} (U : UniversalMachine) (S : CL.Sampler β„“) (n : β„•) (x y a b : BitStr) {c : Prog} {r : Data} {t : β„•} (h : Eval [encode (n, x, y, a, b)] (U.univ.wrapPre S.prog c) r t) :
                βˆƒ (t' : β„•), Eval (wrapPreEnv S n x y a b) c r t'

                Inversion of the prefix.

                The three outcomes #

                theorem MIPRE.Cost.Prog.wrapCore_runs_of_ne_left {β„“ : β„•} (U : UniversalMachine) (S : CL.Sampler β„“) (decD : Data) (n : β„•) (x y a b : BitStr) (hx : List.length x β‰  S.dim n) :
                βˆƒ (t : β„•), (U.univ.wrapCore S.prog decD).Runs (encode (n, x, y, a, b)) Data.nil t
                theorem MIPRE.Cost.Prog.wrapCore_runs_of_ne_right {β„“ : β„•} (U : UniversalMachine) (S : CL.Sampler β„“) (decD : Data) (n : β„•) (x y a b : BitStr) (hx : List.length x = S.dim n) (hy : List.length y β‰  S.dim n) :
                βˆƒ (t : β„•), (U.univ.wrapCore S.prog decD).Runs (encode (n, x, y, a, b)) Data.nil t
                theorem MIPRE.Cost.Prog.wrapCore_runs_of_eq {β„“ : β„•} (U : UniversalMachine) (S : CL.Sampler β„“) (decD : Data) (n : β„•) (x y a b : BitStr) (hx : List.length x = S.dim n) (hy : List.length y = S.dim n) {r : Data} {t₇ : β„•} (h₇ : U.univ.Runs (decD.cons (encode (n, x, y, a, b))) r t₇) :
                βˆƒ (t : β„•), (U.univ.wrapCore S.prog decD).Runs (encode (n, x, y, a, b)) r t
                theorem MIPRE.Cost.Prog.wrapCore_halts_inv {β„“ : β„•} (U : UniversalMachine) (S : CL.Sampler β„“) (decD : Data) (n : β„•) (x y a b : BitStr) {r : Data} {t : β„•} (h : (U.univ.wrapCore S.prog decD).Runs (encode (n, x, y, a, b)) r t) :
                r = Data.nil ∨ βˆƒ (t' : β„•), U.univ.Runs (decD.cons (encode (n, x, y, a, b))) r t'

                The wrapper halts only if the universal machine does on the string's decider.

                The wrapped decider and the verifier a pair denotes #

                def MIPRE.Decider.wrap {β„“ : β„•} (U : Cost.UniversalMachine) (S : CL.Sampler β„“) (decD : Cost.Data) :

                The decider a string denotes: the datum decD the string carries, run by the universal machine, wrapped in the question-length check against the sampler S. The datum need not be the encoding of a program; when it is, encode dec, the run is a run of dec (wrap_accepts_prog).

                Equations
                Instances For
                  @[simp]
                  theorem MIPRE.Decider.wrap_prog {β„“ : β„•} (U : Cost.UniversalMachine) (S : CL.Sampler β„“) (decD : Cost.Data) :
                  (wrap U S decD).prog = U.univ.wrapCore S.prog decD
                  theorem MIPRE.Decider.wrap_accepts {β„“ : β„•} (U : Cost.UniversalMachine) (S : CL.Sampler β„“) (decD : Cost.Data) (n : β„•) (x y a b : Cost.BitStr) :
                  (wrap U S decD).Accepts n x y a b ↔ List.length x = S.dim n ∧ List.length y = S.dim n ∧ βˆƒ (t : β„•), U.univ.Runs (decD.cons (Cost.encode (n, x, y, a, b))) (Cost.encode true) t

                  Acceptance of the wrapped decider: the two questions have the sampler's dimension and the universal machine, run on the string's decider and the input, returns true.

                  theorem MIPRE.Decider.wrap_accepts_prog {β„“ : β„•} (U : Cost.UniversalMachine) (S : CL.Sampler β„“) (dec : Cost.Prog) (n : β„•) (x y a b : Cost.BitStr) :
                  (wrap U S (Cost.encode dec)).Accepts n x y a b ↔ List.length x = S.dim n ∧ List.length y = S.dim n ∧ βˆƒ (t : β„•), dec.Runs (Cost.encode (n, x, y, a, b)) (Cost.encode true) t

                  Acceptance when the datum is the encoding of a program dec: the universal machine's run is a run of dec (UniversalMachine.time_le, halts_of).

                  theorem MIPRE.Decider.wrap_accepts_length {β„“ : β„•} (U : Cost.UniversalMachine) (S : CL.Sampler β„“) (decD : Cost.Data) (n : β„•) (x y a b : Cost.BitStr) (h : (wrap U S decD).Accepts n x y a b) :

                  The wrapped decider accepts only questions of the sampler's dimension: the one structural requirement of def:normal-verifier.

                  The verifier a pair (S, d) denotes: the sampler S, and the datum d β€” the string's decider, run by the universal machine β€” wrapped in the question-length check. Every pair denotes one, well formed or not.

                  Equations
                  Instances For

                    The verifier a pair (S, π’Ÿ) of a sampler and a decider program denotes: ofSamplerDeciderD at the program's encoding.

                    Equations
                    Instances For
                      theorem MIPRE.Verifier.ofSamplerDeciderD_accepts {β„“ : β„•} (U : Cost.UniversalMachine) (S : CL.Sampler β„“) (decD : Cost.Data) (n : β„•) (x y a b : Cost.BitStr) :
                      (ofSamplerDeciderD U S decD).decider.Accepts n x y a b ↔ List.length x = S.dim n ∧ List.length y = S.dim n ∧ βˆƒ (t : β„•), U.univ.Runs (decD.cons (Cost.encode (n, x, y, a, b))) (Cost.encode true) t
                      theorem MIPRE.Verifier.ofSamplerDecider_accepts {β„“ : β„•} (U : Cost.UniversalMachine) (S : CL.Sampler β„“) (dec : Cost.Prog) (n : β„•) (x y a b : Cost.BitStr) :
                      (ofSamplerDecider U S dec).decider.Accepts n x y a b ↔ List.length x = S.dim n ∧ List.length y = S.dim n ∧ βˆƒ (t : β„•), dec.Runs (Cost.encode (n, x, y, a, b)) (Cost.encode true) t

                      The wrapper at the level of data #

                      Decider.wrap is what Verifier.IsBounded bounds, and it is therefore what a tabulation has to run: the bound says nothing about the inner decider, the datum the string carries, since UniversalMachine.halts_of produces a run with no bound on its cost. So the tabulation needs encode (wrapCore univ sampProg decD) as a primitive recursive function of the encoded sampler program and the datum β€” which it can be, because wrapCore mentions the sampler program only under Prog.const (encode Β·) and the datum only under Prog.const.

                      ProgD is that mirror: the constructors of Prog at the level of Data, and the wrapper rebuilt from them. Every _eq lemma is rfl, Prog.toData being structural, and dWrapCore_eq is rfl too β€” nothing here is a second definition to keep in step with the first, it is the same definition seen through the encoding. The existing wrapCheck, wrapHead, wrapTail, wrapCore and everything proved about them are untouched.

                      The wrapper, at the level of data.

                      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
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            def MIPRE.Cost.Prog.ProgD.dWrapCore (univ sampD decD : Data) :
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              theorem MIPRE.Cost.Prog.ProgD.dWrapCore_eq (univ sampProg : Prog) (decD : Data) :
                              dWrapCore (encode univ) (encode sampProg) decD = encode (univ.wrapCore sampProg decD)