Documentation

Complexitylib.Languages.LengthParity

Languages determined by the parity of the input length #

The first genuinely linear-time examples: scan the input, toggling a bit each step, and write the answer once we hit a blank. Demonstrates a textbook scan-style TM with an O(n) time bound, proved by induction on the input.

Main definitions #

Main results #

@[implicit_reducible]
Equations
  • One or more equations did not get rendered due to their size.

Scanning TM that writes 1 if the input length is even, 0 otherwise. Uses exactly 4 control states and halts in |x| + 2 steps on every input.

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

    evenLengthTM halts in |x| + 2 steps on every input, writing Γ.one to output cell 1 iff |x| is even.

    Strings of even length (including the empty string).

    Equations
    Instances For

      Strings of odd length.

      Equations
      Instances For