Transcript Document

CSCI 2670
Introduction to Theory of
Computing
October 13, 2005
Agenda
• Yesterday
– Decidability and regular languages
• Today
– Putting things in perspective
– More on decidability and regular
languages
– Decidability and context free grammars
October 13, 2005
2
Course goals
• Theoretically explore the capabilities
and limitations of computers
– Complexity theory
• What makes some problems computationally
hard and others easy?
– Computability theory
• What problems can be solved by a computer?
– Automata theory
• How can we mathematically model
computation?
October 13, 2005
3
Some perspective
• Automata theory
– Introduced DFA’s, NFA’s, RE’s
• Showed that they all accept the same class
of languages
– Introduced CFG’s, PDA’s
• PDA is essentially an NFA with a stack
• PDA’s and CFG’s accept the same class of
languages
October 13, 2005
4
Perspective (cont.)
• Computability Theory
– Introduced TM’s
• Like PDA’s with more general memory model
– Importance of TM’s
• Church-Turing Thesis
• Any algorithm can be implemented on a TM
– Use the TM model and Church-Turing Thesis to
understand and classify languages
•
•
•
•
•
Decidable languages
Undecidable languages
Recognizable languages
Unrecognizable languages
Complements of languages in these classes
October 13, 2005
5
Perspective (cont.)
• Complexity theory (later this
semester)
– Use TM model to determine how long an
algorithm takes to run
• Function of input length
– Classify algorithms according to their
complexity
October 13, 2005
6
Decidable languages
•
A language is decidable if some
Turing machine decides it
–
Every string in * is either accepted or
rejected
October 13, 2005
7
Some decidable languages
• ADFA = {<B,w> | B is a DFA that
accepts input string w}
• ANFA = {<B,w> | B is an NFA that
accepts input string w}
• AREX = {<R,w> | R is a regular
expression that generates string w}
• EDFA = {<A> | A is a DFA and L(A) = }
• EQDFA = {<A,B> | A and B are DFA’s
and L(A) = L(B)}
October 13, 2005
8
Question
• How would we show that the following
language is decidable?
ALLDFA = {<A> | A is a DFA that
recognizes *}
October 13, 2005
9
Another question
• Let L be any regular language
• How would we show L is decidable?
– Assume L is described using a DFA
October 13, 2005
10
Deciders and CFG’s
• Consider the following language
ACFG = {<G,w> | G is a CFG that
generates string w}
• Is ACFG decidable?
– Problem: How can we get a TM to
simulate a CFG?
• Must be certain CFG tries a finite number of
steps!
– Solution: Use Chomsky normal form
October 13, 2005
11
Chomsky normal form review
• All rules are of the form
A →BC
A →a
• Where A, B, and C are any variables
(B and C cannot be the start variable)
S→ε
• is the only εrule, where S is the start
variable
October 13, 2005
12
How many steps to generate w?
• If |w| = 0
– 1 step
• If |w| = n > 0?
– 2n – 1 steps
October 13, 2005
13
TM simulating ACFG
M = “On input <G>, where G is a CFG
1. Convert G into Chomsky normal form
2. If |w| = 0
 If there is an S → εrule, accept
 Otherwise, reject
3. List all derivations with 2|w|-1 steps
 If any generate w, accept
 Otherwise, reject”
October 13, 2005
14
Empty CFG’s
• Consider the following language
ECFG = {<G> | G is a CFG and L(G) = }
• Theorem: ECFG is decidable
• Can we use the TM in ACFG to prove
this?
– No. There are infinitely many possible
strings in Σ*
– Instead, we need to check if there is any
way to get from the start variable to
some string of October
terminals
13, 2005
15
Work backwards
B = “On input <G>, where G is a CFG
1. Mark all terminals
2. Repeat until no new variables are
marked
•
Mark any variable A if G has a rule
A→U1U2…Uk where U1, U2, …, Uk are all
marked
3. If S is marked, reject
4. Otherwise, accept”
October 13, 2005
16
What about EQCFG?
• Recall for EQDFA, we considered
(L(A)  L(B))  (L(A)  L(B))
• Will this work for CFG’s?
– No. CFG’s are not closed under
complementation or intersection
• EQCFG is not a decidable language!
– We will see this later
October 13, 2005
17
Decidability of CFL’s
Theorem: Every context-free language
L is decidable
Proof: For each w, we need to decide
whether or not w is in L. Let G be a
CFG for L. This problem boils down to
ACFG, which we showed is decidable.
Question: Why don’t we just make a
TM that simulates a PDA?
October 13, 2005
18
Relationship of classes of languages
Regular
Contextfree
Decidable
October 13, 2005
Turingrecognizable
19