CSE 105 theory of computation

Slides:



Advertisements
Similar presentations
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Advertisements

Regular Expressions and DFAs COP 3402 (Summer 2014)
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Regular expressions Regular languages Sipser 1.3 (pages 63-76)
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
CS 310 – Fall 2006 Pacific University CS310 Regular Expressions Sections:1.3 page 63 September 18, 2006 September 20, 2006.
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
1 Regular Languages Finite Automata eg. Supermarket automatic door: exit or entrance.
CS 310 – Fall 2006 Pacific University CS310 Homework 2 & JFLAP September 22, 2006.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
CHAPTER 1 Regular Languages
January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015.
CS 3240 – Chapter 4.  Closure Properties  Algorithms for Elementary Questions:  Is a given word, w, in L?  Is L empty, finite or infinite?  Are L.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 1 Ahmed Ezzat.
 2004 SDU Lecture4 Regular Expressions.  2004 SDU 2 Regular expressions A third way to view regular languages. Say that R is a regular expression if.
1 Introduction to the Theory of Computation Regular Expressions.
Page 1. 1)Let B n = { a k | where k is a multiple of n}. I.e. B 1 = { a k | where k is a multiple of 1} = { a k | k Є {0,1,2,3,…}} = {‘’, a, aa, aaa, aaaa,
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
CSE 105 theory of computation
CSE 105 theory of computation
CSE 105 theory of computation
CSE 105 theory of computation
PROPERTIES OF REGULAR LANGUAGES
Regular Expressions.
CSE 105 theory of computation
Regular Expressions Sections:1.3 page 63 September 17, 2008
CSE 105 theory of computation
Single Final State for NFA
CSE 105 theory of computation
Intro to Theory of Computation
CS 154, Lecture 3: DFANFA, Regular Expressions.
4. Properties of Regular Languages
CSE 105 theory of computation
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CSCI 2670 Introduction to Theory of Computing
CS21 Decidability and Tractability
CS21 Decidability and Tractability
CSE 105 theory of computation
CSE 105 theory of computation
Chapter 1 Regular Language
CSE 105 theory of computation
CSE 105 theory of computation
CSE 105 theory of computation
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
Intro to Theory of Computation
CSE 105 theory of computation
CSE 105 theory of computation
CSE 105 theory of computation
CSE 105 theory of computation
CSE 105 theory of computation
CSE 105 theory of computation
CSE 105 theory of computation
Presentation transcript:

CSE 105 theory of computation Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse105-a/

Today's learning goals Sipser Ch 1.2, 1.3 Decide whether or not a string is described by a given regular expression Design a regular expression to describe a given language Convert between regular expressions and automata Reminder: Midterm 1 is XXX in class

Inductive application of closure Sipser 1.52 p. 64 R is a regular expression over Σ if Σ is shorthand for (0 U 1) if Σ = {0,1}, Parentheses may be omitted, R+ means RR*, Rk means R concatenated with itself k times Watch out for overloaded symbols!

Syntax  Languages The language described by a regular expression, L(R): L ( (0 U 1) U1 ) = { } L ( ) = { }

L(R) Which of the following strings is not in the language described by ( ( (00)*(11) ) U 01 )* 00 01 1101 I don't know

L(R) Let L be the language over {a,b} described by the regular expression ((a U Ø) b*)* Which of the following is not true about L? Some strings in L have equal numbers of a's and b's L contains the string aaaaaa a's never follow b's in any string in L L can also be represented by the regular expression (ab*)* More than one of the above.

Regular expressions in practice Compilers: first phase of compiling transforms Strings to Tokens keywords, operators, identifiers, literals One regular expression for each token type Other software tools: grep, Perl, Python, Java, Ruby, …

"Regular = regular" Sipser Theorem 1.54 p. 66 Theorem: A language is regular if and only if some regular expression describes it. Lemma 1.55: If a language is described by a regular expression, then it is regular. Lemma 1.60: If a language is regular, then it is described by some regular expression

L(R) to NFA (to DFA) Lemma 1.55, page 67 Idea: basic regular expressions are easy to implement as DFA, for inductive step of definition, use closure under regular operations. E.g.: build NFA recognizing the language described by (00 U 11)*

DFA to regular expression Lemma 1.60, page 69 Book version GNFA: start state all, single accept, one arrow from all to all GNFA with fewer states 2 state GNFA Regular expression Idea: use intermediate model GNFA whose labels are regular expressions E.g.: build regular expression describing language recognized by

DFA to regular expression My version Idea: directly from NFAs to regular expressions Use induction on number of edges in NFA Lemma: for any 𝑛≥0, if 𝑀 is a NFA with 𝑛 edges, then there is a regular expression 𝑅 𝑀 such that 𝐿(𝑅 𝑀 )=𝐿(𝑀)

DFA to regular expression My version Lemma: for any 𝑛≥0, if 𝑀 is a NFA with 𝑛 edges, then there is a regular expression 𝑅 𝑀 such that 𝐿(𝑅 𝑀 )=𝐿(𝑀) Notations: Start node of 𝑀 is 𝑞 Accept nodes of 𝑀 are 𝐹 Base case: 𝑛=0. There are two cases: 𝑞∈𝐹: In this case 𝐿 𝑀 = 𝜖 and 𝑅 𝑀 =𝜖 𝑞∉𝐹: In this case 𝐿 𝑀 ={} and 𝑅 𝑀 =𝜙

DFA to regular expression My version Lemma: for any 𝑛≥0, if M is a NFA with 𝑛 edges, then there is a regular expression 𝑅 𝑀 such that 𝐿(𝑅 𝑀 )=𝐿(𝑀) Notation: Start node of 𝑀 is 𝑞, accept nodes of 𝑀 are 𝐹 Induction case: Assume true for n-1, prove for n. Pick edge 𝑞′,𝑞′′ in 𝑀 labeled by 𝑎∈ Σ 𝜖 (that is: 𝑞′′∈𝛿 𝑞 ′ ,𝑎 ) Let 𝑀 1 be 𝑀 with the edge 𝑞 ′ ,𝑞′′ removed Note: 𝑀 1 has n-1 edges Induction: exists regular language 𝑅 1 such that 𝐿( 𝑅 1 )=𝐿( 𝑀 1 ) Notice: 𝐿 𝑀 1 ⊂𝐿(𝑀) Next goal: complete the difference 𝐿(𝑀)\L( 𝑀 1 )

DFA to regular expression My version Induction case: Assume true for n-1, prove for n. Notation: 𝑞 start node of 𝑀, 𝐹 accept nodes of 𝑀 𝑀 1 is 𝑀 with some edge 𝑞′,𝑞′′ labeled by 𝑎 removed Define: 𝑀 𝑠𝑡𝑎𝑟𝑡 : same as 𝑀 1 , but with start node 𝑞 and accept nodes { 𝑞 ′ } 𝑀 𝑚𝑖𝑑𝑑𝑙𝑒 : same as 𝑀 1 , but with start node 𝑞′′ and accept nodes { 𝑞 ′ } 𝑀 𝑒𝑛𝑑 : same as 𝑀 1 , but with start node 𝑞′′ and accept nodes 𝐹 All NFAs with n-1 edges, so can apply induction for each Completing the proof: 𝐿 𝑀 =𝐿 𝑀 1 ∪(𝐿 𝑀 𝑠𝑡𝑎𝑟𝑡 ∘ 𝑎∘𝐿 𝑀 𝑚𝑖𝑑𝑑𝑙𝑒 ∗ ∘𝑎∘𝐿 𝑀 𝑒𝑛𝑑 )

All roads lead to … regular sets? Are there any languages over {0,1} that are not regular? Yes: a language that is recognized by an NFA but not any DFA. Yes: there is some infinite language of strings over {0,1} that is not described by any regular expression. No: all languages over {0,1} are regular because that's what it means to be a language. No: for each set of strings over {0,1}, some DFA recognizes that set. I don't know.

Counting Fact: a countable union of countable sets is countable. Fact: {0,1}* is countably infinite. X* is countably infinite when X is finite. Fact: the set of subsets of a countably infinite sets is uncountable. Fact: there are countably many DFA with Σ={0,1} Fact: there are countably many regular languages over {0,1}

Counting Fact: a countable union of countable sets is countable. Fact: {0,1}* is countably infinite. X* is countably infinite when X is finite. Fact: the set of subsets of a countably infinite sets is uncountable. Fact: there are countably many DFA with Σ={0,1} Fact: there are countably many regular languages over {0,1} Uncountably many languages over {0,1} Countably many regular languages over {0,1}

Proving nonregularity How can we prove that a set is non-regular? Try to design a DFA that recognizes it and, if the first few attempts don't work, conclude there is none that does. Prove that it's a strict subset of some regular set. Prove that it's the union of two regular sets. Prove that its complement is not regular. I don't know.

Where we stand There exist non-regular sets. If we know that some sets are not regular, we can conclude others are also not regular judiciously reasoning using closure properties of class of regular languages. No example of a specific regular set ... yet.

Bounds on DFA in DFA, memory = states Automata can only "remember"… …finitely far in the past …finitely much information If a computation path visits the same state more than once, the machine can't tell the difference between the first time and future times it visited that state.