Question

In: Computer Science

Compare the language generated by Grammar #2 to the language generated by Grammar #1. How do...

Compare the language generated by Grammar #2 to the language generated by Grammar #1. How do the two languages compare to each other? (Is one language a proper subset of the other? Does each language contain a string that the other one does not? Do both grammars generate the very same language?)

grammar #1 where S is the start symbol  

S → tV | iC | iV | i

C → tV

V → iC | iV | i


Grammar #2 where S is the start symbol

S → W

W → YW | Y

Y → CV | V

C → t

V → i

Solutions

Expert Solution

we have two grammar,

grammar #1 where S is the start symbol  

S → tV | iC | iV | i

C → tV

V → iC | iV | i


Grammar #2 where S is the start symbol

S → W

W → YW | Y

Y → CV | V

C → t

V → i

we need to generate languages from the given grammars.

There are three rules for the simplification of CFG ( Context Free Grammar).

1. Elimination of useless symbols

2. Eliminate unit productions

3. Eliminate null productions

take the first grammar,

S → tV | iC | iV | i

C → tV

V → iC | iV | i

take  V → i and put this to in place of v

and we get

S → tV | iC | iV | i

C → tV

V → iC | ii | i

again substitute the values in the grammar

S → tii | ti | tiC | itV | i

C → tiC | tii | ti

V → itV | ii | i

S → tii | ti | tiC | itV | i

C → titii | titi | tii | ti

V → itii | iti | ii | i

and finally we get  the language from grammar 1 , L( G1 )

S → tii | ti | tititii | tititi | titii |titi | ititii | ititi | itii | iti | i

Consider the second Grammar

S → W

W → YW | Y

Y → CV | V

C → t

V → i

Rewrite the given grammar by applying the values of  C → t , V → i

S → W

W → YW | Y

Y → ti | i

apply  Y → ti | i into  W → YW | Y

S → W

W →tiW | iW | ti | i

apply values of W into the grammar

S → W

W →titi | tii | iti | ii | ti | i

and finally we get language from grammar 2, L( G2 )

S → titi | tii | iti | ii | ti | i

Now we have two languages from the given grammar,

L( G1 ) :  S → tii | ti | tititii | tititi | titii |titi | ititii | ititi | itii | iti | i

L(G2 ) : S → titi | tii | iti | ii | ti | i

Compare the both languages by using their string. ( titi | tii | iti | ii | ti | i these all strings belongs to L( G1 ) )

All the strings of the language L(G2 ) does belongs to language  L( G1 ) but both languages are not same . So L( G2 ) is a proper subset of L( G1 ).


Related Solutions

Construct an NPDA that accepts the language defined by the given grammar and give the language...
Construct an NPDA that accepts the language defined by the given grammar and give the language in a formal expression (including a regular expression). S -> AA|a, A-> SA|ab
Compare and contrast t-test and ANOVA: 1. what do they test for? 2. How do they...
Compare and contrast t-test and ANOVA: 1. what do they test for? 2. How do they do it? 3. When would you use them?
Construct a pda that accepts the language defined by the grammar S → aSSSab | λ...
Construct a pda that accepts the language defined by the grammar S → aSSSab | λ . This has already been answered using software with no explanation. I am not interested in the answer so much. I just want an explanation. or at least a step by step formula.
Ex#3: Give a string of lengths, 4, 6, 8 generated by the following grammar G =...
Ex#3: Give a string of lengths, 4, 6, 8 generated by the following grammar G = (V, T, S. P). S → 0S S --> 0S1S S --> λ
Now that you know a bit about BNF's, try writing a grammar (productions) for the "language"...
Now that you know a bit about BNF's, try writing a grammar (productions) for the "language" of a phone number, which consists of: three digits enclosed in parentheses - the first digit cannot be "0" (zero) followed by three digits - the first digit cannot be "0" (zero) followed by a "-" (dash) followed by four digits So, (757)530-4601 is a valid phone number. All the following numbers are invalidaccording to this grammar: 757-530-4601 (area code is not in parentheses)...
Show that a language that is described by a regular expression can also be generated by...
Show that a language that is described by a regular expression can also be generated by a context-free grammar. As a hint, consider each mechanism, such as using a basic form or forming the regular expression re1 ∪ re2 from the expressions re1 and re2, and show how this can be transformed into grammar rules that can be added to the grammars generating the collection of strings denoted by re1 and re2.
Language For this question compare and contrast the role of language as seen by the theorist’s:...
Language For this question compare and contrast the role of language as seen by the theorist’s: Jean Piaget and Lev Vygotsky. Be sure to: 1-explain how they both viewed language in similar ways, 2-how they differed in their views of language and lastly, being that one theorist felt stronger about the role of language leading to higher levels of abstract thinking, what would Piaget/Vygotsky say to one another if they were given the opportunity to critique each other on their...
Make sure the answers are correct, well explained, thoughtful, and have no grammar mistakes. How do...
Make sure the answers are correct, well explained, thoughtful, and have no grammar mistakes. How do abilities and personality traits impact leadership potential? Discuss each of these characteristics (Physical, Mental, Personality) based upon a trait theory perspective. In your opinion, which one of these traits is more important to success?
Make sure the answers are correct, well explained, thoughtful, and have no grammar mistakes. How do...
Make sure the answers are correct, well explained, thoughtful, and have no grammar mistakes. How do abilities and personality traits impact leadership potential? Discuss each of these characteristics (Physical, Mental, Personality) based upon a trait theory perspective. In your opinion, which one of these traits is more important to success?
1. Define and compare state-sponsored and lone wolf terrorism? 2. How effective do you think “body...
1. Define and compare state-sponsored and lone wolf terrorism? 2. How effective do you think “body cameras” are providing transparency in policing?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT