CSE 105 THEORY OF COMPUTATION

Similar documents
CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CSE 105 Theory of Computation

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

V Honors Theory of Computation

Pumping Lemma for CFLs

Decidability (What, stuff is unsolvable?)

CSE 105 THEORY OF COMPUTATION

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CSE 105 THEORY OF COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Properties of Context-Free Languages. Closure Properties Decision Properties

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CSE 105 THEORY OF COMPUTATION

Please give details of your answer. A direct answer without explanation is not counted.

CS21 Decidability and Tractability

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

Turing Machines Part III

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

Cliff s notes for equivalence of CFLs and L(PDAs) LisaCFL L = L(M) for some PDA M L=L(M)forsomePDAM L = L(G) for some CFG G

Homework Assignment 6 Answers

CSE 105 THEORY OF COMPUTATION

1 Showing Recognizability

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Context-Free Languages

Automata and Computability. Solutions to Exercises

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

CSE 105 THEORY OF COMPUTATION

SCHEME FOR INTERNAL ASSESSMENT TEST 3

Final exam study sheet for CS3719 Turing machines and decidability.

1 Unrestricted Computation

MA/CSSE 474 Theory of Computation

2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a

Reducability. Sipser, pages

SE 3310b Theoretical Foundations of Software Engineering. Turing Machines. Aleksander Essex

DM17. Beregnelighed. Jacob Aae Mikkelsen

CSE 105 THEORY OF COMPUTATION

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

Automata and Computability. Solutions to Exercises

Decidability and Undecidability

CS 154. Finite Automata, Nondeterminism, Regular Expressions

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES

CPSC 421: Tutorial #1

Closure Properties of Context-Free Languages. Foundations of Computer Science Theory

Part I: Definitions and Properties

CSE 105 THEORY OF COMPUTATION

CS 154, Lecture 3: DFA NFA, Regular Expressions

CpSc 421 Final Exam December 15, 2006

CSCE 551: Chin-Tser Huang. University of South Carolina

Section 1 (closed-book) Total points 30

CSE 105 THEORY OF COMPUTATION

CSCE 551: Chin-Tser Huang. University of South Carolina

NPDA, CFG equivalence

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

Foundations of Informatics: a Bridging Course

CS20a: Turing Machines (Oct 29, 2002)

CSE 105 Theory of Computation Professor Jeanne Ferrante

Computational Models - Lecture 5 1

Computability Theory

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

Miscellaneous. Closure Properties Decision Properties

Computability Theory

Lecture 12: Mapping Reductions

Undecidable Problems and Reducibility

Theory of Computation (IX) Yijia Chen Fudan University

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Homework 8. a b b a b a b. two-way, read/write

Languages, regular languages, finite automata

I have read and understand all of the instructions below, and I will obey the University Code on Academic Integrity.

CSCC63 Worksheet Turing Machines

Ogden s Lemma for CFLs

CS20a: Turing Machines (Oct 29, 2002)

Introduction to Languages and Computation

Theory Bridge Exam Example Questions

Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata

CISC4090: Theory of Computation

Computational Models - Lecture 4

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement:

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 16 : Turing Machines

CSE 105 Theory of Computation

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

Chapter 3: The Church-Turing Thesis

Automata Theory CS S-12 Turing Machine Modifications

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Intro to Theory of Computation

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

Transcription:

CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/

Today's learning goals Sipser Ch 2 Design a PDA and a CFG for a given language Give informal description for a PDA, given its formal definition Implement a formal definition of a PDA, give an informal description of its behavior Compare the classes of regular languages, context-free languages, and non-context-free languages Distinguish between a DFA, NFA, PDA, and a Turing machine Use the formal definition of a Turing machine

Recap: Context-free languages Context-free grammar One-step derivation Derivation Language generated by grammar

Recap: PDA Sipser Def 2.13 p. 111

PDAs and CFGs are equivalently expressive Theorem 2.20: A language is context-free if and only some nondeterministic PDA recognizes it. Consequences - Quick proof that every regular language is context free - To prove closure of class of CLFs under a given operation, can choose two modes of proof (via CFGs or PDAs) depending on which is easier

Example L = { a i b j c k i=j or i=k, with i,j,k 0 } Which of the following strings are not in L? A. b B. abc C. abbcc D. aabcc E. I don't know.

Example L = { a i b j c k i=j or i=k, with i,j,k 0 } To design a CFG that generates L L = { a i b j c k i=j, with i,j,k 0 } U { a i b j c k i=k, with i,j,k 0 }

Example L = { a i b j c k i=j or i=k, with i,j,k 0 } To design a CFG that generates L L = { a i b j c k i=j, with i,j,k 0 } U { a i b j c k i=k, with i,j,k 0 } S Sc T T atb ε

Example L = { a i b j c k i=j or i=k, with i,j,k 0 } To design a CFG that generates L L = { a i b j c k i=j, with i,j,k 0 } U { a i b j c k i=k, with i,j,k 0 } S T asc T Tb ε

