Context-Free Closure Under Inverse String Homomorphism #
This file proves that context-free languages are closed under inverse string
homomorphism. Given a CFL L over β and a string homomorphism h : α → List β,
the preimage h⁻¹(L) = {w : List α | h(w) ∈ L} is also context-free.
Strategy #
We decompose h⁻¹(L) as π(D ∩ f⁻¹(L)) where the intermediate alphabet is Γ = α ⊕ β:
fHom : Γ → List βerasesSum.inlsymbols and unwrapsSum.inrsymbols.piHom : Γ → List αkeepsSum.inlvalues and erasesSum.inrsymbols.dLangis a regular "well-formedness" language overΓconsisting of valid encodings.fInv Lis CFL (the languageLwithSum.inlsymbols freely inserted).
Then:
fInv Lis CFL via substitution (CF_of_subst_CF).dLang his regular via DFA construction.dLang h ∩ fInv Lis CFL (CF_of_CF_inter_regular).π(dLang h ∩ fInv L)is CFL (CF_closed_under_homomorphism).
Main declarations #
Language.inverseHomomorphicImage: the preimage of a language under a string homomorphism.CF_closed_under_inverse_homomorphism: CFLs are closed under inverse homomorphism.
The preimage of a language L under a string homomorphism h.
This is the set of words w over α such that h(w) ∈ L, where h extends to words by
concatenation: h(a₁⋯aₙ) = h(a₁) ++ ⋯ ++ h(aₙ).
Instances For
DFA state type for recognizing D.
none: dead statesome none: ready/accepting state (completed all blocks)some (some ⟨a, k⟩): currently processingh(a)at positionk
Instances For
DFA transition function for recognizing D.
Equations
- dStep h (some none) (Sum.inl a) = if hl : 0 < (h a).length then some (some ⟨a, ⟨0, hl⟩⟩) else some none
- dStep h (some (some ⟨a, k⟩)) (Sum.inr b) = if (h a).get k = b then if hlast : ↑k + 1 < (h a).length then some (some ⟨a, ⟨↑k + 1, hlast⟩⟩) else some none else none
- dStep h (some none) (Sum.inr val) = none
- dStep h (some (some val)) (Sum.inl val_1) = none
- dStep h none x✝ = none
Instances For
The class of context-free languages is closed under inverse string homomorphism.
Given a context-free language L over alphabet β and a string homomorphism h : α → List β
(with α a finite type), the preimage h⁻¹(L) = {w | h(w) ∈ L} is also context-free.
The class of context-free languages is closed under inverse string homomorphism.