Skip to content

Deterministic context-free languages

15 fully proved

Automata

DefinitionDeterministic pushdown automaton#✓fully proved

A pushdown automaton is deterministic when every transition set has at most one element, and an available ε-transition precludes every consuming transition from the same state and stack symbol.

def PDA.IsDeterministic (M : PDA T σ Γ) : Prop :=
  (∀ (q : σ) (γ : Γ), (M.step q none γ).card ≤ 1) ∧
    (∀ (q : σ) (a : T) (γ : Γ), (M.step q (some a) γ).card ≤ 1) ∧
    ∀ (q : σ) (γ : Γ), (M.step q none γ).Nonempty →
      ∀ (a : T), M.step q (some a) γ = ∅
Sources
  • Sipser, Introduction to the Theory of Computation, 3rd ed., Chapter 2 (deterministic pushdown automata); Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3.
Uses 1 · Used by 2

Language

DefinitionEnd-marker encoding of a word#✓fully proved

Encode a word by copying it to the left summand and appending the end marker Sum.inr ().

def endMarkerEncode (w : List T) : List (T ⊕ Unit) :=
  w.map Sum.inl ++ [Sum.inr ()]
Sources
  • Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3 (deterministic pushdown automata, acceptance by empty stack with an end marker).
Used by 8

DefinitionEnd-marker erasure#✓fully proved

Erase the end marker: a left letter maps to its one-letter word, the end marker maps to the empty word.

def endMarkerErase : T ⊕ Unit → List T
  | .inl a => [a]
  | .inr _ => []
Sources
  • Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3 (deterministic pushdown automata, acceptance by empty stack with an end marker).
Used by 3

DefinitionLanguage of end-marker encoded words#✓fully proved

The encodings of words over T: the words over T ⊕ Unit consisting of left letters followed by a single end marker.

def encodedWords : Language (T ⊕ Unit) :=
  {u | ∃ w : List T, u = endMarkerEncode w}
Sources
  • Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3 (deterministic pushdown automata, acceptance by empty stack with an end marker).
Uses 1 · Used by 2

TheoremErasing the end-marker encoding recovers the word#✓fully proved

Erasing an encoding recovers the word.

theorem endMarkerErase_endMarkerEncode (w : List T) :
    ((endMarkerEncode w).map endMarkerErase).flatten = w
Sources
  • Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3.
Uses 2 · Used by 2

TheoremInjectivity of the end-marker encoding#✓fully proved

Encoding is injective.

theorem endMarkerEncode_injective :
    Function.Injective (endMarkerEncode (T := T))
Sources
  • Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3.
Uses 3 · Used by 1

DefinitionDFA recognizing end-marker encodings#✓fully proved

The DFA for the encodings: state inl false while reading left letters, inl true after the end marker (the accepting state), and inr () dead once anything follows the end marker.

noncomputable def endMarkerDFA : DFA (T ⊕ Unit) (Bool ⊕ Unit) where
  step := fun q c => match q, c with
    | .inl false, .inl _ => .inl false
    | .inl false, .inr _ => .inl true
    | .inl true, _ => .inr ()
    | .inr _, _ => .inr ()
  start := .inl false
  accept := {.inl true}
Sources
  • Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3.
Used by 6

TheoremDead state of the encoding DFA is absorbing#✓fully proved

The dead state of the encoding DFA stays dead.

theorem endMarkerDFA_evalFrom_dead (u : List (T ⊕ Unit)) :
    endMarkerDFA.evalFrom (Sum.inr ()) u = Sum.inr ()
Sources
  • Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3.
Uses 1 · Used by 1

TheoremEncoding DFA stays in its start state on left letters#✓fully proved

The encoding DFA stays in its start state while reading left letters.

theorem endMarkerDFA_evalFrom_inl (w : List T) :
    endMarkerDFA.evalFrom (Sum.inl false) (w.map Sum.inl) = Sum.inl false
Sources
  • Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3.
Uses 1 · Used by 1

TheoremEncoding DFA after the end marker accepts only the empty input#✓fully proved

After the end marker, the encoding DFA can only be in its accepting state on empty input.

theorem endMarkerDFA_evalFrom_afterMarker {u : List (T ⊕ Unit)}
    (h : endMarkerDFA.evalFrom (Sum.inl true) u = Sum.inl true) : u = []
Sources
  • Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3.
Uses 2 · Used by 1

TheoremEncoding DFA accepts every end-marker encoding#✓fully proved

The encoding DFA accepts exactly the encodings: it reaches the accepting state on an encoding.

theorem endMarkerDFA_evalFrom_encode (w : List T) :
    endMarkerDFA.evalFrom (Sum.inl false) (endMarkerEncode w) = Sum.inl true
Sources
  • Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3.
Uses 3 · Used by 1

TheoremEncoding DFA accepts only end-marker encodings#✓fully proved

The encoding DFA reaches the accepting state only on encodings.

theorem exists_endMarkerEncode_of_endMarkerDFA_evalFrom {u : List (T ⊕ Unit)}
    (h : endMarkerDFA.evalFrom (Sum.inl false) u = Sum.inl true) :
    ∃ w : List T, u = endMarkerEncode w
Sources
  • Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3.
Uses 3 · Used by 1

TheoremEnd-marker encodings form a regular language#✓fully proved

The encodings of words form a regular language.

theorem isRegular_encodedWords :
    (encodedWords : Language (T ⊕ Unit)).IsRegular
Sources
  • Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3.
Uses 5 · Used by 1

DefinitionDeterministic context-free language#✓fully proved

A language is deterministic context-free when some deterministic pushdown automaton with finite state and stack alphabets, whose transitions consume letters from a finite set, accepts by empty stack exactly the end-marker encodings of its words.

def IsDeterministicContextFree (L : Language T) : Prop :=
  ∃ (σ Γ : Type) (_ : Fintype σ) (_ : Fintype Γ) (M : PDA (T ⊕ Unit) σ Γ),
    M.IsDeterministic ∧
      (∃ T₀ : Finset (T ⊕ Unit), ∀ (p : σ) (a : T ⊕ Unit) (γ : Γ),
        a ∉ T₀ → M.step p (some a) γ = ∅) ∧
      M.accepts = (fun w : List T => endMarkerEncode w) '' L
Sources
  • Ginsburg and Greibach, "Deterministic context free languages", Information and Control 9 (1966), 620-648; Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3.
Uses 4 · Used by 1

TheoremDeterministic context-free languages are context-free#✓fully proved

Every deterministic context-free language is context-free: the encoded language is accepted by a pushdown automaton, hence context-free; intersecting with the regular language of encodings and erasing the end marker recovers the original language.

theorem IsDeterministicContextFree.isContextFree
    (hL : IsDeterministicContextFree L) : L.IsContextFree
Sources
  • Ginsburg and Greibach, "Deterministic context free languages", Information and Control 9 (1966), 620-648; Hopcroft, Motwani, and Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Section 10.3.
Uses 13

The dependency explorer needs JavaScript and its graph data.

Download the complete graph data.