20
CSCI 2670 Introduction to Theory of Computing October 13, 2005

CSCI 2670 Introduction to Theory of Computing October 13, 2005

Embed Size (px)

DESCRIPTION

October 13, 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?

Citation preview

Page 1: CSCI 2670 Introduction to Theory of Computing October 13, 2005

CSCI 2670Introduction to Theory of

Computing

October 13, 2005

Page 2: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 2

Agenda• Yesterday

– Decidability and regular languages• Today

– Putting things in perspective– More on decidability and regular

languages– Decidability and context free

grammars

Page 3: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 3

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?

Page 4: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 4

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

Page 5: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 5

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

Page 6: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 6

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

Page 7: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 7

Decidable languages• A language is decidable if some

Turing machine decides it– Every string in * is either accepted

or rejected

Page 8: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 8

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)}

Page 9: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 9

Question• How would we show that the

following language is decidable?ALLDFA = {<A> | A is a DFA that

recognizes *}

Page 10: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 10

Another question• Let L be any regular language• How would we show L is decidable?

– Assume L is described using a DFA

Page 11: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 11

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

Page 12: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 12

Chomsky normal form review• All rules are of the form

A →BCA →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

Page 13: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 13

How many steps to generate w?

• If |w| = 0– 1 step

• If |w| = n > 0?– 2n – 1 steps

Page 14: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 14

TM simulating ACFG

M = “On input <G>, where G is a CFG1. Convert G into Chomsky normal

form2. 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”

Page 15: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 15

Empty CFG’s• Consider the following languageECFG = {<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 terminals

Page 16: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 16

Work backwardsB = “On input <G>, where G is a CFG1. Mark all terminals2. 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, reject4. Otherwise, accept”

Page 17: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 17

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

Page 18: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 18

Decidability of CFL’sTheorem: Every context-free

language L is decidableProof: 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?

Page 19: CSCI 2670 Introduction to Theory of Computing October 13, 2005

October 13, 2005 19

Relationship of classes of languages

Regular

Context-free Decidabl

eTuring-recognizable

Page 20: CSCI 2670 Introduction to Theory of Computing October 13, 2005