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

From: x <x_at_not-exists.org>
Date: Wed, 19 Apr 2006 10:17:22 +0300
Message-ID: <e24o4e$fuk$1_at_emma.aioe.org>


"Nick Malik [Microsoft]" <nickmalik_at_hotmail.nospam.com> wrote in message news:1cGdnfANts6ZSdjZRVn-ig_at_comcast.com...
> "Neo" <neo55592_at_hotmail.com> wrote in message
> news:1145298018.123938.13480_at_i39g2000cwa.googlegroups.com...
> >> ... calling one of us an idiot. Not sure who. :-)
> >
> > Well if you don't want the compliment, I'll take it :)
>
> LOL
> >
> >> Prolog is not an inherently type-safe language ...
> >
> > This is slightly off-topic, but I am curious about your view:

> These are good questions, but I'm not sure if you are asking me about my
> views on relational data management or on logical rules management. The
> difference is simple. Relational describes relationships like 'is a' and
> 'has a' and 'is defined by' while logical rules management simply states
> 'the relationship is what you define it to be'.

> It has been well over a decade since I wrote Prolog code, so if someone
> reading this newsgroup knows Prolog and they see this, my sincere
apologies.
> The concept is what I'm trying to convey.

Your Prolog is fine. I also wrote Prolog code 10 years ago (from 1991).

> I will answer your questions with statements that are (or resemble)
Prolog.

> >
> > 1) What is the proper name of the relationship between person and John,
> > person and Mary, fruit and apple, fruit and banana, etc. Ie, fill the
> > verb in: person ____ john.
>
> named_instance(john,person).
> named_instance(mary,person).
> subtype(apple,fruit).
> subtype(banana,fruit).
>
>
> >
> > 2) What is the proper name of the reverse relationship between John and
> > person, Mary and person, apple and fruit, banana and fruit, etc. Ie,
> > fill the verb in: john ___ person.

> ? named_instance(john, A )

> (to which the system responds)
> A = person
>
> (I skipped your question. The answer to the logic of your question is: I
> would consider john to be a named instance of the noun 'person').
>
> >
> > 3) Just as John and Mary "are" persons, and apple and banana "are"
> > fruits, what are person and fruit?
>
> person is a noun. fruit is a noun. In Prolog, they are atoms. They have
> no 'meaning' except as defined by their relationship with john and banana.
> (You will notice that I use lower case, even for proper names. In Prolog,
> lower case tokens are 'atoms' while a token that begins with a capital
> letter is a variable).
>
> >
> > 4) Supposing the answer to question 3 is xyz, what is the proper name
> > of the relationship between xyz and person, xyz and fruit, etc?
>
> not a sensible question in Prolog context. There is no notion of subtype
or
> supertype. Only expression. Imagine that we are talking about Boolean
> logic. A or B. Is A a variable? If we say "A is a B and B is a C,
> therefore A is a C," we have defined the transitive property of 'is a'.
> Before making the statement, the verb 'is a' had no such property. The
> scope of this property may be quite limited. Prolog assumes this. Most
> data management languages have a great many meta-rules. Prolog does too,
> but they are not based on the data. They are, instead, based on the
logic.
>
> >
> > 5) Supposing the answer to question 3 is xyz, what is the proper name
> > of the reverse relationship between person and xyz, fruit and xyz, etc?
> >
>
> See above.
>
>
> Let's say, in Prolog, you want to express the transitive nature of
> 'contains'. It could look like this:
>
> contains(A, B) :- contains(A, X), contains(X, B).
>
> Now let's establish some facts.
>
> contains(cup, coin).
> contains(bucket, cup).
> contains(box, bucket).
> contains(truck, box).
> contains(ship, truck).
>
> We are saying that the coin is in the cup is in the bucket is in the box
is
> in the truck is in the ship.
>
> Now, ask the question: is the coin in the truck?
>
> ? contains(truck, coin)
>
> to which the system responds:
> yes.
> (or 'true.' Not sure anymore ;-).

> It does it by comparing the predicate contains/2 to each of the rules in
the
> system. There are six matching rules. One is an expression. The rest
are
> facts. The comparison doesn't match one of the facts, so the expression
is
> invoked. The expression says: any item is inside another item if you can
> find an intermediary where the item is in the intermediary and the
> intermediary is in the other item... RECURSIVE. Using a depth-first
search,
> the system quickly finds that the coin is in a cup where a cup is in a
> bucket where a bucket is in a box where a box is in a truck, therefore the
> coin is in the truck.

> The entire program is in this post. There is nothing else.

Your post is fine.
Except Codd gone well beyond this with relations and databases. :-) Received on Wed Apr 19 2006 - 09:17:22 CEST

Original text of this message