DCF Closure Under Intersection with a Regular Language #
This file proves that the intersection of a deterministic context-free language with a regular language is again deterministic context-free.
Strategy #
Given a DPDA M over (Q, T, S) and a DFA D over (T, σ), we build a product DPDA
over (Q × σ, T, S) that simulates both machines in parallel:
- On reading input symbol
awith stack topZ: the DPDA component transitions viaM.transition q a Zand the DFA component transitions viaD.step s a. - On an ε-transition with stack top
Z: only the DPDA component moves (viaM.epsilon_transition q Z); the DFA state stays the same. - Acceptance: the product state
(q, s)is accepting iffq ∈ M.final_statesands ∈ D.accept.
Main declarations #
DPDA.productDFA: the product DPDA×DFA constructionDPDA.productDFA_correct: the product acceptsM.acceptsByFinalState ⊓ D.acceptsDCF_inter_regular: DCFLs are closed under intersection with regular languages
theorem
DPDA.productDFA_step_projects
{Q T S σ : Type}
[Fintype Q]
[Fintype T]
[Fintype S]
[Fintype σ]
(M : DPDA Q T S)
(D : DFA T σ)
{c₁ c₂ : (M.productDFA D).toPDA.conf}
(h : PDA.Reaches₁ c₁ c₂)
:
theorem
DPDA.productDFA_step_dfa
{Q T S σ : Type}
[Fintype Q]
[Fintype T]
[Fintype S]
[Fintype σ]
(M : DPDA Q T S)
(D : DFA T σ)
{c₁ c₂ : (M.productDFA D).toPDA.conf}
(h : PDA.Reaches₁ c₁ c₂)
:
theorem
DPDA.productDFA_step_lift
{Q T S σ : Type}
[Fintype Q]
[Fintype T]
[Fintype S]
[Fintype σ]
(M : DPDA Q T S)
(D : DFA T σ)
(q : Q)
(s : σ)
(w : List T)
(γ : List S)
(q' : Q)
(w' : List T)
(γ' : List S)
(hstep : PDA.Reaches₁ { state := q, input := w, stack := γ } { state := q', input := w', stack := γ' })
:
theorem
DPDA.productDFA_reaches_projects
{Q T S σ : Type}
[Fintype Q]
[Fintype T]
[Fintype S]
[Fintype σ]
(M : DPDA Q T S)
(D : DFA T σ)
(q : Q)
(s : σ)
(w : List T)
(γ : List S)
(q' : Q)
(s' : σ)
(w' : List T)
(γ' : List S)
(h : PDA.Reaches { state := (q, s), input := w, stack := γ } { state := (q', s'), input := w', stack := γ' })
:
PDA.Reaches { state := q, input := w, stack := γ } { state := q', input := w', stack := γ' }
theorem
DPDA.productDFA_reaches_dfa_state
{Q T S σ : Type}
[Fintype Q]
[Fintype T]
[Fintype S]
[Fintype σ]
(M : DPDA Q T S)
(D : DFA T σ)
(q : Q)
(s : σ)
(w : List T)
(γ : List S)
(q' : Q)
(s' : σ)
(w' : List T)
(γ' : List S)
(h : PDA.Reaches { state := (q, s), input := w, stack := γ } { state := (q', s'), input := w', stack := γ' })
:
theorem
DPDA.productDFA_reaches_lift
{Q T S σ : Type}
[Fintype Q]
[Fintype T]
[Fintype S]
[Fintype σ]
(M : DPDA Q T S)
(D : DFA T σ)
(q : Q)
(s : σ)
(w : List T)
(γ : List S)
(q' : Q)
(w' : List T)
(γ' : List S)
(hreach : PDA.Reaches { state := q, input := w, stack := γ } { state := q', input := w', stack := γ' })
:
The class of deterministic context-free languages is closed under intersection with regular languages.