Challenge 1: Extending the Sentence Grammar With mouse/saw — Possible Solution ==================================================================== sentence_demo.pl: sentence --> noun_phrase, verb_phrase. noun_phrase --> [the], noun. verb_phrase --> verb, noun_phrase. noun --> [cat]. noun --> [dog]. noun --> [mouse]. verb --> [chased]. verb --> [saw]. Query: ?- phrase(sentence, [the, cat, saw, the, mouse]). true. ?- phrase(sentence, [the, mouse, chased, the, dog]). true. Explanation: Adding noun --> [mouse]. and verb --> [saw]. simply gives noun/1 and verb/1 a third and second alternative respectively, exactly the same way an ordinary Prolog predicate gains a new clause -- nothing about sentence, noun_phrase, or verb_phrase needed to change at all, since they only ever call noun and verb, never enumerate the specific words themselves. Both new sentences succeed because each individual word now has a matching grammar rule, and the overall sentence structure (the + noun, verb, the + noun) is satisfied by both new combinations exactly as it was by the original cat/dog/chased words. WHY THIS WORKS AS AN ANSWER ------------------------------ This adds new vocabulary purely by adding new noun/verb alternatives, demonstrating that DCG rules compose the same way ordinary Prolog clauses do -- the higher-level grammar rules needed no changes at all to accept the newly introduced words.