Formale Systeme, Automaten, Prozesse Übersicht 3 3.1 Kontextfreie Sprachen und Grammatiken 3.2 Ableitungsbäume 3.3 Die pre -Operation 3.4 Entscheidungsprobleme für CFGs 3.5 Normalformen für CFGs 3.6 Chomsky-Normalform 3.7 Greibach-Normalform 3.8 Das Pumping-Lemma für CFLs 3.10 Deterministische Kellerautomaten 3.11 Abschlusseigenschaften kontextfreier Sprachen
Formale Systeme, Automaten, Prozesse Folie 177 Definition 3.9.1 Ein Kellerautomat (PDA) M = (Q, Σ, Γ, δ, q 0, Γ 0, F ) ist ein 7-Tupel. Hierbei ist: Q die endliche Menge der Zustände Σ das Eingabealphabet Γ das Kelleralphabet δ : Q (Σ {ɛ}) Γ 2 Q Γ, wobei δ(q, a, X ) stets eine endliche Menge von Paaren ist, die Übergangsfunktion q 0 Q der Startzustand Γ 0 Γ das Kellerbodensymbol F Q die Menge der Endzustände
Formale Systeme, Automaten, Prozesse Folie 178 Endliche Automaten (NFA) Endliche Steuerung Lesekopf Eingabeband
Formale Systeme, Automaten, Prozesse Folie 179 Kellerautomaten (PDA) Eingabeband Endliche Steuerung Lesekopf Γ 0 Keller
Formale Systeme, Automaten, Prozesse Folie 180 Konfigurationen Definition 3.9.2 Eine Konfiguration eines PDA ist ein Tripel (q, w, γ), wobei q Q ein Zustand, w das noch zu lesende Wort und γ der Kellerinhalt ist. Wir schreiben (q, a w, X β) (p, w, α β) falls (p, α) δ(q, a, X ), wobei a Σ {ɛ}, X Γ. (p, w, α β) ist eine Nachfolgekonfiguration von (q, a w, X β).
Formale Systeme, Automaten, Prozesse Folie 181 Beispiel b, X bx a, X ax b, b ɛ a, a ɛ q ɛ, X X 0 q ɛ, Γ 0 Γ 0 1 q 2 (q 0, abba, Γ 0 ) (q 0, bba, aγ 0 ) (q 0, ba, baγ 0 ) (q 1, ba, baγ 0 ) (q 1, a, aγ 0 ) (q 1, ɛ, Γ 0 ) (q 2, ɛ, Γ 0 )
Formale Systeme, Automaten, Prozesse Folie 182 Definition 3.9.3 Es sei M = (Q, Σ, Γ, δ, q 0, Γ 0, F ) ein PDA. Für ein Eingabewort w ist die Startkonfiguration (q 0, w, Γ 0 ). ist die reflexiv-transitive Hülle von. Die von M durch Endzustand akzeptierte Sprache L(M) ist { w Σ (q 0, w, Γ 0 ) (q, ɛ, β) für ein q F und β Γ }.
Formale Systeme, Automaten, Prozesse Folie 183 b, X bx a, X ax b, b ɛ a, a ɛ q ɛ, X X 0 q ɛ, Γ 0 Γ 0 1 q 2 (q 0, abba, Γ 0 ) (q 0, bba, aγ 0 ) (q 0, ba, baγ 0 ) (q 1, ba, baγ 0 ) (q 1, a, aγ 0 ) (q 1, ɛ, Γ 0 ) (q 2, ɛ, Γ 0 ) Startkonfiguration: (q 0, abba, Γ 0 ) abba wird akzeptiert.
Formale Systeme, Automaten, Prozesse Folie 184 Definition 3.9.4 Es sei M = (Q, Σ, Γ, δ, q 0, Γ 0, F ) ein PDA. Die von M durch leeren Keller akzeptierte Sprache N(M) ist N(M) = { w Σ (q 0, w, Γ 0 ) (p, ɛ, ɛ) für ein p Q} (F spielt keine Rolle und kann weggelassen werden.)
Formale Systeme, Automaten, Prozesse Folie 185 Beispiel b, X bx a, X ax b, b ɛ a, a ɛ q ɛ, X X 0 q ɛ, Γ 0 Γ 0 1 q 2 L(M) = { ww R w {a, b} }, aber N(M) =. b, X bx a, X ax b, b ɛ a, a ɛ q ɛ, X X 0 q ɛ, Γ 0 ɛ 1 q 2 N(M) = { ww R w {a, b} }, aber L(M) =.
Formale Systeme, Automaten, Prozesse Folie 186 Satz 3.9.5 Für einen PDA A = (Q, Σ, Γ, δ, q 0, Γ 0 ) gibt es einen PDA B mit L(B) = N(A).
Formale Systeme, Automaten, Prozesse Folie 187 Beweis. Verwende B = (Q {q 0, q f }, Σ, Γ {Γ 0 }, δ B, q 0, Γ 0, {q f }) B q0 ɛ, Γ 0 Γ 0 Γ 0 q 0 A ɛ, Γ 0 Γ 0 A : (q 0, w, Γ 0 ) A (p, ɛ, ɛ) q f B : (q 0, w, Γ 0 ) B (q 0, w, Γ 0 Γ 0 ) A (p, ɛ, Γ 0 ) B (q f, ɛ, Γ 0 )
Formale Systeme, Automaten, Prozesse Folie 188 Satz 3.9.6 Für einen PDA A = (Q, Σ, Γ, δ, q 0, Γ 0, F ) gibt es einen PDA B mit N(B) = L(A).
Formale Systeme, Automaten, Prozesse Folie 189 Beweis. B = (q {q, q0 }, Σ, Γ {Γ 0 }, δ B, q0, Γ 0 ) A ɛ, X ɛ B ɛ, X X q0 ɛ, Γ 0 Γ 0 Γ 0 q 0 q ɛ, X X B arbeitet wie A, kann aber von Endzuständen spontan nach q, wo der Keller geleert wird.
Formale Systeme, Automaten, Prozesse Folie 190 Satz 3.9.7 Es sei G = (N, T, P, S) eine CFG ohne ɛ-produktionen. Dann gibt es einen PDA M mit N(M) = L(G). Beweis. M = ({q}, T, N T, δ, q, S) wobei δ(q, a, a) = {(q, ɛ)} für alle a T δ(q, ɛ, A) = { (q, α) A α P } für alle A N. Behauptung: (q, w, S) (q, ɛ, ɛ) gdw. S w
Formale Systeme, Automaten, Prozesse Folie 191 Beispiel S asa bsb a b Zugehöriger PDA: ɛ, S asa ɛ, S bsb ɛ, S a ɛ, S b a, a ɛ b, b ɛ bzw. a, S Sa b, S Sb a, S ɛ b, S ɛ a, a ɛ b, b ɛ Das Kellerbodensymbol ist S.
Formale Systeme, Automaten, Prozesse Folie 192 Satz 3.9.8 Es sei M = (Q, Σ, Γ, δ, q 0, Γ 0 ) ein PDA. Dann gibt es eine CFG G mit L(G) = N(M).
Formale Systeme, Automaten, Prozesse Folie 193 Beweis. Für jedes p Q erzeuge eine Grammatik G p = (N, Σ, P, [q 0, Γ 0, p]) wobei N = {[q, Z, r] q, r Q, Z Γ}. P enthält folgende Regeln: falls [q, Z, q k ] a[r, X 1, q 1 ][q 1, X 2, q 2 ] [q k 1, X k, q k ] (r, γ) δ(q, a, Z) mit a Σ {ɛ} γ = X 1 X k mit X i Γ q i Q (alle Möglichkeiten!) Spezialfall: [q, Z, r] a falls γ = ɛ. Es gilt (q 0, w, Γ 0 ) (p, ɛ, ɛ) gdw. [q 0, Γ 0, p] N(M) = L(G p ). p Q w d.h.
Formale Systeme, Automaten, Prozesse Folie 194 Beispiel a, a aa b, a ɛ a, Γ 0 aγ 0 ɛ, Γ 0 ɛ q ɛ, a a 0 q 1 [q 0, Γ 0, q 1 ] a[q 0, a, q 1 ][q 1, Γ 0, q 1 ] [q 0, a, q 1 ] [q 1, a, q 1 ] [q 1, a, q 1 ] b [q 1, Γ 0, q 1 ] ɛ [q 0, Γ 0, q 1 ] a[q 0, a, q 1 ][q 1, Γ 0, q 1 ] a b[q 1, Γ 0, q 1 ] a b