Question

In: Computer Science

Can you please answer this Automata Question Show how a arbitrary regular expression can by systematically...

Can you please answer this Automata Question

Show how a arbitrary regular expression can by systematically turned into a regular grammar. In detail, describe the procedure for producing an equivalent regular grammar.

Solutions

Expert Solution

This algorithm is not very straightforward, and may take a while to understand. We will show how to construct a regular grammar from a regular expression, and it is suggested that you try a few simple exercises using RELIC to confirm your results. The method shown here is simply an example on how you can convert a simple regular expression to a regular grammar.

First of all you must remember the definition of a regular expression and the theorem: for any regular expression e, there exists a regular grammar G recognising exactly the language described by e. Refer to the relevant section in the course notes for the proof upon which the algorithm is based.

The basic idea is the following:

  • if the regular expression is simply 0, we can show that G, with no production rules, is an equivalent regular grammar.
  • if the regular expression is simply 1, we can show that G, with one production rule S (where S is the start symbol), is an equivalent regular grammar.
  • if the regular expression is simply a (a being any terminal), we can show that G, with one production rule Sa (where S is the start symbol), is an equivalent regular grammar.
  • if the regular expression is of the form e+f, where both e and f are regular expressions, use this algorithm to contruct two regular grammars G1 and G2 equivalent to e and f respectively. Now use regular grammar union on these two grammars to construct a regular grammar G which is equivalent to e+f.
  • if the regular expression is of the form ef, where both e and f are regular expressions, use this algorithm to contruct two regular grammars G1 and G2 equivalent to e and f respectively. Now use regular grammar catenation on these two grammars to construct a regular grammar G which is equivalent to ef.
  • if the regular expression is of the form e*, where e is a regular expression, use this algorithm to contruct a regular grammar G equivalent to e. Now use regular grammar Kleene star closure to construct a regular grammar G' which is equivalent to e*.
  • if the regular expression is of the form e+, where e is a regular expression, use this algorithm to contruct a regular grammar G equivalent to e. Now use regular grammar Kleene plus closure to construct a regular grammar G' which is equivalent to e+.

Examples

Note that to simplify the presentation, we will describe regular grammars by just stating their production rules. The non-terminal appearing on the left hand side of the first production is assumed to be the start symbol.

Example 1

Consider the regular expression (a + b)*a. We will now construct a regular grammar for this regular expression. For every terminal symbol a, we create a regular grammar with the rule S \arrow a, start symbol S. We then apply the transformations to these regular grammars, progressively constructing the regular grammar.

First consider the expression a + b. We create two regular grammars:

S1 a and
S2 b

where S1 and S2 are the start symbols. Clearly, these grammars recognise the regular expressions a and b respectively.

Now, we apply the union transformation for regular grammars to get:

S3 a | b
S1 a
S2 b

where S3 is the start symbol. This grammar obviously recognises a + b.

Next, we consider the expression (a + b)*. We already have a regular grammar for (a + b), so now we apply the Kleene star transformation on the regular grammar:

S4 a | b |
S3 a | b
S1 aS3
S2 bS3

where S4 is the start symbol.

Recall that we need a regular grammar that recognises (a + b)*a. We thus consider again the regular expression a. Again, we create a regular grammar that describes the language:

S5 a

where S5 is the start symbol.

We now construct the catenation of the regular grammar describing (a + b)* together with this one. We simply apply the transformation that catenates two regular grammars, to get:

S4 a | b |
S3 aS5 | bS5
S1 aS3
S2 bS3
S5 a

where S4 is the start symbol.

This regular grammar is equivalent to the regular expression (a + b)*a.

Note: Plzzz don' t give dislike.....Plzzz comment if u have any problem i will try to resolve it.......


Related Solutions

