Week 13 - Friday.  What did we talk about last time?  Regular expressions.

Slides:



Advertisements
Similar presentations
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
Advertisements

Week 13 - Wednesday.  What did we talk about last time?  Exam 3  Before review:  Graphing functions  Rules for manipulating asymptotic bounds  Computing.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Discrete Mathematics Lecture 7 Alexander Bukharovich New York University.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
1 Languages and Finite Automata or how to talk to machines...
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)
CSC 361Finite Automata1. CSC 361Finite Automata2 Formal Specification of Languages Generators Grammars Context-free Regular Regular Expressions Recognizers.
Copyright © Cengage Learning. All rights reserved.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
Great Theoretical Ideas in Computer Science.
Language Recognizer Connecting Type 3 languages and Finite State Automata Copyright © – Curt Hill.
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 Longin Jan Latecki Temple University Based on Slides by Elsa L Gunter, NJIT, and by Costas Busch Costas Busch.
Finite-State Machines with No Output
Week 15 - Friday.  What did we talk about last time?  Review second third of the course.
1 Chapter 1 Automata: the Methods & the Madness Angkor Wat, Cambodia.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Lecture 05: Theory of Automata:08 Kleene’s Theorem and NFA.
Week 14 - Wednesday.  What did we talk about last time?  Regular expressions  Introduction to finite state automata.
Regular Expressions and Languages A regular expression is a notation to represent languages, i.e. a set of strings, where the set is either finite or contains.
CHAPTER 1 Regular Languages
Complexity and Computability Theory I Lecture #2 Rina Zviel-Girshin Leah Epstein Winter
NFA defined. NFA A Non-deterministic Finite-state Automata (NFA) is a language recognizing system similar to a DFA. It supports a level of non-determinism.
CS 203: Introduction to Formal Languages and Automata
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Finite Automata Chapter 1. Automatic Door Example Top View.
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
Week 13 - Wednesday.  What did we talk about last time?  Exam 3  Before review:  Graphing functions  Rules for manipulating asymptotic bounds  Computing.
Lecture 2 Compiler Design Lexical Analysis By lecturer Noor Dhia
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
Week 14 - Wednesday.  What did we talk about last time?  Exam 3 post mortem  Finite state automata  Equivalence with regular expressions.
Lecture 15: Theory of Automata:2014 Finite Automata with Output.
Chapter 1 INTRODUCTION TO THE THEORY OF COMPUTATION.
Lecture Three: Finite Automata Finite Automata, Lecture 3, slide 1 Amjad Ali.
Kleene’s Theorem and NFA
Languages.
CSE 105 theory of computation
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz
Copyright © Cengage Learning. All rights reserved.
Modeling Arithmetic, Computation, and Languages
Deterministic Finite Automata
What Are They? Who Needs ‘em? An Example: Scoring in Tennis
Week 14 - Friday CS221.
Jaya Krishna, M.Tech, Assistant Professor
Deterministic Finite Automata
Hierarchy of languages
Some slides by Elsa L Gunter, NJIT, and by Costas Busch
Regular Expression We shall build expressions from the symbols using simple operations include concatenation, union and kleen closure. Several intuitive.
Intro to Data Structures
Minimal DFA Among the many DFAs accepting the same regular language L, there is exactly one (up to renaming of states) which has the smallest possible.
What Are They? Who Needs ‘em? An Example: Scoring in Tennis
Introduction to Finite Automata
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CS21 Decidability and Tractability
CSE 105 theory of computation
Finite-State Machines with No Output
CSE 105 theory of computation
Teori Bahasa dan Automata Lecture 6: Regular Expression
CSE 105 theory of computation
Presentation transcript:

