CS 310 – Fall 2006 Pacific University CS310 Homework 2 & JFLAP September 22, 2006.

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

FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
1 Introduction to Computability Theory Discussion1: Conversion of A DFA to a Regular Expression Prof. Amos Israeli.
Regular expressions Regular languages Sipser 1.3 (pages 63-76)
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
NFAs Sipser 1.2 (pages 47–54). CS 311 Fall Recall… Last time we showed that the class of regular languages is closed under: –Complement –Union.
Regular expressions Regular languages Sipser 1.3 (pages 63-76)
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
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 Converting NFA to DFA Sections:1.2 Page 54 September 15, 2006.
CS 310 – Fall 2006 Pacific University CS310 Regular Expressions Sections:1.3 page 63 September 18, 2006 September 20, 2006.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
Lecture 3: Closure Properties & Regular Expressions Jim Hook Tim Sheard Portland State University.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
Fall 2004COMP 3351 Single Final State for NFA. Fall 2004COMP 3352 Any NFA can be converted to an equivalent NFA with a single final state.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
Regular expressions Sipser 1.3 (pages 63-76). CS 311 Fall Looks familiar…
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS 310 – Fall 2006 Pacific University CS310 Converting NFA to DFA Sections:1.2 Page 54 September 13, 2006.
Lecture 8 Sept 29, 2011 Regular expressions – examples Converting DFA to regular expression. (same works for NFA to r.e. conversion.) Converting R.E. to.
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
1 Non-Deterministic Automata Regular Expressions.
1 Regular Languages Finite Automata eg. Supermarket automatic door: exit or entrance.
Lecture 5UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 5.
Today Chapter 1: RE = Regular Languages, nonregular languages RL pumping lemma Chapter 2: Context-Free Languages (CFLs)
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.
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong DFA to regular.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Theory of Languages and Automata
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Prof. Busch - LSU1 NFAs accept the Regular Languages.
Lecture 5 Sept 06, 2012 Regular expressions – examples Converting DFA to regular expression. (same works for NFA to r.e. conversion.) Converting R.E. to.
CHAPTER 1 Regular Languages
January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015.
Regular Expressions Chapter 6. Regular Languages Regular Language Regular Expression Finite State Machine L Accepts.
CSCI 2670 Introduction to Theory of Computing September 13.
Computability Regular expressions. Languages defined by regular expresses = Regular languages (languages recognized by FSM). Applications. Pumping lemma.
Regular Expressions Section 1.3 (also 1.1, 1.2) CSC 4170 Theory of Computation.
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.
 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.
CSCI 2670 Introduction to Theory of Computing September 7, 2004.
CSCI 2670 Introduction to Theory of Computing September 11, 2007.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Theory of Computation Automata Theory Dr. Ayman Srour.
Theory of Languages and Automata By: Mojtaba Khezrian.
Theory of Languages and Automata By: Mojtaba Khezrian.
CSE 105 theory of computation
CSE 105 theory of computation
Regular Expressions Sections:1.3 page 63 September 17, 2008
Single Final State for NFA
CS 154, Lecture 3: DFANFA, Regular Expressions.
CS 350 — Fall 2018 gilray.org/classes/fall2018/cs350/
NFAs, DFAs, and regular expressions
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
CS21 Decidability and Tractability
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
Intro to Theory of Computation
CSCI 2670 Introduction to Theory of Computing
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
CSE 105 theory of computation
Presentation transcript:

CS 310 – Fall 2006 Pacific University CS310 Homework 2 & JFLAP September 22, 2006

CS 310 – Fall 2006 Pacific University Homework 2 1. Sipser 1.6 cdi -- DFA 2. Sipser 1.7 bdg -- NFA 3. Sipser 1.8 a – Construct the NFA for Union 4. Sipser 1.9 a – Construct the NFA for Concat 5. Sipser 1.10 a – Construct the NFA for * 6. Sipser 1.15 – Build a NFA from a “proof”, show counter example 7. Sipser 1.16 b – NFA to DFA 8. Sipser 1.19 a – Reg Expressions to NFA

