Theory of Computer Science
- C5. Context-free Languages: Normal Form and PDA
Gabriele R¨
- ger
University of Basel
April 1, 2020
Gabriele R¨
- ger (University of Basel)
Theory of Computer Science April 1, 2020 1 / 34
Theory of Computer Science C5. Context-free Languages: Normal Form - - PowerPoint PPT Presentation
Theory of Computer Science C5. Context-free Languages: Normal Form and PDA Gabriele R oger University of Basel April 1, 2020 Gabriele R oger (University of Basel) Theory of Computer Science April 1, 2020 1 / 34 Theory of Computer
University of Basel
Gabriele R¨
Theory of Computer Science April 1, 2020 1 / 34
April 1, 2020 — C5. Context-free Languages: Normal Form and PDA
Gabriele R¨
Theory of Computer Science April 1, 2020 2 / 34
Automata & Formal Languages Languages & Grammars Regular Languages Context-free Languages ε-rules Chomsky Normal Form PDAs Pumping Lemma Closure Properties Decidability Context-sensitive & Type-0 Languages
Gabriele R¨
Theory of Computer Science April 1, 2020 3 / 34
Context-free Grammars and ε-Rules
Gabriele R¨
Theory of Computer Science April 1, 2020 4 / 34
Context-free Grammars and ε-Rules
1 Σ finite alphabet of terminal symbols, 2 V finite set of variables (with V ∩ Σ = ∅), 3 P ⊆ (V × (V ∪ Σ)+) ∪ {S, ε} finite set of rules, 4 If S → ε ∈ P, then all other rules in V × ((V \ {S}) ∪ Σ)+. 5 S ∈ V start variable.
Gabriele R¨
Theory of Computer Science April 1, 2020 5 / 34
Context-free Grammars and ε-Rules
Automata & Formal Languages Languages & Grammars Regular Languages Context-free Languages ε-rules Chomsky Normal Form PDAs Pumping Lemma Closure Properties Decidability Context-sensitive & Type-0 Languages
Gabriele R¨
Theory of Computer Science April 1, 2020 6 / 34
Context-free Grammars and ε-Rules
Gabriele R¨
Theory of Computer Science April 1, 2020 7 / 34
Context-free Grammars and ε-Rules
G ′ ε}. We can find this set Vε by first
Gabriele R¨
Theory of Computer Science April 1, 2020 8 / 34
Context-free Grammars and ε-Rules
Gabriele R¨
Theory of Computer Science April 1, 2020 9 / 34
Chomsky Normal Form
Gabriele R¨
Theory of Computer Science April 1, 2020 10 / 34
Chomsky Normal Form
Automata & Formal Languages Languages & Grammars Regular Languages Context-free Languages ε-rules Chomsky Normal Form PDAs Pumping Lemma Closure Properties Decidability Context-sensitive & Type-0 Languages
Gabriele R¨
Theory of Computer Science April 1, 2020 11 / 34
Chomsky Normal Form
Gabriele R¨
Theory of Computer Science April 1, 2020 12 / 34
Chomsky Normal Form
German: Chomsky-Normalform
Gabriele R¨
Theory of Computer Science April 1, 2020 13 / 34
Chomsky Normal Form
Gabriele R¨
Theory of Computer Science April 1, 2020 14 / 34
Chomsky Normal Form
Gabriele R¨
Theory of Computer Science April 1, 2020 15 / 34
Chomsky Normal Form
Gabriele R¨
Theory of Computer Science April 1, 2020 16 / 34
Chomsky Normal Form
Gabriele R¨
Theory of Computer Science April 1, 2020 17 / 34
Push-Down Automata
Gabriele R¨
Theory of Computer Science April 1, 2020 18 / 34
Push-Down Automata
Automata & Formal Languages Languages & Grammars Regular Languages Context-free Languages ε-rules Chomsky Normal Form PDAs Pumping Lemma Closure Properties Decidability Context-sensitive & Type-0 Languages
Gabriele R¨
Theory of Computer Science April 1, 2020 19 / 34
Push-Down Automata
q0 q1 q2 0,1
Gabriele R¨
Theory of Computer Science April 1, 2020 20 / 34
Push-Down Automata
Pop Push
German: Keller, Stapel
Gabriele R¨
Theory of Computer Science April 1, 2020 21 / 34
Push-Down Automata
Input tape
Read head Push-down automaton Stack access Stack
German: Kellerautomat, Eingabeband, Lesekopf, Kellerzugriff
Gabriele R¨
Theory of Computer Science April 1, 2020 22 / 34
Push-Down Automata
German: Kellerautomat, Eingabealphabet, Kelleralphabet, German: ¨ Uberf¨ uhrungsfunktion
Gabriele R¨
Theory of Computer Science April 1, 2020 23 / 34
Push-Down Automata
q q′ a, A → B1 . . . Bk
Gabriele R¨
Theory of Computer Science April 1, 2020 24 / 34
Push-Down Automata
q q′ a, A → AA a, B → AB a, # → A# b, A → BA b, B → BB b, # → B# a, A → ε b, B → ε a, A → ε b, B → ε ε, # → ε
δ(q, a, A) = {q, AA, q′, ε} δ(q, b, A) = {q, BA} δ(q, ε, A) = ∅ δ(q, a, B) = {q, AB} δ(q, b, B) = {q, BB, q′, ε} δ(q, ε, B) = ∅ δ(q, a, #) = {q, A#} δ(q, b, #) = {q, B#} δ(q, ε, #) = ∅ δ(q′, a, A) = {q′, ε} δ(q′, b, A) = ∅ δ(q′, ε, A) = ∅ δ(q′, a, B) = ∅ δ(q′, b, B) = {q′, ε} δ(q′, ε, B) = ∅ δ(q′, a, #) = ∅ δ(q′, b, #) = ∅ δ(q′, ε, #) = {q′, ε}
Gabriele R¨
Theory of Computer Science April 1, 2020 25 / 34
Push-Down Automata
German: Konfiguration
I n p u t
q
Gabriele R¨
Theory of Computer Science April 1, 2020 26 / 34
Push-Down Automata
German: ¨ Ubergang
Gabriele R¨
Theory of Computer Science April 1, 2020 27 / 34
Push-Down Automata
M c′) if there are configurations c0, . . . , cn (n ≥ 0) where
German: c′ ist in M von c erreichbar
Gabriele R¨
Theory of Computer Science April 1, 2020 28 / 34
Push-Down Automata
M q, ε, ε for some q ∈ Q.
German: M erkennt w, Startkonfiguration
Gabriele R¨
Theory of Computer Science April 1, 2020 29 / 34
Push-Down Automata
q q′ a, A → AA a, B → AB a, # → A# b, A → BA b, B → BB b, # → B# a, A → ε b, B → ε a, A → ε b, B → ε ε, # → ε
Gabriele R¨
Theory of Computer Science April 1, 2020 30 / 34
Push-Down Automata
Gabriele R¨
Theory of Computer Science April 1, 2020 31 / 34
Push-Down Automata
Gabriele R¨
Theory of Computer Science April 1, 2020 32 / 34
Summary
Gabriele R¨
Theory of Computer Science April 1, 2020 33 / 34
Summary
◮ A → BC with variables A, B, C, or ◮ A → a with variable A, terminal symbol a, or ◮ S → ε with start variable S.
Gabriele R¨
Theory of Computer Science April 1, 2020 34 / 34