<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/4f9bb8f68563eae0df616c5312061cd5"
  from="Alain Frisch &lt;frisch@c...&gt;"
  author="Alain Frisch"
  date="2002-07-27T19:44:01"
  subject="Re: [Caml-list] equi-recursive Fold isomorphism"
  prev="2002/07/b44d83525a337150d2d807ee742cdfac"
  next="2002/07/34bde6e06ff33a69d44717031e55dca5"
  prev-in-thread="2002/07/b44d83525a337150d2d807ee742cdfac"
  next-in-thread="2002/08/53ed9625fb1f595602c7030ddf5acc8e"
  prev-thread="2002/07/31df5f956e055f23defa7f42b31cd382"
  next-thread="2002/07/0cb29bb0ea374d69ebccf8accd5a096d"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] equi-recursive Fold isomorphism">
<msg 
  url="2002/07/b44d83525a337150d2d807ee742cdfac"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-27T17:32:25"
  subject="[Caml-list] equi-recursive Fold isomorphism">
<msg 
  url="2002/07/4f9bb8f68563eae0df616c5312061cd5"
  from="Alain Frisch &lt;frisch@c...&gt;"
  author="Alain Frisch"
  date="2002-07-27T19:44:01"
  subject="Re: [Caml-list] equi-recursive Fold isomorphism">
<msg 
  url="2002/08/53ed9625fb1f595602c7030ddf5acc8e"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-08-01T14:49:45"
  subject="[Caml-list] Question about distribution">
<msg 
  url="2002/08/214fa7d010269acc80ff246b88085cea"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-08-01T15:48:47"
  subject="Re: [Caml-list] Question about distribution">
</msg>
<msg 
  url="2002/08/3120d6d86c63690a934a6e153bbab64f"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-08-03T17:35:36"
  subject="Re: [Caml-list] Question about distribution">
</msg>
</msg>
<msg 
  url="2002/07/d6cc835c30bdf5961ac017a3513d4c19"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-28T01:46:42"
  subject="Re: [Caml-list] equi-recursive Fold isomorphism">
<msg 
  url="2002/07/0b573ce0f42e95b4d4fbedbd027299d1"
  from="Alain Frisch &lt;frisch@c...&gt;"
  author="Alain Frisch"
  date="2002-07-28T20:15:02"
  subject="Re: [Caml-list] equi-recursive Fold isomorphism">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
Hello,

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

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

</contents>

</message>

