caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <frisch@clipper.ens.fr>
To: John Max Skaller <skaller@ozemail.com.au>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] equi-recursive Fold isomorphism
Date: Sat, 27 Jul 2002 21:43:09 +0200 (MET DST)	[thread overview]
Message-ID: <Pine.SOL.4.44.0207272131260.18652-100000@clipper.ens.fr> (raw)
In-Reply-To: <3D42D920.2020800@ozemail.com.au>

Hello,

On Sun, 28 Jul 2002, John Max Skaller wrote:

> Given a recursive type
>
>     Fix 'a .  T  (where 'a occurs in T)
>
> we can unfold the type to T' = T['a -> Fix 'a.T],
> we define unfold t = t, if t doesn't start with a fixpoint operator.
>
> Any ideas how to best implement fold, the inverse isomorphism?
>
> Brute force method: examine every subterm, and compare with
> the main term using equi-recusive comparison .. this seems quadratic
> in the number of nodes .. smarter method: only compare arguments
> of fixpoint binders .. can we do any better?

You can keep in each node of the term a hash value for the
corresponding subterm; this hash value should be invariant by
folding/unfolding (you can for instance look at a fixed depth to
compute this hash value and unfold when necessary). These hash values
avoid most equi-recursive comparisons (and elegate most of the
remaining ones).

My Recursive module uses the same technique; it may do what you want:
http://www.eleves.ens.fr:8080/home/frisch/soft#recursive

It helps manipulating recursive structures (and recursive types was
indeed the main motivation) with maximal sharing and unique representation
(that is: two terms that have the same infinite unfolding will
be represented by the same value). You can also have a look at
the following papers, which describe another solution:

[1] Improving the Representation of Infinite Trees to Deal with Sets of Trees,
    Laurent Mauborgne;
    http://www.di.ens.fr/~mauborgn/publi/esop00.ps.gz

[2] Efficient Hash-Consing of Recursive Types, Jeffrey Considine;
    http://www.cs.bu.edu/techreports/2000-006-hashconsing-recursive-types.ps.Z



Hope this helps.

Alain

-------------------
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-07-27 19:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-27 17:32 John Max Skaller
2002-07-27 19:43 ` Alain Frisch [this message]
2002-07-28  1:45   ` John Max Skaller
2002-07-28 20:14     ` Alain Frisch
2002-08-01 14:49   ` [Caml-list] Question about distribution John Max Skaller
2002-08-01 15:48     ` Xavier Leroy
2002-08-03 17:34     ` Daniel de Rauglaudre

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=Pine.SOL.4.44.0207272131260.18652-100000@clipper.ens.fr \
    --to=frisch@clipper.ens.fr \
    --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;
as well as URLs for NNTP newsgroup(s).