Documentation

Complexitylib.Classes.Containments.Internal.ConfigCount

Counting the configurations inside a space bound #

⚠️ Unreviewed by Bolton

Cfg.WithinDecisionSpace bounds head positions, but counting configurations also needs to know the tape contents are pinned down. A head that never leaves its window can never write outside it, so every cell beyond still holds what it started with — that is Windowed, and it is what makes the configuration space finite.

Nothing here mentions a machine: the counting is the same for deterministic and nondeterministic configurations, and both PSPACE ⊆ EXP and the log-space graph arguments use it.

Main definitions #

Main results #

structure Complexity.Windowed {k : } {Q : Type} (x : List Bool) (S : ) (c : Cfg k Q) :

Outside the space window every tape still holds what it started with: the input tape is read-only, and the work and output tapes are blank beyond the reach of their heads.

Instances For
    theorem Complexity.windowed_init {k : } {Q : Type} (q : Q) (x : List Bool) (S : ) :
    Windowed x S (Cfg.init q x)

    The initial configuration is windowed.

    theorem Complexity.Windowed.mono {k : } {Q : Type} {x : List Bool} {S S' : } {c : Cfg k Q} (h : Windowed x S c) (hS : S S') :
    Windowed x S' c

    Enlarging the window preserves the invariant: what is blank beyond S is blank beyond any larger S' too.

    theorem Complexity.Cfg.WithinDecisionSpace.mono {k : } {Q : Type} {n S S' : } {c : Cfg k Q} (h : c.WithinDecisionSpace n S) (hS : S S') :

    Enlarging the space budget preserves a decision-space bound.

    theorem Complexity.cells_writeAndMove_of_ne (t : Tape) (s : Γ) (d : Dir3) {p : } (hp : p t.head) :
    (t.writeAndMove s d).cells p = t.cells p

    Writing at the head leaves every other cell alone.

    @[reducible, inline]
    abbrev Complexity.Code (Q : Type) (k nn S : ) :

    A finite code for configurations inside the space window: the state, the three head positions clamped into range, and the tape contents restricted to the window.

    Equations
    Instances For
      @[instance_reducible]
      instance Complexity.instDecidableEqCode (Q : Type) [DecidableEq Q] (k nn S : ) :
      DecidableEq (Code Q k nn S)

      Codes have decidable equality: the search of Complexitylib.Classes.Containments.Internal.CodeSearch stores them in a Finset. The instance is spelled out because the default synthesis size limit stops short of this nesting depth.

      Equations
      def Complexity.cfgCode {k : } {Q : Type} (nn S : ) (c : Cfg k Q) :
      Code Q k nn S

      The code of a configuration. Clamping keeps this total; on configurations that respect the space bound the clamps are inert.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        theorem Complexity.cfgCode_inj {k : } {Q : Type} {x : List Bool} {S : } {c₁ c₂ : Cfg k Q} (h₁ : Windowed x S c₁) (hs₁ : c₁.WithinDecisionSpace x.length S) (h₂ : Windowed x S c₂) (hs₂ : c₂.WithinDecisionSpace x.length S) (h : cfgCode x.length S c₁ = cfgCode x.length S c₂) :
        c₁ = c₂

        Two windowed configurations inside the space bound with the same code are equal.

        theorem Complexity.card_Code (Q : Type) [Fintype Q] (k nn S : ) :
        Fintype.card (Code Q k nn S) = Fintype.card Q * ((nn + S + 2) * (((S + 1) * 4 ^ (S + 1)) ^ k * ((S + 2) * 4 ^ (S + 2))))

        The number of codes.

        theorem Complexity.card_Code_le_two_pow (Q : Type) [Fintype Q] (k nn S : ) :
        Fintype.card (Code Q k nn S) 2 ^ (Fintype.card Q + (nn + S + 2) + 3 * k * (S + 1) + 3 * (S + 2))

        The configuration count is at most exponential in the space bound. Both PSPACE ⊆ EXP and Savitch's theorem read the count this way: as 2 to something linear in the space bound.