Implement the following two operators has and of in such a way that with phrases like: peter has car of john answers to questions such as: Who has What of X
I have this simple program that define two operator: has (that specify who have what) and of (that specifies who owns what)
This is the solution write in a Prolog source file:
:- op(100, xfy, of).
:- op(200, xfx, has).
peter has car of john.
peter has car of mary.
car of john of mary.
As I can read on the official SWI Prolog documentation related to write_canonical() function: http://www.swi-prolog.org/pldoc/man?predicate=write_canonical%2F1
Write Term on the current output stream using standard parenthesized prefix notation (i.e., ignoring operator declarations). Atoms that need quotes are quoted.
So if I launch a Prolog query inside write_canonical() function:
15 ?- write_canonical(peter has car of john).
has(peter,of(car,john))
true.
I obtain how Prolog interprets the natural language form, is it right?
In the previous case it is pretty simple and appear clear that first evaluate the sentence: (car of john) and then evaluate the sentence: peter has (result of previous evaluation)
having the following interpretation: peter has (car of john)
Ok, this is clear...now we come to my question.
If I do:
16 ?- write_canonical(peter has car of john of mary).
has(peter,of(car,of(john,mary)))
true.
How can I interpret it in natural language? (if that makes any sense in natural language)
At the beginning I I had initially interpreted as the car belongs booth to john and to mary...so I have try to introduce the fact 3 facts of the previous example but if in the Prolog shell I try to execute:
10 ?- peter has car of john of mary.
false.
This appear false.
What is the correct interpretation in natural language?