Documentation

CslibFrontier.Computability.Circuit.Boolean.Tableau.Layout

Block and wire layout of the uniform tableau circuit #

For a multi-tape Turing machine with k work tapes and state type State running for T steps on inputs of length n, the uniform tableau circuit (CslibFrontier/Computability/Circuit/Boolean/Tableau/Basic.lean) has n input wires, two constant gates (false at wire n and true at wire n + 1), and T + 1 blocks of blockSize k State T gates. Work-tape cells -T, …, T and input positions 0, …, n + 1 share numCols T = 2 T + 1 columns. Within each block, gates are arranged into four regions:

Gates refer to earlier wires symbolically (Ref, ColSel, Guard), and Ref.resolve translates each symbolic reference to a concrete wire index via wire. Every region position has an index (idx, Loc.offset) and an arithmetic decoder (ofIdx, gadgetB, gadgetJ) that invert each other on valid indices, so every gate index 2 ≤ g < numGates k State T sits at a unique admissible block position (div_mod_wire, exists_wire_eq).

Main definitions #

Main results #

References #

Positions within a block #

One aspect of an action: the next state, the move of the input head, what is written on a work tape, the move of a work head, and the output symbol.

Instances For
    def Cslib.Circuits.Boolean.Tableau.instDecidableEqAttr.decEq {k✝ : ℕ} {State✝ : Type} [DecidableEq State✝] (x✝ x✝¹ : Attr k✝ State✝) :
    Decidable (x✝ = x✝¹)
    @[instance_reducible]
    instance Cslib.Circuits.Boolean.Tableau.instDecidableEqAttr {k✝ : ℕ} {State✝ : Type} [DecidableEq State✝] :
    DecidableEq (Attr k✝ State✝)
    @[instance_reducible]
    instance Cslib.Circuits.Boolean.Tableau.instFintypeAttr {k✝ : ℕ} {State✝ : Type} [Fintype State✝] :
    Fintype (Attr k✝ State✝)

    The features held in each column: the input head, a work head and a work cell.

    • inPos {k : ℕ} : ColFeat k

      The input head is at the position of the column.

    • head {k : ℕ} (i : Fin k) : ColFeat k

      Work head i is at the cell of the column.

    • cell {k : ℕ} (i : Fin k) (s : Option Bool) : ColFeat k

      The cell of the column on work tape i holds s.

    Instances For
      @[instance_reducible]

      The global features: the state and the view of the output.

      Instances For
        @[instance_reducible]
        def Cslib.Circuits.Boolean.Tableau.instDecidableEqGFeat.decEq {State✝ : Type} [DecidableEq State✝] (x✝ x✝¹ : GFeat State✝) :
        Decidable (x✝ = x✝¹)
        @[instance_reducible]
        instance Cslib.Circuits.Boolean.Tableau.instFintypeGFeat {State✝ : Type} [Fintype State✝] :
        Fintype (GFeat State✝)

        The quantities accumulated by the scan across the columns: the symbol under the input head and the symbols under the work heads.

        Instances For
          @[instance_reducible]

          The gates of a column of the scan.

          • nh {k : ℕ} (i : Fin k) : ScanLoc k

            Work head i is not at the cell of the column.

          • nx {k : ℕ} : ScanLoc k

            The negated input bit of the column.

          • term {k : ℕ} (q : ScanQ k) : ScanLoc k

            The contribution of the column to a scanned quantity.

          • acc {k : ℕ} (q : ScanQ k) : ScanLoc k

            The disjunction of the contributions of the columns so far.

          Instances For
            @[instance_reducible]
            @[reducible, inline]
            abbrev Cslib.Circuits.Boolean.Tableau.numSit (k : ℕ) (State : Type) [Fintype State] :

            The number of situations of a machine.

            inductive Cslib.Circuits.Boolean.Tableau.GlobLoc (k : ℕ) (State : Type) [Fintype State] :

            The global gates: the situations, as chains of conjunctions, and the attributes, as chains of disjunctions over the situations.

            • sit {k : ℕ} {State : Type} [Fintype State] (j : Fin (numSit k State)) (i : Fin (k + 1)) : GlobLoc k State

              The conjunction of the first i + 1 conditions of situation number j.

            • attr {k : ℕ} {State : Type} [Fintype State] (v : Attr k State) (j : Fin (numSit k State + 1)) : GlobLoc k State

              The disjunction of the first j situations having the attribute v.

            Instances For
              @[instance_reducible]
              instance Cslib.Circuits.Boolean.Tableau.instDecidableEqGlobLoc {k✝ : ℕ} {State✝ : Type} {inst✝ : Fintype State✝} [DecidableEq State✝] :
              DecidableEq (GlobLoc k✝ State✝)
              def Cslib.Circuits.Boolean.Tableau.instDecidableEqGlobLoc.decEq {k✝ : ℕ} {State✝ : Type} {inst✝ : Fintype State✝} [DecidableEq State✝] (x✝ x✝¹ : GlobLoc k✝ State✝) :
              Decidable (x✝ = x✝¹)
              @[instance_reducible]
              instance Cslib.Circuits.Boolean.Tableau.instFintypeGlobLoc {k✝ : ℕ} {State✝ : Type} {inst✝ : Fintype State✝} [Fintype State✝] :
              Fintype (GlobLoc k✝ State✝)
              inductive Cslib.Circuits.Boolean.Tableau.Loc (k : ℕ) (State : Type) [Fintype State] :

              The position of a gate within its block: a gate of the scan, a global gate, or one of the sixteen gates computing a feature from its terms (the conjunction false and the running disjunction true of term j).

              Instances For
                @[instance_reducible]
                instance Cslib.Circuits.Boolean.Tableau.instDecidableEqLoc {k✝ : ℕ} {State✝ : Type} {inst✝ : Fintype State✝} [DecidableEq State✝] :
                DecidableEq (Loc k✝ State✝)
                def Cslib.Circuits.Boolean.Tableau.instDecidableEqLoc.decEq {k✝ : ℕ} {State✝ : Type} {inst✝ : Fintype State✝} [DecidableEq State✝] (x✝ x✝¹ : Loc k✝ State✝) :
                Decidable (x✝ = x✝¹)
                @[instance_reducible]
                instance Cslib.Circuits.Boolean.Tableau.instFintypeLoc {k✝ : ℕ} {State✝ : Type} {inst✝ : Fintype State✝} [Fintype State✝] :
                Fintype (Loc k✝ State✝)

                References to wires #

                The column of a reference, relative to the column c of the gate: c, c - 1, c + 1, or the last column.

                Instances For
                  @[instance_reducible]

                  Finite enumeration of column selectors.

                  A condition on the column c of a gate, under which a reference is used; otherwise it reads false.

                  • always : Guard

                    Always.

                  • pos : Guard

                    1 ≤ c.

                  • ltLast : Guard

                    c is not the last column.

                  • inRange : Guard

                    1 ≤ c ≤ n: the column holds an input bit.

                  • outRange : Guard

                    The column holds no input bit.

                  • isZero : Guard

                    c = 0.

                  • isEnd : Guard

                    c = n + 1.

                  • leEnd : Guard

                    1 ≤ c ≤ n + 1.

                  Instances For
                    @[instance_reducible]

                    Finite enumeration of column guards.

                    inductive Cslib.Circuits.Boolean.Tableau.Ref (k : ℕ) (State : Type) [Fintype State] :

                    A reference to a wire, relative to the block and the column of the gate: the constant wires, the input bit of the column, or a position of the current or the previous block.

                    • fls {k : ℕ} {State : Type} [Fintype State] : Ref k State

                      The constant false.

                    • tru {k : ℕ} {State : Type} [Fintype State] : Ref k State

                      The constant true.

                    • inp {k : ℕ} {State : Type} [Fintype State] : Ref k State

                      The input bit of the column, if it holds one.

                    • node {k : ℕ} {State : Type} [Fintype State] (prev : Bool) (l : Loc k State) (cs : ColSel) (g : Guard) : Ref k State

                      The position l of the previous block (prev = true) or the current one, in the column selected by cs, under the guard g.

                    Instances For
                      def Cslib.Circuits.Boolean.Tableau.instDecidableEqRef.decEq {k✝ : ℕ} {State✝ : Type} {inst✝ : Fintype State✝} [DecidableEq State✝] (x✝ x✝¹ : Ref k✝ State✝) :
                      Decidable (x✝ = x✝¹)
                      @[instance_reducible]
                      instance Cslib.Circuits.Boolean.Tableau.instDecidableEqRef {k✝ : ℕ} {State✝ : Type} {inst✝ : Fintype State✝} [DecidableEq State✝] :
                      DecidableEq (Ref k✝ State✝)
                      def Cslib.Circuits.Boolean.Tableau.Ref.toData {k : ℕ} {State : Type} [Fintype State] :
                      Ref k State → Option (Option (Option (Bool × Loc k State × ColSel × Guard)))

                      References as data.

                      instance Cslib.Circuits.Boolean.Tableau.instFiniteRef {k : ℕ} {State : Type} [Fintype State] :
                      Finite (Ref k State)

                      Finiteness of symbolic wire references.

                      def Cslib.Circuits.Boolean.Tableau.colF {k : ℕ} {State : Type} [Fintype State] (f : ColFeat k) (cs : ColSel) (g : Guard) :
                      Ref k State

                      A column feature of the previous block, in the column selected by cs, under the guard g.

                      def Cslib.Circuits.Boolean.Tableau.gfF {k : ℕ} {State : Type} [Fintype State] (f : GFeat State) :
                      Ref k State

                      A global feature of the previous block.

                      def Cslib.Circuits.Boolean.Tableau.act {k : ℕ} {State : Type} [Fintype State] (v : Attr k State) :
                      Ref k State

                      The attribute v of the action of the current step.

                      @[reducible, inline]
                      abbrev Cslib.Circuits.Boolean.Tableau.halted {k : ℕ} {State : Type} [Fintype State] :
                      Ref k State

                      The previous configuration has halted.

                      def Cslib.Circuits.Boolean.Tableau.scanAt {k : ℕ} {State : Type} [Fintype State] (l : ScanLoc k) (cs : ColSel) (g : Guard) :
                      Ref k State

                      A gate of the scan of the current block.

                      The layout #

                      The number of a cell symbol: blank, false, true.

                      The number of a scanned quantity.

                      The position of a gate within a column of the scan.

                      The number of gates of a column of the scan.

                      noncomputable def Cslib.Circuits.Boolean.Tableau.attrIdx {k : ℕ} {State : Type} [Fintype State] (v : Attr k State) :

                      The number of an attribute.

                      noncomputable def Cslib.Circuits.Boolean.Tableau.GlobLoc.idx {k : ℕ} {State : Type} [Fintype State] :
                      GlobLoc k State → ℕ

                      The position of a global gate.

                      The number of global gates.

                      noncomputable def Cslib.Circuits.Boolean.Tableau.GFeat.idx {State : Type} [Fintype State] :
                      GFeat State → ℕ

                      The number of a global feature.

                      The number of a column feature.

                      The position of gate j of kind b within the sixteen gates computing feature number fi.

                      The number of gates computing the global features.

                      The number of gates computing the features of a column.

                      The number of columns: the work cells -T, …, T.

                      The start of the global gates within a block.

                      def Cslib.Circuits.Boolean.Tableau.gfStart (k : ℕ) (State : Type) [Fintype State] (T : ℕ) :

                      The start of the global features within a block.

                      def Cslib.Circuits.Boolean.Tableau.colStart (k : ℕ) (State : Type) [Fintype State] (T : ℕ) :

                      The start of the column features within a block.

                      def Cslib.Circuits.Boolean.Tableau.blockSize (k : ℕ) (State : Type) [Fintype State] (T : ℕ) :

                      The number of gates of a block.

                      def Cslib.Circuits.Boolean.Tableau.numGates (k : ℕ) (State : Type) [Fintype State] (T : ℕ) :

                      The number of gates of the tableau: the two constants and T + 1 blocks.

                      noncomputable def Cslib.Circuits.Boolean.Tableau.Loc.offset {k : ℕ} {State : Type} [Fintype State] (T c : ℕ) :
                      Loc k State → ℕ

                      The offset of a position in column c from the start of its block.

                      noncomputable def Cslib.Circuits.Boolean.Tableau.wire {k : ℕ} {State : Type} [Fintype State] (n T t : ℕ) (l : Loc k State) (c : ℕ) :

                      The wire of a position l of block t, in column c: the inputs come first, then the two constants, then the blocks.

                      Whether a guard holds in column c.

                      The column selected relative to column c.

                      noncomputable def Cslib.Circuits.Boolean.Tableau.Ref.resolve {k : ℕ} {State : Type} [Fintype State] (n T t c : ℕ) :
                      Ref k State → ℕ

                      The wire of a reference from block t and column c.

                      The arguments of a gate with operation op, from its two candidate wires.

                      Decoding positions #

                      The cell symbol with a number.

                      The scanned quantity with a number.

                      The gate of the scan at a position within a column.

                      noncomputable def Cslib.Circuits.Boolean.Tableau.GlobLoc.ofIdx {k : ℕ} {State : Type} [Fintype State] (m : ℕ) :
                      GlobLoc k State

                      The global gate at a position.

                      noncomputable def Cslib.Circuits.Boolean.Tableau.GFeat.ofIdx {State : Type} [Fintype State] (m : ℕ) :
                      GFeat State

                      The global feature with a number.

                      The column feature with a number.

                      The kind of the gate at a position within the gates of a feature.

                      The term of the gate at a position within the gates of a feature.

                      noncomputable def Cslib.Circuits.Boolean.Tableau.posOf {k : ℕ} {State : Type} [Fintype State] (T r : ℕ) :
                      ℕ × Loc k State

                      The column and the position at an offset r of a block: the scan, global gate, global feature or column feature whose region contains r. It inverts Loc.offset (posOf_offset).

                      Decoding inverts the layout #

                      Decoding the index of a scanned quantity recovers the quantity.

                      The index of a scanned quantity is strictly less than 3 + 3 * k.

                      Decoding the index of a scan position recovers the position.

                      The index of a scan position is strictly less than scanWidth k.

                      theorem Cslib.Circuits.Boolean.Tableau.GlobLoc.idx_lt {k : ℕ} {State : Type} [Fintype State] (l : GlobLoc k State) :
                      l.idx < globWidth k State

                      The index of a global gate position is strictly less than globWidth k State.

                      theorem Cslib.Circuits.Boolean.Tableau.GlobLoc.ofIdx_idx {k : ℕ} {State : Type} [Fintype State] (l : GlobLoc k State) :
                      ofIdx l.idx = l

                      Decoding the index of a global gate position recovers the position.

                      theorem Cslib.Circuits.Boolean.Tableau.GFeat.idx_lt {State : Type} [Fintype State] (f : GFeat State) :
                      f.idx < Fintype.card (Option State) + 4

                      The index of a global feature is strictly less than Fintype.card (Option State) + 4.

                      theorem Cslib.Circuits.Boolean.Tableau.GFeat.ofIdx_idx {State : Type} [Fintype State] (f : GFeat State) :
                      ofIdx f.idx = f

                      Decoding the index of a global feature recovers the feature.

                      The index of a column feature is strictly less than 1 + 4 * k.

                      Decoding the index of a column feature recovers the feature.

                      theorem Cslib.Circuits.Boolean.Tableau.gadgetIdx_lt (fi : ℕ) (b : Bool) (j : Fin 8) :
                      gadgetIdx fi b j < 16 * (fi + 1)

                      The gadget index for feature fi is strictly less than 16 * (fi + 1).

                      theorem Cslib.Circuits.Boolean.Tableau.gadgetIdx_div (fi : ℕ) (b : Bool) (j : Fin 8) :
                      gadgetIdx fi b j / 16 = fi

                      Dividing gadgetIdx fi b j by 16 recovers the feature index fi.

                      Decoding the gate kind from gadgetIdx fi b j recovers b.

                      Decoding the term index from gadgetIdx fi b j recovers j.

                      Block bounds and wire division #

                      def Cslib.Circuits.Boolean.Tableau.Loc.ColOK {k : ℕ} {State : Type} [Fintype State] (T c : ℕ) :
                      Loc k State → Prop

                      The column c is admissible for the position l: a column of the window for a gate of the scan or a column feature, and 0 for a global gate.

                      Instances For

                        Any scan gate offset in a valid column is strictly less than globStart k T.

                        theorem Cslib.Circuits.Boolean.Tableau.gfStart_add_gadgetIdx_lt {k : ℕ} {State : Type} [Fintype State] {T : ℕ} (f : GFeat State) (b : Bool) (j : Fin 8) :
                        gfStart k State T + gadgetIdx f.idx b j < colStart k State T

                        Any global-feature gadget offset is strictly less than colStart k State T.

                        theorem Cslib.Circuits.Boolean.Tableau.Loc.offset_lt {k : ℕ} {State : Type} [Fintype State] {T : ℕ} {l : Loc k State} {c : ℕ} (hl : ColOK T c l) :
                        offset T c l < blockSize k State T

                        A position lies within its block.

                        theorem Cslib.Circuits.Boolean.Tableau.Loc.offset_lt_of_lt {k : ℕ} {State : Type} [Fintype State] {T : ℕ} {l : Loc k State} {c : ℕ} (hc : c < numCols T) :
                        offset T c l < blockSize k State T

                        Every position lies within its block, for a column of the window.

                        theorem Cslib.Circuits.Boolean.Tableau.Loc.ColOK.lt {k : ℕ} {State : Type} [Fintype State] {T : ℕ} {l : Loc k State} {c : ℕ} (hl : ColOK T c l) :

                        Any admissible column c for a position l satisfies c < numCols T.

                        The scan region has positive width, including for a machine with no work tapes.

                        theorem Cslib.Circuits.Boolean.Tableau.wire_sub {k : ℕ} {State : Type} [Fintype State] (n T t : ℕ) (l : Loc k State) (c : ℕ) :
                        wire n T t l c - n = 2 + t * blockSize k State T + Loc.offset T c l

                        Subtracting the input offset gives the index of a tableau gate.

                        theorem Cslib.Circuits.Boolean.Tableau.div_mod_wire {k : ℕ} {State : Type} [Fintype State] {n T t : ℕ} {l : Loc k State} {c : ℕ} (hl : Loc.ColOK T c l) :
                        (wire n T t l c - n - 2) / blockSize k State T = t ∧ (wire n T t l c - n - 2) % blockSize k State T = Loc.offset T c l

                        Dividing and reducing wire n T t l c - n - 2 modulo blockSize recovers the block t and intra-block offset l.offset T c.

                        theorem Cslib.Circuits.Boolean.Tableau.posOf_offset {k : ℕ} {State : Type} [Fintype State] {T c : ℕ} {l : Loc k State} (hl : Loc.ColOK T c l) :
                        posOf T (Loc.offset T c l) = (c, l)

                        Decoding the offset of a position gives its column and the position.

                        Every gate sits at a position #

                        theorem Cslib.Circuits.Boolean.Tableau.ScanQ.idx_ofIdx {k m : ℕ} (hm : m < 3 + 3 * k) :
                        (ofIdx m).idx = m

                        Encoding ScanQ.ofIdx m for m < 3 + 3 * k recovers m.

                        Encoding ScanLoc.ofIdx m for m < scanWidth k recovers m.

                        theorem Cslib.Circuits.Boolean.Tableau.GlobLoc.idx_ofIdx {k : ℕ} {State : Type} [Fintype State] {m : ℕ} (hm : m < globWidth k State) :
                        (ofIdx m).idx = m

                        Encoding GlobLoc.ofIdx m for m < globWidth k State recovers m.

                        theorem Cslib.Circuits.Boolean.Tableau.GFeat.idx_ofIdx {State : Type} [Fintype State] {m : ℕ} (hm : m < Fintype.card (Option State) + 4) :
                        (ofIdx m).idx = m

                        Encoding GFeat.ofIdx m for m < Fintype.card (Option State) + 4 recovers m.

                        theorem Cslib.Circuits.Boolean.Tableau.ColFeat.idx_ofIdx {k m : ℕ} (hm : m < 1 + 4 * k) :
                        (ofIdx m).idx = m

                        Encoding ColFeat.ofIdx m for m < 1 + 4 * k recovers m.

                        theorem Cslib.Circuits.Boolean.Tableau.exists_wire_eq {k : ℕ} {State : Type} [Fintype State] {n T g : ℕ} (hg₂ : 2 ≤ g) (hg : g < numGates k State T) :
                        ∃ t ≤ T, ∃ (l : Loc k State) (c : ℕ), Loc.ColOK T c l ∧ wire n T t l c - n = g

                        Every gate after the constants sits at a position of a block.