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

From: Neo <neo55592_at_hotmail.com>
Date: 25 Apr 2006 20:34:49 -0700
Message-ID: <1146022489.034934.291140_at_v46g2000cwv.googlegroups.com>


> --------------------
> person(john).
> judge(john).
> fruit(apple1).
> fruit(tomato1).
> vegetable(tomato1).
> vegetable(broccoli1).
> likes(john, leftover1).
> likes(john, apple1).
> likes(john, tomato1).
>
> thing(X):-vegetable(X).
> thing(X):-fruit(X).
> ----------------------

mAsterdam, you surprise me! You also have Prolog running thru your veins! How many other Prologers are hiding amongst us?

> You really should play a little with prolog:

Yes, Prolog does look very interesting (and compact). I am sure I could learn a lot from it, especially it terms of logical processing; however for now I am focused on developing the most general/flexible method of representing things. Let us see if Prolog is further along than I am with comming example extensions :)

> person(john)

If "likes (john, apple1)" implies "john likes apple1" why isn't "john isa person" written as "isa (john, person)" or is "person (john)" an alternate/equivalent method? If so, what is or how does one determine the name of the relationship via code?

If "isa (john, person)" and "instance (person, john)" are possible, can I relate isa and instance?
Can I write "opposite (isa, instance)" and "opposite (instance, isa)"? Can functions be parameters of other functions?

> thing(X):-vegetable(X).

Based on my limited knowledge of Prolog, it is not clear if vegetable isa thing. What does the following return?

?- thing(vegetable).

> 3 ?- likes(john, What).

Ok, I see "What" is like a variable that can hold many things. The "What" is similar to the "*" in dbd and SQL.

How do I express the following query in Prolog: Find a person who likes a fruit and a vegetable. (Assume there are more persons).
For example in dbd, it would be:

(and (select person instance *)

        (select * like (and (select vegetable instance *)
                                     (select fruit instance *)
                             )
        )

)

If you (or someone) can update the Prolog example and bring it closer to dbd's, that would be great (so we can extend them later):

1) add missing entry classification.
2) add instance relationship between various things.
3) create relationship between instance and isa as in "isa opposite
instance" and "instance opposite isa". Note: the dbd script doesn't show this since it is already created in each new db, however I can perform queries to show the relationship exists. 4) classify likes as a verb.
5) add the missing queries, if possible.

In later example extensions, I'd like to address: Can one add attributes to "likes" in Prolog? Can one add a synonym for "likes"?
Can Prolog handle a thing with multiple name? For example, can I name the judge both john and johnathan? Can Prolog handle two persons named john but with different SS#? Can Prolog handle a person without a name but a SS#? Can Prolog handle the same things in multiple hierarchies? Are things normalized? Received on Wed Apr 26 2006 - 05:34:49 CEST

Original text of this message