Re: Storing data and code in a Db with LISP-like interface
Date: Fri, 28 Apr 2006 10:36:52 +0200
Message-ID: <4451d410$0$31644$e4fe514c_at_news.xs4all.nl>
Neo wrote:
[snip agreement]
>
> Ok, I didn't expect someone familiar with RM/RMDBs/SQL to have such
> difficulties with 'create'.
Some of my difficulties originate from that familiarity. DML's 'insert' would be more innocent-looking. 'Create' is DDL: it changes the strucure of the database - alarm bells! 'Create' can be viewed as a catalog-insert.
[snip agreement]
>>>>>[ person (john) ] how does one determine the name of the relationship via code? >>> >>>>There is no [way], because I did not provide a name for this relationship. >>> >>>It seems there maybe yet another reason. Prolog may not provide a >>>method to determine the function given one set of parameter already >>>specified. Can some experiences Prologer correct me on this? >> >>Can you make your statement in a way which is more test-friendly?
>
>
> Enter the following relationships in prolog:
> class (john, person). meaning one of john's class is person
> instance (person, john). meaning one of person's instance is john
Are you stating the same fact in two ways or are these two facts?
> Then ask prolog, what is the relationship between john and person; and
> vice versa, what is the relationship between person and john. You can
> replace john, person, class, instance with other things that make more
> sense to you, for instance:
>
> parent (johnny, john). meaning johnny's parent is john
> child (john, johnny). meaning john's child is johnny
This clearly looks like you are stating the same fact in two ways - so I am going to assume that.
To prevent redundant solutions you can have one of them as ground fact, the other one as rule.
--------------neofam.pro part 1
has_parent(johnny, john). % meaning johnny's parent is john
has_parent(johnanna, john). % meaning johanna's parent is john
has_child(Parent, Child) :-
has_parent(Child, Parent). % to infer that e.g. john's
% child is johnny
sibling(S1, S2) :- % bonus :-)
has_parent(S1, P),
has_parent(S2, P),
S1 \= S2.
I had to (for now arbitrarily) choose which one to see as basic and which one as derived. That is a choice often coming up, I don't think it is a prolog-specific one.
> Then when prolog is asked, what is the relationship between john and
> johnny, it should respond similar to "john's son johnny" and vice
> versa.
It would have to know (be told or have the rules to infer) that johnny is male and that male children are sons.
> Here is how to do it in dbd:
>
> (create johnny parent john)
> (create john child johnny)
>
> // Following displays parent.
> (msgbox (& (select verb instance *) (select johnny * john)) )
>
> // Following displays child.
> (msgbox (& (select verb instance *) (select john * johnny)) )
>
> In dbd, one can also represent the relationship between verbs, ie
> parent and child as
>
> (create parent reciprocal child)
> (create child reciprocal parent)
Are these two dbd.things or alternate formulations for one dbd.thing?
> Dbd's Food Judge Example C, relates like and likedBy similar to above,
> thus when using the createWRR (create with reciprocal relationship
> also), and user enters "(createWRR john like tomato1)", db
> automatically creates the reciprocal relationship "(create tomato1
> likedBy john)". There is a query later that uses likedBy to find out
> all the people who like tomato1 via the following query: "(select
> tomato1 likedBy *)". Note the Food Judge Example C is posted in
> response to master Prologer Alvin.
>
>
>>Do we have the same concept of "thing"?
>
>
> Unlikely, my concept of thing is the most general possible.
>
>
>>I have a hard time seeing a category as a thing.
>
>
> Your concept of thing is more limited than mine.
Yep.
>>>A relationship is just another thing that is represented in the dbd. The following displays "class": (msgbox (and (select verb instance *) (select john * person))). And the following display "instance": (msgbox (and (select verb instance *) (select person * john))). How would one do this in Prolog? >> >>Why?
>
>
> So that one can determine the relationship between any two things.
>
>
>>>So that the Prolog solution could answer the questions: what is the >>>relationship between john and person; and what is the relationship >>>between person and john. >> >>I'll re-ask: for what purpose do you need to know it? >>Which information need are you satisfying/preempting whith it? >>This would shed some light on what to record.
>
>
> Imagine an andriod is introduced to a group of humans. The droid is
> told john's girlfriend is sally, sally mom is martha, martha's sister
> is ellen, etc. Later when the droid happens to meet john and sally
> together, it can query the relationship between the two, tailor the
> conversation for them or make better sense of things in context of the
> fact they are related as girlfriend/boyfriend :)
Nice scenery.
--------------neofam.pro part 2
human(john). % not needed for the specifically human(sally). % stated information needs. human(martha). human(ellen).
boy(john).
girl(sally).
has_mom(sally, martha).
has_sister(martha, ellen).
has_boyfriend(sally, john).
has_girlriend(Boy, Girl) :-
girl(Girl),
boy(Boy),
has_boyfriend(Girl, Boy).
--------------------------
?- has_girlfriend(Who1, Who2).
Who1 = john
Who2 = sally ;
No
Could you give a more specific situation where the droid would need "thing", "class", "relationship" or "instance"? Received on Fri Apr 28 2006 - 10:36:52 CEST
