Recap from Last Time
|
|
- Austin Godfrey Glenn
- 5 years ago
- Views:
Transcription
1 Regular Expressions
2 Recap from Last Time
3 Regular Languages A language L is a regular language if there is a DFA D such that L( D) = L. Theorem: The following are equivalent: L is a regular language. There is a DFA for L. There is an NFA for L.
4 The Union of Two Languages If L1 and L 2 are languages over the alphabet Σ, the language L 1 L 2 is the language of all strings in at least one of the two languages. If L1 and L 2 are regular languages, is L 1 L 2? ε Machine for L 1 Machine for L 1 L 2 ε Machine for L 2
5 Concatenation Example Let Σ = { a, b,, z, A, B,, Z } and consider these languages over Σ: Noun = { Puppy, Rainbow, Whale, } Verb = { Hugs, Juggles, Loves, } The = { The } The language TheNounVerbTheNoun is { ThePuppyHugsTheWhale, TheWhaleLovesTheRainbow, TheRainbowJugglesTheRainbow, }
6 Concatenating Regular Languages
7 Concatenating Regular Languages Machine for L 1
8 Concatenating Regular Languages Machine for L 1 Machine for L 2
9 Concatenating Regular Languages ε ε Machine for L 1 ε Machine for L 2
10 Concatenating Regular Languages ε ε Machine for L 1 ε Machine for L 2
11 Concatenating Regular Languages ε ε ε Machine for L 1 Machine for L 2 Machine for L 1 L 2
12 The Kleene Closure An important operation on languages is the Kleene Closure, which is defined as Mathematically: L * = L i i = 0 w L* iff n N. w L n Intuitively, all possible ways of concatenating any number of copies of strings in L together.
13 The Kleene Star Machine for L
14 The Kleene Star ε Machine for L
15 The Kleene Star ε Machine for L
16 The Kleene Star ε ε ε Machine for L
17 The Kleene Star ε ε ε Machine for L
18 The Kleene Star ε ε ε Machine for L Machine for L*
19 Another View of Regular Languages
20 Rethinking Regular Languages We currently have several tools for showing a language is regular. Construct a DFA for it. Construct an NFA for it. Apply closure properties to existing languages. We have not spoken much of this last idea.
21 Constructing Regular Languages Idea: Build up all regular languages as follows: Start with a small set of simple languages we already know to be regular. Using closure properties, combine these simple languages together to form more elaborate languages. A bottom-up approach to the regular languages.
22 Regular Expressions Regular expressions are a descriptive format used compactly describe a language. Used extensively in software systems for string processing and as the basis for tools like grep and flex. Conceptually: regular languages are strings describing how to assemble a larger language out of smaller pieces.
23 Atomic Regular Expressions The regular expressions begin with three simple building blocks. The symbol Ø is a regular expression that represents the empty language Ø. The symbol ε is a regular expression that represents the language { ε } This is not the same as Ø! For any a Σ, the symbol a is a regular expression for the language { a }
24 Compound Regular Expressions We can combine together existing regular expressions in four ways. If R1 and R 2 are regular expressions, R 1 R 2 is a regular expression for the concatenation of the languages of R 1 and R 2. If R1 and R 2 are regular expressions, R 1 R 2 is a regular expression for the union of the languages of R 1 and R 2. If R is a regular expression, R* is a regular expression for the Kleene closure of the language of R. If R is a regular expression, (R) is a regular expression with the same meaning as R.
25 Operator Precedence Regular expression operator precedence: (R) R* R 1 R 2 R 1 R 2 So ab*c d is parsed as ((a(b*))c) d
26 Regular Expression Examples The regular expression trick treat represents the regular language { trick, treat } The regular expression booo* represents the regular language { boo, booo, boooo, } The regular expression candy!(candy!)* represents the regular language { candy!, candy!candy!, candy!candy!candy!, }
27 Regular Expressions, Formally The language of a regular expression is the language described by that regular expression. Formally: L(ε) = {ε} L(Ø) = Ø L(a) = {a} L(R1 R 2 ) = L( R 1 ) L( R 2 ) L(R1 R 2 ) = L( R 1 ) L( R 2 ) L(R*) = L( R)* L((R)) = L( R) Worthwhile Worthwhile activity: activity: Apply Apply this this recursive recursive definition definition to to a(b c)((d)) and and see see what what you you get. get.
28 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w contains 00 as a substring }
29 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w contains 00 as a substring } (0 1)*00(0 1)*
30 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w contains 00 as a substring } (0 1)*00(0 1)*
31 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w contains 00 as a substring } (0 1)*00(0 1)*
32 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w contains 00 as a substring } (0 1)*00(0 1)*
33 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w contains 00 as a substring } Σ*00Σ*
34 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w = 4 }
35 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w = 4 }
36 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w = 4 } The The length of of a string w is is denoted w w
37 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w = 4 }
38 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w = 4 } ΣΣΣΣ
39 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w = 4 } ΣΣΣΣ
40 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w = 4 } ΣΣΣΣ
41 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w = 4 } ΣΣΣΣ
42 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w = 4 } Σ
43 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w = 4 } Σ
44 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w contains at most one 0 }
45 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w contains at most one 0 } 1*(0 ε)1*
46 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w contains at most one 0 } 1*(0 ε)1*
47 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w contains at most one 0 } 1*(0 ε)1*
48 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w contains at most one 0 } 1*(0 ε)1*
49 Regular Expressions are Awesome Let Σ = {0, 1} Let L = { w Σ* w contains at most one 0 } 1*0?1*
50 Regular Expressions are Awesome Let Σ = { }, where a represents some letter. Regular expression for addresses:
51 Regular Expressions are Awesome Let Σ = { }, where a represents some letter. Regular expression for addresses: aa*.aa* (.aa*)*
52 Regular Expressions are Awesome Let Σ = { }, where a represents some letter. Regular expression for addresses: aa*.aa* (.aa*)* cs103@cs.stanford.edu first.middle.last@mail.site.org barack.obama@whitehouse.gov
53 Regular Expressions are Awesome Let Σ = { }, where a represents some letter. Regular expression for addresses: aa*.aa* (.aa*)* cs103@cs.stanford.edu first.middle.last@mail.site.org barack.obama@whitehouse.gov
54 Regular Expressions are Awesome Let Σ = { }, where a represents some letter. Regular expression for addresses: aa*.aa* (.aa*)* cs103@cs.stanford.edu first.middle.last@mail.site.org barack.obama@whitehouse.gov
55 Regular Expressions are Awesome Let Σ = { }, where a represents some letter. Regular expression for addresses: aa*.aa* (.aa*)* cs103@cs.stanford.edu first.middle.last@mail.site.org barack.obama@whitehouse.gov
56 Regular Expressions are Awesome Let Σ = { }, where a represents some letter. Regular expression for addresses: a + (.aa*)*@ aa*.aa* (.aa*)* cs103@cs.stanford.edu first.middle.last@mail.site.org barack.obama@whitehouse.gov
57 Regular Expressions are Awesome Let Σ = { }, where a represents some letter. Regular expression for addresses: a + (.a + a +.a + (.a + )* cs103@cs.stanford.edu first.middle.last@mail.site.org barack.obama@whitehouse.gov
58 Regular Expressions are Awesome Let Σ = { }, where a represents some letter. Regular expression for addresses: a + (.a + a +.a + (.a + )* cs103@cs.stanford.edu first.middle.last@mail.site.org barack.obama@whitehouse.gov
59 Regular Expressions are Awesome Let Σ = { }, where a represents some letter. Regular expression for addresses: a + (.a + a + (.a + ) + cs103@cs.stanford.edu first.middle.last@mail.site.org barack.obama@whitehouse.gov
60 Regular Expressions are Awesome Let Σ = { }, where a represents some letter. Regular expression for addresses: a + (.a + )*@a + (.a + ) + cs103@cs.stanford.edu first.middle.last@mail.site.org barack.obama@whitehouse.gov
61 Regular Expressions are Awesome a + (.a + )*@a + (.a + ) q 2. a q 7. a q 0 a q q 3 a q 04. q 5 a q 6 a a a
62 Shorthand Summary R n is shorthand for RR R (n times). Σ is shorthand for any character in Σ. R? is shorthand for (R ε), meaning zero or one copies of R. R+ is shorthand for RR*, meaning one or more copies of R.
63 Time-Out for Announcements!
64 Upcoming Talk WiCS is hosting a talk by Yoky Matsuoka, VP of Technology at Nest Labs and cofounder of Google[x]. Before that, she was a professor of CS, neuroscience, and ME. Coming up next Thursday, November 6 at 4PM at Braun Auditorium. RSVP requested:
65 STEM Fellows Program [T]he Stanford Undergraduate STEM Fellows Program provides support to students who will promote the diversity (broadly defined) of the future professoriate. The program [ seeks] to increase the number of PhDs earned by under-represented groups in the areas of science, technology, engineering, and math. Deadline is December 8, but I'd encourage applying early. Details online at fellowships/fellowships-listing/stanford-undergraduate -stem-fellows-program
66 Problem Set Four Solutions PS4 solutions will be available outside of class today and in the filing cabinet after that. SCPD students: you should receive them soon. Want older solution sets? Pick them up soon before they get recycled!
67 Order in a World of Chaos Please keep the box of exams alphabetized. Everyone pays if even a small number of people scramble the exams.
68 Your Questions
69 I've noticed that you're very passionate about diversity in CS. What advice would you have for someone who is part of a minority and is about to have a job/internship in an environment that is not likely to be diverse?
70 In your opinion, what's the biggest number?
71 What do you do in your free time?
72 Why don't we have a class called Data Structures? Is 106B/X our equivalent of this? Recruiters and interviewers ask me why I haven't taken data structures all the time and I never know how to respond.
73 Back to CS103!
74 The Power of Regular Expressions Theorem: If R is a regular expression, then L( R) is regular. Proof idea: Show how to convert a regular expression into an NFA.
75 A Marvelous Construction The following theorem proves the language of any regular expression is regular: Theorem: For any regular expression R, there is an NFA N such that L(R) = L( N) N has exactly one accepting state. N has no transitions into its state. N has no transitions out of its accepting state.
76 A Marvelous Construction The following theorem proves the language of any regular expression is regular: Theorem: For any regular expression R, there is an NFA N such that L(R) = L( N) N has exactly one accepting state. N has no transitions into its state. N has no transitions out of its accepting state.
77 A Marvelous Construction The following theorem proves These the language of These are are stronger stronger any regular expression is regular: Theorem: For any regular expression R, there is an NFA N such that L(R) = L( N) N has exactly one accepting state. requirements requirements than than are are necessary necessary for for a a normal normal NFA. NFA. We We enforce enforce these these rules rules to to simplify simplify the the construction. construction. N has no transitions into its state. N has no transitions out of its accepting state.
78 Base Cases ε Automaton for ε Automaton for Ø a Automaton for single character a
79 Construction for R 1 R 2
80 Construction for R 1 R 2 Machine for R 1 Machine for R 2
81 Construction for R 1 R 2 Machine for R 1 Machine for R 2
82 Construction for R 1 R 2 ε Machine for R 1 Machine for R 2
83 Construction for R 1 R 2 ε Machine for R 1 Machine for R 2
84 Construction for R 1 R 2
85 Construction for R 1 R 2 Machine for R 1 Machine for R 2
86 Construction for R 1 R 2 Machine for R 1 Machine for R 2
87 Construction for R 1 R 2 ε Machine for R 1 ε Machine for R 2
88 Construction for R 1 R 2 ε Machine for R 1 ε Machine for R 2
89 Construction for R 1 R 2 ε ε Machine for R 1 ε ε Machine for R 2
90 Construction for R 1 R 2 ε ε Machine for R 1 ε ε Machine for R 2
91 Construction for R*
92 Construction for R* Machine for R
93 Construction for R* Machine for R
94 Construction for R* Machine for R ε
95 Construction for R* ε ε Machine for R ε
96 Construction for R* ε ε ε Machine for R ε
97 Construction for R* ε ε ε Machine for R ε
98 Why This Matters Many software tools work by matching regular expressions against text. One possible algorithm for doing so: Convert the regular expression to an NFA. (Optionally) Convert the NFA to a DFA using the subset construction. Run the text through the finite automaton and look for matches. Runs extremely quickly!
99 The Power of Regular Expressions Theorem: If L is a regular language, then there is a regular expression for L. This is not obvious! Proof idea: Show how to convert an arbitrary NFA into a regular expression.
100 From NFAs to Regular Expressions s 1, s 2,, s n
101 From NFAs to Regular Expressions s 1, s 2,, s n Regular expression: (s 1 s 2 s n )*
102 From NFAs to Regular Expressions s 1 s 2 s n Regular expression: (s 1 s 2 s n )*
103 From NFAs to Regular Expressions s 1 s 2 s n Regular expression: (s 1 s 2 s n )* Key Key idea: idea: Label Label transitions transitions with with arbitrary arbitrary regular regular expressions. expressions.
104 From NFAs to Regular Expressions
105 From NFAs to Regular Expressions R Regular expression: R
106 From NFAs to Regular Expressions R Regular expression: R Key Key idea: idea: If If we we can can convert convert any any NFA NFA into into something something that that looks looks like like this, this, we we can can easily easily read read off off the the regular regular expression. expression.
107 From NFAs to Regular Expressions R Regular expression: R s 1 s 2 s n
108 From NFAs to Regular Expressions R Regular expression: R (s 1 s 2 s n )*
109 From NFAs to Regular Expressions R Regular expression: R (s 1 s 2 s n )* Regular expression: (s 1 s 2 s n )*
110 From NFAs to Regular Expressions R Regular expression: R
111 From NFAs to Regular Expressions R Regular expression: R s 1 s 2 s n
112 From NFAs to Regular Expressions R Regular expression: R Ø
113 From NFAs to Regular Expressions R Regular expression: R Ø Regular expression: Ø
114 From NFAs to Regular Expressions R Regular expression: R
115 From NFAs to Regular Expressions R Regular expression: R R 11 R 22 R 12 R q 21 2 q 1
116 From NFAs to Regular Expressions R Regular expression: R R 11 * R 12 (R 22 R 21 R 11 *R 12 )* q 1 q 2
117 From NFAs to Regular Expressions R Regular expression: R R 11 * R 12 (R 22 R 21 R 11 *R 12 )* q 1 q 2
118 From NFAs to Regular Expressions R 11 R 22 R 12 q 1 R q 21 2
119 From NFAs to Regular Expressions R 11 R 22 R 12 q s q 1 q 2 R 21 q f
120 From NFAs to Regular Expressions R 11 R 22 R 12 ε ε q s q 1 q 2 R 21 q f
121 From NFAs to Regular Expressions R 11 R 22 R 12 ε ε q s q 1 q 2 R 21 q f
122 From NFAs to Regular Expressions R 11 R 22 R 12 ε ε q s q 1 q 2 R 21 q f
123 From NFAs to Regular Expressions R 11 R 22 R 12 ε ε q s q 1 q 2 R 21 q f Could Could we we eliminate this this state state from from the the NFA? NFA?
124 From NFAs to Regular Expressions R 11 R 22 R 12 ε ε q s q 1 q 2 R 21 q f
125 From NFAs to Regular Expressions R 11 R 22 R 12 ε ε q s q 1 q 2 R 21 q f
126 From NFAs to Regular Expressions ε R 11 * R 12 R 11 R 22 R 12 ε ε q s q 1 q 2 R 21 q f Note: Note: We're We're using using concatenation concatenation and and Kleene Kleene closure closure in in order order to to skip skip this this state. state.
127 From NFAs to Regular Expressions ε R 11 * R 12 R 11 R 22 R 12 ε ε q s q 1 q 2 R 21 q f
128 From NFAs to Regular Expressions ε R 11 * R 12 R 11 R 22 R 12 ε ε q s q 1 q 2 R 21 q f
129 From NFAs to Regular Expressions ε R 11 * R 12 R 11 R 22 R 12 ε ε q s q 1 q 2 R 21 q f
130 From NFAs to Regular Expressions ε R 11 * R 12 R 11 R 22 R 12 ε ε q s q 1 q 2 R 21 q f R 21 R 11 * R 12
131 From NFAs to Regular Expressions ε R 11 * R 12 R 11 R 22 R 12 ε ε q s q 1 q 2 R 21 q f R 21 R 11 * R 12
132 From NFAs to Regular Expressions ε R 11 * R 12 R 22 q s q 2 ε q f R 21 R 11 * R 12
133 From NFAs to Regular Expressions R 11 * R 12 R 22 q s q 2 ε q f R 21 R 11 * R 12
134 From NFAs to Regular Expressions R 11 * R 12 q s q 2 ε q f R 22 R 21 R 11 * R 12 Note: Note: We're We're using using union union to to combine combine these these transitions transitions together. together.
135 From NFAs to Regular Expressions q s R 11 * R 12 q 2 ε q f R 22 R 21 R 11 * R 12
136 From NFAs to Regular Expressions q s R 11 * R 12 q 2 ε q f R 22 R 21 R 11 * R 12
137 From NFAs to Regular Expressions q s R 11 * R 12 q 2 ε q f R 22 R 21 R 11 * R 12
138 From NFAs to Regular Expressions q s R 11 * R 12 q 2 ε q f R 22 R 21 R 11 * R 12
139 From NFAs to Regular Expressions R 11 * R 12 (R 22 R 21 R 11 *R 12 )* ε q s R 11 * R 12 q 2 ε q f R 22 R 21 R 11 * R 12
140 From NFAs to Regular Expressions R 11 * R 12 (R 22 R 21 R 11 *R 12 )* ε q s R 11 * R 12 q 2 ε q f R 22 R 21 R 11 * R 12
141 From NFAs to Regular Expressions R 11 * R 12 (R 22 R 21 R 11 *R 12 )* ε q s q f
142 From NFAs to Regular Expressions R 11 * R 12 (R 22 R 21 R 11 *R 12 )* q s q f
143 From NFAs to Regular Expressions R 11 * R 12 (R 22 R 21 R 11 *R 12 )* q s q f
144 From NFAs to Regular Expressions R 11 * R 12 (R 22 R 21 R 11 *R 12 )* q s q f R 11 R 22 R 12 q 1 R q 21 2
145 The Construction at a Glance Start with an NFA for the language L. Add a new state qs and accept state q f to the NFA. Add ε-transitions from each original accepting state to q f, then mark them as not accepting. Repeatedly remove states other than qs and q f from the NFA by shortcutting them until only two states remain: q s and q f. The transition from qs to q f is then a regular expression for the NFA.
146 Our Transformations direct conversion state elimination DFA NFA Regexp subset construction recursive transform
147 Theorem: The following are all equivalent: L is a regular language. There is a DFA D such that L( D) = L. There is an NFA N such that L( N) = L. There is a regular expression R such that L( R) = L.
148 Next Time Applications of Regular Languages Answering so what? Intuiting Regular Languages What makes a language regular? The Myhill-Nerode Theorem The limits of regular languages.
Concatenation. The concatenation of two languages L 1 and L 2
Regular Expressions Problem Problem Set Set Four Four is is due due using using a late late period period in in the the box box up up front. front. Concatenation The concatenation of two languages L 1
More informationRecap from Last Time
Regular Expressions Recap from Last Time Regular Languages A language L is a regular language if there is a DFA D such that L( D) = L. Theorem: The following are equivalent: L is a regular language. There
More informationFinite Automata Part Two
Finite Automata Part Two DFAs A DFA is a Deterministic Finite Automaton A DFA is defined relative to some alphabet Σ. For each state in the DFA, there must be exactly one transition defined for each symbol
More informationIntroduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.
Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures and Instructions 23.10. 3.11. 17.11. 24.11. 1.12. 11.12.
More informationUNIT-III REGULAR LANGUAGES
Syllabus R9 Regulation REGULAR EXPRESSIONS UNIT-III REGULAR LANGUAGES Regular expressions are useful for representing certain sets of strings in an algebraic fashion. In arithmetic we can use the operations
More informationIntroduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.
Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures Tuesday 10:45 pm - 12:15 pm Instructions Tuesday 12:30
More informationHKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed
HKN CS/ECE 374 Midterm 1 Review Nathan Bleier and Mahir Morshed For the most part, all about strings! String induction (to some extent) Regular languages Regular expressions (regexps) Deterministic finite
More informationCS 154, Lecture 3: DFA NFA, Regular Expressions
CS 154, Lecture 3: DFA NFA, Regular Expressions Homework 1 is coming out Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and
More informationCS 154. Finite Automata, Nondeterminism, Regular Expressions
CS 54 Finite Automata, Nondeterminism, Regular Expressions Read string left to right The DFA accepts a string if the process ends in a double circle A DFA is a 5-tuple M = (Q, Σ, δ, q, F) Q is the set
More informationCS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa
CS:4330 Theory of Computation Spring 2018 Regular Languages Finite Automata and Regular Expressions Haniel Barbosa Readings for this lecture Chapter 1 of [Sipser 1996], 3rd edition. Sections 1.1 and 1.3.
More informationClosure under the Regular Operations
September 7, 2013 Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have shown this closure
More informationClarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.
CMSC 330: Organization of Programming Languages Last Lecture Languages Sets of strings Operations on languages Finite Automata Regular expressions Constants Operators Precedence CMSC 330 2 Clarifications
More information1 Alphabets and Languages
1 Alphabets and Languages Look at handout 1 (inference rules for sets) and use the rules on some examples like {a} {{a}} {a} {a, b}, {a} {{a}}, {a} {{a}}, {a} {a, b}, a {{a}}, a {a, b}, a {{a}}, a {a,
More informationFinite Automata Part Two
Finite Automata Part Two Recap from Last Time Old MacDonald Had a Symbol, Σ-eye-ε-ey, Oh! You may have noticed that we have several letter- E-ish symbols in CS103, which can get confusing! Here s a quick
More informationNondeterministic Finite Automata and Regular Expressions
Nondeterministic Finite Automata and Regular Expressions CS 2800: Discrete Structures, Spring 2015 Sid Chaudhuri Recap: Deterministic Finite Automaton A DFA is a 5-tuple M = (Q, Σ, δ, q 0, F) Q is a finite
More informationHow do regular expressions work? CMSC 330: Organization of Programming Languages
How do regular expressions work? CMSC 330: Organization of Programming Languages Regular Expressions and Finite Automata What we ve learned What regular expressions are What they can express, and cannot
More informationLecture 3: Nondeterministic Finite Automata
Lecture 3: Nondeterministic Finite Automata September 5, 206 CS 00 Theory of Computation As a recap of last lecture, recall that a deterministic finite automaton (DFA) consists of (Q, Σ, δ, q 0, F ) where
More informationSri vidya college of engineering and technology
Unit I FINITE AUTOMATA 1. Define hypothesis. The formal proof can be using deductive proof and inductive proof. The deductive proof consists of sequence of statements given with logical reasoning in order
More informationCSE 105 THEORY OF COMPUTATION
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
More informationFinite Automata Part One
Finite Automata Part One Computability Theory What problems can we solve with a computer? What kind of computer? Computers are Messy http://en.wikipedia.org/wiki/file:eniac.jpg Computers are Messy That
More informationNon-deterministic Finite Automata (NFAs)
Algorithms & Models of Computation CS/ECE 374, Fall 27 Non-deterministic Finite Automata (NFAs) Part I NFA Introduction Lecture 4 Thursday, September 7, 27 Sariel Har-Peled (UIUC) CS374 Fall 27 / 39 Sariel
More informationNondeterministic Finite Automata
Nondeterministic Finite Automata Not A DFA Does not have exactly one transition from every state on every symbol: Two transitions from q 0 on a No transition from q 1 (on either a or b) Though not a DFA,
More informationWhat we have done so far
What we have done so far DFAs and regular languages NFAs and their equivalence to DFAs Regular expressions. Regular expressions capture exactly regular languages: Construct a NFA from a regular expression.
More informationAnnouncements. Problem Set Four due Thursday at 7:00PM (right before the midterm).
Finite Automata Announcements Problem Set Four due Thursday at 7:PM (right before the midterm). Stop by OH with questions! Email cs3@cs.stanford.edu with questions! Review session tonight, 7PM until whenever
More informationAutomata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,
Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu ETH Zürich (D-ITET) September, 24 2015 Last week was all about Deterministic Finite Automaton We saw three main
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION "Winter" 2018 http://cseweb.ucsd.edu/classes/wi18/cse105-ab/ Today's learning goals Sipser Section 1.1 Design an automaton that recognizes a given language. Specify each of
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION "Winter" 2018 http://cseweb.ucsd.edu/classes/wi18/cse105-ab/ Today's learning goals Sipser Section 1.1 Determine if a language is regular Apply closure properties to conclude
More information2017/08/31 Chapter 1.2 & 1.3 in Sipser Ø Announcement:
Regular Expressions Human-aware and Robo.cs Operations 2017/08/31 Chapter 1.2 & 1.3 in Sipser Ø Announcement: q q q q Many thanks to students who have responded so far! There is still time to respond to
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION Spring 2018 http://cseweb.ucsd.edu/classes/sp18/cse105-ab/ Today's learning goals Sipser Section 1.1 Prove closure properties of the class of regular languages Apply closure
More informationChapter Five: Nondeterministic Finite Automata
Chapter Five: Nondeterministic Finite Automata From DFA to NFA A DFA has exactly one transition from every state on every symbol in the alphabet. By relaxing this requirement we get a related but more
More informationCSE 105 Theory of Computation Professor Jeanne Ferrante
CSE 105 Theory of Computation http://www.jflap.org/jflaptmp/ Professor Jeanne Ferrante 1 Announcement & Reminders HW 2: Grades not available yet, will be soon Solutions posted, read even if you did well
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY NON-DETERMINISM and REGULAR OPERATIONS THURSDAY JAN 6 UNION THEOREM The union of two regular languages is also a regular language Regular Languages Are
More informationDeterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)
Deterministic Finite Automata Non deterministic finite automata Automata we ve been dealing with have been deterministic For every state and every alphabet symbol there is exactly one move that the machine
More informationCS21 Decidability and Tractability
CS21 Decidability and Tractability Lecture 3 January 9, 2017 January 9, 2017 CS21 Lecture 3 1 Outline NFA, FA equivalence Regular Expressions FA and Regular Expressions January 9, 2017 CS21 Lecture 3 2
More informationRegular Expressions. Definitions Equivalence to Finite Automata
Regular Expressions Definitions Equivalence to Finite Automata 1 RE s: Introduction Regular expressions are an algebraic way to describe languages. They describe exactly the regular languages. If E is
More informationFoundations of
91.304 Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.3: Regular Expressions) David Martin dm@cs.uml.edu d with some modifications by Prof. Karen Daniels, Spring 2012
More informationText Search and Closure Properties
Text Search and Closure Properties CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Chinese University of Hong Kong Fall 2017 1/30 Text Search 2/30 grep program grep -E regexp file.txt Searches
More informationCS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)
CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) Definition 1 (Alphabet) A alphabet is a finite set of objects called symbols. Definition 2 (String)
More informationRegular Expressions and Language Properties
Regular Expressions and Language Properties Mridul Aanjaneya Stanford University July 3, 2012 Mridul Aanjaneya Automata Theory 1/ 47 Tentative Schedule HW #1: Out (07/03), Due (07/11) HW #2: Out (07/10),
More informationCMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata
: Organization of Programming Languages Theory of Regular Expressions Finite Automata Previous Course Review {s s defined} means the set of string s such that s is chosen or defined as given s A means
More informationAutomata: a short introduction
ILIAS, University of Luxembourg Discrete Mathematics II May 2012 What is a computer? Real computers are complicated; We abstract up to an essential model of computation; We begin with the simplest possible
More informationExamples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application
Examples of Regular Expressions 1. 0 10, L(0 10 ) = {w w contains exactly a single 1} 2. Σ 1Σ, L(Σ 1Σ ) = {w w contains at least one 1} 3. Σ 001Σ, L(Σ 001Σ ) = {w w contains the string 001 as a substring}
More informationNonregular Languages
Nonregular Languages Recap from Last Time Theorem: The following are all equivalent: L is a regular language. There is a DFA D such that L( D) = L. There is an NFA N such that L( N) = L. There is a regular
More informationCS 121, Section 2. Week of September 16, 2013
CS 121, Section 2 Week of September 16, 2013 1 Concept Review 1.1 Overview In the past weeks, we have examined the finite automaton, a simple computational model with limited memory. We proved that DFAs,
More informationWhat Is a Language? Grammars, Languages, and Machines. Strings: the Building Blocks of Languages
Do Homework 2. What Is a Language? Grammars, Languages, and Machines L Language Grammar Accepts Machine Strings: the Building Blocks of Languages An alphabet is a finite set of symbols: English alphabet:
More informationCOM364 Automata Theory Lecture Note 2 - Nondeterminism
COM364 Automata Theory Lecture Note 2 - Nondeterminism Kurtuluş Küllü March 2018 The FA we saw until now were deterministic FA (DFA) in the sense that for each state and input symbol there was exactly
More informationPS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010
University of Virginia - cs3102: Theory of Computation Spring 2010 PS2 - Comments Average: 77.4 (full credit for each question is 100 points) Distribution (of 54 submissions): 90, 12; 80 89, 11; 70-79,
More informationjflap demo Regular expressions Pumping lemma Turing Machines Sections 12.4 and 12.5 in the text
On the menu today jflap demo Regular expressions Pumping lemma Turing Machines Sections 12.4 and 12.5 in the text 1 jflap Demo jflap: Useful tool for creating and testing abstract machines Finite automata,
More informationCS21 Decidability and Tractability
CS21 Decidability and Tractability Lecture 2 January 5, 2018 January 5, 2018 CS21 Lecture 2 1 Outline Finite Automata Nondeterministic Finite Automata Closure under regular operations NFA, FA equivalence
More informationComputational Models Lecture 2 1
Computational Models Lecture 2 1 Handout Mode Iftach Haitner. Tel Aviv University. October 30, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.
More informationComputational Models Lecture 2 1
Computational Models Lecture 2 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. March 16/18, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice
More informationFinite Automata Part One
Finite Automata Part One Computability Theory What problems can we solve with a computer? What problems can we solve with a computer? What kind of computer? Computers are Messy http://www.intel.com/design/intarch/prodbref/27273.htm
More informationDecision, Computation and Language
Decision, Computation and Language Non-Deterministic Finite Automata (NFA) Dr. Muhammad S Khan (mskhan@liv.ac.uk) Ashton Building, Room G22 http://www.csc.liv.ac.uk/~khan/comp218 Finite State Automata
More informationTheory of Languages and Automata
Theory of Languages and Automata Chapter 1- Regular Languages & Finite State Automaton Sharif University of Technology Finite State Automaton We begin with the simplest model of Computation, called finite
More informationUNIT II REGULAR LANGUAGES
1 UNIT II REGULAR LANGUAGES Introduction: A regular expression is a way of describing a regular language. The various operations are closure, union and concatenation. We can also find the equivalent regular
More informationCS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,
CS 54, Lecture 2: Finite Automata, Closure Properties Nondeterminism, Why so Many Models? Streaming Algorithms 0 42 Deterministic Finite Automata Anatomy of Deterministic Finite Automata transition: for
More informationRegular expressions and Kleene s theorem
and Kleene s theorem Informatics 2A: Lecture 5 John Longley School of Informatics University of Edinburgh jrl@inf.ed.ac.uk 29 September 2016 1 / 21 1 More closure properties of regular languages Operations
More informationContext Free Grammars
Automata and Formal Languages Context Free Grammars Sipser pages 101-111 Lecture 11 Tim Sheard 1 Formal Languages 1. Context free languages provide a convenient notation for recursive description of languages.
More informationCS243, Logic and Computation Nondeterministic finite automata
CS243, Prof. Alvarez NONDETERMINISTIC FINITE AUTOMATA (NFA) Prof. Sergio A. Alvarez http://www.cs.bc.edu/ alvarez/ Maloney Hall, room 569 alvarez@cs.bc.edu Computer Science Department voice: (67) 552-4333
More informationTheory of Computation (I) Yijia Chen Fudan University
Theory of Computation (I) Yijia Chen Fudan University Instructor Yijia Chen Homepage: http://basics.sjtu.edu.cn/~chen Email: yijiachen@fudan.edu.cn Textbook Introduction to the Theory of Computation Michael
More informationFinite Automata Part One
Finite Automata Part One Computability Theory What problems can we solve with a computer? What kind of computer? Computers are Messy http://www.intel.com/design/intarch/prodbref/27273.htm We need a simpler
More information1.3 Regular Expressions
51 1.3 Regular Expressions These have an important role in descriing patterns in searching for strings in many applications (e.g. awk, grep, Perl,...) All regular expressions of alphaet are 1.Øand are
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Regular Expressions and Finite Automata CMSC 330 Spring 2017 1 How do regular expressions work? What we ve learned What regular expressions are What they
More informationCMSC 330: Organization of Programming Languages. Regular Expressions and Finite Automata
CMSC 330: Organization of Programming Languages Regular Expressions and Finite Automata CMSC330 Spring 2018 1 How do regular expressions work? What we ve learned What regular expressions are What they
More informationLecture 2: Connecting the Three Models
IAS/PCMI Summer Session 2000 Clay Mathematics Undergraduate Program Advanced Course on Computational Complexity Lecture 2: Connecting the Three Models David Mix Barrington and Alexis Maciel July 18, 2000
More informationCS 455/555: Finite automata
CS 455/555: Finite automata Stefan D. Bruda Winter 2019 AUTOMATA (FINITE OR NOT) Generally any automaton Has a finite-state control Scans the input one symbol at a time Takes an action based on the currently
More informationTheory of Computation (II) Yijia Chen Fudan University
Theory of Computation (II) Yijia Chen Fudan University Review A language L is a subset of strings over an alphabet Σ. Our goal is to identify those languages that can be recognized by one of the simplest
More informationText Search and Closure Properties
Text Search and Closure Properties CSCI 330 Formal Languages and Automata Theory Siu On CHAN Fall 208 Chinese University of Hong Kong /28 Text Search grep program grep -E regex file.txt Searches for an
More informationRecap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.
Recap DFA,NFA, DTM Slides by Prof. Debasis Mitra, FIT. 1 Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { {, } } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite
More informationTDDD65 Introduction to the Theory of Computation
TDDD65 Introduction to the Theory of Computation Lecture 2 Gustav Nordh, IDA gustav.nordh@liu.se 2012-08-31 Outline - Lecture 2 Closure properties of regular languages Regular expressions Equivalence of
More informationMathematical Logic Part Three
Mathematical Logic Part Three Recap from Last Time What is First-Order Logic? First-order logic is a logical system for reasoning about properties of objects. Augments the logical connectives from propositional
More informationCS 154. Finite Automata vs Regular Expressions, Non-Regular Languages
CS 154 Finite Automata vs Regular Expressions, Non-Regular Languages Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and guessing
More informationMathematical Logic Part Three
Mathematical Logic Part Three Recap from Last Time What is First-Order Logic? First-order logic is a logical system for reasoning about properties of objects. Augments the logical connectives from propositional
More informationCOMP4141 Theory of Computation
COMP4141 Theory of Computation Lecture 4 Regular Languages cont. Ron van der Meyden CSE, UNSW Revision: 2013/03/14 (Credits: David Dill, Thomas Wilke, Kai Engelhardt, Peter Höfner, Rob van Glabbeek) Regular
More information3515ICT: Theory of Computation. Regular languages
3515ICT: Theory of Computation Regular languages Notation and concepts concerning alphabets, strings and languages, and identification of languages with problems (H, 1.5). Regular expressions (H, 3.1,
More informationClosure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism
Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties Recall a closure property is a statement
More informationCMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013
CMPSCI 250: Introduction to Computation Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013 λ-nfa s to NFA s to DFA s Reviewing the Three Models and Kleene s Theorem The Subset
More informationBefore we show how languages can be proven not regular, first, how would we show a language is regular?
CS35 Proving Languages not to be Regular Before we show how languages can be proven not regular, first, how would we show a language is regular? Although regular languages and automata are quite powerful
More informationAutomata and Languages
Automata and Languages Prof. Mohamed Hamada Software Engineering Lab. The University of Aizu Japan Nondeterministic Finite Automata with empty moves (-NFA) Definition A nondeterministic finite automaton
More informationComputational Models - Lecture 4
Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION Spring 2017 http://cseweb.ucsd.edu/classes/sp17/cse105-ab/ Today's learning goals Sipser Ch 1.1, 1.2 Distinguish between an NFA and a DFA Define nondeterminism and why it
More informationComplexity Theory Part I
Complexity Theory Part I Outline for Today Recap from Last Time Reviewing Verifiers Nondeterministic Turing Machines What does nondeterminism mean in the context of TMs? And just how powerful are NTMs?
More informationRegular languages, regular expressions, & finite automata (intro) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/
Regular languages, regular expressions, & finite automata (intro) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/ 1 L = {hello, bonjour, konnichiwa, } Σ = {a, b, c,, y, z}!2 Σ = {a, b, c,, y, z} Σ*
More informationCMPSCI 250: Introduction to Computation. Lecture #23: Finishing Kleene s Theorem David Mix Barrington 25 April 2013
CMPSCI 250: Introduction to Computation Lecture #23: Finishing Kleene s Theorem David Mix Barrington 25 April 2013 Finishing Kleene s Theorem A Normal Form for λ-nfa s Building λ-nfa s by Induction Why
More informationCS311 Computational Structures Regular Languages and Regular Expressions. Lecture 4. Andrew P. Black Andrew Tolmach
CS311 Computational Structures Regular Languages and Regular Expressions Lecture 4 Andrew P. Black Andrew Tolmach 1 Expressions Weʼre used to using expressions to describe mathematical objects Example:
More information10. Finite Automata and Turing Machines
. Finite Automata and Turing Machines Frank Stephan March 2, 24 Introduction Alan Turing s th Birthday Alan Turing was a completely original thinker who shaped the modern world, but many people have never
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 3.3, 4.1 State and use the Church-Turing thesis. Give examples of decidable problems.
More informationRegular expressions and Kleene s theorem
and Informatics 2A: Lecture 5 Alex Simpson School of Informatics University of Edinburgh als@inf.ed.ac.uk 25 September, 2014 1 / 26 1 More closure properties of regular languages Operations on languages
More informationCISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata
CISC 4090: Theory of Computation Chapter Regular Languages Xiaolan Zhang, adapted from slides by Prof. Werschulz Section.: Finite Automata Fordham University Department of Computer and Information Sciences
More informationFormal Languages. We ll use the English language as a running example.
Formal Languages We ll use the English language as a running example. Definitions. A string is a finite set of symbols, where each symbol belongs to an alphabet denoted by. Examples. The set of all strings
More information10. The GNFA method is used to show that
CSE 355 Midterm Examination 27 February 27 Last Name Sample ASU ID First Name(s) Ima Exam # Sample Regrading of Midterms If you believe that your grade has not been recorded correctly, return the entire
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION "Winter" 2018 http://cseweb.ucsd.edu/classes/wi18/cse105-ab/ Today's learning goals Sipser Section 1.1 Construct finite automata using algorithms from closure arguments Determine
More informationGEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I
GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I Internal Examination 2017-18 B.Tech III Year VI Semester Sub: Theory of Computation (6CS3A) Time: 1 Hour 30 min. Max Marks: 40 Note: Attempt all three
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be
More information1 More finite deterministic automata
CS 125 Section #6 Finite automata October 18, 2016 1 More finite deterministic automata Exercise. Consider the following game with two players: Repeatedly flip a coin. On heads, player 1 gets a point.
More informationIntro to Theory of Computation
Intro to Theory of Computation 1/19/2016 LECTURE 3 Last time: DFAs and NFAs Operations on languages Today: Nondeterminism Equivalence of NFAs and DFAs Closure properties of regular languages Sofya Raskhodnikova
More informationEquivalence of DFAs and NFAs
CS 172: Computability and Complexity Equivalence of DFAs and NFAs It s a tie! DFA NFA Sanjit A. Seshia EECS, UC Berkeley Acknowledgments: L.von Ahn, L. Blum, M. Blum What we ll do today Prove that DFAs
More informationTHEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET
THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET Regular Languages and FA A language is a set of strings over a finite alphabet Σ. All languages are finite or countably infinite. The set of all languages
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION Spring 2017 http://cseweb.ucsd.edu/classes/sp17/cse105-ab/ Review of CFG, CFL, ambiguity What is the language generated by the CFG below: G 1 = ({S,T 1,T 2 }, {0,1,2}, { S
More informationTheory of Computation
Fall 2002 (YEN) Theory of Computation Midterm Exam. Name:... I.D.#:... 1. (30 pts) True or false (mark O for true ; X for false ). (Score=Max{0, Right- 1 2 Wrong}.) (1) X... If L 1 is regular and L 2 L
More information