Re: Storing data and code in a Db with LISP-like interface
Date: Fri, 28 Apr 2006 00:34:24 +0200
Message-ID: <445146b0$0$31656$e4fe514c_at_news.xs4all.nl>
Neo wrote:
>>...
>
> For example in dbd, it is possible for the app to determine the name of
> that relationship between john and person. A relationship is just
> another thing that is represented in the db.
It depends on your information need.
What do you want to know about the relationship?
Which questions are you going to ask about it?
> 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?
What do the answers to both queries tell me?
I apologize for replying to your questions with other questions. I think that in order to be able to come up with a more definite answer, I need a better sense of the purpose of the questions.
>>>If "isa (john, person)" and "instance (person, john)" are possible, >>>can I relate isa and instance? >> >>In several ways.
>
> I have doubts that Prolog can.
If you are not going to try you will keep them.
>>>Can I write "opposite (isa, instance)" and "opposite (instance, isa)"? >> >>Not sure what you mean here.
>
>
> Basically this is the same question as the prior one. Can functions be
> treated the same as function parameters. Assume following in Prolog:
>
> class (john, person) implying john's class is person.
> instance (person, john) implying person's instance in john.
>
> Now can I do the following:
> reciprocal (class, instance)
> reciprocal (instance, class)
>
> See next dbd example doing the above with verbs like and likedBy.
>
>
>>>Can functions be parameters of other functions? >> >>Yes, second order logic is possible.
>
>
> I meant the function itself, not the function's results as show above
> by reciprocal (instance, class).
>
>
>>>>thing(X):-vegetable(X). >>> >>>Based on my limited knowledge of Prolog, >>>it is not clear if vegetable isa thing. >> >>Not according to this clause. This clause could read as: >>If X is a vegetable, it is a thing.
>
>
> Then the Prolog example is not representing the same things (including
> relationships which are also things in dbd). When displayed as a
> hierarchy, the dbd's class/instance hierarchy would be:
>
> thing
> -instance-
> fruit
> -instance-
> tomato1
> vegetable
> -instance-
> tomato1
>
> Where as Prolog's would be:
No, not Prolog's, just neof.pro's (as interpreted by prolog).
> thing
> -instance-
There was no mention of instance in neof.pro, because it was (and is) not clear to me how (and what of) "instance" is needed and how it is part of the universe of discourse.
> tomato1
That tomato1 is a thing was not given as a ground fact, but inferred. Does that matter?
> fruit
> -instance-
> tomato1
> vegetable
> -instance-
> tomato1
>
> The difference being, fruit and vegetables are not classied as things.
Catagories as things - do you need that?
> An app could not determine this based on things represented.
Which is not at all surprising because these categories weren't represented as things.
Why do you think it is noteworthy?
>>>isa thing. What does the following return? >>>?- thing(vegetable). >> >>I would expect prolog to return "No".
>
>
> And I would too since it did not represent that vegetable is a thing as
> in the dbd example.
add "
thing(vegetable).
"
to your program/database and find out. I see no need.
>>>How do I express the following query in Prolog: >>>Find a person who likes a fruit and a vegetable. >>>(and (select person instance *) >>> (select * like (and (select vegetable instance *) >>> (select fruit instance *)))) >> >>?- person(P), likes(P, F), likes(P, V), fruit(F), vegetable(V).
>
>
> I actually expressed what I meant more clearly in the query then in
> english which was ambigious :( I meant find a person who likes
> something that is both a vegetable and a fruit.
?- person(P), likes(P, Thing), likes(P, Thing), fruit(Thing), vegetable(Thing).
P = john
Thing = tomato1 ;
No
>>>Can one add attributes to "likes" in Prolog? >> >>Did you try?
>
>
> No I did not. Believe or not developing/implementing a data model more
> general/flexible than RM takes up a bit of time, so I am going to rely
BTW flexibility in general is IMO not something to aim for.
> on user who know more than I can gather by briefly browsing over Prolog
> manuals :)
Give it a few hours. Download some prolog and play with just neof.pro and some queries. I really think you will not regret that. I am not claiming prolog is the perfect tool for you, but I do think playing with it would give you some interesting perspectives on your quest.
>>>If you (or someone) can update the Prolog example and bring it closer
>
>
> I'll be posting a new extension of the example (Food Judge Example C)
> shortly.
>
Received on Fri Apr 28 2006 - 00:34:24 CEST