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

From: mAsterdam <mAsterdam_at_vrijdag.org>
Date: Wed, 26 Apr 2006 21:15:22 +0200
Message-ID: <444fc6a8$0$31645$e4fe514c_at_news.xs4all.nl>


Marshall Spight wrote:
> Neo wrote:
>

>>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?

>
>
> I think you are correct that "person(john)" is the canonical
> way to specify that john satisfies the predicate "person."
>
> However, I am unclear what this word "isa" you are always
> using means. The only "isa" that I know of has been completely
> replaced with "pci".

I took it to mean short for "is a".

>>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 *)
>>                             )
>>        )
>>)

>
>
> Even my lame prolog skills are up to that question. Especially
> since mAsterdam did all the typing already. Hmmm. SWI-Prolog
> comes from ... Amsterdam? Hmmm.
>
> "Find X where X is a person, X likes V, V is a vegetable,
> X likes F, and F is a fruit."
>
> bash-3.1$ pl
> Welcome to SWI-Prolog (Multi-threaded, Version 5.2.6)
> Copyright (c) 1990-2003 University of Amsterdam.
> SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
> and you are welcome to redistribute it under certain conditions.
> Please visit http://www.swi-prolog.org for details.
>
> For help, use ?- help(Topic). or ?- apropos(Word).
>
> ?- consult('neo.pro').
> % neo.pro compiled 0.00 sec, 2,104 bytes
>
> Yes
> ?- person(X),likes(X,V),vegetable(V),likes(X,F),fruit(F).
>
> X = john
> V = tomato1
> F = apple1 ;
>
> X = john
> V = tomato1
> F = tomato1 ;
>
> No
> ?-

My prolog skills are as lame as yours - we even came up with allmost the same query-formulation :-)

> Amusingly, since we have specified that the tomato is both
> a fruit and a vegetable, anyone who likes tomatoes will qualify,
> as we see above. However, the reader is strongly cautioned!
> The tomato is *not* a vegetable!

Sadly now both our prolog systems think it /is/.

> To me, perhaps the most interesting thing about prolog is the
> trivial ease with which one can write the ancestor query,
> which causes such consternation for SQL.
>
>
> Marshall
>
Received on Wed Apr 26 2006 - 21:15:22 CEST

Original text of this message