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

29
BU CS 332 – Theory of Computation Lecture 13: MidSemester Feedback Enumerators Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020

Upload: others

Post on 30-May-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

BU CS 332 – Theory of Computation

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

Reading:Sipser Ch 4.1

Mark BunMarch 16, 2020

Page 2: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 3: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 4: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 5: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 6: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 7: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

Enumerators

3/16/2020 CS332 ‐ Theory of Computation 7

Page 8: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 9: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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”

Page 10: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 11: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 12: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 13: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

Decidable Languages

3/16/2020 CS332 ‐ Theory of Computation 13

Page 14: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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?

Page 15: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 16: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 17: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 18: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

Other decidable languages

3/16/2020 CS332 ‐ Theory of Computation 18

Page 19: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 20: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 21: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 22: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 23: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

Classes of Languages

3/16/2020 CS332 ‐ Theory of Computation 23

context free

regular

recognizable

decidable

Page 24: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

More Examples

3/16/2020 CS332 ‐ Theory of Computation 24

Page 25: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 26: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

3/16/2020 CS332 ‐ Theory of Computation 26

Page 27: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 28: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

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

Page 29: Lecture 13 - cs-people.bu.edu · Lecture 13: • Mid‐Semester Feedback • Enumerators • Decidable Languages Reading: Sipser Ch 4.1 Mark Bun March 16, 2020. What aspects of the

Symmetric Difference

3/16/2020 CS332 ‐ Theory of Computation 29