Regular Expressions Assignment Write a regular expression for each of the following. Can you show output...
Regular Expressions Assignment Write a regular expression for each of the following. Can you show output please. A blank line (may contain spaces) Postal abbreviation (2 letters) for State followed by a space and then the 5-digit zip code A KU student username (Ex. lpork247) A “valid” email address (also explain how you defined “valid”) A SSN pattern (ddd-dd-dddd)
Please describe in detail how you got the answer. Give a regular expression which describes the...
Please describe in detail how you got the answer. Give a regular expression which describes the set of strings over {a, b, c} in which every a is immediately followed by at least one c.
This is a multipart question, can you please show the work on how you did the...
This is a multipart question, can you please show the work on how you did the problems. 1.Cost of Debt: 30 year Bonds Current Price 101.5% of par value 7.6 % Coupon Rate Semi Annual Bond 5 years to maturity Tax Rate: 40% What is the Cost of Debt? After Tax? 2.Preferred Stock: Dividend $7.50 Current Price $60.00 What is the Cost of Preferred? 3.Equity: Risk Free Rate 6.50% Market Risk Premium 6.25% Stock Beta 0.7 What is the Cost...
Please show how you get to the answer and explain it! Please thoroughly show how to...
Please show how you get to the answer and explain it! Please thoroughly show how to do this! I'm so confused. Given the following information for Gator Company who uses the LIFO method: ​ ​ ​ ​ Net ​ NRV Minus ​ ​ ​ Realizable Replacement Normal Item Quantity Cost Value Cost Profit 1 1 $17.70 $24.60 $18.00 $17.10 2 1 10.80 8.28 9.30 5.58 3 1 72.00 64.80 67.20 57.60 4 1 4.80 3.12 2.88 2.64 5 1 12.00...
Can you please show me the work on how you get your answer please (thank you...
Can you please show me the work on how you get your answer please (thank you in advance kings and queens of chegg) Problem 1: The following selected information is provided about a manufacturing company: Raw material purchases800,000 Direct labor 415,000 Overhead applied730,000 Actual overhead745,000 Selling and administrative salaries500,000 Other selling and administrative expenses185,000 Sales revenue5,000,000 Inventory data: January 1 December 31Raw material 75,000 100,000Work in process 105,000 140,000Finished goods 120,000 125,000Calculate the cost of goods sold. Assume that under/over...
(Please show work so I can understand how you got to the answer - Thank you...
(Please show work so I can understand how you got to the answer - Thank you very much ) Via Gelato is a popular neighborhood gelato shop. The company has provided the following data concerning its operations: Fixed Element per Month Variable Element per Liter Actual Total for June Revenue $ 13.00 $ 72,540 Raw materials $ 4.75 $ 30,330 Wages $ 5,700 $ 1.50 $ 14,560 Utilities $ 1,730 $ 0.30 $ 3,800 Rent $ 2,700 $ 2,700 Insurance...
Please answer in less than an hour :) Can you explain and show how we get...
Please answer in less than an hour :) Can you explain and show how we get the Specific Cutting pressure in GPa if vertical force is 0.882 kN, feed rate is .0508 mm/rev, and depth of the cut is 1.8161 mm.  
Please answer the following question. a. How can you organizes and coordinates the daily operations of...
Please answer the following question. a. How can you organizes and coordinates the daily operations of assigned staff to meet work goals such as ensuring activities are in compliance with all laws, policies, regulations and goals? b. How can you demonstrate continuous effort to improve operations, decrease turnaround times, streamline work processes, and work cooperatively and jointly to provide quality seamless customer service? c. How can you prioritize and coordinate work assignments such as training, coaching and instructs employees as...
(a) How Context Free languages are different from Regular languages. (b) What are the automata accepting...
(a) How Context Free languages are different from Regular languages. (b) What are the automata accepting those languages and how they are different from DFA and NFA. (c) How the grammar of Context Free Languages looks different from those in Regular languages.
Can someone please show me how to do the work on this please. Question The transactions...
Can someone please show me how to do the work on this please. Question The transactions of the Fury Delivery Service are recorded in the general journal below. Instructions: 1. Post the journal entries to the attached general ledger “T” accounts. 2. Prepare a trial balance on the form provided after the “T” accounts. General Journal Date Account Titles and Explanation Debit Credit 2017 Sept. 1 Cash Common Stock (Stockholders invested cash in business) 25,000 25,000 4 Equipment Cash Notes...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT