Context-Free Closure Under Prefix #
Proof that context-free languages are closed under the prefix operation, via the PDA equivalence (the "all states accept" / verification-mode approach).
Strategy #
Given a CFL L accepted by PDA M (empty-stack), we build a prefix PDA whose
language is exactly prefixLang L. The prefix PDA has two operating modes:
- Normal mode (
Sum.inlstates) – followsM's transitions, consuming input. - Verification mode (
Sum.inrstates) – entered nondeterministically from normal mode (only when the input has been fully consumed). In this mode all ofM's transitions (including reads) become ε-transitions, so the PDA can check that the remaining stack is "completable", i.e. that there exists some continuation wordvunder whichMwould reach empty stack.
Main declarations #
PDA.input_splitting– splitting a computation at a given input boundaryPrefixClosure.prefixPDA– the prefix PDA constructionis_PDA_prefixLang–is_PDA L → is_PDA (prefixLang L)Language.IsContextFree.prefixLang– CFLs are closed under prefix
noncomputable def
PrefixClosure.prefixPDA
{T : Type}
[Fintype T]
{Q S : Type}
[Fintype Q]
[Fintype S]
(M : PDA Q T S)
:
The prefix PDA.
States are Q ⊕ Q where Sum.inl q is normal mode and Sum.inr q
is verification mode.
Equations
- One or more equations did not get rendered due to their size.
Instances For
PDA-recognisable languages are closed under prefix.
theorem
Language.IsContextFree.prefixLang
{T : Type}
[Fintype T]
{L : Language T}
(h : L.IsContextFree)
:
Context-free languages are closed under the prefix operation (proved via the PDA equivalence with the "all states accept" construction).
Context-free languages are closed under the prefix operation
(project-level is_CF formulation).