Formal Language Automata

Questions & Answers

(30pt) Expressions can be written without the need of parentheses in postfix form (also called reverse Polish notation). The name comes from the fact that the operator comes after the operands: a+bis written as ab+. A postfix expression can be easily evaluated using a stack. (a) (10pt) Using the underlying grammar from Fig. 4.1, write an S-attributed grammar that associates with the root of the parse tree the postfix expression corresponding to the (infix)expression produced by the tree. (b) (5pt) Use this S-attributed attributed grammar to draw the annotated parse tree for the expression (- 3 + 2) * 7 - 1. Show the attribute flow (arrows and values). (c) (10pt) Using the underlying grammar from Fig. 4.3, write an L-attributed grammar that associates with the root of the parse tree the postfix expression corresponding to the (infix)expression produced by the tree. (d) (5pt) Use this L-attributed attributed grammar to draw the annotated parse tree for the expression (- 3 + 2) * 7 - 1. Show the attribute flow (arrows and values).


) Consider the language: ) (10pt) Construct a grammar, G₁, for P that is LL(1). Build its LL(1) parse table (as inFig. 2.20) to prove that it is LL(1). (10pt) Construct a grammar, G2, for P that is SLR(1) but not LL(1). Build its SLR(1) parsetable (as in Fig. 2.28) to prove that it is SLR(1). Prove also that it is not LL(1). Construct a grammar, G3, for P that is not SLR(1). Prove that it is not SLR(1). ) Show the parse tree and the left derivation for the string [([]) ()]$$ in G₁. ›) (4pt) Show the trace of the table-driven LL(1) parse (as in Fig. 2.21) using G₁ for the samestring. ) Show the parse tree and the right derivation for the string [([]) ()]$$ in G₂. (4pt) Show the trace of the table-driven SLR(1) parse (as in Fig. 2.30) using G₂ for the same string. The grammars G₁..3 above must have a production P → S$$, with P not appearing anywhere else in the grammar. The parse tables are built as done in the textbook, not as done by j flap.You can use jflap to help but you need to modify its output. Do not upload screenshots from jflap. Write your own tables.


\text { Design a grammar for } L=\left\{a^{n} b^{m} c^{n} d^{m}, n>0\right\}


5- Given figure of 3x8 decoder built with 1x2 decoders. What are the correct signals for operation? (similar to this figure) A. YXZ → Y1,Y2,Y3 B. ZXY → Y1,Y2,Y3 C. ZYX → Y1,Y2,Y3 D. XYZ → Y1,Y2,Y3


Problem 1 (23 pts.) Consider the following claim: Claim. {21n: n € Z} U {14n: n € Z} c{7n:n €Z}. (a) (3 pts.) Write the claim as an (equivalent) if-then statement. Grading Notes. While a detailed rubric cannot be provided in advance as it gives away solution details, the following is a general idea of how points are distributed for this problem. We give partial credit where we can. (3) Correctness. Regardless of how you formulate your proof, you will need to have an if-then statement that is equivalent to the original. (b) (11 pts.) Give a direct proof by cases that the claim is true. As a hint, you might want to prove the if-then statement you constructed in (a). To get full points you must use a mixture of formal notation and word explanations (e.g. the "column" format). Each step of your proof should have an explanation as to how/why you could make that logical step. When in doubt, more detail is better than less. Grading Notes. While a detailed rubric cannot be provided in advance as it gives away solution details, the following is a general idea of how points are distributed for this problem. If you can at least get part-way, we give partial credit where we can. (9) Correctness. If your proof is not correct, this is where you'll get docked. (2) Regardless of how you formulate your proof, you will need clearly labeled exhaustive cases. (6) Regardless of how you formulate your proof, somewhere you'll need certain facts without which the proof wouldn't work. E.g. if it weren't true that the sum of two integers is integer, would your proof fail? If so, then that is a fact I need to see stated somewhere. (1) The order of these facts makes sense, so that you're not inferring something before you have all the facts to infer it. E.g. you cannot use the fact that the sum of two integers is integer if you don't already know that you have two integers to begin with. The order of how you use these does not have to exactly match those in the sample solutions, but there are orders that will not work and you will lose points if, for example, you use "the difference of ints is int" before you use "the product of ints is int". If you combine some steps (such as "the difference and product of ints is int" or "the product of two non-zero ints is a non-zero int") that is fine. Just don't combine all (see below). (2) Communication. We need to see a mix of notation and intuition, preferably in the "column" format with the notation on the left, and the reasons on the right. If you skip too many steps at once, or we cannot follow your proof, or if your solution is overly wordy or confusing, this is where you'll get docked. (c) (3 pts.) State (but do not prove) the contrapositive of your statement from part (a). Grading Notes. While a detailed rubric cannot be provided in advance as it gives away solution details, the following is a general idea of how points are distributed for this problem. We give partial credit where we can. (3) Correctness. You have to have the contrapositive statement of whatever if-then state- ment you wrote in part (a). (d) (3 pts.) State (but do not prove) the converse of your statement from part (a). Grading Notes. While a detailed rubric cannot be provided in advance as it gives away solution details, the following is a general idea of how points are distributed for this problem. We give partial credit where we can. (3) Correctness. Regardless of how you formulate your proof, you will need to have an if-then statement that is the contrapositive of the original. (e) (3 pts.) Give a disproof by counter-example of the converse from part (d). (That is, show that the converse is not true by providing an example that demonstrates it is not true.) Remember that any disproof by counter-example not only provides the counter-example, but also an explanation as to why it is a counter-example. Grading Notes. Note that this problem gives you practice disproving a statement by counter-example, which requires clearly stating a counter-example, and then showing why it is a counter-example.


No Search results found!

Kindly submit your queries
we will make sure available to you as soon as possible.

Search Other Question