From: Andreas Rossberg <rossberg@ps.uni-sb.de>
To: John Max Skaller <skaller@ozemail.com.au>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] How to compare recursive types?
Date: Thu, 25 Apr 2002 10:54:32 +0200 [thread overview]
Message-ID: <3CC7C448.97542B67@ps.uni-sb.de> (raw)
In-Reply-To: <3CC757B2.7030706@ozemail.com.au>
John Max Skaller wrote:
>
> >>>If you add lambdas (under recursion) things get MUCH harder. Last time I
> >>>looked the problem of equivalence of such types under the equi-recursive
> >>>interpretation you seem to imply (i.e. recursion is `transparent') was
> >>>believed to be undecidable.
> >>>
> >>In the first instance, the client will have to apply type functions
> >>to create types ..
> >
> >I don't understand what you mean.
>
> Like C++ tempates.
>
> all (x:type) type list = Empty | x * list x;
But that's not the point. You do the same in ML. Still, if you allow
arbitrary (probably higher-order) type declarations of the above form to
be mutually recursive, it is unknown whether you can still decide type
equivalence.
> so the compiler doesn't have to deal directly with the type functions,
> other than to apply them to create instance types.
It has, because reduction of an application of a recursive type function
may yield new redexes. In general, this procedure does not terminate.
Using non-uniform recursion you can create type terms that correspond to
irrational trees.
> >OCaml avoids the problem by requiring uniform recursion for structural
> >types, so that all lambdas can be lifted out of the recursion.
>
> Ah. I see... you don't happen to have any references to online
> material explaining that?
Not really, but the OCaml sources are relatively readable :-)
> .. let me guess, the fixpoints aren't allowed
> inside the lambdas .. ok .. I have a picture of it in my head ..
Not sure what you call "the fixpoints" (in your sources you called the
actual fixpoint construct "Bind" and used "Fix" for recursive refs).
Using the correct terminology the restriction is that lambdas are not
allowed under fixpoints.
> >Still, ordinary graph traversal seems the more appropriate approach to
> >me: represent types as cyclic graphs and check whether the reachable
> >subgraphs are equivalent.
> >
> Yeah .. well .. that's what my algorithm is doing ..
> I just need a better algorithm :-)
Why not use standard graph algorithms then?
> 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.
Huh? These types ARE equal: they both have the same infinite unrolling.
The rational trees representing them are equal in the theories I know of
- speaking of even or odd does not make any sense for infinite counts.
--
Andreas Rossberg, rossberg@ps.uni-sb.de
"Computer games don't affect kids; I mean if Pac Man affected us
as kids, we would all be running around in darkened rooms, munching
magic pills, and listening to repetitive electronic music."
- Kristian Wilson, Nintendo Inc.
-------------------
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
next prev parent reply other threads:[~2002-04-25 8:53 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
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 ` Andreas Rossberg [this message]
2002-04-25 13:20 ` [Caml-list] How to compare recursive types? 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=3CC7C448.97542B67@ps.uni-sb.de \
--to=rossberg@ps.uni-sb.de \
--cc=caml-list@inria.fr \
--cc=skaller@ozemail.com.au \
/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