{0ⁿ 1ᵐ : n ≥ m}: a push-down language with inequality counter #
A small variant of AnBn: the input is 0ⁿ 1ᵐ with the extra condition
n ≥ m. The machine structurally mirrors anbnTM — a single work tape is
used as a unary counter (push on 0, pop on 1) — but the end-of-input
branches accept unconditionally: after scanning the full input without
hitting a mismatch, the remaining stack height is exactly n − m ≥ 0,
which we accept.
The machine has six control states (start, initWork, scanZeros,
scanOnes, reject, done) and maintains the invariant that the work
head equals the current stack size. Emptiness is detected structurally
via the permanently-▷ cell 0.
Main definitions #
TM.zeroPrefixTM— 6-state 1-work-tape push-down machine.Language.zeroPrefix—{0ⁿ 1ᵐ : n ≥ m}.
Main results #
zeroPrefixTM_reachesIn— halts in|x| + 3steps on every input.zeroPrefix_in_DTIME,zeroPrefix_mem_P.
Control states of zeroPrefixTM.
start: initial state. Moves all heads from cell 0 (▷) to cell 1.initWork: rewinds work head back to cell 0 (where ▷ marks emptiness).scanZeros: scanning the0-prefix; pushes on0, transitions on1.scanOnes: scanning the1-suffix; pops on1, rejects on0.reject: sink state; consumes remaining input then halts with0.done: halted.
- start : ZeroPrefixPhase
- initWork : ZeroPrefixPhase
- scanZeros : ZeroPrefixPhase
- scanOnes : ZeroPrefixPhase
- reject : ZeroPrefixPhase
- done : ZeroPrefixPhase
Instances For
Equations
- One or more equations did not get rendered due to their size.
Push-down TM deciding {0ⁿ 1ᵐ : n ≥ m}. One work tape used as a unary
counter: the work head holds the current stack size (0 means empty,
detected by reading ▷ at cell 0). End-of-input is accepted in both
scan states — reaching a blank means we consumed the input without a
mismatch, so n ≥ m.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The output that zeroPrefixTM produces when run from scan state s
with work head h (= stack size) and remaining input rest.
Differs from anbnExpected only in end-of-input branches: scanZeros
and scanOnes at end of input always accept (output .one).
Equations
- Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.reject x✝ [] = Complexity.Γw.zero
- Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.reject x✝ (head :: rest) = Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.reject x✝ rest
- Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.scanZeros x✝ [] = Complexity.Γw.one
- Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.scanZeros x✝ (false :: rest) = Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.scanZeros (x✝ + 1) rest
- Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.scanZeros 0 (true :: rest) = Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.reject 1 rest
- Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.scanZeros h.succ (true :: rest) = Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.scanOnes h rest
- Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.scanOnes x✝ [] = Complexity.Γw.one
- Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.scanOnes x✝ (false :: rest) = Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.reject x✝ rest
- Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.scanOnes 0 (true :: rest) = Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.reject 1 rest
- Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.scanOnes h.succ (true :: rest) = Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.scanOnes h rest
- Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.start x✝¹ x✝ = Complexity.Γw.blank
- Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.initWork x✝¹ x✝ = Complexity.Γw.blank
- Complexity.TM.zeroPrefixExpected Complexity.TM.ZeroPrefixPhase.done x✝¹ x✝ = Complexity.Γw.blank
Instances For
zeroPrefixTM halts in |x| + 3 steps on every input, writing the
correct answer to output cell 1.
zeroPrefixTM decides Language.zeroPrefix in time |x| + 3.
zeroPrefix ∈ DTIME(n + 3).