Week 14 - Wednesday.  What did we talk about last time?  Exam 3 post mortem  Finite state automata  Equivalence with regular expressions.

Slides:



Advertisements
Similar presentations
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Advertisements

Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
Pushdown Automata Chapter 12. Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely.
CFGs and PDAs Sipser 2 (pages ). Long long ago…
Week 13 - Wednesday.  What did we talk about last time?  Exam 3  Before review:  Graphing functions  Rules for manipulating asymptotic bounds  Computing.
Pushdown Automata Part II: PDAs and CFG Chapter 12.
Introduction to Computability Theory
CS5371 Theory of Computation
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
Validating Streaming XML Documents Luc Segoufin & Victor Vianu Presented by Harel Paz.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
1 Foundations of Software Design Lecture 23: Finite Automata and Context-Free Grammars Marti Hearst Fall 2002.
79 Regular Expression Regular expressions over an alphabet  are defined recursively as follows. (1) Ø, which denotes the empty set, is a regular expression.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Grammars, Languages and Finite-state automata Languages are described by grammars We need an algorithm that takes as input grammar sentence And gives a.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
Problem of the DAY Create a regular context-free grammar that generates L= {w  {a,b}* : the number of a’s in w is not divisible by 3} Hint: start by designing.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
Languages & Strings String Operations Language Definitions.
Lecture 16 Oct 18 Context-Free Languages (CFL) - basic definitions Examples.
Week 14 - Friday.  What did we talk about last time?  Exam 3 post mortem  Finite state automata  Equivalence with regular expressions.
Finite-State Machines with No Output
CSCI 2670 Introduction to Theory of Computing September 21, 2005.
Week 15 - Friday.  What did we talk about last time?  Review second third of the course.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
::ICS 804:: Theory of Computation - Ibrahim Otieno SCI/ICT Building Rm. G15.
CS/IT 138 THEORY OF COMPUTATION Chapter 1 Introduction to the Theory of Computation.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Pushdown Automata (PDA) Intro
Context-free Grammars Example : S   Shortened notation : S  aSaS   | aSa | bSb S  bSb Which strings can be generated from S ? [Section 6.1]
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Grammars CPSC 5135.
Computabilty Computability Finite State Machine. Regular Languages. Homework: Finish Craps. Next Week: On your own: videos +
Pushdown Automata Part I: PDAs Chapter Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2)
Week 14 - Wednesday.  What did we talk about last time?  Regular expressions  Introduction to finite state automata.
CHAPTER 1 Regular Languages
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
CS 203: Introduction to Formal Languages and Automata
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 10 Automata, Grammars and Languages.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
Mathematical Foundations of Computer Science Chapter 3: Regular Languages and Regular Grammars.
1 Language Recognition (11.4) Longin Jan Latecki Temple University Based on slides by Costas Busch from the courseCostas Busch
Pushdown Automata Hopcroft, Motawi, Ullman, Chap 6.
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.
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.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
Lecture 6: Context-Free Languages
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
1 Chapter Pushdown Automata. 2 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations.
Theory of Languages and Automata By: Mojtaba Khezrian.
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
CSCI 2670 Introduction to Theory of Computing September 16, 2004.
Week 13 - Friday.  What did we talk about last time?  Regular expressions.
Chapter 1 INTRODUCTION TO THE THEORY OF COMPUTATION.
Formal Languages, Automata and Models of Computation
Pushdown Automata.
Copyright © Cengage Learning. All rights reserved.
Context free grammar.
CSE 105 theory of computation
PARSE TREES.
Chapter 7 Regular Grammars
Intro to Data Structures
Context-Free Grammars
Chapter 2 Context-Free Language - 01
Presentation transcript:

Week 14 - Wednesday

 What did we talk about last time?  Exam 3 post mortem  Finite state automata  Equivalence with regular expressions

 U2 has 17 minutes to cross a bridge for a concert  Plan a way to get them across in the darkness  They have one flashlight  A maximum of two people can cross the bridge at one time, and one of them must have the flashlight  The flashlight must be walked back and forth  Each band member walks at a different speed  Bono:1 minute to cross  The Edge:2 minutes to cross  Adam:5 minutes to cross  Larry:10 minutes to cross  A pair must walk together at the rate of the slower man's pace

