Theory of Computation
Theory of Computation
THEORY OF COMPUTATION
Fall 2017
http://cseweb.ucsd.edu/classes/fa17/cse105-a/
Today's learning goals Sipser Ch 1.4, 2.1
• Apply the Pumping Lemma in proofs of nonregularity
• Identify some nonregular sets
• Define context-free grammars
• Test if a specific string can be generated by a given
context-free grammar
Pumping Lemma Sipser p. 78 Theorem 1.70
# states in DFA
recognizing A
Transition labels
along loop
Proof strategy
To prove that a language L is not regular
(V, Σ, R, S)
Variables: finite set of (usually upper case) variables V
If G = (V, Σ, R, S) Notation:
the language
generated by G is Terminology: sequence of
denoted L(G). rule applications is
derivation
An example?
Consider the CFG
({S}, {0}, R, S)
where R is the following set of rules
S 0S
S0
V = { S, T, V, W }
Σ = { a,b }
R = { S aT T bV V bW W a }
S
Designing a CFG
Can CFGs
Building a CFG to describe the language describe simple
sets?
{ abba }
( { S, T, V, W } , { a,b } , { S aT , T bV , V bW , W a }, S )
OR
( { S } , { a,b } , { S abba } , S )
Is every regular language a CFL?
• Approach 1: start with an arbitrary DFA M, build a CFG
that generates L(M).
• Approach 2: build CFGs for {a}, {ε}, {}; then show that the
class of CFL is closed under the regular operations
(union, concatenation, Kleene star).
Approach 1
Claim: Given any DFA M, there is a CFG whose language is L(M).
Construction:
Trace computation using variables to denote state
Given M = (Q,Σ,δ,q0,F) a DFA, define the CFG
V = { Si | qi is in Q }
Σ
R = { Si aSj | δ(qi,a) = qj } U { Si ε | qi is in F}
S = S0 Then prove correctness…
Approach 2
If G1 = (V1, Σ, R1, S1) and G2 = (V2, Σ, R2, S2) are CFGs
and G1 describes L1, G2 describes L2, how can we combine
the grammars so we describe L1 U L2 ?
One approach:
- what is shortest string in the language?
- how do we go from shorter strings to longer ones?
Designing a CFG
Building a CFG to describe the language
{ anbn | n ≥ 0 }