Documentation

MIPRE.TM.CookLevin.Layout

The variable format of the describer #

The binary format of the variables of the Cook–Levin tableau of the interpreter machine U (planning/succinct-cook-levin.md, S3). An index is a list of m bits, least significant first. With its top bit set it is structured: a tag (3 bits), the time t (W bits), the tape d (4), the position p (W), the cell value v (3), the state q (Qb), the thirteen window centers (13 W) and the gate g (Gb); tags 0..6 are cell, head, state, emitOne, emitBad, emitted, aux. With its top bit clear and value j < 4T it is an answer variable: the cell at position j' / 2 + 3 of tape A (for j < 2T, j' = j) or B (j' = j - 2T), with the value blank for j' even and 1 for j' odd, so that the first 4T variables are the tapeBits of the two answers.

fieldsOf reads the fields of an index, decodeVar the tableau variable they denote (if any), and encodeVar is the structured index of a variable; decodeVar_encodeVar is the round trip. The circuit computes exactly fieldsOf on its input bits (FieldFml.lean).

Codes of symbols, tapes and states #

The code of a tape: the input tapes 0..6, the work tapes 7..12.

Equations
Instances For

    The tape of a code.

    Equations
    Instances For
      @[irreducible]

      The number of states, including the halting state. Irreducible: a definitional unfolding evaluates Fintype.card (Option Ctl), which does not terminate in practice.

      Instances For

        The code of a state.

        Equations
        Instances For

          Widths and offsets #

          @[irreducible]

          The width of the state field.

          Equations
          Instances For

            The width of the time, position and center fields: W = e + 4, where S = 2^e.

            Equations
            Instances For

              The tableau length.

              Equations
              Instances For

                The width of the gate field for a check circuit of G gates.

                Equations
                Instances For

                  The offsets of the fields of a structured index.

                  Equations
                  Instances For

                    Bit strings and numbers #

                    The value of the bits off .. off + w of a bit string.

                    Equations
                    Instances For

                      The fields of an index #

                      The fields read from an index: the top bit, the structured fields, and for an answer index the decoded tape, position and value with the range check ansOk.

                      Instances For

                        The fields of the index ib (a bit string of length m), for the answer length T.

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

                          Decoding #

                          noncomputable def MIPRE.TM.CookLevin.Desc.decodeVar (e G : ℕ) (F : Fields) :

                          The tableau variable denoted by the fields of an index, if any.

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

                            Encoding #

                            The w-bit binary representation of n, least significant bit first.

                            Equations
                            Instances For

                              The w-bit fields js a, …, js (a + n - 1), concatenated.

                              Equations
                              Instances For
                                @[simp]
                                theorem MIPRE.TM.CookLevin.Desc.length_jsPack (w : ℕ) (js : ℕ → ℕ) (a n : ℕ) :
                                List.length (jsPack w js a n) = n * w
                                theorem MIPRE.TM.CookLevin.Desc.jsPack_add (w : ℕ) (js : ℕ → ℕ) (a n k : ℕ) :
                                jsPack w js a (n + k) = jsPack w js a n ++ jsPack w js (a + n) k
                                def MIPRE.TM.CookLevin.Desc.packFields (e G tag t d p v q : ℕ) (js : ℕ → ℕ) (g : ℕ) :

                                The structured index with the given fields.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  theorem MIPRE.TM.CookLevin.Desc.length_packFields (e G tag t d p v q : ℕ) (js : ℕ → ℕ) (g : ℕ) :
                                  List.length (packFields e G tag t d p v q js g) = mOf e G
                                  theorem MIPRE.TM.CookLevin.Desc.bitField_of_eq (ib pre mid post : Cost.BitStr) (off w : ℕ) (h : ib = pre ++ (mid ++ post)) (hoff : List.length pre = off) (hw : List.length mid = w) :
                                  bitField ib off w = Cost.bitsVal mid

                                  Reading a field out of a concatenation.

                                  theorem MIPRE.TM.CookLevin.Desc.getD_of_eq (ib pre post : Cost.BitStr) (b : Bool) (off : ℕ) (h : ib = pre ++ b :: post) (hoff : List.length pre = off) :
                                  List.getD ib off false = b
                                  theorem MIPRE.TM.CookLevin.Desc.packFields_flag (e G tag t d p v q : ℕ) (js : ℕ → ℕ) (g : ℕ) :
                                  List.getD (packFields e G tag t d p v q js g) (flagOff e G) false = true
                                  theorem MIPRE.TM.CookLevin.Desc.packFields_tag (e G tag t d p v q : ℕ) (js : ℕ → ℕ) (g : ℕ) :
                                  bitField (packFields e G tag t d p v q js g) tagOff 3 = tag % 2 ^ 3
                                  theorem MIPRE.TM.CookLevin.Desc.packFields_t (e G tag t d p v q : ℕ) (js : ℕ → ℕ) (g : ℕ) :
                                  bitField (packFields e G tag t d p v q js g) tOff (W e) = t % 2 ^ W e
                                  theorem MIPRE.TM.CookLevin.Desc.packFields_d (e G tag t d p v q : ℕ) (js : ℕ → ℕ) (g : ℕ) :
                                  bitField (packFields e G tag t d p v q js g) (dOff e) 4 = d % 2 ^ 4
                                  theorem MIPRE.TM.CookLevin.Desc.packFields_p (e G tag t d p v q : ℕ) (js : ℕ → ℕ) (g : ℕ) :
                                  bitField (packFields e G tag t d p v q js g) (pOff e) (W e) = p % 2 ^ W e
                                  theorem MIPRE.TM.CookLevin.Desc.packFields_v (e G tag t d p v q : ℕ) (js : ℕ → ℕ) (g : ℕ) :
                                  bitField (packFields e G tag t d p v q js g) (vOff e) 3 = v % 2 ^ 3
                                  theorem MIPRE.TM.CookLevin.Desc.packFields_q (e G tag t d p v q : ℕ) (js : ℕ → ℕ) (g : ℕ) :
                                  bitField (packFields e G tag t d p v q js g) (qOff e) Qb = q % 2 ^ Qb
                                  theorem MIPRE.TM.CookLevin.Desc.packFields_js (e G tag t d p v q : ℕ) (js : ℕ → ℕ) (g k : ℕ) (hk : k < 13) :
                                  bitField (packFields e G tag t d p v q js g) (jsOff e k) (W e) = js k % 2 ^ W e
                                  theorem MIPRE.TM.CookLevin.Desc.packFields_g (e G tag t d p v q : ℕ) (js : ℕ → ℕ) (g : ℕ) :
                                  bitField (packFields e G tag t d p v q js g) (gOff e) (Gb G) = g % 2 ^ Gb G
                                  theorem MIPRE.TM.CookLevin.Desc.fieldsOf_packFields (e G tag t d p v q : ℕ) (js : ℕ → ℕ) (g T : ℕ) :
                                  fieldsOf e G T (packFields e G tag t d p v q js g) = { flag := true, tag := tag % 2 ^ 3, t := t % 2 ^ W e, d := d % 2 ^ 4, p := p % 2 ^ W e, v := v % 2 ^ 3, q := q % 2 ^ Qb, js := fun (k : Fin 13) => js ↑k % 2 ^ W e, g := g % 2 ^ Gb G, ansOk := false }

                                  The fields of a structured index are the packed values (reduced modulo their widths).

                                  def MIPRE.TM.CookLevin.Desc.jsFun (e : ℕ) (js : Tape 7 6 → Center (Sof e)) (k : ℕ) :

                                  The window centers of an aux variable as a function on tape codes.

                                  Equations
                                  Instances For
                                    theorem MIPRE.TM.CookLevin.Desc.jsFun_tapeCode (e : ℕ) (js : Tape 7 6 → Center (Sof e)) (d : Tape 7 6) :
                                    jsFun e js (tapeCode d) = ↑(js d)

                                    S < 2^W and 2S + 7 < 2^W.

                                    Decoding inverts encoding.