Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 105 theory of computation

Similar presentations


Presentation on theme: "CSE 105 theory of computation"— Presentation transcript:

1 CSE 105 theory of computation
Fall 2017

2 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

3 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!

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

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

6 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.

7 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, …

8 "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

9 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)*

10 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

11 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 𝐿(𝑅 𝑀 )=𝐿(𝑀)

12 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 𝑅 𝑀 =𝜙

13 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 )

14 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 ∪(𝐿 𝑀 𝑠𝑡𝑎𝑟𝑡 ∘ 𝑎∘𝐿 𝑀 𝑚𝑖𝑑𝑑𝑙𝑒 ∗ ∘𝑎∘𝐿 𝑀 𝑒𝑛𝑑 )

15 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.

16 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}

17 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}

18 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.

19 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.

20 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.


Download ppt "CSE 105 theory of computation"

Similar presentations


Ads by Google