General
Material
Lecture 1
Lecture 2
Lecture 3
Lecture 4
Lecture 5

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

Back to the exercise