Documentation

Complexitylib.Languages.FirstCell

Languages determined by the first input cell #

Non-trivial languages whose membership can be decided by reading just the first cell after on the input tape. We build a single 3-state TM decideFirstCellTM parameterized by a predicate yesOn : Γ → Bool, prove it runs in exactly 2 steps, and specialize it to several concrete languages.

Main definitions #

Concrete languages #

Main results #

The first cell after on the initial input tape, as a Γ symbol. This is the cell the machine reads on its second step.

Equations
Instances For
    @[simp]

    firstCell x reads cell 1 of the initial input tape.

    Control states of decideFirstCellTM.

    Instances For
      @[implicit_reducible]
      Equations
      • One or more equations did not get rendered due to their size.
      def Complexity.TM.decideFirstCellTM {n : } (yesOn : ΓBool) :
      TM n

      Parametric 3-state TM: advance past on input and output, then read input cell 1 and write 1 if yesOn iHead, else 0. Always halts in exactly 2 steps.

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

        decideFirstCellTM yesOn halts in exactly 2 steps on every input, with output cell 1 set to Γ.one if yesOn (firstCell x) is true and Γ.zero otherwise.

        theorem Complexity.TM.decideFirstCellTM_decidesInTime {yesOn : ΓBool} {L : Language} (hL : ∀ (x : List Bool), x L yesOn (firstCell x) = true) :
        (decideFirstCellTM yesOn).DecidesInTime L fun (x : ) => 2

        Generic bridge from decideFirstCellTM_reachesIn to DecidesInTime. Whenever a language L is characterized by x ∈ L ↔ yesOn (firstCell x), the 0-work-tape version of decideFirstCellTM yesOn decides L in 2 steps.

        @[reducible, inline]

        The language {[]}: the only accepted string is the empty one.

        Equations
        Instances For

          Strings whose first bit is 1.

          Equations
          Instances For

            Strings whose first bit is 0.

            Equations
            Instances For

              {[]} ∈ DTIME(2): decided in 2 steps by decideFirstCellTM (· = Γ.blank).

              Alternative proof: nonempty ∈ P via P_compl applied to {[]} ∈ P.

              Alternative proof: nonempty ∈ P via P_union.