1
votes

I am studying DCG grammars and parse trees in Prolog using Ivan Bratko's Programming for Artificial Intelligence. In a program that uses a DCG grammar to extrapolate the meaning of a sentence, I find these two predicates that, I think, represent a kind of semantic knowledge:

properName(john) --> [john].
properName(mary) --> [mary].

How should I read these predicates? I am thinking that they mean: it is true that an element of a list represented by the string "john" is a proper name and this proper name is John (same thing for Mary).

Is it my reading correct or are there some other implications?

2
The grammar from the book doesn't seem to be online (e.g,. a Google Books preview), but more of the grammar is shown in this question, for those who are interested.Joshua Taylor

2 Answers

2
votes

This is a trivial predicate that does not lend itself to interpretation outside of the context in which it is used.

In other words, it can only be used to demand that a proper name is used in a certain way, by a DCG rule that uses it on its right-hand side. The way you have shown it, in isolation, it means nothing more than:

'john' is a proper name, and so is 'mary'.

EDIT

I might be wrong here, but you are still abusing the English language to describe things that are best described using a formal language. Prolog is a formal language, with a defined syntax and semantics. It can be used to formally describe logical relationships, or computation. Trying to faithfully translate it into English is bound to be clumsy and unnecessary. Something as trivial as the predicate in your question turns into something that is silly, difficult to understand, and difficult to work with.

P.S. The correct spelling of the word you like so much is representation. http://machaut.uchicago.edu/?resource=Webster%27s&word=representation&use1913=on

2
votes

properName(X) is just an unary rule (in the context of DCG; it is a ternary predicate in Prolog - check it out with ?- listing(properName) ). you could've called it "socks", or "jam", it's totally up to you. So the semantic knowledge about it representing proper name "john" or "mary" is nowhere to be found in the code (it uses naming as self-documenting feature, but documentation is not code).

The predicate allows for an atom john or mary to be present in the input stream, and nothing else; and demands that X unified with that atom.

You could've defined it thus:

name(X) --> [X], { member(X, [john, mary]) }.

then,

4 ?- phrase( name(X), [john,jack], Z).
X = john,
Z = [jack] ;
false.

5 ?- phrase( name(X), [jack,john], Z).
false.

8 ?- phrase( name(X), [john,mary], Z).
X = john,
Z = [mary] ;
false.

9 ?- phrase( name(X), [mary,john,jack], Z).
X = mary,
Z = [john, jack].

11 ?- phrase( name(jack), [jack,mary,john], Z).
false.