2.1.4 Representing Models

How to represent first-order models in Prolog?

Let's suppose that we have fixed our vocabulary. For example, suppose we've decided to work with the vocabulary specified before and have it in our database. How should we represent models of this vocabulary in Prolog?

We only use exact models.

In this general formulation, this is an impossibly difficult question. We don't have the remotest chance of dealing with all models of this vocabulary, for there are models of this vocabulary based on any non-empty domain whatsoever. In particular, there are lots of infinite models. Now, it is possible to give useful finite representations of some infinite models - but most are too big and too unruly to be worked with computationally. Hence we shall confine our attention to finite models of our vocabulary (i.e. ones with a finite domain). In addition, matters are much simpler if we only have to deal with exact models.

Recall that exact models are models where every element of the domain is named by exactly one constant. So, let's rephrase our question: How should we represent a finite exact model over the above vocabulary?

The vocabulary fixes the domain.

Because of the one-to-one correspondence between constants and domain elements in exact models, our vocabulary already tells us all we need to know about the domain of the model to be represented: It tells us how many elements there will be in its domain. In fact we shall simply assume that the domains of the models we represent consist of the constants in our vocabulary. Thus given our example vocabulary, the models we speak of in the following will invariably have the domain .

Herbrand Models

Such models, where the domain contains the constant symbols of the language in use, are called Herbrand models. Thus we not only restrict ourselves to considering exact models in the following, but even to the more narrow class of Herbrand models. Luckily, Herbrand models are enough in a very strong sense. In short, even if we are interested in a model with a fixed number of items of any kind (anything different from constant symbols; say, four human beings) in its domain, there will be an isomorphic model with a domain that instead consists of the same number of constant symbols (say , , and ), and this model will do the same job at satisfying any formulae. We will encounter the concept of a Herbrand model again (and give it a formal definition) in Section 9.1.3.

Listing positive facts.

So we use the vocabulary (asserted to the database, see Section 2.1.1) to represent the domain of all models we want to speak about. Hence all we need to do in order to represent a model is to give an exhaustive listing of all the atomic facts that hold in it. And these facts can all be written as atomic formulae without variables. We can then simply assume all other atomic facts (i.e. all other variable-free atomic formulae licensed by our vocabulary) to be false in the represented model. Besides saying that such a listing of atomic formulae represents a model, we will also say that it specifies that model or call it a (model) specification .

?- Question!

Why don't we allow atomic formulae with variables into model specifications? Hint: Think about how variables are interpreted (see Section 1.2.2).

Now here is an example of how to represent a model in Prolog:

[therapist(john), therapist(mary), moron(peter), moron(anna), love(peter,anna)]

Fairly obviously, this list represents a model in which both John and Mary are therapists, both Peter and Anna are morons, and Peter loves Anna.

Negative facts are implicit

But it is important to be aware that other properties are implicitly recorded. For example:

Thus, given our vocabulary we have completely described a unique exact model over it by explicitly listing positive information and implicitly listing negative information.

?- Question!

Which of the following are correct Prolog model specifications (over the example vocabulary) according to our conventions:

  1. [therapist(john), therapist(mary), moron(peter), moron(anna), hate(peter,anna)]

  2. [therapist(john), therapist(mary), ~moron(peter), moron(anna), love(peter,anna)]

  3. [therapist(john)>therapist(mary), moron(peter), boring(anna), love(peter,anna)]

  4. [therapist(mary), moron(x), moron(anna), love(peter,anna)]

  5. [therapist(mary), moron(mary),love(mary,mary)]

exampleModels.pl: View Download

The file exampleModels.pl contains the representations of some models (over our vocabulary). The models are numbered for easy access.


Aljoscha Burchardt, Stephan Walter, Alexander Koller, Michael Kohlhase, Patrick Blackburn and Johan Bos
Version 1.2.5 (20030212)