Designing a PDA L = { a i b j c k i=j or i=k, with i,j,k 0 } Informal description of PDA: How would you design an algorithm that, given a string, decides if it is in this set? - What information do you need to track? - How much memory do you need? - Are you using non-determinism?

Designing a PDA L = { a i b j c k i=j or i=k, with i,j,k 0 } Informal description of PDA: The PDA pushes a $ to indicate the top of the stack, then starts reading a's, pushing each one on to the stack. The PDA guesses when it's reached the end of the a's and whether to match the number of a's to the number of b's or the number of c's. If trying to match number of b's with number of a's: PDA pops off a's for each b read. If there are more a's on the stack but no more b's being read, reject. When the end of the stack ($) is reached, the number of a's matches the number of b's. If this is the end of the input or if any number of c's is read at this point, accept; otherwise, reject. If trying to match the number of c's with number of a's: first read any number of b's without changing stack contents and then nondeterministically guess when to start reading c's. For each c read, pop one a off the stack. When the end of the stack ($) is reached the number of a's and c's so far match.

Designing a PDA L = { a i b j c k i=j or i=k, with i,j,k 0 } Formal definition of PDA:

Conventions for PDAs Can "test for end of stack" without providing details We can always push the end-of-stack symbol, $, at the start. Can "test for end of input" without providing details Can transform PDA to one where accepting states are only those reachable when there are no more input symbols. Don't always need to provide a state transition diagram!

Other classes of languages? Are all strings context-free? A. Yes, because every string is finite. B. Yes, because the set of all strings is regular. C. No, because the computation could get stuck. D. No, because the type is wrong. E. I don't know.

Other classes of languages? Are all sets of strings over fixed alphabet Σ context-free? A. Yes, because the class of CFL is a strict superse of RL. B. Yes, because the set of all strings is regular. C. No, because we can apply the Pumping Lemma. D. No, because the diagonalization argument applies again. E. I don't know.

Informal intuition Which specific language is not context-free? A. { 0 n 1 m 0 n m,n 0 } B. { 0 n 1 n 0 n n 0 } C. { 0 n 1 2n n 0 } D. { 0 n 1 2m m,n 0 } E. I don't know.

Examples of non-context-free languages { a n b n c n 0 n } Sipser Ex 2.36 {a i b j c k 0 i j k } Sipser Ex 2.37 { w w w is in {0,1} * } Sipser Ex 2.38 To prove Pumping lemma for CFLs

Closure properties of.. The class of regular languages is closed under Union Concatenation Star Complementation Intersection Difference Reversal Homomorphism The class of context-free languages is closed under Union Concatenation Star Reversal Homomorphism It is not closed under Intersection Complement Difference

Turing machines Unlimited input Unlimited (read/write) memory Unlimited time

Turing machine computation Read/write head starts at leftmost position on tape Input string written on leftmost squares of tape, rest is blank Computation proceeds according to transition function: Given current state of machine, and current symbol being read the machine transitions to new state writes a symbol to its current position (overwriting existing symbol) moves the tape head L or R Computation ends if and when it enters either the accept or the reject state.

Language of a Turing machine L(M) = { w computation of M on w halts after entering the accept state} i.e. L(M) = { w M is accepted by w} Comparing TMs and PDAs, which of the following is true: A. Both TMs and PDAs may accept a string before reading all of it. B. A TM may only read symbols, whereas a PDA may write to its stack. C. Both TMs and PDAs must read the string from left to right. D. States in a PDA must be either accepting or rejecting, but in a TM may be neither. E. I don't know.

Why is this model relevant? Division between program (CPU, state space) and data (memory) is a cornerstone of all modern computing Unbounded memory is outer limits of what modern computers (PCs, quantum computers, DNA computers) can implement. Simple enough to reason about (and diagonalize against), expressive enough to capture modern computation.

Formal definition of TM

Example What is Σ? A. { 0 } B. { 0,, R } C. {, R } D. { } E. I don't know.

Example Which of these strings is not accepted by this TM? A. ε B. 0 C. 00 D. More than one above. E. I don't know. What is the language of this TM?

Configurations of a TM Current state Current tape contents Current location of read/write head u q v current state is q current tape contents are uv (and then all blanks) current head location is first symbol of v

Configurations of a TM Current state Current tape contents Current location of read/write head Start configuration on w: q0 w Accepting configuration: u q_acc v Rejecting configuration: u q_rej v current state is q u q v current tape contents are uv (and then all blanks) current head location is first symbol of v Halting configuration: any configuration that is either rejecting or halting.

Deciders and recognizers Sipser p. 144 L is Turing recognizable if some Turing machine recognizes it. L is a decider if it always decides. L is Turing decidable if some Turing machine decides it.

Reminders RQ 4b due Saturday April 30 RQ 5 due Monday May 2 HW5 due Friday May 6 HW sheet + Gradescope link available soon