Student Lecture

 List strings accepted by the FSA A  List strings accepted by the FSA B s0s0 s0s0 s1s1 s1s1 s2s2 s2s s3s3 s3s A s1s1 s1s s0s0 s0s0 B

 Two states of a finite-state automaton are *- equivalent if any string accepted by the automaton when it starts from one state is accepted when starting from the other  Given an automaton A with eventual-state function N *, we can formally say:  States s and t in A are*-equivalent iff N * (s,w) and N * (t,w) are both accepting states or both not  It turns out that *-equivalence defines an equivalence relation

 *-equivalence is hard to demonstrate directly  Instead, we'll focus on equivalence after k or fewer inputs  Given an automaton A with eventual-state function N *, we can formally say:  States s and t in A are k-equivalent iff N * (s,w) and N * (t,w) are both accepting states or both not, for all strings w of length k or less

 For k ≥ 0, k-equivalence is an equivalence relation  For k ≥ 0, the k-equivalence classes partition the set of all states of the automaton into a union of mutually disjoint subsets  For k ≥ 1, if two states are k-equivalent, they are also (k-1)-equivalent  For k ≥ 1, each k-equivalence class is a subset of a (k-1)-equivalence class  Any two states that are k-equivalent for all integers k ≥ 0 are *-equivalent

 Let A be an FSA with next-state function N  Given any states s and t in A: 1. s is 0-equivalent to t iff either s and t are both accepting states or they are both nonaccepting states 2. For every integer k ≥ 1, s is k-equivalent to t iff s and t are (k-1)-equivalent and for any input symbol m, N(s,m) and N(t,m) are also (k-1)-equivalent  These theorems essentially allow us to create a recursive definition for testing k-equivalence

 Find the 0-equivalence classes, the 1- equivalence classes, and the 2-equivalence classes for the following FSA: s1s1 s1s1 s2s2 s2s2 s3s3 s3s s4s4 s4s4 0 0 s0s0 s0s

 Keep finding k-equivalence classes for larger and larger values of k  If you ever find that the set of k-equivalence classes is equal to the set of (k+1)-equivalence classes, that is the set of *-equivalence classes  This is known as a fixed point in mathematics

 We can build a new FSA from the *-equivalence classes  Recall that [s] means the equivalence class of s  This FSA is called the quotient automaton A', and is defined from an FSA A with states S, input symbols I, and next-state function N as follows: 1. The set of states S' of A' is the set of *-equivalent classes of states of A 2. The set of input symbols I' of A' equals I 3. The initial state of A' is [s 0 ] where s o is the initial state of A 4. The accepting states of A' are the states of the form [s] where s is an accepting state of A 5. The next-state function N': S' x I  S' is: For all states [s] in S' and input symbols m, N'([s], m) = [N(s,m)]

 Let A be an FSA with states S, input symbols I, and next-state function N  To build A': 1. Find the set of 0-equivalence classes of S 2. For each integer k ≥ 1, find the k-equivalence classes of S until the k-equivalence classes are the same as the (k-1)-equivalence classes 3. Build a quotient automaton whose states are the equivalence classes given above with transition function N'([s],m) = [N(s,m)] for any input symbol m

 Find the quotient automaton for the following FSA s1s1 s1s1 s2s2 s2s2 s3s3 s3s s4s4 s4s4 0 0 s0s0 s0s

 Two automata A 1 and A 2 are equivalent iff L(A 1 ) = L(A 2 )  Proving the languages accepted by two automata can be difficult  However, the quotient automata for both A 1 and A 2 will be the same (except for labeling) if A 1 is equivalent to A 2

 Prove that the following two automata are equivalent by finding their quotient automata s0s0 s0s0 s2s2 s2s2 s1s1 s1s s3s3 s3s s0's0' s0's0' s1's1' s1's1' s2's2' s2's2' 0, s3's3' s3's3'

 A context free language is one that can be described by a context free grammar  Every regular language is context free, but there are context free languages that are not regular  Classic examples:  Strings of k 0's followed by k 1's  Palindromes made up of a's and b's  Legally nested parentheses  All of these involve counting arbitrary numbers of characters  Regular expressions can't count

 Instead of using regular expressions, a context free language is often described with a grammar  A grammar is a formal system of rewriting rules consisting of  Terminals: symbols of the alphabet  Non-terminals: symbols that produce other sequences of terminals and non-terminals  Grammars often start with the non-terminal starting symbol S  Any string that can be derived from S through some sequence of rule rewrites is a string in the language

 The following is a grammar that produces the language of strings of 1s and 0s that end in a 1 S  A1S  A1  A  ε | 1 | 0 | A1 | A0  This language is regular and is equivalent to (0 | 1)* 1  The following is a grammar that produces the language of a k b k where k ≥ 1 (which is not regular S  AS  A  A  ab | aAb

 Write a grammar that legal nesting of parentheses and braces in Java  Don't worry about the stuff that goes inside  Write a grammar for legal mathematical expressions in Java using variables and integers, +, -, *, /, and parentheses  Write a grammar that corresponds to the same language defined by the regular expression ab* (a | bb) (ba)*

 As you know, regular languages can be expressed by regular expressions and finite state automata  Thus, regular expressions are equal to FSAs in power  Context free languages can be expressed by context free grammars  There is also a class of automata called pushdown automata that correspond to context free languages

 To make the PDA for the language 0 k 1 k, k ≥ 1, we have the following:  In this case, the notation X/Y means that if X is on the top of the stack, replace it with Y  The top of the stack is Z  Notation is not well standardized for PDAs  It's awkward keeping track of the stack s1s1 s1s1 s2s2 s2s2 s0s0 s0s0 0: Z/AZ 0: A/AA 1: A/ε 1: A/A 1: Z/Z

 Finish context free languages  Chomsky's hierarchy of grammars

 Finish Assignment 10  Due Monday before midnight  Internship or Job Opportunity:  Walz IT consulting firm  Offices in Lititz and King of Prussia  Experience with Salesforce, JavaScript, and SQL a bonus  Both technical and business-oriented opportunities  Contact me for more information  Lancaster Chamber of Commerce is hiring an full-time IT Manager  Contact me for details