Prolog : Combining DCG grammars with other restrictions

Viewed 686

I'm very impressed by Prolog's DCG and how quickly I can produce all the possible structures that fit a particular grammar.

But I'd like to combine this search with other constraints. For example, define a complex grammar and ask Prolog to generate all sentences with not more than 10 words. Or all sentences that don't repeat the same word twice.

Is it possible to add extra constraints like this to a DCG grammer? Or do I basically have to translate the DCG back into normal Prolog clauses and start modifying them?

2 Answers
Related