nlp in prolog - Blackburn & Bos 1999

I'm studying Blackburn & Bos (1999) Representation and Inference for

Natural Language (www.comsem.org) and having trouble w/exercise 1.2.3 on

page 17. I'm learning prolog at the same time. I'd be grateful for a

critique of my inelegant solution to the first half of the question, and a

hint for the second half!

Let a vocabulary be defined by the predicates relation/2 - relation(rel,

arity) means 'rel' is a two-place relation in our vocabulary - and

constant/1 - constant(c) means 'c' is a constant in our vocabulary.

Let a model be represented by a list of relations over the vocabulary.

(I omit the proper set-theoretic definition of model and exact model here.

Doesn't affect the exercise.)

From B&B - "Write a prolog program which when given a vocabulary and a

list, determines whether or not the list represents an (exact) model over

that vocabulary. Can your program be used to generate all the exact models

over that vocabulary? If not, write a program that can."

Example Vocabulary (from B&B)

relation(loves,2). constant(mia).

relation(hates,2). constant(vincent).

relation(customer,1). constant(honey-bunny).

relation(robber,1). constant(pumpkin).

Example of a model

[customer(mia), loves(mia, vincent)]

My solution to the first half:

exact_model([]).

exact_model([H|T]) :-

exact_model_term(H),

exact_model(T).

exact_model_term(Term) :-

functor(Term, F, Arity),

Arity > 0,

relation(F, Arity),

Term =.. [F|Args],

exact_model(Args).

% cheat, args aren't a model, but have the

% same form, a list of terms over vocab

exact_model_term(Term) :-

functor(Term, F, Arity),

Arity == 0,

constant(F).

But of course, the univ operator (=..) at least means this program won't

work as a generator. Any hints? I don't think I'm supposed to consider

other representations of the vocabulary or model.

Thanks!!

dhf