CIT 425- AUTOMATA THEORY, COMPUTABILITY and FORMAL LANGUAGES LECTURE NOTE by DR. OYELAMI M. O. Introduction • This Course Cons

Total Page:16

File Type:pdf, Size:1020Kb

CIT 425- AUTOMATA THEORY, COMPUTABILITY and FORMAL LANGUAGES LECTURE NOTE by DR. OYELAMI M. O. Introduction • This Course Cons CIT 425- AUTOMATA THEORY, COMPUTABILITY AND FORMAL LANGUAGES LECTURE NOTE BY DR. OYELAMI M. O. Status: Core Description: Words and String. Concatenation, word Length; Language Definition. Regular Expression, Regular Language, Recursive Languages; Finite State Automata (FSA), State Diagrams; Pumping Lemma, Grammars, Applications in Computer Science and Engineering, Compiler Specification and Design, Text Editor and Implementation, Very Large Scale Integrated (VLSI) Circuit Specification and Design, Natural Language Processing (NLP) and Embedded Systems. Introduction This course constitutes the theoretical foundation of computer science. Loosely speaking we can think of automata, grammars, and computability as the study of what can be done by computers in principle, while complexity addresses what can be done in practice. This course has applications in the following areas: o Digital design, o Programming languages o Compilers construction Languages Dictionaries define the term informally as a system suitable for the expression of certain ideas, facts, or concepts, including a set of symbols and rules for their manipulation. While this gives us an intuitive idea of what a language is, it is not sufficient as a definition for the study of formal languages. We need a precise definition for the term. A formal language is an abstraction of the general characteristics of programming languages. Languages can be specified in various ways. One way is to list all the words in the language. Another is to give some criteria that a word must satisfy to be in the language. Another important way is to specify a language through the use of some terminologies: 1 Alphabet: A finite, nonempty set Σ of symbols. String: Finite sequence of symbols from the alphabet. For example, if the alphabet Σ = {a, b}, then abab and aaabbba are strings on Σ. The concatenation of two strings w and υ is the string obtained by appending the symbols of υ to the right end of w, that is, if w=a1a2…an and b=b1b2…bm then the concatenation of w and v , denoted by wv, is wv=a1a2…anb1b2…bm. The reverse of a string is obtained by writing the symbols in reverse order; if w is a string as R R shown above, then its reverse w is w =an…a2a1. The length of a string w, denoted by |w|, is the number of symbols in the string. Empty String: A string with no symbols at all denoted by λ. The following simple relations hold for all w. Substring: Any string of consecutive symbols in some string w, a substring of w, i.e w=vu Then the substrings υ and u are said to be a prefix and a suffix of w, respectively. For example, if w = abbab, then {λ, a, ab, abb, abba, abbab} is the set of all prefixes of w, while bab, ab, b are some of its suffixes. If u and υ are strings, then the length of their concatenation is the sum of the individual lengths, that is, |uv|=|u| + |v| If w is a string, then wn stands for the string obtained by repeating w n times. As a special case, we define w0=λ for all w. If Σ is an alphabet, then we use Σ* to denote the set of strings obtained by concatenating zero or more symbols from Σ. The set Σ* always contains λ. To exclude the empty string, we define While Σ is finite by assumption, Σ* and Σ+ are always infinite since there is no limit on the length of the strings in these sets. A language is defined very generally as a subset of Σ*. A string in a language L will be called a word/sentence of L. This definition is quite broad; any set of strings on an alphabet Σ can be considered a language. 2 Example 3 GRAMMARS To study languages mathematically, we need a mechanism to describe them. Definition: A grammar G is defined as a quadruple G = (V, T, S, P), where V is a finite set of objects called variables/non-terminals, T is a finite set of objects called terminal symbols, S ∈ V is a special symbol called the start variable, P is a finite set of productions. Derivation The production rules are the heart of a grammar; they specify how the grammar transforms one string into another, and through this they define a language associated with the grammar. The production rules are of the form x → y where x is an element of (V ∪ T)+ and y is in (V ∪ T)*. The productions are applied in the following manner: Given a string w of the form w=uxv, we say the production x → y is applicable to this string, and we may use it to replace x with y, thereby obtaining a new string: z=uyv 4 Language Generated by a Grammar 5 Example Example Let G be the grammar with vocabulary V = {S, A, a, b}, set of terminals T = {a, b}, starting symbol S, and productions P = {S → aA, S → b, A → aa}. What is L(G), the language of this grammar? Solution From the start state S we can derive aA using the production S → aA. We can also use the production S → b to derive b. From aA the production A → aa can be used to derive aaa. No additional words can be derived. Hence, L(G) = {b, aaa}. 6 Example Example State the grammar that generates the set {0n1n | n = 0, 1, 2, . }. Solution The solution is the grammar G = (V, T, S, P), where V = {A, S}, T = {0, 1}, S is the starting symbol, and the productions are S → 0A1 S → A A → 0A1 A → λ. Chomsky Classification of Grammars Grammars can be classified according to the types of productions that are allowed. According to Noam Chomosky, there are four types of grammars: Type 0, Type 1, Type 2, and Type 3. The following table shows how they differ from each other: 7 8 9 10 Type 3 grammar is also called Regular Grammar. Regular Languages and Regular Grammars A language is regular if there exists a finite accepter for it. Therefore, every regular language can be described by some dfa or some nfa. Such a description can be very useful, for example, if we want to show the logic by which we decide if a given string is in a certain language. But in many instances, we need more concise ways of describing regular languages. Regular Expressions Finite languages can be described by means of regular expressions. Regular expression is a formula that describes a possible set of string of a language. • Regular expressions have the capability to express finite languages by defining a pattern for finite strings of symbols. • The grammar defined by regular expressions is known as regular grammar. • The language defined by regular grammar is known as regular language. • Like in Mathematics, brackets (and ) are used for grouping. There are a number of algebraic laws that are obeyed by regular expressions, which can be used to manipulate regular expressions. Operations The three operations employed by a regular expression on languages are: Union of two languages L and M is written as L U M = {s | s is in L or s is in M} Concatenation of two languages L and M is written as LM = {st | s is in L and t is in M} The Kleene Closure of a language L is written as L* = Zero or more occurrence of language L. Notations If r and s are regular expressions denoting the languages L(r) and L(s), then Union: (r)|(s) is a regular expression denoting L(r) U L(s) or L(r + s) Concatenation: (r)(s) is a regular expression denoting L(r)L(s) or L( r.s ) Kleene closure: (r)* is a regular expression denoting (L(r))* or L(r*) (r) is a regular expression denoting L(r) 11 Precedence and Associativity *, concatenation (.), and | (pipe sign) are left associative * has the highest precedence Concatenation (.) has the second highest precedence. | (pipe sign) has the lowest precedence of all. Representing valid Tokens of a Language in Regular Expression If x is a regular expression, then: x* means zero or more occurrence of x. i.e., it can generate { e, x, xx, xxx, xxxx, … } x+ means one or more occurrence of x. i.e., it can generate { x, xx, xxx, xxxx … } or x.x* x? means at most one occurrence of x i.e., it can generate either {x} or {e}. [a-z] is all lower-case alphabets of English language. [A-Z] is all upper-case alphabets of English language. [0-9] is all natural digits used in mathematics. Representing occurrence of symbols using regular expressions letter = [a – z] or [A – Z] digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 or [0-9] sign = [ + | - ] Representing Language Tokens using Regular Expressions Decimal = (sign)?(digit)+ Identifier = (letter)(letter | digit)* SUMMARY OF THE COMPONENTS OF REGULAR EXPRESSION 12 Regular Operators Example If language L is {nb, qb} and language M is {cf, cpq}, then L+M is {nb, qb, cf, cpq} LM is (nbcf, nbcpq, qbcf, qbcpq} L* is ( ϵ, nb, qb, nbnb, …, qbnbnbqb, …} Note: Σ is an alphabet and Σ* is the set of all strings from the alphabet. Examples of Regular Expression Union The symbol + means union or or. Example 1: 0+1 means either a zero or a one. Example 2: Consider the expression (0+1)01* The language described by this expression is the set of all binary strings •that start with either 0 or 1as indicated by (0+1), •for which the second symbol is 0 •that end with zero or more 1s as indicated by 1 The language described by this expression is {00, 001, 0011, 00111,..., 10, 101, 1011, 10111,...,} Concatenation The concatenation of two REs is obtained by writing the one after the other.
Recommended publications
  • Theory of Computer Science
    Theory of Computer Science MODULE-1 Alphabet A finite set of symbols is denoted by ∑. Language A language is defined as a set of strings of symbols over an alphabet. Language of a Machine Set of all accepted strings of a machine is called language of a machine. Grammar Grammar is the set of rules that generates language. CHOMSKY HIERARCHY OF LANGUAGES Type 0-Language:-Unrestricted Language, Accepter:-Turing Machine, Generetor:-Unrestricted Grammar Type 1- Language:-Context Sensitive Language, Accepter:- Linear Bounded Automata, Generetor:-Context Sensitive Grammar Type 2- Language:-Context Free Language, Accepter:-Push Down Automata, Generetor:- Context Free Grammar Type 3- Language:-Regular Language, Accepter:- Finite Automata, Generetor:-Regular Grammar Finite Automata Finite Automata is generally of two types :(i)Deterministic Finite Automata (DFA)(ii)Non Deterministic Finite Automata(NFA) DFA DFA is represented formally by a 5-tuple (Q,Σ,δ,q0,F), where: Q is a finite set of states. Σ is a finite set of symbols, called the alphabet of the automaton. δ is the transition function, that is, δ: Q × Σ → Q. q0 is the start state, that is, the state of the automaton before any input has been processed, where q0 Q. F is a set of states of Q (i.e. F Q) called accept states or Final States 1. Construct a DFA that accepts set of all strings over ∑={0,1}, ending with 00 ? 1 0 A B S State/Input 0 1 1 A B A 0 B C A 1 * C C A C 0 2. Construct a DFA that accepts set of all strings over ∑={0,1}, not containing 101 as a substring ? 0 1 1 A B State/Input 0 1 S *A A B 0 *B C B 0 0,1 *C A R C R R R R 1 NFA NFA is represented formally by a 5-tuple (Q,Σ,δ,q0,F), where: Q is a finite set of states.
    [Show full text]
  • Cs 61A/Cs 98-52
    CS 61A/CS 98-52 Mehrdad Niknami University of California, Berkeley Mehrdad Niknami (UC Berkeley) CS 61A/CS 98-52 1 / 23 Something like this? (Is this good?) def find(string, pattern): n= len(string) m= len(pattern) for i in range(n-m+ 1): is_match= True for j in range(m): if pattern[j] != string[i+ j] is_match= False break if is_match: return i What if you were looking for a pattern? Like an email address? Motivation How would you find a substring inside a string? Mehrdad Niknami (UC Berkeley) CS 61A/CS 98-52 2 / 23 def find(string, pattern): n= len(string) m= len(pattern) for i in range(n-m+ 1): is_match= True for j in range(m): if pattern[j] != string[i+ j] is_match= False break if is_match: return i What if you were looking for a pattern? Like an email address? Motivation How would you find a substring inside a string? Something like this? (Is this good?) Mehrdad Niknami (UC Berkeley) CS 61A/CS 98-52 2 / 23 What if you were looking for a pattern? Like an email address? Motivation How would you find a substring inside a string? Something like this? (Is this good?) def find(string, pattern): n= len(string) m= len(pattern) for i in range(n-m+ 1): is_match= True for j in range(m): if pattern[j] != string[i+ j] is_match= False break if is_match: return i Mehrdad Niknami (UC Berkeley) CS 61A/CS 98-52 2 / 23 Motivation How would you find a substring inside a string? Something like this? (Is this good?) def find(string, pattern): n= len(string) m= len(pattern) for i in range(n-m+ 1): is_match= True for j in range(m): if pattern[j] != string[i+
    [Show full text]
  • Regular Languages and Finite Automata for Part IA of the Computer Science Tripos
    N Lecture Notes on Regular Languages and Finite Automata for Part IA of the Computer Science Tripos Prof. Andrew M. Pitts Cambridge University Computer Laboratory c 2012 A. M. Pitts Contents Learning Guide ii 1 Regular Expressions 1 1.1 Alphabets,strings,andlanguages . .......... 1 1.2 Patternmatching................................. .... 4 1.3 Somequestionsaboutlanguages . ....... 6 1.4 Exercises....................................... .. 8 2 Finite State Machines 11 2.1 Finiteautomata .................................. ... 11 2.2 Determinism, non-determinism, and ε-transitions. .. .. .. .. .. .. .. .. .. 14 2.3 Asubsetconstruction . .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..... 17 2.4 Summary ........................................ 20 2.5 Exercises....................................... .. 20 3 Regular Languages, I 23 3.1 Finiteautomatafromregularexpressions . ............ 23 3.2 Decidabilityofmatching . ...... 28 3.3 Exercises....................................... .. 30 4 Regular Languages, II 31 4.1 Regularexpressionsfromfiniteautomata . ........... 31 4.2 Anexample ....................................... 32 4.3 Complementand intersectionof regularlanguages . .............. 34 4.4 Exercises....................................... .. 36 5 The Pumping Lemma 39 5.1 ProvingthePumpingLemma . .... 40 5.2 UsingthePumpingLemma . ... 41 5.3 Decidabilityoflanguageequivalence . ........... 44 5.4 Exercises....................................... .. 45 6 Grammars 47 6.1 Context-freegrammars . ..... 47 6.2 Backus-NaurForm ................................
    [Show full text]
  • Practical Experiments with Regular Approximation of Context-Free Languages
    Practical Experiments with Regular Approximation of Context-Free Languages Mark-Jan Nederhof German Research Center for Arti®cial Intelligence Several methods are discussed that construct a ®nite automaton given a context-free grammar, including both methods that lead to subsets and those that lead to supersets of the original context-free language. Some of these methods of regular approximation are new, and some others are presented here in a more re®ned form with respect to existing literature. Practical experiments with the different methods of regular approximation are performed for spoken-language input: hypotheses from a speech recognizer are ®ltered through a ®nite automaton. 1. Introduction Several methods of regular approximation of context-free languages have been pro- posed in the literature. For some, the regular language is a superset of the context-free language, and for others it is a subset. We have implemented a large number of meth- ods, and where necessary, re®ned them with an analysis of the grammar. We also propose a number of new methods. The analysis of the grammar is based on a suf®cient condition for context-free grammars to generate regular languages. For an arbitrary grammar, this analysis iden- ti®es sets of rules that need to be processed in a special way in order to obtain a regular language. The nature of this processing differs for the respective approximation meth- ods. For other parts of the grammar, no special treatment is needed and the grammar rules are translated to the states and transitions of a ®nite automaton without affecting the language.
    [Show full text]
  • Neural Edit Operations for Biological Sequences
    Neural Edit Operations for Biological Sequences Satoshi Koide Keisuke Kawano Toyota Central R&D Labs. Toyota Central R&D Labs. [email protected] [email protected] Takuro Kutsuna Toyota Central R&D Labs. [email protected] Abstract The evolution of biological sequences, such as proteins or DNAs, is driven by the three basic edit operations: substitution, insertion, and deletion. Motivated by the recent progress of neural network models for biological tasks, we implement two neural network architectures that can treat such edit operations. The first proposal is the edit invariant neural networks, based on differentiable Needleman-Wunsch algorithms. The second is the use of deep CNNs with concatenations. Our analysis shows that CNNs can recognize regular expressions without Kleene star, and that deeper CNNs can recognize more complex regular expressions including the insertion/deletion of characters. The experimental results for the protein secondary structure prediction task suggest the importance of insertion/deletion. The test accuracy on the widely-used CB513 dataset is 71.5%, which is 1.2-points better than the current best result on non-ensemble models. 1 Introduction Neural networks are now used in many applications, not limited to classical fields such as image processing, speech recognition, and natural language processing. Bioinformatics is becoming an important application field of neural networks. These biological applications are often implemented as a supervised learning model that takes a biological string (such as DNA or protein) as an input, and outputs the corresponding label(s), such as a protein secondary structure [13, 14, 15, 18, 19, 23, 24, 26], protein contact maps [4, 8], and genome accessibility [12].
    [Show full text]
  • Context-Free Grammars
    Chapter 3 Context-Free Grammars By Dr Zalmiyah Zakaria •Context-Free Grammars and Languages •Regular Grammars Formal Definition of Context-Free Grammars (CFG) A CFG can be formally defined by a quadruple of (V, , P, S) where: – V is a finite set of variables (non-terminal) – (the alphabet) is a finite set of terminal symbols , where V = – P is a finite set of rules (production rules) written as: A for A V, (v )*. – S is the start symbol, S V 2 Formal Definition of CFG • We can give a formal description to a particular CFG by specifying each of its four components, for example, G = ({S, A}, {0, 1}, P, S) where P consists of three rules: S → 0S1 S → A A → Sept2011 Theory of Computer Science 3 Context-Free Grammars • Terminal symbols – elements of the alphabet • Variables or non-terminals – additional symbols used in production rules • Variable S (start symbol) initiates the process of generating acceptable strings. 4 Terminal or Variable ? • S → (S) | S + S | S × S | A • A → 1 | 2 | 3 • The terminal symbols are { (, ), +, ×, 1, 2, 3} • The variable symbols are S and A Sept2011 Theory of Computer Science 5 Context-Free Grammars • A rule is an element of the set V (V )*. • An A rule: [A, w] or A w • A null rule or lambda rule: A 6 Context-Free Grammars • Grammars are used to generate strings of a language. • An A rule can be applied to the variable A whenever and wherever it occurs. • No limitation on applicability of a rule – it is context free 8 Context-Free Grammars • CFG have no restrictions on the right-hand side of production rules.
    [Show full text]
  • Theory of Computation
    Theory of Computation Alexandre Duret-Lutz [email protected] September 10, 2010 ADL Theory of Computation 1 / 121 References Introduction to the Theory of Computation (Michael Sipser, 2005). Lecture notes from Pierre Wolper's course at http://www.montefiore.ulg.ac.be/~pw/cours/calc.html (The page is in French, but the lecture notes labelled chapitre 1 to chapitre 8 are in English). Elements of Automata Theory (Jacques Sakarovitch, 2009). Compilers: Principles, Techniques, and Tools (A. Aho, R. Sethi, J. Ullman, 2006). ADL Theory of Computation 2 / 121 Introduction What would be your reaction if someone came at you to explain he has invented a perpetual motion machine (i.e. a device that can sustain continuous motion without losing energy or matter)? You would probably laugh. Without looking at the machine, you know outright that such the device cannot sustain perpetual motion. Indeed the laws of thermodynamics demonstrate that perpetual motion devices cannot be created. We know beforehand, from scientic knowledge, that building such a machine is impossible. The ultimate goal of this course is to develop similar knowledge for computer programs. ADL Theory of Computation 3 / 121 Theory of Computation Theory of computation studies whether and how eciently problems can be solved using a program on a model of computation (abstractions of a computer). Computability theory deals with the whether, i.e., is a problem solvable for a given model. For instance a strong result we will learn is that the halting problem is not solvable by a Turing machine. Complexity theory deals with the how eciently.
    [Show full text]
  • A Representation-Based Approach to Connect Regular Grammar and Deep Learning
    The Pennsylvania State University The Graduate School A REPRESENTATION-BASED APPROACH TO CONNECT REGULAR GRAMMAR AND DEEP LEARNING A Dissertation in Information Sciences and Technology by Kaixuan Zhang ©2021 Kaixuan Zhang Submitted in Partial Fulfillment of the Requirements for the Degree of Doctor of Philosophy August 2021 The dissertation of Kaixuan Zhang was reviewed and approved by the following: C. Lee Giles Professor of College of Information Sciences and Technology Dissertation Adviser Chair of Committee Kenneth Huang Assistant Professor of College of Information Sciences and Technology Shomir Wilson Assistant Professor of College of Information Sciences and Technology Daniel Kifer Associate Professor of Department of Computer Science and Engineering Mary Beth Rosson Professor of Information Sciences and Technology Director of Graduate Programs, College of Information Sciences and Technology ii Abstract Formal language theory has brought amazing breakthroughs in many traditional areas, in- cluding control systems, compiler design, and model verification, and continues promoting these research directions. As recent years have witnessed that deep learning research brings the long-buried power of neural networks to the surface and has brought amazing break- throughs, it is crucial to revisit formal language theory from a new perspective. Specifically, investigation of the theoretical foundation, rather than a practical application of the con- necting point obviously warrants attention. On the other hand, as the spread of deep neural networks (DNN) continues to reach multifarious branches of research, it has been found that the mystery of these powerful models is equally impressive as their capability in learning tasks. Recent work has demonstrated the vulnerability of DNN classifiers constructed for many different learning tasks, which opens the discussion of adversarial machine learning and explainable artificial intelligence.
    [Show full text]
  • 6.035 Lecture 2, Specifying Languages with Regular Expressions and Context-Free Grammars
    MIT 6.035 Specifying Languages with Regular Expressions and Context-Free Grammars Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology Language Definition Problem • How to precisely define language • Layered struc ture of langua ge defifinitiition • Start with a set of letters in language • Lexical structurestructure - identifies “words ” in language (each word is a sequence of letters) • Syntactic sstructuretructure - identifies “sentences ” in language (each sentence is a sequence of words) • Semantics - meaning of program (specifies what result should be for each input) • Today’s topic: lexical and syntactic structures Specifying Formal Languages • Huge Triumph of Computer Science • Beautiful Theoretical Results • Practical Techniques and Applications • Two Dual Notions • Generative approach ((grammar or regular expression) • Recognition approach (automaton) • Lots of theorems about convertingconverting oonene approach automatically to another Specifying Lexical Structure Using Regular ExpressionsExpressions • Have some alphabet ∑ = set of letters • R egular expressions are bu ilt from: • ε -empty string • AAnyn yl lettere tte rf fromr oma alphabetlp ha be t ∑ •r1r2 – regular expression r1 followed by r2 (sequence) •r1| r2 – either regular expression r1 or r2 (choice) • r* - iterated sequence and choice ε | r | rr | … • Parentheses to indicate grouping/precedence Concept of Regular Expression Generating a StringString Rewrite regular expression until have only a sequence of letters (string) left Genera
    [Show full text]
  • Constraints for Membership in Formal Languages Under Systematic Search and Stochastic Local Search
    Digital Comprehensive Summaries of Uppsala Dissertations from the Faculty of Science and Technology 1027 Constraints for Membership in Formal Languages under Systematic Search and Stochastic Local Search JUN HE ACTA UNIVERSITATIS UPSALIENSIS ISSN 1651-6214 ISBN 978-91-554-8617-4 UPPSALA urn:nbn:se:uu:diva-196347 2013 Dissertation presented at Uppsala University to be publicly examined in Room 2446, Polacksbacken, Lägerhyddsvägen 2D, Uppsala, Friday, April 26, 2013 at 13:00 for the degree of Doctor of Philosophy. The examination will be conducted in English. Abstract He, J. 2013. Constraints for Membership in Formal Languages under Systematic Search and Stochastic Local Search. Acta Universitatis Upsaliensis. Digital Comprehensive Summaries of Uppsala Dissertations from the Faculty of Science and Technology 1027. 74 pp. Uppsala. ISBN 978-91-554-8617-4. This thesis focuses on constraints for membership in formal languages under both the systematic search and stochastic local search approaches to constraint programming (CP). Such constraints are very useful in CP for the following three reasons: They provide a powerful tool for user- level extensibility of CP languages. They are very useful for modelling complex work shift regulation constraints, which exist in many shift scheduling problems. In the analysis, testing, and verification of string-manipulating programs, string constraints often arise. We show in this thesis that CP solvers with constraints for membership in formal languages are much more suitable than existing solvers used in tools that have to solve string constraints. In the stochastic local search approach to CP, we make the following two contributions: We introduce a stochastic method of maintaining violations for the regular constraint and extend our method to the automaton constraint with counters.
    [Show full text]
  • Regular Languages and Finite Automata for Part IA of the Computer Science Tripos
    N Lecture Notes on Regular Languages and Finite Automata for Part IA of the Computer Science Tripos Prof. Andrew M. Pitts Cambridge University Computer Laboratory c 2010 A. M. Pitts First Edition 1998. Revised 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010. Contents Learning Guide ii 1 Regular Expressions 1 1.1 Alphabets, strings, and languages . ...... 1 1.2 Patternmatching ................................ 4 1.3 Some questions about languages . ... 6 1.4 Exercises .................................... 8 2 Finite State Machines 11 2.1 Finiteautomata ................................. 11 2.2 Determinism, non-determinism, and ε-transitions . 14 2.3 Asubsetconstruction . .... .... .... ..... .... .... ... 17 2.4 Summary .................................... 20 2.5 Exercises .................................... 20 3 Regular Languages, I 23 3.1 Finite automata from regular expressions . ........ 23 3.2 Decidabilityofmatching . 28 3.3 Exercises .................................... 30 4 Regular Languages, II 31 4.1 Regular expressions from finite automata . ..... 31 4.2 Anexample ................................... 32 4.3 Complement and intersection of regular languages . ......... 34 4.4 Exercises .................................... 36 5 The Pumping Lemma 39 5.1 ProvingthePumpingLemma. 40 5.2 UsingthePumpingLemma.. .... .... ..... .... .... .... 41 5.3 Decidability of language equivalence . ....... 44 5.4 Exercises .................................... 45 6 Grammars 47 6.1 Context-freegrammars . 47 6.2 Backus-NaurForm ..............................
    [Show full text]
  • Theory of Computation
    Theory of Computation Todd Gaugler December 14, 2011 2 Contents 1 Mathematical Background 5 1.1 Overview . .5 1.2 Number System . .5 1.3 Functions . .6 1.4 Relations . .6 1.5 Recursive Definitions . .8 1.6 Mathematical Induction . .9 2 Languages and Context-Free Grammars 11 2.1 Languages . 11 2.2 Counting the Rational Numbers . 13 2.3 Grammars . 14 2.4 Regular Grammar . 15 3 Normal Forms and Finite Automata 17 3.1 Review of Grammars . 17 3.2 Normal Forms . 18 3.3 Machines . 20 3.3.1 An NFA λ ..................................... 22 4 Regular Languages 23 4.1 Computation . 24 4.2 The Extended Transition Function . 24 4.3 Algorithms . 26 4.3.1 Removing Non-Determinism . 26 4.3.2 State Minimization . 26 4.3.3 Expression Graph . 26 4.4 The Relationship between a Regular Grammar and the Finite Automaton . 26 4.4.1 Building an NFA corresponding to a Regular Grammar . 27 4.4.2 Closure . 27 4.5 Review for the First Exam . 28 4.6 The Pumping Lemma . 28 5 Pushdown Automata and Context-Free Languages 31 5.1 Pushdown Automata . 31 5.2 Variations on the PDA Theme . 34 5.3 Acceptance of Context-Free Languages . 36 3 CONTENTS CONTENTS 5.4 The Pumping Lemma for Context-Free Languages . 36 5.5 Closure Properties of Context- Free Languages . 37 6 Turing Machines 39 6.1 The Standard Turing Machine . 39 6.2 Turing Machines as Language Acceptors . 40 6.3 Alternative Acceptance Criteria . 41 6.4 Multitrack Machines . 42 6.5 Two-Way Tape Machines .
    [Show full text]