CSE 105 THEORY OF COMPUTATION

Similar documents
CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

Context-Free Languages

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

CSE 105 THEORY OF COMPUTATION

CPS 220 Theory of Computation Pushdown Automata (PDA)

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

(pp ) PDAs and CFGs (Sec. 2.2)

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

CSE 105 THEORY OF COMPUTATION

Pushdown Automata (Pre Lecture)

CSE 105 THEORY OF COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CISC4090: Theory of Computation

Pushdown Automata: Introduction (2)

Computability Theory

CSE 105 THEORY OF COMPUTATION

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

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Pushdown Automata. Chapter 12

Foundations of Informatics: a Bridging Course

Lecture 17: Language Recognition

Properties of Context-Free Languages. Closure Properties Decision Properties

Computational Models - Lecture 5 1

Homework. Context Free Languages. Announcements. Before We Start. Languages. Plan for today. Final Exam Dates have been announced.

Theory of Computation (IV) Yijia Chen Fudan University

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. The stack

October 6, Equivalence of Pushdown Automata with Context-Free Gramm

CSE 105 THEORY OF COMPUTATION

CSE 105 Theory of Computation Professor Jeanne Ferrante

CSE 105 THEORY OF COMPUTATION

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

Nondeterministic Finite Automata

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

(pp ) PDAs and CFGs (Sec. 2.2)

Outline. CS21 Decidability and Tractability. Machine view of FA. Machine view of FA. Machine view of FA. Machine view of FA.

MA/CSSE 474 Theory of Computation

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

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

CSE 105 THEORY OF COMPUTATION

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

Computational Models - Lecture 4

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

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Sri vidya college of engineering and technology

CFGs and PDAs are Equivalent. We provide algorithms to convert a CFG to a PDA and vice versa.

CSE 105 THEORY OF COMPUTATION

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

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

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

CSE 105 Theory of Computation

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

CSE 105 THEORY OF COMPUTATION

Introduction to Theory of Computing

Theory of Computation

Pushdown Automata (2015/11/23)

Equivalence of CFG s and PDA s

Accept or reject. Stack

CSE 105 THEORY OF COMPUTATION

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

Turing Machines Part III

CS Pushdown Automata

Push-down Automata = FA + Stack

Intro to Theory of Computation

Chapter Five: Nondeterministic Finite Automata

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Computability Theory

Pushdown Automata. Reading: Chapter 6

Decidability (intro.)

Pushdown Automata (PDA) The structure and the content of the lecture is based on

Computational Models Lecture 5

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

Theory of Computation (I) Yijia Chen Fudan University

Decision, Computation and Language

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

NPDA, CFG equivalence

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

CSE 105 Homework 5 Due: Monday November 13, Instructions. should be on each page of the submission.

Languages, regular languages, finite automata

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)

Miscellaneous. Closure Properties Decision Properties

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Computational Models: Class 5

CISC 4090 Theory of Computation

Theory of Computation

CPS 220 Theory of Computation REGULAR LANGUAGES

Final exam study sheet for CS3719 Turing machines and decidability.

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

Transcription:

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

Today's learning goals Sipser Ch 2 Define push down automata Trace the computation of a push down automaton Design a push down automaton recognizing a given language

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

Designing CFGs Sipser p. 104 Given a language L over Σ, to prove L is a context-free language need to build a CFG that generates it. How? Express L as union of simpler languages If L is regular, design DFA and convert into CFG Exploit any recursive structure in L.

Example Design a CFG recognizing the language {a n b m n m} On Thursday, we showed that the language {a n b n n 0} is CFL. How can we use its CFG for this example? A. Use the same CFG but reverse the role of variables and terminals. B. Use the same set of variables, terminals, and start state, but reverse the RHS and LHS of each rule. C. We can't use it directly: the two sets are not related. D. We can't use it directly: the class of CFLs is not closed under complementation. E. I don't know.

Example Design a CFG recognizing the language {a n b m n m} = {a n b m n > m} U {a n b m n < m} Simpler problem: Design a CFG generating the language {a n b m n > m}

Example Design a CFG recognizing the language {a n b m n m} = {a n b m n > m} U {a n b m n < m} Simpler problem: Design a CFG generating the language {a n b m n > m} G 1 = ( {S 1 }, {a,b}, R, S 1 ) with rules S 1 à as 1 b as 1 a

