Question: Question 1. (24 points) Context-free grammars (a) (10 points) Construct a context-free grammar that produces all (simplified) Prolog assertions with any finite number (1 or
Question 1. (24 points) Context-free grammars (a) (10 points) Construct a context-free grammar that produces all (simplified) Prolog assertions with any finite number (1 or greater) of names. Such assertions take the form atoml(namel, name2, ..., nameN). The predicate names (atoml) have to start with a lowercase letter followed by any sequence of lower-case letters and digits. Names (namel to nameN) are either variables (starting with an uppercase letter or underscore, potentially followed by additional uppercase letters) or names (starting with a lowercase letter followed by any sequence of lower-case letters and digits). Assume that all names only consist of letters or, for variables only, an underscore (but only as starting symbol). Represent your grammar in BNF (use words starting with upper-case letters to denote nonterminals; you do not need to enclose them in angled brackets i i). DO NOT use EBNE. (b) (8 points) Use the grammar from part (a) derive the following Prolog assertions. Represent your derivations as parse trees. (i) key(X, Y,-). (ii) r3(-X, AB, 121). (c) (6 points) Express your CFG as concisely as possible in EBNF.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
