Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Android Graphics

Authors: Wallace Jackson

1st Edition

1430257857, 978-1430257851

More Books

Students also viewed these Programming questions

Question

What is a virtual private network ( VPN ) ?

Answered: 1 week ago