Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
Contextfree and Noncontextfree
Languages
We have used the closure properties and
the pumping lemma to show that languages
are not regular.
We cannot use the previous pumping
lemma to show that a lan
Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
Converting CFGs to PDAs
Theorem: Let G = (V, , R, S) be a CFG.
Then there is a PDA M so that L(M) =
L(G).
Example: CFGs to PDAs
Given the CFG G below, create the
corresponding PDA M
R R + T  T
T T *
Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
Deductive Proofs
Sequence of statements leading from a
hypothesis H to a conclusion statement C.
Each step must follow by a logical principle.
Follow means modus ponens: if A then B.
Typically, the hy
Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
TM Example
Construct a TM for the nonregular language
pal of palindromes over cfw_a, b.
Consider the palindromes:
aabaaaba
aabaab
Closure Properties
Recursively enumerable languages are
closed under u
Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
ChurchTuring Thesis
PDAs are a restricted model of
computation, since there are languages that
can be solved by an algorithm but that are
not accepted by any PDA (e.g. cfw_aibici  i 0
ChurchTuring
Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
PDAs to CFGs
We have learned how to generate PDAs
given a CFG, but how do we derive a CFG
for a given PDA?
Theorem: If a PDA recognizes a language,
the it is context free.
PDAs to CFGs: Final State
Ac
Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
Logistics
CS 252
Theory of Computation
Available on the web.
Lecture Notes
Assignments
Schedule
Dr. Julie A. Adams
Logistics
Class time: Tu. Thurs. 11:00 AM 12:15 PM
Location: Room 306, Featheringill
Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
Languages
Is cfw_aibi  i N a regular language?
A Criterion for Regularity
Definition: Let L be a language over . Two
strings x, y * are distinguishable with
respect to L iff there exists a string z*
Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
Finite State Machines
Construct a FA that recognizes the
language of all strings of 0s and 1s of
length at least 1 that if they were
interpreted as binary representations of
integers, would represent
Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
Regular Expressions, FAs and NFAs
Kleenes Theorem: Any regular language
can be accepted by a FA, and the
language accepted by any finite
automaton is regular.
Kleenes Theorem
Kleenes Theorem: A langua
Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
CFLs
We can use CFGs to give us all strings in a
language.
How do we determine if a given string is in
the language?
Algorithms that determine if a given string is in a
contextfree language are calle
Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
NFAs versus FAs
Show that: For any FA
M = (Q, , , q0, F), there exists an NFA
M1 = (Q1, , 1, q1, F1) such that
L(M) = L(M1).
NFAs versus FAs
NFAs may look more powerful than FAs,
but they are not!
The
Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
Nondeterminism
Look at the following transition diagram for
the set of strings over cfw_a, b that contain at
most 2 as.
Why is this not a transition diagram of a FA?
When does this machine accept a st
Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
NFA to DFA example
2
a
1
b
4
3
a
1. Convert NFA to an NFA
NFA to DFA example
2. Convert NFA to a DFA
1
Regular Languages and
Expressions
A regular language over is a language
that can be built from
Theory of Automata, Formal Languages and Computation
CS 252

Spring 2008
ContextFree Grammars
A common method of defining the syntax
of programming languages are BackusNaur form (BNF), syntax diagrams, and
contextfree grammars.
ContextFree Grammars
Definition: A context