Linguistics 482 - Computational Linguistics Prolog Notes A. C. Brett acbrett@uvic.ca
Department of Linguistics
University of Victoria
Clearihue C139
Last updated: 20 October 2002

Facts

Facts are the sentence-like constructs of the Prolog language that consist of just a structure, followed by the period that ends all Prolog clauses.

In a Prolog program that causes the Listener to function as a recogniser or parser of the sentences of a natural language, facts are often used to encode the lexicon of the natural language. The following lines illustrate facts that might be employed for this purpose:

   det(those).                       % DET --> those
   det(this, sg).                    % DET[SG] --> this
   det(these, pl).                   % DET[PL] --> these
   word(the, det, _).                % DET[.] --> the
   lex(them, pro, agr(3, pl, acc)).  % PRO[AGR:<3,PL,ACC>] --> them 
As the comments show, the foregoing facts translate lexical rewrite rule into Prolog. In all these examples, the lexical item has been recorded as an argument of the structure that constitutes the fact. In the first three examples, the category of the lexical item has been used as the structure name.

Note that, in all the examples, atoms have been used to represent the lexical category label as well as the lexical item. Although, as illustrated in the comments, upper case letters are normally used to represent category labels, sequences of characters that begin with an upper case letter is treated as variables in Prolog. Hence, sequences of characters beginning with lower case letters must be used for the category labels, as well as for data values such as the lexical items themselves and also the features values that have been recorded.

Note also that, although the facts in the first three examples all have the same name, the first has only one argument, while the second and third have two. Hence, the first example represents a different structure from the next two. It can be said to be an instance of a det/1 predicate, where the number 1 in det/1 is the number of arguments of the structure with the name det. This number is identified as the arity of the structure, and of the predicate. Since they have the same name and the same arity, the second and third example constitute two instances of a det/2 predicate.

The fourth and fifth examples above represent clauses of word/3 and lex/3 predicates, respectively. In both of these facts, the category labels of the lexical items to which they correspond are recorded as arguments. The structure names, and hence the names of the two predicates, are arbitrary, albeit meaningful.

Linguistics 482 Prolog Introductory Notes Top of Page