本次美国代写是CFG相关的一个assignment,需要用到Latex

Overview

This homework assignment will test your knowledge of context-free grammars (CFGs) and parsing, which you have learned in class. Please submit your assignment via Gradescope by the deadline. This is an individual assignment, and all answers must be typed. However, you are allowed to hand-draw any parse trees and scan and attach them in your final submission.

Problems

1. (8 Points) For each of the following context-free grammars, state the number of valid inputs supported by that grammar. As an example, the grammar G : E ! a j b j c results in 3 valid inputs—a, b, and c. Note that the empty string may be a valid input wherever applicable (this means that if an empty string is a possible input, you should consider it as part of your total count). You also do not need to list the different possible inputs.

2. (8 Points) Suppose there is a context-free grammar G such that the language of G, L(G), supports palindrome inputs, where inputs consist of characters from the alphabet  = fa; c; e; rg.

Examples of valid inputs for L:

• racecar
• a
• The empty string

Examples of invalid inputs for L:

• race (not a palindrome)
• abcba (b = 2 )
• ack (composite of the first two cases)

(a) (6 Points) Construct G.

(b) (2 Points) Is L a regular language? Explain why or why not.