11.4 Regular Language Topics

Similar documents
Homework 3 Solutions

Regular Sets and Expressions

Integration by Substitution

One Minute To Learn Programming: Finite Automata

LINEAR TRANSFORMATIONS AND THEIR REPRESENTING MATRICES

Algebra Review. How well do you remember your algebra?

Lecture 5. Inner Product

Polynomial Functions. Polynomial functions in one variable can be written in expanded form as ( )

Binary Representation of Numbers Autar Kaw

Example A rectangular box without lid is to be made from a square cardboard of sides 18 cm by cutting equal squares from each corner and then folding

Regular Languages and Finite Automata

A Visual and Interactive Input abb Automata. Theory Course with JFLAP 4.0

FORMAL LANGUAGES, AUTOMATA AND THEORY OF COMPUTATION EXERCISES ON REGULAR LANGUAGES

9.3. The Scalar Product. Introduction. Prerequisites. Learning Outcomes

Reasoning to Solve Equations and Inequalities

MODULE 3. 0, y = 0 for all y

Use Geometry Expressions to create a more complex locus of points. Find evidence for equivalence using Geometry Expressions.

Integration. 148 Chapter 7 Integration

PHY 140A: Solid State Physics. Solution to Homework #2

Unambiguous Recognizable Two-dimensional Languages

and thus, they are similar. If k = 3 then the Jordan form of both matrices is

Warm-up for Differential Calculus

SPECIAL PRODUCTS AND FACTORIZATION

Brillouin Zones. Physics 3P41 Chris Wiebe

Treatment Spring Late Summer Fall Mean = 1.33 Mean = 4.88 Mean = 3.

Example 27.1 Draw a Venn diagram to show the relationship between counting numbers, whole numbers, integers, and rational numbers.

flex Regular Expressions and Lexical Scanning Regular Expressions and flex Examples on Alphabet A = {a,b} (Standard) Regular Expressions on Alphabet A

4.11 Inner Product Spaces

19. The Fermat-Euler Prime Number Theorem

PROF. BOYAN KOSTADINOV NEW YORK CITY COLLEGE OF TECHNOLOGY, CUNY

Econ 4721 Money and Banking Problem Set 2 Answer Key

Java CUP. Java CUP Specifications. User Code Additions You may define Java code to be included within the generated parser:

Mathematics. Vectors. hsn.uk.net. Higher. Contents. Vectors 128 HSN23100

Solution to Problem Set 1

Section 7-4 Translation of Axes

Factoring Polynomials

Experiment 6: Friction

Bypassing Space Explosion in Regular Expression Matching for Network Intrusion Detection and Prevention Systems

FAULT TREES AND RELIABILITY BLOCK DIAGRAMS. Harry G. Kwatny. Department of Mechanical Engineering & Mechanics Drexel University

Physics 43 Homework Set 9 Chapter 40 Key

Small Business Networking

Lecture 3 Gaussian Probability Distribution

Section 5-4 Trigonometric Functions

1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall Final Exam

Operations with Polynomials

Math 135 Circles and Completing the Square Examples

On decidability of LTL model checking for process rewrite systems

6.2 Volumes of Revolution: The Disk Method

Graphs on Logarithmic and Semilogarithmic Paper

e.g. f(x) = x domain x 0 (cannot find the square root of negative values)

trademark and symbol guidelines FOR CORPORATE STATIONARY APPLICATIONS reviewed

A.7.1 Trigonometric interpretation of dot product A.7.2 Geometric interpretation of dot product

Bayesian Updating with Continuous Priors Class 13, 18.05, Spring 2014 Jeremy Orloff and Jonathan Bloom

Linear Equations in Two Variables

Small Business Networking

Small Business Networking

AREA OF A SURFACE OF REVOLUTION

How To Network A Smll Business

Small Business Networking

Basic Analysis of Autarky and Free Trade Models

Babylonian Method of Computing the Square Root: Justifications Based on Fuzzy Techniques and on Computational Complexity

Vectors Recap of vectors

Or more simply put, when adding or subtracting quantities, their uncertainties add.

Review guide for the final exam in Math 233

Appendix D: Completing the Square and the Quadratic Formula. In Appendix A, two special cases of expanding brackets were considered:

9 CONTINUOUS DISTRIBUTIONS

1.2 The Integers and Rational Numbers

Second Term MAT2060B 1. Supplementary Notes 3 Interchange of Differentiation and Integration

Physics 6010, Fall 2010 Symmetries and Conservation Laws: Energy, Momentum and Angular Momentum Relevant Sections in Text: 2.6, 2.

CHAPTER 11 Numerical Differentiation and Integration

RIGHT TRIANGLES AND THE PYTHAGOREAN TRIPLETS

Drawing Diagrams From Labelled Graphs

5.2. LINE INTEGRALS 265. Let us quickly review the kind of integrals we have studied so far before we introduce a new one.

How To Set Up A Network For Your Business

3 The Utility Maximization Problem

All pay auctions with certain and uncertain prizes a comment

Geometry 7-1 Geometric Mean and the Pythagorean Theorem

15.6. The mean value and the root-mean-square value of a function. Introduction. Prerequisites. Learning Outcomes. Learning Style

