Re: Storing data and code in a Db with LISP-like interface

From: Neo <neo55592_at_hotmail.com>
Date: 24 Apr 2006 13:52:41 -0700
Message-ID: <1145911961.911737.316310_at_g10g2000cwb.googlegroups.com>


Nick, I looked over the initial Prolog solution in more detail and had some questions and comments. In general, it seems to have modelled some revelant data and performed the queries. And I am not too concerned about syntax or verboseness of a solution and whether functions have to be written to process the data.

> likes (john,fruit, X) :- fruit (X).
> likes (john,vegetable, X) :- vegetable (X).

It appears you defined functions which create a relationship between three things where the third is the function's parameter.

> fruit (apple).
> fruit (tomato).

So this stores the relationships:
likes (john, fruit, apple)
likes (john, fruit, tomato)

Question, how does Prolog know that john likes apple -vs- john likes fruit -vs- john likes fruit and apple? How does Prolog know that apple is a fruit? In the dbd (exp db / db for dummies) example, john likes apple1 which is an entry (in food contest) and a fruit.

> vegetable (broccoli).
> vegetable (tomato).

So this stores the relationships:
likes (john, vegetable, broccoli)
likes (john, vegetable, tomato)

Similar questions to above. And how does Prolog know that tomato is both a fruit and vegetable? In dbd example, tomato1 isa entry, isa fruit and isa vegetable?

> likes (john, leftover).

:) This one needs no explanation, john likes leftover. Note in dbd, leftOver1 is an entry.

> // find a fruit that john likes
> ?- likes(john, fruit, Y)
> reply Y = apple

How did Prolog know that apple is a fruit?

> // find a vegetable that john likes
> ?- likes(john, vegetable, Y)
> reply Y = broccoli

Same type of question, how did Prolog know that broccoli is a vegetable?

> // does john like broccoli?
> ?- likes(john, _, broccoli)
> reply true.

OK (kind of). So Prolog assumes that param1 likes the remaining parameters?

> // does john like any vegetable?
> ?- likes(john, vegetable, _)
> reply true.

OK, but the dbd example does not model that john likes vegetable (which is a type/class) or all vegetables.

> // is tomato a vegetable?
> ?- vegetable(tomato).
> reply true.

Prolog orginally stored: likes (john, vegetable, tomato) Thus, if tomato is a vegetable, then is vegetable a john? Or does the isa relationship only apply between the last and 2nd to last parameters? And what if the function had four parameters?

While the initial Prolog solution did model some revelant data, it appears to have left out other (see list below). If you would like to update it, that is fine, but you don't have to. You could leave it the way it is and see how it handles things as I extending this example to further evaluate flexibility.

Things modelled in Food Judge Example implemented with dbd.

1) person, entry, fruit, vegetable are types/classes.
2) John is a person.
3) like is a verb. (the verb class already existed in db)
4) apple1 is a entry/fruit.
5) broccoli1 is a entry/vegetable.
6) tomato1 is a entry/fruit/vegetable.
7) leftOver1 is an entry.

Also I will be posting an updated Food Judge Example as it was a quickie and not fully commented. Received on Mon Apr 24 2006 - 22:52:41 CEST

Original text of this message