[Haskell-cafe] Re: Set Operations In Haskell's Type System

John Creighton johns243a at gmail.com
Fri May 7 02:25:33 EDT 2010



On May 6, 4:30 am, Bartek Ćwikłowski <paczesi... at gmail.com> wrote:
> hello,
>
> 2010/5/6 John Creighton <johns2... at gmail.com>:
>
> > "a" isa "d" if their exists a "b" and "c" such that the following
> > conditions hold:
>
> > "a" isa subset of "b",
> > "b" isa "c"
> > "c" is a subset of "d"
>
> This definition doesn't make sense - it's recursive, but there's no
> base case, unless this is some kind of co-recursion.
>
> Are you sure that "subset" isn't what you really want? With subset you
> can already ask questions such as "is tabby cat an animal?". If so, my
> code (from hpaste) already has this (iirc isDescendentOf ).

When I succeed in implementing it I'll show you the result. Anyway,
some perspective (perhaps), I once asked, "what is the difference
between a subset and an element of a set:

http://www.n-n-a.com/science/about33342-0-asc-0.html

It sounds like a strange question but is a cat a subset of noun? Cat
is relay just a word or a label, we could be referring to the word
Cat, The set of all Cats or a particular cat. If by Nouns we mean
physical things then the set of cats is a subset of the set of things
that are nouns. However, if by noun we mean a type of word, then cat
is not a type or word but noun is a type of word. From the perspective
of programing the latter observation seems more useful. It involves
some context in that we wish to treat word types and instances of
those word types differently rather then trying to fit them into some
homogeneous hierarchy.

For instance if we are building grammar parsing rules then we probably
only care what type or word or phrase something is and any
hierarchical relationship beyond that are not relevant to the context
of parsing. Now if our goal is only to parse then perhaps their is a
better approach but object oriented programing has shown how subclass
polymorphism adds some level of abstraction and helps to make code
more generic. Haskel's type system allows for even more generic
approaches.

To summarize, I have chosen to define isa as a relationship between
hierarchies, while subset/superset are our standard heiercrical view
of the world (e.g. animal kingdom). Now with regards to my definition,
let's go further. Let's create an equivalence between a noun phrase of
length one and a Noun.

http://en.wikipedia.org/wiki/Noun_phrase

while we may wish to view the noun as primitive, with regards to
meaning the phrase narrows the scope of the noun.

For instance big cat, means that cat can no longer refer to all cats
but the cats must be big.

Now if we want to know if "big cat" is a noun, it is enough to know
that, "big cat" is a subset of cat, cat is a common noun, and common
noun is a subset of noun. (I'm aware some may object to big cat being
a noun but big cat is a thing and a noun is a thing).


This keeps us from directly having to program a direct relationship
between "big cat" and noun. One of the goals of AI is to minimize what
we have to tell our system in order to solve a problem. This is
referred to as the A to I ratio. Generic programing has this
characteristic in that our code is widely applicable. The isa rule
above makes code more generic in that we are now able to write
functions four nouns which will apply to say "big cat" with out even
having to tell our program that "big cat" is a noun, rather it can
directly infer it from the rules we supplied.

----------------------
note 1) Okay I'm aware some will argue my definitions here and if it
helps I could choose new words, the only question really is, is the
relationship isa which I described a useful abstraction. I think it is
and weather it is or not would of course depend on if it reduces the
amount of code that needs to be written and it produces the correct
results. We could create other relationships which embody what other
people think a useful isa function should do and they could be used
either in parallel with my relationship or with a completely different
approach. I cannot say weather such alternative relationships will be
more or less useful.

note2 ) For the purpose of the above I guess we can define Noun to be
a noun phrase of length one (we can choose a different word if someone
prefers to call this instead of a noun.),

note 3) Anyway, with regards to the above I am using subset with
regards to scope (the number of _____ something can refer to) and isa
with regards to type of scope. So noun says the scope refers to a
person place or thing and then, the noun (or noun phrase) limits the
scope of these things that the phrase/noun can refer to. This is
perhaps not the standard English/linguistic usage and I am sure their
are many reasonable objections to the above on semantic grounds. I am
not interested in a debate on semantics but will listen to suggestions
for alternative terms/definitions.


More information about the Haskell-Cafe mailing list