General
Lab Material
Lab 1
Lab 2
Lab 3
Lab 4
Lab 5
Lab 6

Hint

A sentence can consist of a conjunction of two sentences which are either simple sentences or are again conjunctions of sentences. So, we need a recursive rule.

However, the most obvious solution

s --> s, conj, s.
    
won't work in Prolog. It will make Prolog go into an endless loop if you ask it to recognize an ungrammatical sentence. So, you somehow have to work around this problem.

By the way, it is a general property of DCGs that they cannot handle left-recursive grammar rules, i.e., grammar rules where the first category on the right hand side of the rule is the same as the category on the left hand side of the rule.

Solution

Now, look back at the solution you have found for nouns modified by a prepositional phrase. (here), and make sure you have not used a left recursive rule.

Back to lab 1.