The Definite Integral

MATH 150 HOMEWORK 4 SOLUTIONS

Repeated multiplication is represented using exponential notation, for example:

Modular Generic Verification of LTL Properties for Aspects

EQUATIONS OF LINES AND PLANES

Lectures 8 and 9 1 Rectangular waveguides

Generating In-Line Monitors For Rabin Automata

Unleashing the Power of Cloud

6 Energy Methods And The Energy of Waves MATH 22C

Module Summary Sheets. C3, Methods for Advanced Mathematics (Version B reference to new book) Topic 2: Natural Logarithms and Exponentials

Concept Formation Using Graph Grammars

Small Business Cloud Services

AntiSpyware Enterprise Module 8.5

Quick Reference Guide: Reset Password

CURVES ANDRÉ NEVES. that is, the curve α has finite length. v = p q p q. a i.e., the curve of smallest length connecting p to q is a straight line.

How fast can we sort? Sorting. Decision-tree model. Decision-tree for insertion sort Sort a 1, a 2, a 3. CS Spring 2009

Novel Methods of Generating Self-Invertible Matrix for Hill Cipher Algorithm

Protocol Analysis / Analysis of Software Artifacts Kevin Bierhoff

Virtual Machine. Part II: Program Control. Building a Modern Computer From First Principles.

CUBIC-FOOT VOLUME OF A LOG

baby on the way, quit today

Transcription:

54 Regulr Lnguges nd Finite Automt Find simple regulr expression for the regulr lnguge recognized by this NFA. Hint: Trnsform the NFA into DFA, nd then find the minimum-stte DFA. Chllenge 12. Wht cn you sy bout the regulr lnguge ccepted by DFA in which ll sttes re finl? 11.4 Regulr Lnguge Topics We ve lredy seen chrcteriztions of regulr lnguges by regulr expressions, lnguges ccepted by DFAs, nd lnguges ccepted by NFAs. In this section we ll introduce still nother chrcteriztion of regulr lnguges in terms of certin restricted grmmrs. We ll discuss some properties of regulr lnguges tht cn be used to find lnguges tht re not regulr. Regulr Grmmrs A regulr lnguge cn be described by specil kind of grmmr in which the productions tke certin form. A grmmr is clled regulr grmmr if ech production tkes one of the following forms, where the cpitl letters re nonterminls nd w is nonempty string of terminls: S! ", S! w, S! T, S! wt. The thing to keep in mind here is tht only one nonterminl cn pper on the right side of production, nd it must pper t the right end of the right side. For exmple, the productions A! Bc nd S! TU re re not prt of regulr grmmr. But the production A! bca is OK. The most importnt spect of grmmr writing is knowledge of the lnguge under discussion. We should lso remember tht grmmrs re not unique. So we shouldn t be surprised when two people come up with two different grmmrs for the sme lnguge. To strt things off, we ll look t few regulr grmmrs for some simple regulr lnguges. Ech line of the following list describes regulr lnguge in terms of regulr expression nd regulr grmmr. As you look through the following list, cover up the grmmr column with your hnd nd try to dis-

11.4 Regulr Lnguge Topics 55 cover your own version of regulr grmmr for the regulr lnguge of ech regulr expression. Regulr Expression * S! " S Regulr Grmmr ( + b)* S! " S bs * + b* S! " A B A! A B! b bb *b b* (b)* S! b S S! ba A! " A S! " bs The lst three exmples in the preceding list involve products of lnguges. Most problems occur in trying to construct regulr grmmr for lnguge tht is the product of lnguges. Let s look t n exmple to see whether we cn get some insight into constructing such grmmrs. Suppose we wnt to construct regulr grmmr for the lnguge of the regulr expression *bc*. First we observe tht the strings of *bc* strt with either the letter or the letter b. We cn represent this property by writing down the following two productions, where S is the strt symbol: S! S b C. These productions llow us to derive strings of the form bc, bc, bc, nd so on. Now ll we need is definition for C to derive the lnguge of c*. The following two productions do the job: C! " c C. Therefore regulr grmmr for *bc* cn be written s follows: S! S b C C! " c C. EXAMPLE 1 Smple Regulr Grmmrs

56 Regulr Lnguges nd Finite Automt We ll consider some regulr lnguges, ll of which consist of strings of s followed by strings of b s. The lrgest lnguge of this form is the lnguge { m b n m, n! N}, which is represented by the regulr expression *b*. A regulr grmmr for this lnguge cn be written s follows: S " # S B B " b bb. Let s look t four sublnguges of { m b n m, n! N} tht re defined by whether ech string contins occurrences of or b. The following list shows ech lnguge together with regulr expression nd regulr grmmr. Lnguge Expression Regulr Grmmr { m b n m! 0 nd n > 0} *bb* S " S B B " b bb. { m b n m > 0 nd n! 0} *b* S " A A " A B B " # bb. { m b n m > 0 nd n > 0} *bb* S " A A " A B B " b bb. { m b n m > 0 or n > 0} *b* + *bb* S " A bb A " # A B B " # b B. $ Any regulr lnguge hs regulr grmmr; conversely, ny regulr grmmr genertes regulr lnguge. To see this, we ll give two lgorithms: one to trnsform n NFA to regulr grmmr nd the other to trnsform regulr grmmr to n NFA, where the lnguge ccepted by the NFA is identicl to the lnguge generted by the regulr grmmr. NFA to Regulr Grmmr (11.11) Perform the following steps to construct regulr grmmr tht genertes the lnguge of given NFA: 1. Renme the sttes to set of uppercse letters. 2. The strt symbol is the NFA s strt stte. 3. For ech stte trnsition from I to J lbeled with, crete the production I " J.