Example Design a CFG recognizing the language {a n b m n m} = {a n b m n > m} U {a n b m n < m} CFG generating the language {a n b m n > m} is G 1 = ( {S 1 }, {a,b}, R, S 1 ) with rules S 1 à as 1 b as 1 a CFG generating the language {a n b m n < m} is G 2 = ( {S 2 }, {a,b}, R, S 2 ) with rules S 2 à as 2 b S 2 b b

Example For {a n b m n > m}: G 1 = ( {S 1 }, {a,b}, R, S 1 ) with S 1 à as 1 b as 1 a For {a n b m n < m}: G 2 = ( {S 2 }, {a,b}, R, S 2 ) with S 2 à as 2 b S 2 b b What is CFG generating {a n b m n m}? A. G 1 U G 2 B. ( {S 1, S 2 }, {a,b}, R, S 1 ) with S 1 à as 1 b as 1 a, S 2 à as 2 b S 2 b b C. ( {S 1, S 2 }, {a,b}, R, S 2 ) with S 1 à as 1 b as 1 as 2, S 2 à as 2 b S 2 b b D. ( {S, S 1, S 2 }, {a,b}, R, S) with S à S 1 S 2, S 1 à as 1 b as 1 a, S 2 à as 2 b S 2 b b E. I don't know.

An alternative Sipser p. 109 NFA + stack

Pushdown automata Sipser p. 109 NFA + stack At each step 1. Transition to new state based on current state, letter read, and top letter of stack. 2. (Possibly) push or pop a letter to (or from) top of stack

Pushdown automata Sipser p. 109 NFA + stack Accept a string if there is some sequence of states and some sequence of stack contents which processes the entire input string and ends in an accepting state.

State diagram for PDA Sipser p. 109 If hand-drawn or in Sipser State transition labelled a, b à c means "when machine reads an a from the input and the top symbol of the stack is a b, it may replace the b with a c." In JFLAP: use ; instead of à

State diagram for PDA Sipser p. 109 If hand-drawn or in Sipser State transition labelled a, b à c means "when machine reads an a from the input and the top symbol of the stack is a b, it may replace the b with a c." What edge label would indicate "Read a 0, don't pop anything from stack, don t push anything to the stack"? A. 0, ε à ε B. ε, 0 à ε C. ε, ε à 0 D. ε à ε, 0 E. I don't know.

Useful trick What would ε, ε à $ mean? A. Without reading any input or popping any symbol from stack, push $ B. If the input string and stack are both empty strings, push $ C. At the end of reading the input string, push $ to top of stack D. I don't know.

Useful trick What would ε, ε à $ mean? A. Without reading any input or popping any symbol from stack, push $ B. If the input string and stack are both empty strings, push $ C. At the end of reading the input string, push $ to top of stack D. I don't know. Why is this useful? Commonly used from initial state (at start of computation) to record top of stack with a special symbol) we'll see applications soon!

Formal definition of PDA Sipser Def 2.13 p. 111

Designing a PDA L = { 0 i 1 i+1 i 0 } Informal description of PDA: Read symbols from the input. As each 0 is read, push it onto the stack. As soon as 1s are seen, pop a 0 off the stack for each 1 read. If the stack becomes empty and there is exactly one 1 left to read, read that 1 and accept the input. If the stack becomes empty and there are either zero or more than one 1s left to read, or if the 1s are finished while the stack still contains 0s, or if any 0s appear in the input following 1s, reject the input.

Designing/Tracing a PDA L = { 0 i 1 i+1 i 0 } What are the contents of the stack after processing 001? A. (TOP) $00 B. (TOP) 00$ C. (TOP) 0$ D. (TOP) 100$ E. I don't know.

Designing/Tracing a PDA L = { 0 i 1 i+1 i 0 } Which of the following strings are not accepted by this PDA? A. 0 B. 1 C. 01 D. 011 E. I don't know.

Designing/Tracing a PDA L = { 0 i 1 i+1 i 0 } Which of these CFGs generate L? Assume V = set of variables mentioned in rules; Σ={0,1}, S start A. S à ε 0S1 B. S à ε 0S11 C. S à T1 0S1, T à ε D. S à ε 0T1, T à ε 0T1 E. I don't know.

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

Overview??? Context-free languages Regular languages

Reminders HW4 due Wednesday April 27 Gradescope link now available