Jianguo Lu 1 03-60-214: Lab 3 Jan 30, Winter 2004.

Slides:



Advertisements
Similar presentations
Exercises for Chapter 2. Summary for the Quiz Some numbers –199  less than 100  55 Conclusion –There are students who did read textbook at least for.
Advertisements

4b Lexical analysis Finite Automata
Lecture 6 Nondeterministic Finite Automata (NFA)
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
CPSC Compiler Tutorial 4 Midterm Review. Deterministic Finite Automata (DFA) Q: finite set of states Σ: finite set of “letters” (input alphabet)
Lecture 8 From NFA to Regular Language. Induction on k= # of states other than initial and final states K=0 a a* b a c d c*a(d+bc*a)*
Regular Expressions and DFAs COP 3402 (Summer 2014)
Transparency No. 2-1 Formal Language and Automata Theory Homework 3.
3.2 Pumping Lemma for Regular Languages Given a language L, how do we know whether it is regular or not? If we can construct an FA to accept the language.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CS5371 Theory of Computation
1 The scanning process Goal: automate the process Idea: –Start with an RE –Build a DFA How? –We can build a non-deterministic finite automaton (Thompson's.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
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.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
Topics Automata Theory Grammars and Languages Complexities
Automating Construction of Lexers. Example in javacc TOKEN: { ( | | "_")* > | ( )* > | } SKIP: { " " | "\n" | "\t" } --> get automatically generated code.
1.Defs. a)Finite Automaton: A Finite Automaton ( FA ) has finite set of ‘states’ ( Q={q 0, q 1, q 2, ….. ) and its ‘control’ moves from state to state.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
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 language,
NFA ε - NFA - DFA equivalence. What is an NFA An NFA is an automaton that its states might have none, one or more outgoing arrows under a specific symbol.
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
Decidable Questions About Regular languages 1)Membership problem: “Given a specification of known type and a string w, is w in the language specified?”
Jianguo Lu : regular expression and automata.
COMP3190: Principle of Programming Languages DFA and its equivalent, scanner.
Transition Diagrams Lecture 3 Wed, Jan 21, Building Transition Diagrams from Regular Expressions A regular expression consists of symbols a, b,
CMSC 330: Organization of Programming Languages Finite Automata NFAs  DFAs.
Theory of Computing CSCI 356/541 Lab Session. Outline Lab 1: Finite Automata  Construct and Run Construct and Run  Manipulating Transitions Manipulating.
Exercise Solution for Exercise (a) {1,2} {3,4} a b {6} a {5,6,1} {6,2} {4} {3} {5,6} { } b a b a a b b a a b a,b b b a.
Finite Automata Chapter 1. Automatic Door Example Top View.
Chapter 2 Scanning. Dr.Manal AbdulazizCS463 Ch22 The Scanning Process Lexical analysis or scanning has the task of reading the source program as a file.
1 Chapter Constructing Efficient Finite Automata.
using Deterministic Finite Automata & Nondeterministic Finite Automata
98 Nondeterministic Automata vs Deterministic Automata We learned that NFA is a convenient model for showing the relationships among regular grammars,
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
1 Section 11.3 Constructing Efficient Finite Automata First we’ll see how to transform an NFA into a DFA. Then we’ll see how to transform a DFA into a.
1 Lexical Analysis Uses formalism of Regular Languages Uses formalism of Regular Languages Regular Expressions Regular Expressions Deterministic Finite.
Deterministic Finite Automata Nondeterministic Finite Automata.
COMP3190: Principle of Programming Languages DFA and its equivalent, scanner.
Lecture #5 Advanced Computation Theory Finite Automata.
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.
Theory of Computation Automata Theory Dr. Ayman Srour.
Department of Software & Media Technology
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
CIS Automata and Formal Languages – Pei Wang
Lexical analysis Finite Automata
Two issues in lexical analysis
Recognizer for a Language
Finite Automata & Regular Languages
Review: NFA Definition NFA is non-deterministic in what sense?
Chapter 2 FINITE AUTOMATA.
Jaya Krishna, M.Tech, Assistant Professor
More on DFA minimization and DFA equivalence
COSC 3340: Introduction to Theory of Computation
4. Properties of Regular Languages
Nondeterministic Finite Automata
Non Deterministic Automata
Transition Diagrams Lecture 3 Fri, Jan 21, 2005.
Theory of Computation Lecture #
DFA Equivalence & Minimization
Finite Automata.
4b Lexical analysis Finite Automata
CSCI 2670 Introduction to Theory of Computing
4b Lexical analysis Finite Automata
NFA’s With ε-Transitions
CHAPTER 1 Regular Languages
Presentation transcript:

Jianguo Lu : Lab 3 Jan 30, Winter 2004

Jianguo Lu 2 Exercises Draw the diagrams of an FA (DFA or NFA) for the following languages, the alphabet is {a, b,..., z}. Write the regular expression after you have the diagram. –A string containing an 'a'; –A string containing two consecutive 'a's. Write regular expressions for each of the following languages over the alphabet {a,b, c}: the strings that the first a precede the first b. The string with no ‘a’ or no ‘b’ is legal. Convert the following NFA to DFA, and minimize it.

Jianguo Lu 3 solutions Draw the diagrams of an FA (DFA or NFA) for the following languages, the alphabet is {a, b,..., z}. Write the regular expression after you have the diagram. –A string containing an 'a'; –A string containing two consecutive 'a's. Solutions a-z q1q1 q2q2 a q1q1 q3q3 q2q2 a a

Jianguo Lu 4 Problem 2 Write regular expressions for each of the following languages over the alphabet {a,b, c}: the strings that the first a precede the first b. The string with no ‘a’ or no ‘b’ is legal. Solution: –put the problem in another way: before ‘a’ there should not be any ‘b’; –It can be anything after ‘a’; –If both ‘a’ and ‘b’ appears in the string, ‘a’ must precedes ‘b’, otherwise it is a legal string. c*a[abc]*|[bc]*

Jianguo Lu 5 Problem 3 NFA to DFA –First compute the epsilon closure of the start state. Let the closure as the new start state. E(0)={0}; Let {0} equals to A, the new start state; –Next compute all the states that can be reached on all input symbols from A: Move(A, $)={1}; E(move(A,$)=e({1}) = {1,2,3,5,7}, let it be a new state B. E(move(A,L)=e({}) ={} Since we generated a new state B, we need to try all the input on B E(move(B,$))=e({4,8})={4, 7,2,3 5,8}, let it be a new state C. E(move(B,L))=e({6})={6,7,2,3,5}, let it be a new state D. Now compute the states can be reached from C and D, on all input symbols. E(move(C,$))=e({4,8})=C E(move(C,L))=e({6})=D E(move(D,$))=e({4,8})=C E(move(D,L))=e({6})=D C is going to be the final state because it contains final states 4 and 8.

Jianguo Lu 6 The corresponding DFA L A C B $ $ $ D L $ L

Jianguo Lu 7 Minimization of the DFA –The initial partition is (ABD) (C), because C is the final state, while others are not. –Lets try to split group (ABD) Move(A, $)=B Move(B,$)=C, Since B and C are distinguishable state, so are A and B. –So (ABD) is split into (A)(BD) –Let’s try to see whether (BD) can be further split Try B and D on all input symbols, first on $ –Move(B,$)=C –Move(D,$)=C –Can’t tell the difference, so try the next symbol Try B and D on symbol L: –Move(B,L)=D –Move(D,L)=D –Still can’t tell the difference; All the possible symbols are tried, B and D are equivalent.

Jianguo Lu 8 The minimized DFA A C BD $ $ $ L L