11.4 Regulr Lnguge Topics 57 4. For ech stte trnsition from I to J lbeled with!, crete the production I " J. 5. For ech finl stte K, crete the production K "!. It s esy to see tht the lnguge of the NFA nd the lnguge of the constructed grmmr re the sme. Just notice tht ech stte trnsition in the NFA corresponds exctly with production in the grmmr so tht the cceptnce pth in the NFA for some string corresponds to derivtion by the grmmr for the sme string. Let s do n exmple. EXAMPLE 2 From NFA to Regulr Grmmr Let s see how (11.11) trnsforms the following NFA into regulr grmmr: Strt S I b K! J The lgorithm tkes this NFA nd constructs the following regulr grmmr with strt symbol S: S " I J I " bk J " J K K "!. For exmple, to ccept the string, the NFA follows the pth S, J, J, K with edges lbeled!,,, respectively. The grmmr derives this string with the following sequence of productions: S " J, J " J, J " K, K "!. # Now let s look t the converse problem of constructing n NFA from regulr grmmr. For the opposite trnsformtion we ll first tke regulr grmmr nd rewrite it so tht ll the productions hve one of two forms S " x or S " xt, where x is either! or single letter. Let s see how to do this so tht we don t lose ny generlity. For exmple, if we hve production like

58 Regulr Lnguges nd Finite Automt A! bcb, we cn replce it by the following two productions, where C is new nonterminl: A! bc nd C! cb. Now let s look t n lgorithm tht does the job of trnsforming regulr grmmr into n NFA. Regulr Grmmr to NFA (11.12) Perform the following steps to construct n NFA tht ccepts the lnguge of given regulr grmmr: 1. If necessry, trnsform the grmmr so tht ll productions hve the form A! x or A! xb, where x is either single letter or ". 2. The strt stte of the NFA is the grmmr s strt symbol. 3. For ech production I! J, construct stte trnsition from I to J lbeled with the letter. 4. For ech production I! J, construct stte trnsition from I to J lbeled with ". 5. If there re productions of the form I! for some letter, then crete single new stte symbol F. For ech production I!, construct stte trnsition from I to F lbeled with. 6. The finl sttes of the NFA re F together with ll I for which there is production I! ". It s esy to see tht the lnguge of the NFA is the sme s the lnguge of the given regulr grmmr becuse the productions used in the derivtion of ny string correspond exctly with the stte trnsitions on the pth of cceptnce for the string. Here s n exmple. EXAMPLE 3 From Regulr Grmmr to NFA Let s use (11.12) to trnsform the following regulr grmmr into n NFA: S! S bi I! I. Since there is production I!, we need to introduce new stte F, which then gives us the following NFA:

11.4 Regulr Lnguge Topics 59 b Strt S I F! Properties of Regulr Lnguges We need to fce the fct tht not ll lnguges re regulr. To see this, let s look t clssic exmple. Suppose we wnt to find DFA or NFA to recognize the following lnguge. { n b n n! 0}. After few ttempts t trying to find DFA or n NFA or regulr expression or regulr grmmr, we might get the ide tht it cn t be done. But how cn we be sure tht lnguge is not regulr? We cn try to prove it. A proof usully proceeds by ssuming tht the lnguge is regulr nd then trying to find contrdiction of some kind. For exmple, we might be ble to find some property of regulr lnguges tht the given lnguge doesn t stisfy. So let s look t few properties of regulr lnguges. One useful property of regulr lnguges comes from the observtion tht ny DFA for n infinite regulr lnguge must contin loop to recognize infinitely mny strings. For exmple, suppose DFA with four sttes ccepts the 4-letter string bcd. To ccept bcd the DFA must enter five sttes. For exmple, if the sttes of the DFA re numbered 0, 1, 2, nd 3, where 0 is the strt stte nd 3 is the finl stte, then there must be pth through the DFA strting t 0 nd ending t 3 with edges lbeled, b, c, nd d. For exmple, if the pth is 0, 1, 2, 1, 3, then the following grph represents portion of the DFA tht contins the the pth to ccept bcd. 2 Strt c 0 1 b d 3 Of course, the loop 1, 2, 1 cn be trveled ny number of times. For exmple, the pth 0, 1, 2, 1, 2, 1, 3 ccepts the string bcbcd. So the DFA will ccept the strings, d, bcd, bcbcd,..., (bc) n d,.... This is the property tht we wnt to describe. We ll generlize the ide illustrted in our little exmple. Suppose DFA with m sttes recognizes n infinite regulr lnguge. If s is string