Week 13 - Friday

 What did we talk about last time?  Regular expressions

 You are paddling a canoe around a perfectly circular pond  Enjoying yourself immensely, you fail to notice that a goblin has crept up to the shore  You remember four things from your old lessons on goblin lore  Goblins can't swim  Goblins are always hungry for human flesh  Goblins can run four times as fast as people can paddle canoes  People can run faster than goblins  The goblin always assumes that you are making for the closest point on the shore and is always trying to cut you off  If you can get to the shore, you can escape, provided that the goblin isn't waiting for you (you need a little margin)  What's your escape strategy?

 Let Σ = {0, 1}  Find regular expressions for the following languages:  The language of all strings of 0's and 1's that have even length and in which the 0's and 1's alternate  The language consisting of all strings of 0's and 1's with an even number of 1's  The language consisting of all strings of 0's and 1's that do not contain two consecutive 1's  The language that gives all binary numbers written in normal form (that is, without leading zeroes, and the empty string is not allowed)

 Regular expressions are used in some programming languages (notably Perl) and in grep and other find and replace tools  The notation is generally extended to make it a little easier, as in the following:  [ A – C] means any character in that range,  [A – C] means ( A | B | C )  [0 – 9] means ( 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 )  [ABC] means (A | B | C )  ABC means the concatenation of A, B, and C  A dot stands for any letter: A.C could match AxC, A&C, ABC  ^ means NOT, thus [^D – Z] means not the characters D through Z  Repetitions:  R? means 0 or 1 repetitions of R  R* means 0 or more repetitions of R  R+ means 1 or more repetitions of R  Notations vary and have considerable complexity  Use this notation to describe the regular expression for legal C++ identifiers

Student Lecture

 A finite-state automaton is an idealized machine composed of five objects: 1. A finite set I, called the input alphabet, of input symbols 2. A set S of states the automaton can be in 3. A designated state s 0 called the initial state 4. A designed set of states called the set of accepting states 5. A next-state function N: S x I  S that maps a current state with current input to the next state

 FSA's are often described with a state transition diagram  The starting state has an arrow  The accepting states are marked with circles  Each rule is represented by a labeled transition arrow  The following FSA represents a vending machine 0¢ 25¢ 75¢ 50¢ $1 $1.25 half-dollar quarter half-dollar quarter half-dollar quarter

 Consider this FSA:  What are its states?  What are its input symbols?  What is the initial state of A?  What are the accepting states of A?  What is N(s 1, 1)?  What's a verbal description for the strings accepted? s0s0 s0s0 s1s1 s1s1 s2s2 s2s

 Consider the same FSA:  We can also describe an FSA using an annotated next-state table  A next-state table gives shows what the transition is for each state for all possible input  An annotated next-state table also marks the initial state and accepting states  Find the annotated next-state table for this FSA s0s0 s0s0 s1s1 s1s1 s2s2 s2s

 Consider the following annotated next-state table   marks initial state   marks accepting states):  Draw the corresponding transition state diagram abc  UZYY  VVVV YZVY  ZZZZ

 Consider this FSA again:  Which state will be reached on the following inputs: i. 01 ii iii iv  What's a verbal description for the strings accepted? s0s0 s0s0 s1s1 s1s1 s2s2 s2s

 Let A be a FSA with a set of states S, set of input symbols I, and next-state function N: X x I  S  Let I * be the set of all strings over I  The eventual-state function N * : S x I *  S is the following  N * (s,w) = the state that A goes to if the symbols of w are input to A in sequence, starting with A in state s  All of this is just a notational convenience so that we have a way of talking about the state that a string will transition an FSA to  We say that w is accepted by A iff N * (s 0, w) is an accepting state of A  The language of A, L(A) = { w  I * | w is accepted by A }

 Design a finite-state automaton that accepts the set of all strings of 0's and 1's such that the number of 1's in the string is divisible by 3  Make a regular expression for this language  Design a finite-state automaton that accepts the set of all strings of 0's and 1's that contain exactly one 1  Make a regular expression for this language

 Kleene's Theorem shows that Finite-State Automata are equivalent to regular expressions  That is, for every finite-state automaton there is some equivalent regular expression, and vice versa  We won't prove it, but it should be intuitively clear because there are algorithms for building FSA's from regular expressions and vice versa

 Languages that can be expressed as an FSA or a regular expression are called regular  Some languages are not regular  For example, the language consisting of strings a k b k, meaning all strings that have a positive number of a's followed by the same number of b's, is not regular  Prove it (by contradiction)  Hint: We use the pigeonhole principle to show that more than one sequence of a p and a q must end up the in the same state

 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'

 Simplifying finite state automata  Context free languages  Push down automata

 Keep reading Chapter 12  Work on Assignment 10  Due Friday, April 22 before midnight