Deterministic Linearly Bounded Automata #
A deterministic linearly bounded automaton (DLBA) is a deterministic Turing machine whose read/write head is restricted to the portion of the tape containing the input. This makes the configuration space finite, yielding powerful decidability results that do not hold for unrestricted Turing machines.
We adapt Mathlib's Turing machine framework (Turing.TM0, Turing.TM1) by replacing
the infinite Turing.Tape with a fixed-length BoundedTape.
Main Definitions #
DLBA.BoundedTape Γ n— A tape ofncells over alphabetΓwith a head positionDLBA.Machine Γ Λ— A deterministic linearly bounded automatonDLBA.Cfg Γ Λ n— Configuration (state + bounded tape contents)DLBA.step— Single computation step (none= halted)DLBA.iterateStep— Multi-step computationDLBA.Halts— Whether the machine eventually haltsDLBA.HaltsAt— The specific step at which the machine first haltsDLBA.Accepts— Whether the machine halts in an accepting stateDLBA.complementMachine— Complement machine (same transitions, negated acceptance)
Main Results #
DLBA.Cfg.instFintype— The configuration space is finite (for finite alphabets/states)DLBA.iterateStep_none_mono— Once halted, the machine remains haltedDLBA.complement_step_eq— The complement machine takes identical transitionsDLBA.complement_halts_iff— The complement machine halts iff the original doesDLBA.complement_accepts_iff— On halting inputs, complement accepts iff original rejectsDLBA.halts_iff_haltsWithin— A DLBA halts iff it halts withinFintype.card CfgstepsDLBA.decidableHalts— The halting problem for DLBAs is decidableDLBA.decidableAccepts— Acceptance for DLBAs is decidable
References #
- Kuroda, S.Y. (1964), "Classes of languages and linear-bounded automata"
- Myhill, J. (1960), "Linear bounded automata"
Implementation Notes #
We use Fin (n + 1) to index tape cells, guaranteeing at least one cell exists.
Head movement is clamped at boundaries: moving left at position 0 or right at the
last position leaves the head in place. This is the standard convention for DLBAs, where
boundary markers prevent the head from leaving the input region.
Direction #
Equations
- DLBA.instReprDir = { reprPrec := DLBA.instReprDir.repr }
Equations
- DLBA.instReprDir.repr DLBA.Dir.left prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "DLBA.Dir.left")).group prec✝
- DLBA.instReprDir.repr DLBA.Dir.right prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "DLBA.Dir.right")).group prec✝
- DLBA.instReprDir.repr DLBA.Dir.stay prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "DLBA.Dir.stay")).group prec✝
Instances For
Equations
- DLBA.instFintypeDir = { elems := { val := ↑DLBA.Dir.enumList, nodup := DLBA.Dir.enumList_nodup }, complete := DLBA.instFintypeDir._proof_1 }
Equations
Instances For
Equations
- DLBA.instInhabitedDir = { default := DLBA.instInhabitedDir.default }
Bounded Tape #
A bounded tape of n + 1 cells over alphabet Γ, with a read/write head.
This replaces the infinite Turing.Tape used in unrestricted Turing machines.
The tape always has at least one cell (indexed by Fin (n + 1)).
Contents of each tape cell
Current head position
Instances For
Equations
Instances For
Read the symbol under the head.
Instances For
Write a symbol at the current head position.
Instances For
Move the head, clamping at boundaries (left end = 0, right end = n).
Equations
- t.moveHead DLBA.Dir.stay = { contents := t.contents, head := t.head }
- t.moveHead DLBA.Dir.left = { contents := t.contents, head := if h : 0 < ↑t.head then ⟨↑t.head - 1, ⋯⟩ else t.head }
- t.moveHead DLBA.Dir.right = { contents := t.contents, head := if h : ↑t.head < n then ⟨↑t.head + 1, ⋯⟩ else t.head }
Instances For
Equations
- DLBA.BoundedTape.instFintype = Fintype.ofInjective (fun (t : DLBA.BoundedTape Γ n) => (t.contents, t.head)) ⋯
Machine Definition #
A deterministic linearly bounded automaton.
Γis the tape alphabet (must include a blank symbol, but we keep it general)Λis the finite set of statestransitionmaps(state, symbol)to(new_state, symbol_to_write, direction), ornoneto signal halting.acceptdetermines which states are accepting (used to define the recognized language).initialis the start state.
Transition function. Returns
noneto halt.- accept : Λ → Bool
Which states are accepting (decidable predicate).
- initial : Λ
The initial state.
Instances For
Configuration #
Equations
Instances For
Step Function #
Execute one step of the DLBA. Returns none if the machine halts
(i.e., the transition function returns none for the current state and symbol).
The configuration just before halting can be inspected for acceptance.
Equations
Instances For
Iterate the step function k times. Returns some cfg' if the machine is
still running after k steps, or none if it halted at or before step k.
Equations
- DLBA.iterateStep M cfg 0 = some cfg
- DLBA.iterateStep M cfg k.succ = (DLBA.iterateStep M cfg k).bind (DLBA.step M)
Instances For
Halting and Acceptance #
The machine halts from configuration cfg if there exists a step at which
iterateStep returns none.
Equations
- DLBA.Halts M cfg = ∃ (k : ℕ), DLBA.iterateStep M cfg k = none
Instances For
The halting configuration: the configuration of the machine at the last step before it halts. This is where we check acceptance.
Equations
- DLBA.haltingCfg M cfg h = match _hk : DLBA.iterateStep M cfg (Nat.find h - 1) with | some c => c | none => cfg
Instances For
The machine accepts from configuration cfg if it halts and the last
configuration before halting has an accepting state.
Equations
Instances For
The machine rejects from configuration cfg if it halts and the last
configuration before halting has a non-accepting state.
Equations
Instances For
The language recognized by a DLBA: the set of inputs (of each length) that the machine accepts.
Equations
- DLBA.Language M n = {w : Fin (n + 1) → Γ | DLBA.Accepts M (DLBA.initCfg M w)}
Instances For
The language recognized by a DLBA, defined on non-empty lists.
Equations
- DLBA.LanguageOfMachine M w = ∃ (hw : w ≠ []), DLBA.Accepts M (DLBA.initCfgList M w hw)
Instances For
Recognition via an embedding from the input alphabet into the tape alphabet.
Equations
- DLBA.LanguageViaEmbed M embed w = ∃ (hw : List.map embed w ≠ []), DLBA.Accepts M (DLBA.initCfgList M (List.map embed w) hw)
Instances For
Recognition with an explicit decision for the empty word (see LBA.LanguageRecognized).
Equations
- DLBA.LanguageRecognized M embed acceptEmpty w = (acceptEmpty = true ∧ w = [] ∨ DLBA.LanguageViaEmbed M embed w)
Instances For
Complement Machine #
The complement of a deterministic DLBA: same transitions, negated acceptance. This is the key construction for showing closure under complement.
Equations
- DLBA.complementMachine M = { transition := M.transition, accept := fun (q : Λ) => !M.accept q, initial := M.initial }
Instances For
Decidability of Halting #
Equations
- DLBA.decidableHalts M cfg = decidable_of_iff (∃ k ≤ Fintype.card (DLBA.Cfg Γ Λ n), DLBA.iterateStep M cfg k = none) ⋯
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- DLBA.decidableLanguage M w = DLBA.decidableAccepts M (DLBA.initCfg M w)
Closure Under Intersection and Union #
Product machine for showing closure under intersection. Runs two LBAs in parallel by taking their product state space. Both machines share the same tape (for the intersection construction, we need them to operate on the same input).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Configuration Space Cardinality #
A language over a finite alphabet T is DLBA-recognizable if it is accepted by some
finite deterministic linearly bounded automaton over the tape alphabet Option (T ⊕ Γ)
(arbitrary finite work alphabet Γ), with the input written canonically via some ∘ Sum.inl
and an explicit decision acceptEmpty for the empty word — the same convention as the
Turing-machine/recursive definitions.
Equations
- One or more equations did not get rendered due to their size.