study material 2it70 finite automata and process...
TRANSCRIPT
Study Material
2IT70 Finite Automata and Process Theory
Technische Universiteit Eindhoven
June 8, 2016
Study material
Updated reader: Chapters 3 and 5
Hopcroft, Motwani & Ullman (2001)
Background reading: Chapters 5-7More specific: 5.1, 5.2; 6.1, 6.2, 6.3; 7.1, 7.2, 7.4
Exercises
Proofs
Lm 3.15bc: combining and splitting productions of a CFGLm 3.28 & Th 3.29: eliminating non-generating variablesLm 3.31 & Th 3.32: eliminating non-reachable variablesTh 3.39 & 3.42: produced by CFG vs. yield of a parse treeTh 3.44 & 3.48: from CFG to PDA, from PDA to ePDATh 3.52: intersection of context-free and regularTh 3.54: Pumping Lemma for CFL
2 IT70 (2016) Study Material 2 / 34
Push-Down Automata & Context-Free Languages
2IT70 Finite Automata and Process Theory
Technische Universiteit Eindhoven
June 8, 2016
Formal definition
push-down automaton P = (Q, Σ, ∆, ∅, →, q0, F )
Q states
Σ input alphabet, τ ∉ Σ
∆ stack alphabet, ∅ ∉∆ empty stack symbol
→ ⊆ Q ×Στ ×∆∅ ×∆∗ ×Q transition relation
with Στ = Σ ∪ {τ} and ∆∅ =∆ ∪ {∅}
q0 ∈ Q initial state
F ⊆ Q final states
accepted language
L(P) = {w ∈ Σ∗ ∣ ∃q ∈ F ∃x ∈∆∗∶ (q0,w , ε) ⊢∗P(q, ε, x) }
2 IT70 (2016) Push-Down Automata & Context-Free Languages 4 / 34
Invariant table
q0 q1 q2 q3a[∅/1] b[1/ε] τ[∅/ε]
a[1/11] b[1/ε]
L(P) = { anbn ∣ n ⩾ 1 }
2 IT70 (2016) Push-Down Automata & Context-Free Languages 5 / 34
Invariant table
q0 q1 q2 q3a[∅/1] b[1/ε] τ[∅/ε]
a[1/11] b[1/ε]
L(P) = { anbn ∣ n ⩾ 1 }
state q input w stack x
q0 ε ε
q1 an 1n 1 ⩽ n
q2 anbm 1n−m 1 ⩽ m ⩽ n
q3 anbn ε 1 ⩽ n
if (q,w , x) in invariant table then (q0,w , ε) ⊢∗P(q, ε, x)
2 IT70 (2016) Push-Down Automata & Context-Free Languages 5 / 34
Language of a CFG
context-free grammar G = (V , T , R , S )
V variables and T terminals
R ⊆ V ×(V ∪T )∗ production rules A→ α
S ∈ V start symbol
productions ⇒G ⊆ (V∪T ) × (V∪T )
γ ⇒G γ′ if γ = β1Aβ2, A→ α rule of G , γ′ = β1αβ2
production sequences
γ0 ⇒G γ1 ⇒G ⋯⇒G γn
language of a variable
LG(A) = {w ∈ T∗ ∣ A ⇒∗
Gw }
language of the grammar
L(G) = LG(S)
2 IT70 (2016) Push-Down Automata & Context-Free Languages 6 / 34
Avoiding the inductive proofs
lemma CFGs G1 = (V1, T1, R1, S1 ) and G2 = (V2, T2, R2, S2 )
moreover V1 and V2 disjoint
define CFG G = ({S} ∪V1 ∪ V2, T1 ∪T2, R , S )
if R = {S → S1 ∣ S2} ∪R1 ∪ R2 then L(G) = L(G1) ∪L(G2)
if R = {S → S1S2} ∪R1 ∪ R2 then L(G) = L(G1) ⋅L(G2)
if R = {S → ε ∣ S1S} ∪ R1 then L(G) = L(G1)∗
2 IT70 (2016) Push-Down Automata & Context-Free Languages 7 / 34
Avoiding the inductive proofs (cont.)
CFG G with production rules
S → S1 ∣ S2S1 → aB B → ε ∣ bBS2 → bA A→ ε ∣ aA
then L(G) = { abn, bam ∣ n,m ⩾ 0 }
proof use the lemma
LG(A) = { am ∣ m ⩾ 0 } and LG(B) = { b
n ∣ n ⩾ 0 }
LG(S1) = {a} ⋅ { bn ∣ n ⩾ 0 } and LG(S2) = {b} ⋅ { a
m ∣ m ⩾ 0 }
L(G) = { abn ∣ n ⩾ 0 } ∪ { bam ∣ m ⩾ 0 }
2 IT70 (2016) Push-Down Automata & Context-Free Languages 8 / 34
Context-free languages
language L is context-free if L = L(G) for CFG G
{ anbn ∣ n ⩾ 0 } and {wwR ∣ w ∈ {0,1}∗ } are context-free
but not regular
2 IT70 (2016) Push-Down Automata & Context-Free Languages 9 / 34
Yield of a parse tree
CFG G = (V , T , R , S )
set PTG of all parse trees of G
[X ] single node tree, X ∈ V ∪T
[A→ ε] two node tree, root A, leaf ε for rule A→ ε ∈ R
[A→ PT 1,PT 2, . . . ,PT k]
rule A→ X1⋯Xk ∈ Rparse trees PTi with root Xi
yield function yield ∶ PTG → (V ∪T )∗
yield([X ]) = X yield([A → ε]) = ε
yield([A → PT 1, . . . ,PT k]) = yield(PT 1) ⋅ . . . ⋅ yield(PT k)
parse tree PT is complete if yield(PT ) ∈ T ∗
2 IT70 (2016) Push-Down Automata & Context-Free Languages 10 / 34
A parse tree with yield ()(())
S
S S
( S )
ε
( S )
( S )
ε
2 IT70 (2016) Push-Down Automata & Context-Free Languages 11 / 34
A parse tree with yield ()(())
S
S S
( S )
ε
( S )
( S )
ε
2 IT70 (2016) Push-Down Automata & Context-Free Languages 11 / 34
From CFG to parse trees
theorem CFG G = (V , T , R , S )
A ⇒∗G
w implies w = yield(PT )
for parse tree PT with root A
proof by induction on n :
A ⇒n
Gw implies ∃PT ∈ PTG(A)∶w = yield(PT )
for all A ∈ V and w ∈ T ∗
thus L(G)={w ∈ T ∗ ∣ S ⇒∗G
w }
⊆{ yield(PT ) ∣ PT complete parse tree of G , root S }
2 IT70 (2016) Push-Down Automata & Context-Free Languages 12 / 34
From parse tree to CFG
theorem CFG G
for parse tree PT , root A and yield w : Aℓ⇒∗
Gw
proof induction on the height of the parse tree PT
thus { yield(PT ) ∣ PT complete parse tree of G , root S }⊆
{w ∈ T ∗ ∣ S ⇒∗G
w }=L(G)
2 IT70 (2016) Push-Down Automata & Context-Free Languages 13 / 34
Useless symbols
CFG G = (V ,T ,R ,S)
symbol X ∈ V ∪T generating if X ⇒∗G
w ∈ T ∗
symbol X ∈ V ∪T reachable if ∃α,β∶S ⇒∗G
αXβ
symbol X ∈ V ∪T is useful if both generating and reachable
2 IT70 (2016) Push-Down Automata & Context-Free Languages 14 / 34
Finding of generating variables
CFG G = (V ,T ,R ,S) with L(G) ≠ ∅
symbol X ∈ V ∪T is generating if X ⇒∗G
w ∈ T ∗ andGen(G) = { X ∣ X generating }
lemma put
Gen0 = T
Geni+1 = Geni ∪ { A ∣ A→G α, α ∈ Gen∗i}
Gen = ⋃∞i=0 Geni
then Gen(G) = Gen
theorem CFG G ′ = (V ′,T ,R ′,S) with V ′ = V ∩Gen(G) and
R ′ = { A→ α ∈ R ∣ A ∈ Gen, α ∈ Gen∗ }
then L(G) = L(G ′) and all symbols of G ′ generating
2 IT70 (2016) Push-Down Automata & Context-Free Languages 15 / 34
Finding of reachable variables
CFG G = (V ,T ,R ,S) with L(G) ≠ ∅
symbol X ∈ V ∪T is reachable if S ⇒∗G
αXβ andReach(G) = { X ∣ X reachable }
lemma put
Reach0 = {S}
Reachi+1 = Reach i ∪ {X ∣ A→G γ, A ∈ Reach i , γαXβ }
Reach = ⋃∞i=0 Reach i
then Reach(G) = Reach
theorem CFG G ′ = (V ′,T ,R ′,S) with V ′ = V ∩Reach(G) and
R ′ = { A→ α ∈ R ∣ A ∈ Reach }
then L(G) = L(G ′) and all variables of G ′ reachable
2 IT70 (2016) Push-Down Automata & Context-Free Languages 16 / 34
From CFG to PDA
theorem CFG G = (V , T , R , S )
a PDA P exists such that L(P) = L(G)
proof P = ({q0,q1,q2}, T , V ∪T , ∅,→,q0,{q2}) with
(1) q0τ[∅/S]ÐÐÐÐ→ q1
(2) q1a[a/ε]ÐÐÐ→ q1 for all a ∈ T (matching step)
(3) q1τ[A/α]ÐÐÐÐ→ q1 for all A → α ∈ R (production step)
(3) q1τ[∅/ε]ÐÐÐÐ→ q2
claim γℓ⇒∗
Gw iff (q1,w , γ) ⊢∗
P(q1, ε, ε)
2 IT70 (2016) Push-Down Automata & Context-Free Languages 17 / 34
PDA accepting on empty stack
PDA P = (Q, Σ, ∆, D, →, q0 ) accepting on empty stack
Q finite set of states
Σ input alphabet
∆ data alphabet or stack alphabet
D ∈∆ stack bottom symbol,
→ ⊆ Q ×Στ ×∆ ×∆∗×Q transitions where Στ = Σ ∪ {τ}
q0 ∈ Q initial state.
accepted language N (P) = {w ∈ Σ∗ ∣ ∃q ∈ Q ∶ (q0,w ,D) ⊢∗P(q, ε, ε) }
2 IT70 (2016) Push-Down Automata & Context-Free Languages 18 / 34
From ePDA to CFG
ePDA P = (Q,Σ,∆,→,q0,D) gives CFG G = (V , Σ, →, S)
V = {S} ∪ { [qd q′′ ] ∣ q,q′′ ∈ Q, d ∈∆ }
production rules
S → [q0Dq′] for all q′ ∈ Q
[qd q′′ ]→ a[p0d1p1][p1 d2p2]⋯[pk−1dk pk ]
if qa[d/d1⋯dk ]ÐÐÐÐÐÐ→P q′
with p0,p1, . . . ,pk ∈ Q such that p0 = q′ and pk = q
′′
[qd q′′ ]→ [p0d1p1][p1d2p2]⋯[pk−1dk pk ]
if qτ[d/d1⋯dk]ÐÐÐÐÐÐ→P q′
with q′′,p1, . . . ,pk ∈ Q such that p0 = q′ and pk = q
′′
[qd q′′ ]: state q reaches state q′′ when processing stack symbol d
2 IT70 (2016) Push-Down Automata & Context-Free Languages 19 / 34
An example construction
q0 q1a[D/1D]
a[1/11] b[1/ε]
τ[D/ε]
2 IT70 (2016) Push-Down Automata & Context-Free Languages 20 / 34
An example construction
q0 q1a[D/1D]
a[1/11] b[1/ε]
τ[D/ε]
S → [q0Dq0] ∣ [q0Dq1]
[q0Dq0] → a[q11q0][q0Dq0] ∣ a[q11q1][q1Dq0]
[q0Dq1] → a[q11q0][q0Dq1] ∣ a[q11q1][q1Dq1]
[q11q0] → a[q11q0][q0 1q0] ∣ a[q11q1][q1 1q0]
[q11q1] → a[q11q0][q0 1q1] ∣ a[q11q1][q1 1q1]
[q11q1] → b
[q1Dq1] → ε
2 IT70 (2016) Push-Down Automata & Context-Free Languages 20 / 34
Closure properties of context-free languages
language L is context-free if L = L(G) for CFG G
theorem context-free languages L1, L2 and L
(a) the union L1 ∪ L2 is also context-free
(b) the concatenation L1 ⋅ L2 is also context-free
(c) the Kleene closure L∗ is also context-free
2 IT70 (2016) Push-Down Automata & Context-Free Languages 21 / 34
Intersection of context-free and regular
theorem context-free language L1, regular language L2then L1 ∩ L2 is context-free
proof PDA P = (Q1, Σ, ∆, ∅, →P , q10 , F ) for L1
DFA D = (Q2, Σ, δ, q20 , F2) for L2
define PDA P ′ = (Q1 ×Q2, Σ, ∆, ∅, →P′ , (q10 ,q
20), F1 × F2) by
(q1,q2)a[d/x]ÐÐÐÐ→P′ (q
′
1,q′
2) iff q1a[d/x]ÐÐÐÐ→P q′1 and δ(q2,a) = q
′
2
(q1,q2)τ[d/x]ÐÐÐÐ→P′ (q
′
1,q2) iff q1τ[d/x]ÐÐÐÐ→P q′1
claim ((q1,q2),w , z) ⊢∗P′((q̄1, q̄2), ε, z
′) iff
(q1,w , z) ⊢∗P(q̄1, ε, z
′) and (q2,w) ⊢∗
D(q̄2, ε)
2 IT70 (2016) Push-Down Automata & Context-Free Languages 22 / 34
Pumping lemma for context-free languages
theorem if L ⊆ Σ∗ is a context-free language then
∃m > 0 ∶
∀w ∈ L, ∣w ∣ ⩾ m ∶
∃u, v , x , y , z ∶ w = uv x y z ∧ ∣v x y ∣ ⩽ m ∧ ∣v y ∣ > 0 ∶
∀i ⩾ 0 ∶ uv i x y iz ∈ L
2 IT70 (2016) Push-Down Automata & Context-Free Languages 23 / 34
Some languages that are not context-free
Pumping Lemma: if L ⊆ Σ∗ is such that
∀m > 0 ∶
∃w ∈ L, ∣w ∣ ⩾ m ∶
∀u, v , x , y , z ∶ w = uv x y z ∧ ∣v x y ∣ ⩽ m ∧ ∣v y ∣ > 0 ∶
∃i ⩾ 0 ∶ uv i x y iz ∉ L
then L is NOT a context-free language
the language L1 = { anbncn ∣ n ⩾ 0 } is not context-free
for any m > 0, consider ambmcm
the language L2 = {ww ∣ w ∈ {a,b}∗ } is not context-free
for any m > 0, consider ambmambm
2 IT70 (2016) Push-Down Automata & Context-Free Languages 24 / 34
Labeled Transition Systems andBisimulation
2IT70 Finite Automata and Process Theory
Technische Universiteit Eindhoven
June 8, 2016
Labeled transition system
labeled transition system S = (Q, Σ, →S , q0 )
finite/infinite set of states Q
finite/infinite set of actions Σ
transition relation →S ⊆ Q ×Στ ×Q
initial state q0
transitions qαÐ→S q′ for action α ∈ Στ
2 IT70 (2016) Labeled Transition Systems and Bisimulation 26 / 34
Example LTS
a buffer of capacity 2
ε0 1
00 11
10 01
in1 in0
out1 out0
in0
in1
in0
out0
in1out1
out0
out1
2 IT70 (2016) Labeled Transition Systems and Bisimulation 27 / 34
An infinite LTS
a counter process
q0 q1 q2 q3 q4
p1 p2 p3 p4
up up up
down down down
downdown
up
down
2 IT70 (2016) Labeled Transition Systems and Bisimulation 28 / 34
Branching bisimulation
LTS S = (Q, Σ, →S , q0 )
branching bisimulation relation R ⊆ Q ×Q for S
(i) if R(q,p) and qaÐ→S q′ then exist p̄,p′ ∈ Q such that
pτÐ→∗
S p̄ and p̄aÐ→S p′ with R(q, p̄) and R(q′,p′)
(ii) symmetric condition if R(q,p) and paÐ→S p′
2 IT70 (2016) Labeled Transition Systems and Bisimulation 29 / 34
Branching bisimulation
LTS S = (Q, Σ, →S , q0 )
branching bisimulation relation R ⊆ Q ×Q for S
(i) if R(q,p) and qaÐ→S q′ then exist p̄,p′ ∈ Q such that
pτÐ→∗
S p̄ and p̄aÐ→S p′ with R(q, p̄) and R(q′,p′)
(ii) symmetric condition if R(q,p) and paÐ→S p′
(iii) if R(q,p) and qτÐ→S q′ then either exist p̄,p′ ∈ Q such that
pτÐ→∗
S p̄ and p̄τÐ→S p′ with R(q, p̄) and R(q′,p′) or
exists p′ ∈ Q such that pτÐ→∗
S p′ with R(q,p′) and R(q′,p′)
(iv) symmetric condition if R(q,p) and pτÐ→S p′
states q,p ∈ Q branching bisimilar if R(q,p)
2 IT70 (2016) Labeled Transition Systems and Bisimulation 29 / 34
Branching bisimulation (cont.)
s1
t1
s2
s ′2
t2
a τ
a
s1
t1
s2
s ′2
t2
τ τ
τ
s1
t1
s2
τ
left-to-right transfer condition for visible actions
left-to-right transfer condition for silent steps
2 IT70 (2016) Labeled Transition Systems and Bisimulation 30 / 34
Coloring for branching bisimulation
q0
q4
q1
q5
q2
q6
q3
τa
τ
b
a
b b
τ
0
0
0
0
0
0
0
2 IT70 (2016) Labeled Transition Systems and Bisimulation 31 / 34
Coloring for branching bisimulation
q0
q1 q2 q3
q4 q5 q6
τa
τ
b
a
b b
τ
1
1 2 2
3 3 3
2 IT70 (2016) Labeled Transition Systems and Bisimulation 31 / 34
Coloring for branching bisimulation
q0
q1 q2 q3
q4 q5 q6
τa
τ
b
a
b b
τ
4
5 6 6
3 3 3
2 IT70 (2016) Labeled Transition Systems and Bisimulation 31 / 34
Coloring for branching bisimulation
q0
q1 q2 q3
q4 q5 q6
τa
τ
b
a
b b
τ
7
8 6 6
3 3 3
2 IT70 (2016) Labeled Transition Systems and Bisimulation 31 / 34
Composing LTS: an abstract example
a
b
S1
c dS2
processes S1 and S2
2 IT70 (2016) Labeled Transition Systems and Bisimulation 32 / 34
Composing LTS: an abstract example
a
b
S1
c dS2
a
b
a
b
a
b
c d
c d
c d
S1 ∥∅ S2
process S1 ∥∅ S2
2 IT70 (2016) Labeled Transition Systems and Bisimulation 32 / 34
Composing LTS: an abstract example
a
b
S1
c dS2
a
b
a
b
a
b
c d
c d
c d
e
f
S1 ∥γ S2
process S1 ∥γ S2 where γ(a, c) = e and γ(b,d) = f
2 IT70 (2016) Labeled Transition Systems and Bisimulation 32 / 34
Composing LTS: an abstract example
a
b
S1
c dS2
e
f
∂H(S1 ∥γ S2)
process ∂H(S1 ∥γ S2) where γ(a, c) = e, γ(b,d) = f ,H = {a,b, c ,d}
2 IT70 (2016) Labeled Transition Systems and Bisimulation 32 / 34
Composing LTS: an abstract example
a
b
S1
c dS2
τ
f
τI (∂H(S1 ∥γ S2))
process τI (∂H(S1 ∥γ S2)) where γ(a, c) = e, γ(b,d) = f ,H = {a,b, c ,d} and I = {e}
2 IT70 (2016) Labeled Transition Systems and Bisimulation 32 / 34
Study Material
2IT70 Finite Automata and Process Theory
Technische Universiteit Eindhoven
June 8, 2016
Study material
Updated reader: Chapters 3 and 5
Hopcroft, Motwani & Ullman (2001)
Background reading: Chapters 5-7More specific: 5.1, 5.2; 6.1, 6.2, 6.3; 7.1, 7.2, 7.4
Exercises
Proofs
Lm 3.15bc: combining and splitting productions of a CFGLm 3.28 & Th 3.29: eliminating non-generating variablesLm 3.31 & Th 3.32: eliminating non-reachable variablesTh 3.39 & 3.42: produced by CFG vs. yield of a parse treeTh 3.44 & 3.48: from CFG to PDA, from PDA to ePDATh 3.52: intersection of context-free and regularTh 3.54: Pumping Lemma for CFL
2 IT70 (2016) Study Material 34 / 34