0
votes

I was reading Learn Prolog Now! and I'm confused about their use of logic and I was hoping someone can clarify the ambiguity of arguments in rules.

For example, on Chapter 1, knowledge base 4 they reference the following rule:

loves(vincent,mia).

They then provide a query:

loves(marsellus,X), woman(X).

and then the make the English statement:

"Now, remember that , means "and", so this query says: is there any individual X such that Marsellus loves X and X is a woman ?"

The key word being, Marsellus loves X.

This is worded in a way that makes me think there is some "logic" tied to the arrangement of arguments, such as to say,

Is it true that loves(vincent,mia). "logically" means:

  1. vincent loves mia?

BUT is it false that

  1. mia loves vincent?

That's what I originally thought but then on Chapter 3, example 2: Descendant they have the following example of:

child(bridget,caroline).

Then the English statement: "That is, Caroline is a child of Bridget"

But if #1 above is true (vincent loves mia), then shouldn't this be read as Bridget is a child of Caroline?

Or does the order of arguments not matter and it's your additional programming that will determine the logic of the arguments?

2
A predicate r(a,b) means that (a,b) is in the relation r:A->B. Nothing more is implied. So everything depends on how you define the relation r. - 2bigpigs

2 Answers

3
votes

loves(X, Y) intuitively would mean X loves Y but not Y loves X. But as a programmer, you could assume it's symmetrical. It just wouldn't be as intuitive. It just depends upon how you choose to define it. Prolog Now chose the most intuitive meaning, so loves(X, Y) means X loves Y, but not Y loves X.

Whether child(X, Y) means X is a child of Y or Y is a child of X is up to the programmer. child used by itself as the name of the fact/predicate in this context is a bit ambiguous here (it's not a verb and isn't part of a phrase) and you just have to roll with whatever the Prolog Now site chose as their meaning. When you view the functor as a verb, the arguments are interpreted left to right as expected. So, better, would be to use child_of(X, Y) to mean X is a child of Y so that it's clearer.

0
votes

Prolog as a language wouldn't care whether you define love(X,Y) as X loves Y or Y loves X. It's probably just a convention that we tend to follow in first order logic. As to why we'd choose the ordering convention we usually follow, It's probably because the predicate defines a relation between two terms. So the order would depend on how you define the relation.

A predicate r(a,b) means that (a,b) is in the relation r:A->B.

The way i would clear my doubts of the case you've given in the question is:

loves(a,?) ? should anything which a loves. And child(a,?) ? should be anything which is a child of a.

It would depend on how you define the relation 'child'.

As far as i know ( which isn't far ), There's no hard rule in logic that stops you from defining predicates the way you want. You could define love(X,Y) as 'X loves Y' or 'X is loved by Y' as long as you're consistent.