Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Context-free Languages 1. Consider the following inductive definition of monomials and of polynomials in the variables a and b Monomials a and b are monomials
Context-free Languages 1. Consider the following inductive definition of monomials and of polynomials in the variables a and b Monomials a and b are monomials every non-zero numeral is a monomial; e if n is a non-zero numeral and is either a or b, then r n is a monomial if m and m2 are two monomials, so is m1 m2; nothing else is a monomial Polynomials e0 is a polynomial; every monomial is a polynomial: if pi and p2 are two polynomials, so are pi + p2 and pi -p2 e nothing else is a polynomia (a) Write a context-free grammar for the language of monomials in the variables a and b over the alphabet {a, b, ^, ., 0, 1, 2, 3, 4, 5, 6, 7, 8, 9} (b) Write a context-free grammar for the language of polynomials in the variables a and b over the alphabet U {+,-) 2. Consider the grammar given by the production rules below, with start symbol B. over the alphabet which describes a subset of Java/F# Boolean expressions For each of the following words in ". first write a leftmost derivation of the word according to the grammar above.1 Then draw the corresponding parse tree. Recall that in a derivation only one non-terminal at a time gets rewritten. (a) x = y+a-1 Context-free Languages 1. Consider the following inductive definition of monomials and of polynomials in the variables a and b Monomials a and b are monomials every non-zero numeral is a monomial; e if n is a non-zero numeral and is either a or b, then r n is a monomial if m and m2 are two monomials, so is m1 m2; nothing else is a monomial Polynomials e0 is a polynomial; every monomial is a polynomial: if pi and p2 are two polynomials, so are pi + p2 and pi -p2 e nothing else is a polynomia (a) Write a context-free grammar for the language of monomials in the variables a and b over the alphabet {a, b, ^, ., 0, 1, 2, 3, 4, 5, 6, 7, 8, 9} (b) Write a context-free grammar for the language of polynomials in the variables a and b over the alphabet U {+,-) 2. Consider the grammar given by the production rules below, with start symbol B. over the alphabet which describes a subset of Java/F# Boolean expressions For each of the following words in ". first write a leftmost derivation of the word according to the grammar above.1 Then draw the corresponding parse tree. Recall that in a derivation only one non-terminal at a time gets rewritten. (a) x = y+a-1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started