Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: John Max Skaller <skaller@ozemail.com.au>
To: caml-list@inria.fr
Cc: Andreas Rossberg <rossberg@ps.uni-sb.de>
Subject: Re: [Caml-list] How to compare recursive types?
Date: Thu, 25 Apr 2002 14:41:44 +1000	[thread overview]
Message-ID: <3CC78908.7050507@ozemail.com.au> (raw)
In-Reply-To: <3CC757B2.7030706@ozemail.com.au>

Argg.. my algorithm is wrong. Here is a counterexample:

typedef x = x * int;
typedef y = (y * int) * int;

If you just unroll these types for a while, they look equal,
but they aren't: in fact y might be considered a subtype of x.
Type x is any cyclic list of n>0 ints.
Type y is any non-empty cyclic list of an *even* number of ints.
Y might be represented in C using

struct y {
  y *next;
  int first;
  int second;
};

Now I *really* need a proper algorithm ..

Felix is extensional: in a product, we normally expand
types, but we can't do that if the type is recursive.

A pointer must be used not only at the fix point,
but at any possible fixpoint of an equivalent
definition...so any strongly connected components
have to be refered to by a pointer I think .. this
would solve the representation problem above
(at least in this case) but the fact remains
that the types above are not equal.

A similar example:

x2 = x * int;
x3 = x2 * int;
...

shows how to construct a type holding 'at least'
a certain number of ints... and my algorithm
also fails to distinguish these types.
Here., the representations would be different ..
there is no recursion in the 'top' part of the type,
so an expanded struct would be used ..

Hmmm.. does it show one type is a subtype
of the other .. hmmm .. perhaps it shows that
there exists a type  which both types are
subtypes of .. that sounds right ..


-- 
John Max Skaller, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850




-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2002-04-25  4:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-17  9:49 [Caml-list] Polymorphic variants John Max Skaller
2002-04-17 10:43 ` Remi VANICAT
2002-04-17 23:49   ` John Max Skaller
2002-04-18  1:23     ` Jacques Garrigue
2002-04-18  9:04       ` John Max Skaller
2002-04-24  6:55   ` [Caml-list] How to compare recursive types? John Max Skaller
2002-04-24  9:07     ` Andreas Rossberg
2002-04-24  9:26       ` Haruo Hosoya
2002-04-24 13:14       ` John Max Skaller
2002-04-24 15:04         ` Andreas Rossberg
2002-04-25  1:11           ` John Max Skaller
2002-04-25  4:41             ` John Max Skaller [this message]
2002-04-25  7:03               ` [Caml-list] How to compare recursive types? Solution! John Max Skaller
2002-04-25 13:31                 ` Jerome Vouillon
2002-04-27  4:11                   ` John Max Skaller
2002-04-25  8:54             ` [Caml-list] How to compare recursive types? Andreas Rossberg
2002-04-25 13:20     ` Jerome Vouillon
2002-04-27  3:43       ` John Max Skaller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3CC78908.7050507@ozemail.com.au \
    --to=skaller@ozemail.com.au \
    --cc=caml-list@inria.fr \
    --cc=rossberg@ps.uni-sb.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox