caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pierre Weis <weis@pauillac.inria.fr>
To: Michel.Levy@imag.fr (Michel Levy)
Cc: caml-list@pauillac.inria.fr
Subject: Re: definition recursive de valeur
Date: Fri, 23 Feb 1996 13:19:58 +0100 (MET)	[thread overview]
Message-ID: <199602231219.NAA06135@pauillac.inria.fr> (raw)
In-Reply-To: <v01530503ad5226209225@[129.88.38.40]> from "Michel Levy" at Feb 22, 96 03:16:50 pm


[Franc,ais plus bas]

> Let us define the following infinite values :
> let rec x = 1::x ;;
> let rec y = 1::y;;
> x = y;;
> The evaluation of the last expression doesn't terminate.
> We could consider that the equations above have solutions wich are infinite
> rational trees and there exists a algorithm to test the equality of such
> trees, could it be possible either to use such an algorithm, either to
> refuse to test the equality.

As you may know, Caml offers two polymorphic predicates to compare
values, that is == (physical identity) and = (re'cursive descent into
values to find differences). None of these is the mathematical
equality, except for some basic data types such that integers. In the
library of the Caml V3.1 system, we have a third ``equal''
predicate that ``Compare graphs''. Unfortunately this ``equal''
predicate is hard to implement efficiently, is highly not portable,
and moreover was found not very useful in practice: when people need
such a sophisticated predicate, they need a complex semantic equality,
upto some equivalence relationship, this predicate by no means
correspond to ``equal'', so that they must write the predicate by themselves.

Pierre Weis

[Franc,ais]

> Définissons les deux valeurs infinies suivantes :
> let rec x = 1::x;;
> let rec y = 1::y;;
> x = y;;
> Demandons à vérifier leur égalités : camllight essaie de comparer x et y
> par une méthode qui ne se termine pas.
> Pour les arbres infinis rationnels (cf Prolog) l'égalité est décidable : ne
> serait-il pas possible soit de refuser de comparer x et y, soit d'utiliser
> l'algorithme testant l'égalité de ce type d'arbre.

Comme vous le savez certainement, Caml vous offre 2 pre'dicat
polymorphes pour comparer les valeurs, == l'identite' physique et =
(descente re'cursive dans les valeurs pour trouver des
diffe'rences). Aucun des deux n'est l'egalite' mathe'matique, sauf
pour quelques types de donne'es de base comme les entiers. Dans la
bibliothe`que de Caml V3.1, il y  a un troisie`me pre'dicat ``equal''
qui ``compare les graphes''. Malheureusement ce pre'dicat ``equal''
est difficile a` imple'menter efficacement, est hautement non
portable, et comble de tout pas tre`s utile en pratique: quand on a
besoin d'un pre'dicat aussi sophistique', l'expe'rience prouve qu'on a
besoin en fait d'une e'galite' se'mantique complexe (modulo
e'quivalence) qui ne correspond pas non plus a` ``equal'', et on est
force' de l'e'crire soi-me^me.

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis







  reply	other threads:[~1996-02-23 12:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-02-22 14:16 Michel Levy
1996-02-23 12:19 ` Pierre Weis [this message]
1996-03-05 21:34 Kip Rugger

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=199602231219.NAA06135@pauillac.inria.fr \
    --to=weis@pauillac.inria.fr \
    --cc=Michel.Levy@imag.fr \
    --cc=caml-list@pauillac.inria.fr \
    /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).