Langlib

Langlib.Automata.DeterministicPushdown.ClosureProperties.Complement

def DPDA.complement {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) :
DPDA Q T S

Construct the complement DPDA by replacing the set of accepting states with its complement. This is a syntactic operation that swaps which states are accepting.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    @[simp]

    The complement DPDA has the same transition functions as the original.

    The complement DPDA has the same ε-transition functions as the original.

    theorem DPDA.complement_toPDA_reaches {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (q q' : Q) (w : List T) (γ γ' : List S) :
    PDA.Reaches { state := q, input := w, stack := γ } { state := q', input := [], stack := γ' } PDA.Reaches { state := q, input := w, stack := γ } { state := q', input := [], stack := γ' }

    The multi-step reachability relation is the same for a DPDA and its complement, because the step function depends only on the transitions, not the accepting states.

    theorem DPDA.complement_isTotal {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (h : M.IsTotal) :

    Complementing a total DPDA yields a total DPDA: flipping the accepting states changes neither the transitions (so totality is preserved) nor whether two empty-input configurations agree (so acceptance consistency is preserved).

    For a total DPDA, the complemented DPDA accepts precisely the complement of the original language.

    Complement closure for total presentations. If L is recognized by a total DPDA, so is Lᶜ: complement the total DPDA.

    theorem is_DCF_complement {T : Type} [Fintype T] {L : Language T} (hL : is_DCF L) :

    Complement closure for deterministic context-free languages. Every DCF L has Lᶜ deterministic context-free as well. An arbitrary final-state DPDA for L need not decide every input, so the proof first totalizes it (DPDA.exists_equivalent_total) into an equivalent total DPDA and then complements that — no DPDA.IsTotal hypothesis on the input is required.

    Deterministic context-free languages are closed under complement.