lecture 13 - cs-people.bu.edu · lecture 13: • mid‐semester feedback • enumerators •...

Post on 30-May-2020

1 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

BU CS 332 – Theory of Computation

Lecture 13:• Mid‐Semester Feedback• Enumerators• Decidable Languages

Reading:Sipser Ch 4.1

Mark BunMarch 16, 2020

What aspects of the course help you learn best?

• Examples in class• Reviewing past homeworks/exams in class• Textbook• Posting materials online• Lecture, generally• Office hours• In‐depth problem‐solving in discussion section• Top Hat questions• Piazza discussions / instructor response

3/16/2020 CS332 ‐ Theory of Computation 2

What in the class so far has hindered your learning?• Pace of information transmission / workload• Criteria for formality of proofs on homework and exams• Poor handwriting• Questions in class not fully answered• Lack of organization in discussion• Broad concepts

• “Bureaucratic descriptions”• “All materials concluded”

3/16/2020 CS332 ‐ Theory of Computation 3

What specific changes can we make to improve your learning?• More examples• Post solutions / other materials online• Discussion solutions• More Top Hat questions• Go slower• More guidelines for how to solve each type of problem• Looser grading• Midterm too long• More detailed slides

3/16/2020 CS332 ‐ Theory of Computation 4

Do you understand what is expected from you in this class?• Reading the book before vs. after class• Need to do every problem in the book to succeed?• Lack of coordination between readings and lectures• “I have to attend lectures, read the material in the book, do some practice problems and then attempt the homework”• Exam grading critical over formatting vs. looser standards on homework

3/16/2020 CS332 ‐ Theory of Computation 5

How can you improve your own learning?• Read the book• Solve more practice problems• Review HW solutions• Come to office hours• Time management• Open mind to more abstract ways of thinking

3/16/2020 CS332 ‐ Theory of Computation 6

Enumerators

3/16/2020 CS332 ‐ Theory of Computation 7

TMs are equivalent to… • TMs with “stay put”• TMs with 2‐way infinite tapes• Multi‐tape TMs• Nondeterministic TMs• Random access TMs• Enumerators• Finite automata with access to an unbounded queue = 2‐stack PDAs• Primitive recursive functions• Cellular automata• “Turing‐complete” programming languages (C, Python, Java…)

3/16/2020 CS332 ‐ Theory of Computation 8

Enumerators

• Starts with two blank tapes• Prints strings to printer

strings eventually printed by • May never terminate (even if language is finite)• May print the same string many times

3/16/2020 CS332 ‐ Theory of Computation 9

Finite control

Work tape

“Printer”

Enumerator Example1. Initialize 2. Repeat forever:• Calculate  (in binary)• Send  to printer• Increment 

What language does this enumerator enumerate?

3/16/2020 CS332 ‐ Theory of Computation 10

Enumerable = Turing‐RecognizableTheorem: A language is Turing‐recognizable  some enumerator enumerates it

Start with an enumerator  for  and give a TM

3/16/2020 CS332 ‐ Theory of Computation 11

Enumerable = Turing‐RecognizableTheorem: A language is Turing‐recognizable  some enumerator enumerates it

Start with a TM  for  and give an enumerator

3/16/2020 CS332 ‐ Theory of Computation 12

Decidable Languages

3/16/2020 CS332 ‐ Theory of Computation 13

1928 – The Entscheidungsproblem

3/16/2020 CS332 ‐ Theory of Computation 14

The “Decision Problem”

Is there an algorithm which takes as input a formula (in first‐order logic) and decides whether it’s logically valid?

Questions about regular languagesDesign a TM which takes as input a DFA  and a string  , and determines whether  accepts 

How should the input to this TM be represented?Let  . List each component of the tuple separated by ;• Represent  by ,‐separated binary strings • Represent  by ,‐separated binary strings• Represent  by a ,‐separated list of triples 

, …

Denote the encoding of  by 

3/16/2020 CS332 ‐ Theory of Computation 15

Representation independenceComputability (i.e., decidability and recognizability) is not affected by the choice of encoding

Why? A TM can always convert between different encodings

For now, we can take  to mean “any reasonable encoding”

3/16/2020 CS332 ‐ Theory of Computation 16

A “universal” algorithm for recognizing regular languages

Theorem: is decidable

Proof: Define a 3‐tape TM  on input 1. Check if  is a valid encoding (reject if not)2. Simulate  on  , i.e.,• Tape 2: Maintain 𝑤 and head location of 𝐷• Tape 3: Maintain state of 𝐷, update according to 𝛿

3. Accept iff ends in an accept state

3/16/2020 CS332 ‐ Theory of Computation 17

Other decidable languages

3/16/2020 CS332 ‐ Theory of Computation 18

CFG GenerationTheorem: is Turing‐recognizableProof idea: Define a TM  recognizing

On input  :1.  Enumerate all strings that can be generated from (i.e., all length‐1 derivations, all length‐2 derivations, …)

2.  If any of these strings equal  , accept

3/16/2020 CS332 ‐ Theory of Computation 19

CFG GenerationTheorem: is decidable

Chomsky Normal Form for CFGs:• Can have a rule 𝑆 → 𝜀• All remaining rules of the form 𝐴 → 𝐵𝐶 or 𝐴 → 𝑎• Cannot have 𝑆 on the RHS of any rule

Lemma: Any CFG can be converted into an equivalent CFG in Chomsky Normal FormLemma: If  is in Chomsky Normal Form, any nonempty string w that can be derived from  has a derivation with at most  steps

3/16/2020 CS332 ‐ Theory of Computation 20

CFG GenerationTheorem: is decidableProof idea: Define a TM  recognizing

On input  :1. Convert  into Chomsky Normal Form2. Enumerate all strings derivable in  steps3. If any of these strings equal  , accept

3/16/2020 CS332 ‐ Theory of Computation 21

Context Free Languages are DecidableTheorem: Every CFL  is decidableProof: Let  be a CFG generating  . The following TM decides 

On input  :1. Run the decider for  on input 2. Accept if the decider accepts; reject otherwise

3/16/2020 CS332 ‐ Theory of Computation 22

Classes of Languages

3/16/2020 CS332 ‐ Theory of Computation 23

context free

regular

recognizable

decidable

More Examples

3/16/2020 CS332 ‐ Theory of Computation 24

Decidability of 

Theorem: is decidableProof: The following TM decides 

On input  , where  is a DFA with  states:1. Perform  steps of breadth‐first search on state 

diagram of  to determine if an accept state is reachable from the start state

2. Accept if an accept state reachable; reject otherwise

3/16/2020 CS332 ‐ Theory of Computation 25

3/16/2020 CS332 ‐ Theory of Computation 26

Decidability of 

Theorem: is decidableProof: The following TM decides

On input  , where  is a CFG with  states:1. Mark all terminal symbols in 2. Repeat until no new variable is marked:

Mark any variable 𝐴 where 𝐺 has a rule 𝐴 → 𝑈 𝑈 …𝑈 and   every symbol 𝑈 , … ,𝑈 is marked

3. Accept if the start variable is unmarked; else reject

3/16/2020 CS332 ‐ Theory of Computation 27

New Deciders from Old

Theorem: is decidableProof: The following TM decides 

On input  , where  are DFAs:1. Construct a DFA  that recognizes the symmetric 

difference

2. Run the decider for  on  and return its output

3/16/2020 CS332 ‐ Theory of Computation 28

Symmetric Difference

3/16/2020 CS332 ‐ Theory of Computation 29

top related