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

From: Nick Malik [Microsoft] <nickmalik_at_hotmail.nospam.com>
Date: Sat, 22 Apr 2006 10:11:59 -0700
Message-ID: <86qdnTjN37xb_9fZnZ2dnUVZ_sKdnZ2d_at_comcast.com>


> Now, suppose I wanted to classify an actual tomato (tomato1) as both a
> fruit and a vegetable, where would I add it to the above "class
> hierarchy"? (You don't need to show me actual Prolog, just adjust above
> tree)
>

Prolog is a graph, not a tree. To illustrate it as a tree misses the point. Humans <categorize> in trees, but our brains <think> in graphs. We freely associate things as they need to be, with relationships that cannot be categorized with a single taxonomy. Multiple overlapping taxonomies are required. Prolog simply removes the requirement for a single taxonomy.

To solve the problem I posed, I placed the entire prolog program below, with the two facts you provided (Tomato is both a fruit and a vegetable).

You could just as easily have asked "Why the Tomato is both a fruit and a vegetable," and with the addition of attributes and decision criteria, you could have the Prolog app reply that a Tomato is, in fact, both but that an Apple is both a fruit and a computer. :-) If you tell me what you would consider those criteria to be, I'll be happy to update the app to reflect.

Note: the verb 'named instance' and 'subtype' are invented. I invented them for this example. They could just as easily have been 'foo' and 'bar'.

named_instance(john,person).
named_instance(mary,person).

subtype(apple,fruit).
subtype(banana,fruit).
subtype(tomato, fruit).
subtype(tomato, vegetable).


-- 
--- Nick Malik [Microsoft]
    MCSD, CFPS, Certified Scrummaster
    http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not 
representative of my employer.
   I do not answer questions on behalf of my employer.  I'm just a 
programmer helping programmers.
Received on Sat Apr 22 2006 - 19:11:59 CEST

Original text of this message