caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Andrej.Bauer@andrej.com
Cc: Simon Frost <sdfrost@ucsd.edu>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Equality of functional values
Date: Wed, 31 Jan 2007 00:55:03 +1100	[thread overview]
Message-ID: <1170165303.6391.20.camel@rosella.wigram> (raw)
In-Reply-To: <45BF471A.6060603@fmf.uni-lj.si>

On Tue, 2007-01-30 at 14:24 +0100, Andrej Bauer wrote:
> Simon Frost wrote:
> > I'm trying to use a software package written in ocaml (IBAL), however,
> > it fails a test due to 'Fatal error: exception Invalid_argument("equal:
> > functional value"). It seems that equality isn't defined for functional
> > values in OCAML (although I'm not an expert), so I'm wondering what the
> > workaround is.
> 
> This may not sound very helpful, but: you are doing something wrong if 
> you need to rely on equality of functions. Equality of functions is not 
> computable.
> 
> A suitable workaround would be to tell us what it is that you are doing, 
> and we will tell you what to use instead of functions (if possible). To 
> give you an idea of what you I am talking about:
> 
> Suppose you came to us and complained that you cannot compare 
> polynomials with integer coefficients, and it turned out that you 
> represent polynomials as functions. We would then tell you not to do 
> that, and represent polynomials as arrays (or lists) of coefficients, or 
> objects, or some other data structure that is equipped with decidable 
> equality.

Actually the idea 'equality of functions is not computable'
is misleading .. IMHO. Equality of programmer written
'functions' should always be computable: more precisely one hopes
every function could have a mechanically verifiable proof
of correctness and wished programming languages provided an 
easy way to prove one.

Of course for an arbitrary function, equality isn't decidable,
but programmers don't write arbitrary functions (except in
error).

Andrej's suggestion amounts to a proof technique: use some
fixed function (which is equal to itself) plus a comparable
data structure. This may not be so easy to do though.

BTW: Felix is one of the few general languages around that
actually allows a statement of semantics:

typeclass SemiGroup[t with Eq[t]] {
  virtual fun add: t * t -> t;
  axiom assoc(x:t, y:t, z:t): add(x, add(y,z)) == add(add(x,y),z);
}

These axioms are checkable:

instance SemiGroup[int] {
  fun add:int * int -> int = "$1+$2";
}

axiom_check(1,2,3);

however there's currently no way to state and prove
theorems. It would be interesting if someone had some
idea how to use one of the existing theorem provers
to act as a proof assistant (verify user given proof,
filling in enough 'gaps' in the formal steps to make
it practical).

An extension to Ocaml which allowed for semantics
might be interesting: the usual technique is to just
put comments: that's pretty weak in this day an age 
isn't it?


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  reply	other threads:[~2007-01-30 13:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-29 21:04 Simon Frost
2007-01-29 21:11 ` [Caml-list] " Tom
2007-01-29 21:23   ` Brian Hurt
2007-01-29 21:59 ` Gerd Stolpmann
2007-01-30  8:17   ` Christophe Raffalli
2007-01-30  8:45   ` David MENTRE
2007-01-30 13:24 ` Andrej Bauer
2007-01-30 13:55   ` skaller [this message]
2007-01-30 14:21     ` Brian Hurt
2007-01-30 15:21     ` Jeff Polakow
2007-01-30 15:49       ` Jacques Carette
2007-01-30 17:23         ` Chris King
2007-01-30 20:18           ` Tom
2007-01-30 20:30             ` Gerd Stolpmann
2007-01-30 20:41               ` Fernando Alegre
2007-01-30 21:01                 ` Christophe TROESTLER
2007-01-30 21:08                   ` Tom
2007-01-30 21:46                     ` Christophe TROESTLER
2007-01-30 22:05                       ` Fernando Alegre
2007-01-30 23:13                         ` skaller
2007-01-30 23:06     ` Andrej Bauer
2007-01-31  0:15       ` Jacques Carette
2007-01-31  7:03         ` Stefan Monnier
2007-01-31 12:54           ` [Caml-list] " Jacques Carette
2007-01-31  0:15       ` [Caml-list] " 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=1170165303.6391.20.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=Andrej.Bauer@andrej.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=sdfrost@ucsd.edu \
    /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).