CS 310 – Fall 2006 Pacific University Example aa* U aba*b*

CS 310 – Fall 2006 Pacific University Homework #3 Due Oct 20 Posted on the web site Be sure you have the correct version of the questions!

CS 310 – Fall 2006 Pacific University Quick Review Regular Expression: –Use regular operations and languages to create a regular expression R whose value is a language L(R) –order of operations: *, concat, U –Can build an NFA from a Regular Expression R= a, a є ∑ R= ε R=Ø R= R 1 U R 2, R 1, R 2 are regular R= R 1 R 2, R 1, R 2 are regular R= R 1 *, R 1 is regular Today: How can we build a Regular Expression from a DFA?

CS 310 – Fall 2006 Pacific University Proof Lemma: If a language is regular, it is described by a regular expression Proof Idea: If a language is regular, there exists a DFA that accepts it. We need to convert a DFA to a regular expression. Steps: –Convert DFA to GNFA –Convert GNFA to Regular Expression –GNFA?!

CS 310 – Fall 2006 Pacific University Generalized NFA NFA where the transitions may have regular expressions as labels rather than just ∑ or ε –Reads blocks of symbols from the input –Wait, why are we doing this? to build up the regular expression slowly from the DFA ab* a* (aa)* aa ab U ba b ab ε q start q accept b*

CS 310 – Fall 2006 Pacific University GNFA Start state transitions to every other state, no transitions to start state Single accept state, transition to it from every other state, no way out, Start state != accept state Except for the start and accept states, one arrow goes from every state to every other state (except the start state) and also from every state to itself. ab* a* (aa)* aa ab U ba b ab ε q start q accept Special case of GNFA that we will use! b*

CS 310 – Fall 2006 Pacific University DFA to GNFA 1 1, 0 0 Add new start state with ε- transitions to old start state and Ø to every other state Ø means you never take the transition Replace multiple transitions in same direction with Union If no transition exists between states, add transitions with Ø labels (just as placeholders)

CS 310 – Fall 2006 Pacific University DFA to Regular Expression 3 State DFA 5 State GNFA 4 State GNFA 4 State GNFA 3 State GNFA 2 State GNFA Regular Expression We can reduce the GNFA by one state at a time 2 states How many transitions? What do the labels on the transitions look like?

CS 310 – Fall 2006 Pacific University GNFA to Regular Expression Each GNFA has at least 2 states (start and accept) To convert GNFA to Regular Expression: –GNFA has k states, k >= 2 if k > 2 then Produce a GNFA with k-1 states repeat q start q accept 1 (1*0*)*

CS 310 – Fall 2006 Pacific University GNFA to k-1 States Pick any state in the machine that is not the start or accept state and remove it Fix up the transitions so the language remains the same R4 R2 R1 R3 Rip this out! (R1(R2)*R3) U R4 This change needs to be made for every pair of states connected through the removed state

CS 310 – Fall 2006 Pacific University Example, NFA to Regular Expression b a, ba

CS 310 – Fall 2006 Pacific University JFLAP Let’s you experiment with languages/machines/etc. Great functionality UI is horrible Main Menu

CS 310 – Fall 2006 Pacific University Build a NFA

CS 310 – Fall 2006 Pacific University The NFA

CS 310 – Fall 2006 Pacific University Test Input

CS 310 – Fall 2006 Pacific University Accepted!

CS 310 – Fall 2006 Pacific University Exercise {w | every odd position of w is 1 } NFA? How do we write this?

CS 310 – Fall 2006 Pacific University Exercise {w | w does not contain 110 } NFA? How do we write this?

CS 310 – Fall 2006 Pacific University Exercise {w| w contains even # 0s or exactly two 1s} NFA? How do we write this?