Linearly Bounded Automata #
A linearly bounded automaton (LBA) is a nondeterministic Turing machine whose read/write head is confined to a region of the tape whose length is bounded by a linear function of the input length.
The canonical model used here is the endmarker presentation is_LBA/LBA (below): the
input w is written bracketed between a left endmarker ⊢ and a right endmarker ⊣, so the
tape is ⊢ w ⊣ (with |w| + 2 cells). The empty word gets the genuine two-cell tape ⊢⊣, on
which the machine runs like any other input — so the machine itself decides ε, with no
external flag. The head is confined to the bracketed region by the usual boundary clamping.
The tape alphabet is EndAlpha T Γ = Option (T ⊕ Γ) ⊕ Bool: the Sum.inl part is the
marker-free interior alphabet (none = blank, some (Sum.inl t) = input symbol,
some (Sum.inr γ) = a work symbol over an arbitrary finite work alphabet Γ), and
Sum.inr false/Sum.inr true are the endmarkers ⊢/⊣. The input is written canonically, so
the recognizer cannot do hidden preprocessing. Because Γ is an arbitrary finite type, the
interior provides Θ(|w|) bits of read/write working space — genuine linear space, the standard
Kuroda/Hopcroft–Ullman LBA, for which the recognised languages are exactly the context-sensitive
ones (CS = LBA, see Equivalence/EndmarkerToFlag.lean).
The shared machine/configuration vocabulary (Machine, Step, Reaches, Accepts) and the
plain list-loading helpers (loadList, initCfgList, LanguageViaEmbed) live here too; they
are reused by the internal marker-free bounded-tape model (Automata/LinearBounded/Positive.lean,
is_LBA_pos), which the CS = LBA development uses as the genuinely space-bounded core (it
recognizes exactly the ε-free context-sensitive languages); the empty word is supplied here by the
endmarker model running on ⊢⊣.
This is a separate automaton class from deterministic DLBAs. It reuses the bounded tape and
configuration types from Langlib.Automata.DeterministicLinearBounded.Definition.
The LBA accepts from configuration cfg if some computation path reaches an accepting state.
Equations
- LBA.Accepts M cfg = ∃ (cfg' : DLBA.Cfg Γ Λ n), LBA.Reaches M cfg cfg' ∧ M.accept cfg'.state = true
Instances For
The language recognized by an LBA, defined on non-empty lists.
Equations
- LBA.LanguageOfMachine M w = ∃ (hw : w ≠ []), LBA.Accepts M (LBA.initCfgList M w hw)
Instances For
Recognition via an embedding from the input alphabet into the tape alphabet.
Equations
- LBA.LanguageViaEmbed M embed w = ∃ (hw : List.map embed w ≠ []), LBA.Accepts M (LBA.initCfgList M (List.map embed w) hw)
Instances For
An internal helper: the language LanguageViaEmbed M embed together with an explicit decision
b for the empty word. The |w|-cell tape cannot run on ε, so this combinator is used only to
state the recognized languages of the endmarker simulators (Equivalence/EndmarkerTape.lean,
Equivalence/EndmarkerToFlag.lean), where b is always the derived value decide (ε ∈ L) — it
is never a free parameter of any automaton model.
Equations
- LBA.LanguageRecognized M embed b w = (b = true ∧ w = [] ∨ LBA.LanguageViaEmbed M embed w)
Instances For
The canonical endmarker model #
The input is bracketed ⊢ w ⊣ (|w| + 2 cells); the empty word gets the two-cell tape ⊢⊣,
so the machine decides ε itself.
The left endmarker ⊢.
Equations
Instances For
The right endmarker ⊣.
Equations
Instances For
The bracketed input tape ⊢ w ⊣: |w| + 2 cells, with the head at the left endmarker.
Even the empty word gets the genuine two-cell tape ⊢⊣, so no separate empty-word flag is
needed.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The initial configuration of an endmarker LBA on input w: start state, head on ⊢.
Equations
- LBA.initCfgEnd M w = { state := M.initial, tape := LBA.loadEnd w }
Instances For
The language recognized by an endmarker LBA: the input is bracketed ⊢ w ⊣ and the machine
accepts by an ordinary accepting run (it can accept ε by inspecting the adjacent ⊢⊣).
Equations
- LBA.LanguageEnd M w = LBA.Accepts M (LBA.initCfgEnd M w)
Instances For
A language over a finite alphabet T is LBA-recognizable if some finite nondeterministic
linearly bounded automaton over the canonical endmarker alphabet Option (T ⊕ Γ) ⊕ Bool
recognizes it with its input bracketed by endmarkers (⊢ w ⊣). The empty word is handled by the
machine itself (it runs on the two-cell tape ⊢⊣), with no external accept-empty flag.
Equations
- is_LBA L = ∃ (Γ : Type) (Λ : Type) (x : Fintype Γ) (x : Fintype Λ) (x : DecidableEq Γ) (x : DecidableEq Λ) (M : LBA.Machine (LBA.EndAlpha T Γ) Λ), LBA.LanguageEnd M = L