CS2 Language Processing note 3
|
|
- Hester Mason
- 6 years ago
- Views:
Transcription
1 CS2 Language Processing note 3 CS2Ah 5..4 CS2 Language Processing note 3 Nondeterministic finite automata In this lecture we look at nondeterministic finite automata and prove the Conversion Theorem, which shows how to turn a nondeterministic automaton into a deterministic one that recognises the same language. Nondeterministic finite automata Recall that the essential restriction we made when defining deterministic finite automata was to require that in each state there is exactly one possible transition for each input symbol. We now drop this restriction, obtaining a larger class of automata called nondeterministic automata (NFAs). It may happen that during a computation an NFA has several choices where to go next, or that it has no choice at all and gets stuck. Non-determinism gives us greater flexibility when modelling reactive systems; we can use it to describe systems whose behaviour we cannot completely predict. We pay a price for this flexibility NFAs do not share the convenient feature of DFAs that for each input string there is exactly one computation path that can be entirely predicted. In this course, we shall mainly use NFAs as a technical tool that turns out to be very useful in our investigation of regular languages. We start by giving a formal definition: Definition 3.. A nondeterministic finite automaton (or NFA) is a tuple consisting of:. a finite set of states, 2. a finite alphabet, 3. a distinguished starting state, 4. a set of final states (the ones that indicate acceptance), and 5. a description of all the possible transitions. must be given by a table that answers the following question: Given a state and an input symbol a, what are the possible next states? Thus the entries in the table are sets of states, as opposed to single states for a DFA. Remark 3.2. In mathematical terms, is a function from the set to the powerset of. We can also view as a subset of, that is, a ternary relation, where a tuple!" #$ %'&( is in if a transition from to '& is possible on input #.
2 > 4 CS2 Language Processing note 3 CS2Ah 5..4 Therefore, is often referred to as the transition relation of the NFA. Example 3.3. Figure shows an NFA, which can formally be specified as follows: a,b a b a 2 3 where the transition relation Figure : The NFA of Example 3.3 ) +*,'-" /. 2" 3"45, a b ,'3"45 98: is given by the following table: a b -,'-" /.:4,'-"4. ;,<=4,'3"4 ; 3 ; ; Recall that we use the symbol ; to denote the empty set. If it appears in a transition table, this means that no transitions are possible in the corresponding situation. We are now faced with the issue of how to define the notion of accepting a string for an NFA. The problem is that many different computations are possible on a given input string. An NFA is said to accept a string > if there is at least one computation of on > that does not get stuck and that ends in a state belonging to. Just as for DFAs, the language recognised (or accepted) by an NFA?@ A, B DCFEG accepts > Example 3.3 continued. The language accepted by the NFA?@ HAI KJ > aba E > L, a b 4'C<MN of Figure is is defined to be: that is, the language consisting of all strings over the alphabet, a b 4 ending in aba. Example 3.4: An enhanced combination lock. Recall the combination lock of Example.. We modelled it by a DFA accepting all strings over the alphabet, /O/O/O7 9 4 that ended with 2. In Exercise 3 of Lecture Note you were asked to enhance the lock in such a way that different key combinations can be used to open it. Specifically, you were asked to design a DFA whose language consists of all strings over, /O/OO7 9 4 ending in either 2, 2, or. If you did that exercise, you will have realized that constructing such a DFA is not so easy. It is much easier to construct an NFA accepting the same language Figure 2 shows one. 2
3 CS2 Language Processing note 3 CS2Ah Figure 2: An NFA for the enhanced combination lock NFAs with PPP -transitions In some situations it can be useful to enhance NFAs by allowing transitions that are not triggered by any input symbol; such transitions are called P -transitions. If in a state an P -transition to a state & is possible, then whenever the automaton reaches state in a computation it can immediately proceed to state & without needing any further input. Formally, an NFA with P -transitions is a tuple satisfying the same specifications as an NFA (cf. Definition 3.), except that the table describing the transition relation has an additional column that for each state gives the set of all states reachable from by an P -transition. Example 3.5. Figure 3 shows an NFA with P -transitions, which can formally be speci- a b a c Figure 3: An NFA with P -transitions fied as follows: Q*%,'-6 /.: 2" 36 %R645, 3 a b c 45-6,SR645 98:
4 P Z CS2 Language Processing note 3 CS2Ah 5..4 where the transition relation is given by the following table: a b c P -,5.:4 ; ;,5. " 36 R"4. ;,<=4 ; ;,'3"4 3 ; ;,SR64 ; R ; The language accepted by consists of the string abac and all its suffixes, that is,?@ HTU V, c ac bac abac 45O The Powerset Construction It is clear that every regular language, that is, every language recognised by some DFA, can be recognised by an NFA, as DFAs are just special cases of NFAs in which the possibility of nondeterminism is not exploited. Furthermore, every language recognised by some NFA can also be recognised by an NFA with P -transitions, because any NFA can be viewed as an NFA with P -transitions in which no P -transitions occur. The very surprising fact is that the converse of these observations is also true any language recognised by an NFA, with or without P -transitions, is regular. Theorem 3.6. If a language? is accepted by some NFA with P -transitions, then there is also a DFA that accepts?. Therefore, every language accepted by an NFA, with or without P -transitions, is regular. Proof: Let W + H 9 2 be an NFA with P -transitions that accepts?. We shall build Q HYG 2 2Z// [&\ < a DFA X that accepts the same language. The idea is to keep track of all possible computations of using the states of X. This is done by identifying each state of X with a certain subset of, namely all the possible states that could be in at that point. Hence we let Y^ _` a, the power set of (sometimes written cb ), that is, the set of all subsets of. The initial state ZS of X is the set of all states of that are reachable in without reading any input ( and anything reachable from / using just P -transitions). For a state B and a letter a, we write dfe a if Z is reachable from in after reading the input symbol a, again allowing for possible P -transitions. For Zg and a we can then define " hz I jï kml/n,oes a dqe p o4. In other words, " hz a is the set of all possible states that can be reached from some state in Z on reading the symbol a (allowing for any number of P -transitions). Finally we take &,<Z9r )E=ZsAut V;64. We can prove that this DFA X does indeed accept the same language as by induction on the length of strings. (Exercise: Do so!) Since set of states of the DFA X we construct in the proof of Theorem 3.6 is the powerset of the set of states of the NFA we started with, the construction is often referred to as the powerset construction. Actually, we can slightly simplify X by discarding all states that cannot be reached from the start state ZS by any possible sequence of transitions obviously such states are useless anyway. Then we can construct X in a systematic way by the following conversion algorithm: 4
5 p CS2 Language Processing note 3 CS2Ah Construct the start state Z consisting of and all states of that can be reached from by one or several P -transitions. Mark Z/ as unfinished. 2. While there still are unfinished states: (a) Take an unfinished state Z. (b) For each a v, let " hz #=w xi9kmlyn,oze{ d e. If 6 HZ #= is neither finished nor unfinished yet, then mark 6 HZc #" as unfinished. (c) Mark Z as finished. 3. Mark all states that contain a final state from as final states of X. o4 An example conversion It is easiest to understand the proof by seeing a worked example in action. convert the NFA in Figure 4 into a DFA X recognising the same language. We shall Figure 4: An NFA with P -transitions We first construct the start state ZS of X. It consists of the start state - of and all states reachable from - by P -transitions. Thus we have Z'} V,'-6 /. =4. Now we construct the transition function using the conversion algorithm described in the previous section. We represent the current status of by an incomplete table; unfinished states are those whose rows are incomplete and finished states are those whose rows are complete. We start with:,'-" /. 2=4 5
6 CS2 Language Processing note 3 CS2Ah 5..4 Now we take the only unfinished state,'-6. 2=4 and compute its transitions. We add the two states reachable from,'-" /. 2=4 by reading and, respectively, as new unfinished states to our table:,'-6 /. =4,'3" RN ~"4 ;,'36 RN ~"4 ; We proceed with state,'3" RN ~"4 :,'-" /. 2=4,'36 RN ~"4 ;,'3" RN ~"4,'~6 2=4,<" 36 2 = ~"4 ;,'~6 =4,<" 36 2 = ~"4 And state ; :,'-" /. 2=4,'36 RN ~"4 ;,'3" RN ~"4,'~6 2=4,<" 36 2 = ~"4,'~6 =4,<" 36 2 = ~"4 And so on:,'-6 /. =4,'36 %RN ~"4 ;,'36 RN ~"4,'~6 254,<" 3" 2 " ~"4,'~" 2=4,'~6 254 ;,<" 3" 2 " ~"4,'-6 /.: 2=4,'36 RN ~=4 ;,'36 R6 ~"4,'~6 =4,<" 36 2 " ~=4,'~6 2=4,'~6 =4 ;,<" 36 2 " ~=4,SRN ~6 254,'36 ~"4,SRN ~" 2=4,'36 ~"4,'-6 /. =4,'36 %RN ~"4 ;,'36 RN ~"4,'~6 254,<" 3" 2 " ~"4,'~" 2=4,'~6 254 ;,<" 3" 2 " ~"4,SRN ~6 2=4,'3" ~"4,SRN ~6 =4,'~6 254,<" 2 " ~=4,'3" ~"4,<" 2 " ~"4,'-6 /.: 2=4,'36 RN ~=4 ;,'36 R6 ~"4,'~6 =4,<" 36 2 " ~=4,'~6 2=4,'~6 =4 ;,<" 36 2 " ~=4,SRN ~6 254,'36 ~"4,SRN ~" 2=4,'~6 =4,<" 2 = ~"4,'36 ~"4,'~6 =4,'36 ~"4,<" 2 = ~"4 6
7 CS2 Language Processing note 3 CS2Ah 5..4 Finally, we obtain the complete transition function :,'-" /. 2=4,'36 RN ~"4 ;,'3" RN ~"4,'~6 2=4,<" 36 2 = ~"4,'~6 =4,'~6 2=4 ;,<" 36 2 = ~"4,SRN ~6 =4,'36 ~=4,SR6 ~6 2=4,'~6 2=4,<= 2 " ~"4,'36 ~"4,'~6 2=4,'36 ~=4,<= 2 " ~"4,SRN ~6 =4 ; This table also gives us the state set of X : J,'-6 /. =45,'36 R6 ~"45 ;N,'~" 2=45,< ~"45 7,SR6 ~" ,'36 ~545,<= " ~=4 M O The alphabet is the same as that of,, 4, and we already know the start state,,'-6 /.: 2=4. It remains to determine the set of final states. It consists of all states of X that contain a final state of, i.e., of all states that contain. Therefore, the set of final states is J,'~6 2545,SRN ~6 =4 M O The DFA X is displayed in Figure 5., {,,2} φ {3,4,6} {6,7} {2,5,6} {2,3,5,6} {3,6} {4,6.7} Figure 5: A DFA equivalent to the NFA of Figure 4 7
8 CS2 Language Processing note 3 CS2Ah 5..4 DFAs versus NFAs We have seen that NFAs and DFAs recognise exactly the same class of languages, namely the regular languages. It is natural to ask what the relative merits and demerits of the two forms of automata are. More to the point, why introduce the class of NFAs at all, given that we already have a class of automata that do the same job? The determinism of a DFA is important when implementing a program (or physical machine) for recognising a regular language. NFAs are not as well suited to language recognition because nondeterminism gives the machine the possibility of making incorrect choices. In general, when an NFA is used for language recognition, it is necessary to backtrack and explore all possible choices: a time consuming activity. On the other hand, NFAs are very convenient for demonstrating that languages are regular. Often it is much easier to provide an NFA for a language than a DFA think of Example 3.4. In particular, one of the problems with finding a DFA for a regular language is that, in general, a DFA for a language might have to be significantly larger than a corresponding NFA. Quantitatively, we see from the proof of the Conversion Theorem that, given an NFA with states, the corresponding DFA X might have as many as c states, making the conversion computationally explosive. (The example in Figure 4, worked out above, happens to be particularly well behaved!) Sometimes, but not always, it is possible to improve on the DFA produced by the Conversion Theorem, by finding an equivalent DFA with fewer states. Nevertheless, in general, even the smallest DFA for a language grows exponentially in the size of the NFA recognising the language. Exercises. List all possible computations for the NFA in Figure 2 when given the input string...-6.:.-c. 2. Describe the language recognised by the NFA in Figure Consider the NFA where *,'-6 /.: 2" 3"45 7, is given by the following table: a a b 45-6,'-"45 8 b -,'-" /. 2" 3"4 ;. ;,'-"4 ;,5.:4 3 ;,<=4 (a) Give a string beginning with a that is not accepted by. (b) Construct a DFA that accepts the same language as. 4. Let be an alphabet. Prove that every finite language?ƒ C is regular. Don Sannella 8
lec3:nondeterministic finite state automata
lec3:nondeterministic finite state automata 1 1.introduction Nondeterminism is a useful concept that has great impact on the theory of computation. When the machine is in a given state and reads the next
More informationFinite automata. We have looked at using Lex to build a scanner on the basis of regular expressions.
Finite automata We have looked at using Lex to build a scanner on the basis of regular expressions. Now we begin to consider the results from automata theory that make Lex possible. Recall: An alphabet
More informationFormal Languages and Compilers Lecture IV: Regular Languages and Finite. Finite Automata
Formal Languages and Compilers Lecture IV: Regular Languages and Finite Automata Free University of Bozen-Bolzano Faculty of Computer Science POS Building, Room: 2.03 artale@inf.unibz.it http://www.inf.unibz.it/
More informationCS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG)
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG) Objectives Introduce Pushdown Automaton (PDA) Show that PDA = CFG In terms of descriptive power Pushdown Automaton (PDA) Roughly
More informationCMPSCI 250: Introduction to Computation. Lecture 20: Deterministic and Nondeterministic Finite Automata David Mix Barrington 16 April 2013
CMPSCI 250: Introduction to Computation Lecture 20: Deterministic and Nondeterministic Finite Automata David Mix Barrington 16 April 2013 Deterministic and Nondeterministic Finite Automata Deterministic
More information6 NFA and Regular Expressions
Formal Language and Automata Theory: CS21004 6 NFA and Regular Expressions 6.1 Nondeterministic Finite Automata A nondeterministic finite automata (NFA) is a 5-tuple where 1. is a finite set of states
More informationCSE450. Translation of Programming Languages. Lecture 20: Automata and Regular Expressions
CSE45 Translation of Programming Languages Lecture 2: Automata and Regular Expressions Finite Automata Regular Expression = Specification Finite Automata = Implementation A finite automaton consists of:
More informationFront End: Lexical Analysis. The Structure of a Compiler
Front End: Lexical Analysis The Structure of a Compiler Constructing a Lexical Analyser By hand: Identify lexemes in input and return tokens Automatically: Lexical-Analyser generator We will learn about
More informationLast lecture CMSC330. This lecture. Finite Automata: States. Finite Automata. Implementing Regular Expressions. Languages. Regular expressions
Last lecture CMSC330 Finite Automata Languages Sets of strings Operations on languages Regular expressions Constants Operators Precedence 1 2 Finite automata States Transitions Examples Types This lecture
More informationImplementation of Lexical Analysis
Implementation of Lexical Analysis Lecture 4 (Modified by Professor Vijay Ganesh) Tips on Building Large Systems KISS (Keep It Simple, Stupid!) Don t optimize prematurely Design systems that can be tested
More informationCompiler Construction
Compiler Construction Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-16/cc/ Conceptual Structure of a Compiler Source code x1 := y2
More informationFinite Automata. Dr. Nadeem Akhtar. Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur
Finite Automata Dr. Nadeem Akhtar Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur PhD Laboratory IRISA-UBS University of South Brittany European University
More informationImplementation of Lexical Analysis
Implementation of Lexical Analysis Outline Specifying lexical structure using regular expressions Finite automata Deterministic Finite Automata (DFAs) Non-deterministic Finite Automata (NFAs) Implementation
More informationImplementation of Lexical Analysis
Implementation of Lexical Analysis Outline Specifying lexical structure using regular expressions Finite automata Deterministic Finite Automata (DFAs) Non-deterministic Finite Automata (NFAs) Implementation
More informationECS 120 Lesson 16 Turing Machines, Pt. 2
ECS 120 Lesson 16 Turing Machines, Pt. 2 Oliver Kreylos Friday, May 4th, 2001 In the last lesson, we looked at Turing Machines, their differences to finite state machines and pushdown automata, and their
More informationCS402 Theory of Automata Solved Subjective From Midterm Papers. MIDTERM SPRING 2012 CS402 Theory of Automata
Solved Subjective From Midterm Papers Dec 07,2012 MC100401285 Moaaz.pk@gmail.com Mc100401285@gmail.com PSMD01 MIDTERM SPRING 2012 Q. Point of Kleen Theory. Answer:- (Page 25) 1. If a language can be accepted
More informationIntroduction to Computers & Programming
16.070 Introduction to Computers & Programming Theory of computation 5: Reducibility, Turing machines Prof. Kristina Lundqvist Dept. of Aero/Astro, MIT States and transition function State control A finite
More informationCSE450. Translation of Programming Languages. Automata, Simple Language Design Principles
CSE45 Translation of Programming Languages Automata, Simple Language Design Principles Finite Automata State Graphs A state: The start state: An accepting state: A transition: a A Simple Example A finite
More informationLexical Analysis. Lecture 2-4
Lexical Analysis Lecture 2-4 Notes by G. Necula, with additions by P. Hilfinger Prof. Hilfinger CS 164 Lecture 2 1 Administrivia Moving to 60 Evans on Wednesday HW1 available Pyth manual available on line.
More information14.1 Encoding for different models of computation
Lecture 14 Decidable languages In the previous lecture we discussed some examples of encoding schemes, through which various objects can be represented by strings over a given alphabet. We will begin this
More informationCT32 COMPUTER NETWORKS DEC 2015
Q.2 a. Using the principle of mathematical induction, prove that (10 (2n-1) +1) is divisible by 11 for all n N (8) Let P(n): (10 (2n-1) +1) is divisible by 11 For n = 1, the given expression becomes (10
More informationLexical Analysis. Lecture 3-4
Lexical Analysis Lecture 3-4 Notes by G. Necula, with additions by P. Hilfinger Prof. Hilfinger CS 164 Lecture 3-4 1 Administrivia I suggest you start looking at Python (see link on class home page). Please
More informationImplementation of Lexical Analysis. Lecture 4
Implementation of Lexical Analysis Lecture 4 1 Tips on Building Large Systems KISS (Keep It Simple, Stupid!) Don t optimize prematurely Design systems that can be tested It is easier to modify a working
More informationLexical Analysis. Chapter 2
Lexical Analysis Chapter 2 1 Outline Informal sketch of lexical analysis Identifies tokens in input string Issues in lexical analysis Lookahead Ambiguities Specifying lexers Regular expressions Examples
More informationTheory of Computation Prof. Raghunath Tewari Department of Computer Science and Engineering Indian Institute of Technology, Kanpur
Theory of Computation Prof. Raghunath Tewari Department of Computer Science and Engineering Indian Institute of Technology, Kanpur Lecture 01 Introduction to Finite Automata Welcome everybody. This is
More informationAutomating Construction of Lexers
Automating Construction of Lexers Regular Expression to Programs Not all regular expressions are simple. How can we write a lexer for (a*b aaa)? Tokenizing aaaab Vs aaaaaa Regular Expression Finite state
More informationI have read and understand all of the instructions below, and I will obey the Academic Honor Code.
Midterm Exam CS 341-451: Foundations of Computer Science II Fall 2014, elearning section Prof. Marvin K. Nakayama Print family (or last) name: Print given (or first) name: I have read and understand all
More informationCS 310: State Transition Diagrams
CS 30: State Transition Diagrams Stefan D. Bruda Winter 207 STATE TRANSITION DIAGRAMS Finite directed graph Edges (transitions) labeled with symbols from an alphabet Nodes (states) labeled only for convenience
More informationModule 11. Directed Graphs. Contents
Module 11 Directed Graphs Contents 11.1 Basic concepts......................... 256 Underlying graph of a digraph................ 257 Out-degrees and in-degrees.................. 258 Isomorphism..........................
More informationBehaviour Diagrams UML
Behaviour Diagrams UML Behaviour Diagrams Structure Diagrams are used to describe the static composition of components (i.e., constraints on what intstances may exist at run-time). Interaction Diagrams
More informationCS 432 Fall Mike Lam, Professor. Finite Automata Conversions and Lexing
CS 432 Fall 2017 Mike Lam, Professor Finite Automata Conversions and Lexing Finite Automata Key result: all of the following have the same expressive power (i.e., they all describe regular languages):
More information1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}
CSE 5 Homework 2 Due: Monday October 6, 27 Instructions Upload a single file to Gradescope for each group. should be on each page of the submission. All group members names and PIDs Your assignments in
More informationIntroduction to Lexical Analysis
Introduction to Lexical Analysis Outline Informal sketch of lexical analysis Identifies tokens in input string Issues in lexical analysis Lookahead Ambiguities Specifying lexical analyzers (lexers) Regular
More informationFinite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016
Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016 Lecture 15 Ana Bove May 23rd 2016 More on Turing machines; Summary of the course. Overview of today s lecture: Recap: PDA, TM Push-down
More informationEquivalence of NTMs and TMs
Equivalence of NTMs and TMs What is a Turing Machine? Similar to a finite automaton, but with unlimited and unrestricted memory. It uses an infinitely long tape as its memory which can be read from and
More informationNondeterministic Finite Automata (NFA): Nondeterministic Finite Automata (NFA) states of an automaton of this kind may or may not have a transition for each symbol in the alphabet, or can even have multiple
More informationLimitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and
Computer Language Theory Chapter 4: Decidability 1 Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and
More informationDecision Properties of RLs & Automaton Minimization
Decision Properties of RLs & Automaton Minimization Martin Fränzle formatics and Mathematical Modelling The Technical University of Denmark Languages and Parsing MF Fall p./ What you ll learn. Decidable
More informationLexical Analysis - 2
Lexical Analysis - 2 More regular expressions Finite Automata NFAs and DFAs Scanners JLex - a scanner generator 1 Regular Expressions in JLex Symbol - Meaning. Matches a single character (not newline)
More informationDefinition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,
CMPSCI 601: Recall From Last Time Lecture 5 Definition: A context-free grammar (CFG) is a 4- tuple, variables = nonterminals, terminals, rules = productions,,, are all finite. 1 ( ) $ Pumping Lemma for
More informationUNIT -2 LEXICAL ANALYSIS
OVER VIEW OF LEXICAL ANALYSIS UNIT -2 LEXICAL ANALYSIS o To identify the tokens we need some method of describing the possible tokens that can appear in the input stream. For this purpose we introduce
More information(Refer Slide Time: 0:19)
Theory of Computation. Professor somenath Biswas. Department of Computer Science & Engineering. Indian Institute of Technology, Kanpur. Lecture-15. Decision Problems for Regular Languages. (Refer Slide
More informationLecture 2 Finite Automata
Lecture 2 Finite Automata August 31, 2007 This lecture is intended as a kind of road map to Chapter 1 of the text just the informal examples that I ll present to motivate the ideas. 1 Expressions without
More informationCS Lecture 2. The Front End. Lecture 2 Lexical Analysis
CS 1622 Lecture 2 Lexical Analysis CS 1622 Lecture 2 1 Lecture 2 Review of last lecture and finish up overview The first compiler phase: lexical analysis Reading: Chapter 2 in text (by 1/18) CS 1622 Lecture
More informationConverting a DFA to a Regular Expression JP
Converting a DFA to a Regular Expression JP Prerequisite knowledge: Regular Languages Deterministic Finite Automata Nondeterministic Finite Automata Regular Expressions Conversion of Regular Expression
More informationFormal Languages and Automata
Mobile Computing and Software Engineering p. 1/3 Formal Languages and Automata Chapter 3 Regular languages and Regular Grammars Chuan-Ming Liu cmliu@csie.ntut.edu.tw Department of Computer Science and
More informationLexical Analysis. Implementation: Finite Automata
Lexical Analysis Implementation: Finite Automata Outline Specifying lexical structure using regular expressions Finite automata Deterministic Finite Automata (DFAs) Non-deterministic Finite Automata (NFAs)
More informationMIT Specifying Languages with Regular Expressions and Context-Free Grammars. Martin Rinard Massachusetts Institute of Technology
MIT 6.035 Specifying Languages with Regular essions and Context-Free Grammars Martin Rinard Massachusetts Institute of Technology Language Definition Problem How to precisely define language Layered structure
More informationDecidable Problems. We examine the problems for which there is an algorithm.
Decidable Problems We examine the problems for which there is an algorithm. Decidable Problems A problem asks a yes/no question about some input. The problem is decidable if there is a program that always
More informationCompiler Construction
Compiler Construction Lecture 2: Lexical Analysis I (Introduction) Thomas Noll Lehrstuhl für Informatik 2 (Software Modeling and Verification) noll@cs.rwth-aachen.de http://moves.rwth-aachen.de/teaching/ss-14/cc14/
More informationDr. D.M. Akbar Hussain
1 2 Compiler Construction F6S Lecture - 2 1 3 4 Compiler Construction F6S Lecture - 2 2 5 #include.. #include main() { char in; in = getch ( ); if ( isalpha (in) ) in = getch ( ); else error (); while
More information2010: Compilers REVIEW: REGULAR EXPRESSIONS HOW TO USE REGULAR EXPRESSIONS
2010: Compilers Lexical Analysis: Finite State Automata Dr. Licia Capra UCL/CS REVIEW: REGULAR EXPRESSIONS a Character in A Empty string R S Alternation (either R or S) RS Concatenation (R followed by
More informationLimited Automata and Unary Languages
Limited Automata and Unary Languages Giovanni Pighizzini and Luca Prigioniero Dipartimento di Informatica, Università degli Studi di Milano, Italy {pighizzini,prigioniero}@di.unimi.it Abstract. Limited
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 2.2 Define push-down automata informally and formally Trace the computation
More information1 Variations of the Traveling Salesman Problem
Stanford University CS26: Optimization Handout 3 Luca Trevisan January, 20 Lecture 3 In which we prove the equivalence of three versions of the Traveling Salesman Problem, we provide a 2-approximate algorithm,
More informationAlgebra of Sets. Aditya Ghosh. April 6, 2018 It is recommended that while reading it, sit with a pen and a paper.
Algebra of Sets Aditya Ghosh April 6, 2018 It is recommended that while reading it, sit with a pen and a paper. 1 The Basics This article is only about the algebra of sets, and does not deal with the foundations
More informationSolutions to Homework 10
CS/Math 240: Intro to Discrete Math 5/3/20 Instructor: Dieter van Melkebeek Solutions to Homework 0 Problem There were five different languages in Problem 4 of Homework 9. The Language D 0 Recall that
More informationCS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 5
CS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 5 CS 536 Spring 2015 1 Multi Character Lookahead We may allow finite automata to look beyond the next input character.
More informationMIT Specifying Languages with Regular Expressions and Context-Free Grammars
MIT 6.035 Specifying Languages with Regular essions and Context-Free Grammars Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology Language Definition Problem How to precisely
More informationJNTUWORLD. Code No: R
Code No: R09220504 R09 SET-1 B.Tech II Year - II Semester Examinations, April-May, 2012 FORMAL LANGUAGES AND AUTOMATA THEORY (Computer Science and Engineering) Time: 3 hours Max. Marks: 75 Answer any five
More informationSemantics via Syntax. f (4) = if define f (x) =2 x + 55.
1 Semantics via Syntax The specification of a programming language starts with its syntax. As every programmer knows, the syntax of a language comes in the shape of a variant of a BNF (Backus-Naur Form)
More informationTheory of Computation
Theory of Computation For Computer Science & Information Technology By www.thegateacademy.com Syllabus Syllabus for Theory of Computation Regular Expressions and Finite Automata, Context-Free Grammar s
More informationChapter 3 Lexical Analysis
Chapter 3 Lexical Analysis Outline Role of lexical analyzer Specification of tokens Recognition of tokens Lexical analyzer generator Finite automata Design of lexical analyzer generator The role of lexical
More informationRegular Languages. MACM 300 Formal Languages and Automata. Formal Languages: Recap. Regular Languages
Regular Languages MACM 3 Formal Languages and Automata Anoop Sarkar http://www.cs.sfu.ca/~anoop The set of regular languages: each element is a regular language Each regular language is an example of a
More informationFAdo: Interactive Tools for Learning Formal Computational Models
FAdo: Interactive Tools for Learning Formal Computational Models Rogério Reis Nelma Moreira DCC-FC& LIACC, Universidade do Porto R. do Campo Alegre 823, 4150 Porto, Portugal {rvr,nam}@ncc.up.pt Abstract
More informationGreedy Algorithms 1. For large values of d, brute force search is not feasible because there are 2 d
Greedy Algorithms 1 Simple Knapsack Problem Greedy Algorithms form an important class of algorithmic techniques. We illustrate the idea by applying it to a simplified version of the Knapsack Problem. Informally,
More informationFinite-State Transducers in Language and Speech Processing
Finite-State Transducers in Language and Speech Processing Mehryar Mohri AT&T Labs-Research Finite-state machines have been used in various domains of natural language processing. We consider here the
More informationLanguages and Compilers
Principles of Software Engineering and Operational Systems Languages and Compilers SDAGE: Level I 2012-13 3. Formal Languages, Grammars and Automata Dr Valery Adzhiev vadzhiev@bournemouth.ac.uk Office:
More informationCompiler course. Chapter 3 Lexical Analysis
Compiler course Chapter 3 Lexical Analysis 1 A. A. Pourhaji Kazem, Spring 2009 Outline Role of lexical analyzer Specification of tokens Recognition of tokens Lexical analyzer generator Finite automata
More informationCOMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou
COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou Administrative! [ALSU03] Chapter 3 - Lexical Analysis Sections 3.1-3.4, 3.6-3.7! Reading for next time [ALSU03] Chapter 3 Copyright (c) 2010 Ioanna
More informationMidterm I (Solutions) CS164, Spring 2002
Midterm I (Solutions) CS164, Spring 2002 February 28, 2002 Please read all instructions (including these) carefully. There are 9 pages in this exam and 5 questions, each with multiple parts. Some questions
More informationG52LAC Languages and Computation Lecture 6
G52LAC Languages and Computation Lecture 6 Equivalence of Regular Expression and Finite Automata Henrik Nilsson University of Nottingham G52LACLanguages and ComputationLecture 6 p.1/28 This Lecture (1)
More informationLearn Smart and Grow with world
Learn Smart and Grow with world All Department Smart Study Materials Available Smartkalvi.com TABLE OF CONTENTS S.No DATE TOPIC PAGE NO. UNIT-I FINITE AUTOMATA 1 Introduction 1 2 Basic Mathematical Notation
More informationFormal Definition of Computation. Formal Definition of Computation p.1/28
Formal Definition of Computation Formal Definition of Computation p.1/28 Computation model The model of computation considered so far is the work performed by a finite automaton Formal Definition of Computation
More informationRegular Expression Constrained Sequence Alignment
Regular Expression Constrained Sequence Alignment By Abdullah N. Arslan Department of Computer science University of Vermont Presented by Tomer Heber & Raz Nissim otivation When comparing two proteins,
More informationAdministrivia. Lexical Analysis. Lecture 2-4. Outline. The Structure of a Compiler. Informal sketch of lexical analysis. Issues in lexical analysis
dministrivia Lexical nalysis Lecture 2-4 Notes by G. Necula, with additions by P. Hilfinger Moving to 6 Evans on Wednesday HW available Pyth manual available on line. Please log into your account and electronically
More information2.8 Universal Turing Machines and the Halting Problem
2.8 Universal Turing Machines and the Halting Problem Through the hierarchy of Slide 74 we indirectly get a sense that Turing Machines are at least as computationally powerful as any other known model
More informationCS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5
CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5 This fifth problem set explores the regular languages, their properties, and their limits. This will be your first foray into computability theory,
More informationComplexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np
Chapter 1: Introduction Introduction Purpose of the Theory of Computation: Develop formal mathematical models of computation that reflect real-world computers. Nowadays, the Theory of Computation can be
More informationRamsey s Theorem on Graphs
Ramsey s Theorem on Graphs 1 Introduction Exposition by William Gasarch Imagine that you have 6 people at a party. We assume that, for every pair of them, either THEY KNOW EACH OTHER or NEITHER OF THEM
More informationThis is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS
1 THE FORMALIZATION OF MATHEMATICS by Harvey M. Friedman Ohio State University Department of Mathematics friedman@math.ohio-state.edu www.math.ohio-state.edu/~friedman/ May 21, 1997 Can mathematics be
More informationR10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?
R1 SET - 1 1. a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA? 2. a) Design a DFA that accepts the language over = {, 1} of all strings that
More information3 No-Wait Job Shops with Variable Processing Times
3 No-Wait Job Shops with Variable Processing Times In this chapter we assume that, on top of the classical no-wait job shop setting, we are given a set of processing times for each operation. We may select
More informationName: Finite Automata
Unit No: I Name: Finite Automata What is TOC? In theoretical computer science, the theory of computation is the branch that deals with whether and how efficiently problems can be solved on a model of computation,
More informationIntroduction to Sets and Logic (MATH 1190)
Introduction to Sets and Logic () Instructor: Email: shenlili@yorku.ca Department of Mathematics and Statistics York University Dec 4, 2014 Outline 1 2 3 4 Definition A relation R from a set A to a set
More informationTo prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):
CS 70 Discrete Mathematics for CS Fall 2003 Wagner Lecture 7 This lecture returns to the topic of propositional logic. Whereas in Lecture 1 we studied this topic as a way of understanding proper reasoning
More informationFormal Languages and Compilers Lecture VI: Lexical Analysis
Formal Languages and Compilers Lecture VI: Lexical Analysis Free University of Bozen-Bolzano Faculty of Computer Science POS Building, Room: 2.03 artale@inf.unibz.it http://www.inf.unibz.it/ artale/ Formal
More informationThe Relational Data Model. Functional Dependencies. Example. Functional Dependencies
The Relational Data Model Functional Dependencies 1 Functional Dependencies X -> A is an assertion about a relation R that whenever two tuples of R agree on all the attributes of X, then they must also
More informationCS3102 Theory of Computation Problem Set 2, Spring 2011 Department of Computer Science, University of Virginia
CS3102 Theory of Computation Problem Set 2, Spring 2011 Department of Computer Science, University of Virginia Gabriel Robins Please start solving these problems immediately, and work in study groups.
More informationTheory of Computation Dr. Weiss Extra Practice Exam Solutions
Name: of 7 Theory of Computation Dr. Weiss Extra Practice Exam Solutions Directions: Answer the questions as well as you can. Partial credit will be given, so show your work where appropriate. Try to be
More informationSymbolic Automata Library for Fast Prototyping
http://excel.fit.vutbr.cz Symbolic Automata Library for Fast Prototyping Michaela Bieliková not_in{@} in{e,x,c} in{e,l} F I T Abstract Finite state automata are widely used in the fields of computer science
More informationCIT3130: Theory of Computation. Regular languages
ƒ CIT3130: Theory of Computation Regular languages ( M refers to the first edition of Martin and H to IALC by Hopcroft et al.) Definitions of regular expressions and regular languages: A regular expression
More informationComputer Sciences Department
1 Reference Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER 3 D E C I D A B I L I T Y 4 Objectives 5 Objectives investigate the power of algorithms to solve problems.
More informationImplementation of Lexical Analysis
Written ssignments W assigned today Implementation of Lexical nalysis Lecture 4 Due in one week y 5pm Turn in In class In box outside 4 Gates Electronically Prof. iken CS 43 Lecture 4 Prof. iken CS 43
More informationImplementation of Lexical Analysis
Written ssignments W assigned today Implementation of Lexical nalysis Lecture 4 Due in one week :59pm Electronic hand-in Prof. iken CS 43 Lecture 4 Prof. iken CS 43 Lecture 4 2 Tips on uilding Large Systems
More informationDefinition 2.8: A CFG is in Chomsky normal form if every rule. only appear on the left-hand side, we allow the rule S ǫ.
CS533 Class 02b: 1 c P. Heeman, 2017 CNF Pushdown Automata Definition Equivalence Overview CS533 Class 02b: 2 c P. Heeman, 2017 Chomsky Normal Form Definition 2.8: A CFG is in Chomsky normal form if every
More informationFinding Strongly Connected Components
Yufei Tao ITEE University of Queensland We just can t get enough of the beautiful algorithm of DFS! In this lecture, we will use it to solve a problem finding strongly connected components that seems to
More informationT Reactive Systems: Kripke Structures and Automata
Tik-79.186 Reactive Systems 1 T-79.186 Reactive Systems: Kripke Structures and Automata Spring 2005, Lecture 3 January 31, 2005 Tik-79.186 Reactive Systems 2 Properties of systems invariants: the system
More informationDISCRETE-event dynamic systems (DEDS) are dynamic
IEEE TRANSACTIONS ON CONTROL SYSTEMS TECHNOLOGY, VOL. 7, NO. 2, MARCH 1999 175 The Supervised Control of Discrete-Event Dynamic Systems François Charbonnier, Hassane Alla, and René David Abstract The supervisory
More informationLL(1) predictive parsing
LL(1) predictive parsing Informatics 2A: Lecture 11 Mary Cryan School of Informatics University of Edinburgh mcryan@staffmail.ed.ac.uk 10 October 2018 1 / 15 Recap of Lecture 10 A pushdown automaton (PDA)
More information