caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Andrej Bauer <Andrej.Bauer@fmf.uni-lj.si>
To: Christophe TROESTLER <Christophe.Troestler+ocaml@umh.ac.be>,
	Caml <caml-list@inria.fr>
Subject: Re: [Caml-list] Compiler feature - useful or not?
Date: Fri, 16 Nov 2007 09:23:28 +0100	[thread overview]
Message-ID: <473D5380.2010508@fmf.uni-lj.si> (raw)
In-Reply-To: <20071116.014620.919650100.Christophe.Troestler+ocaml@umh.ac.be>

Christophe TROESTLER wrote:
> I believe Z is generally defined as a quotient of the disjoint union
> (borrowed as variants in programming languages) of N and N
> (identifying the two 0).  Of course you can also define it as a
> quotient of N×N by the smaller equivalent relation "~" s.t. (n,m) ~
> (n+1,m+1) and it is quite nice as addition is "inherited" from the one
> on N×N but I am not sure it is the way it is usually done.

As another mathematician, also prone to nitpicking, I beg to differ. It 
is more natural to define Z as a quotient of N x N, because this is just 
a special case of a general construction of a (commutative) ring out of 
a (commutative) rig.

A rig is a structure with 0, + and * but no subtraction.

A ring is a structure with 0, +, - and *.

(Of course you need to imagine suitable axioms for 0, +, * such as 
commutativity, associativity and distributivity, but I am not writing 
them down here.)

 From every rig M we can construct a ring R as a quotient (M x M)/~ of M 
x M where we define

   (a,b) ~ (c,d)  iff  a+d = b+c

Think of (a,b) as the "non-existent" difference a-b. This construction 
is natural in the technical sense that it is left adjoint to the 
forgetful functor(*) from rings to rigs. (In non-mathematician language: 
if we already have + and *, there is a _best_ way of getting - as well.)

Caveat: (*) the use of "functor" here was as in mathematics, not as in 
ocaml.

In what way is natural, or canonical, the construction of Z defined by 
sticking together two copies of N?

To add some value to this post, other than mathematical willy waving, 
let me pose a puzzle. Implement the above in Ocaml, i.e., start with:

module type RIG =
sig
   type t
   val zero : t
   val add : t -> t -> t
   val mul : t -> t -> t
end

module type RING =
sig
   include RIG
   val sub : t -> t -> t
end

The puzzle is this: write down the module type for the construction 
taking a rig and returning the free ring over it. It is _not_ just

module type ConstructRing = functor (M : RIG) -> RING

because that would allow _any_ ring whatsoever as the result. It has to 
be the ring that comes from M via above construction, so there has to be 
extra stuff, such as an embedding of M into the resulting R. But what else?

Andrej


  reply	other threads:[~2007-11-16  8:23 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-13 23:41 Edgar Friendly
2007-11-14  0:08 ` [Caml-list] " Yaron Minsky
2007-11-14  0:21   ` Martin Jambon
2007-11-14  7:58     ` Pierre Weis
2007-11-14 12:37       ` Alain Frisch
2007-11-14 13:56         ` Virgile Prevosto
2007-11-14 14:35         ` Pierre Weis
2007-11-14 16:38           ` Alain Frisch
2007-11-14 18:43             ` Pierre Weis
2007-11-14 19:19               ` Edgar Friendly
2007-11-15  6:29               ` Alain Frisch
2007-11-15 13:26                 ` Pierre Weis
2007-11-15 17:29                   ` Edgar Friendly
2007-11-15 20:28                     ` Fernando Alegre
2007-11-16  0:47                       ` Brian Hurt
2007-11-15 22:37                     ` Michaël Le Barbier
2007-11-15 22:24                   ` Michaël Le Barbier
2007-11-16  0:30                   ` Yaron Minsky
2007-11-16  1:51                     ` Martin Jambon
2007-11-16  9:23                       ` Alain Frisch
2007-11-16 14:17                         ` rossberg
2007-11-16 15:08                         ` Martin Jambon
2007-11-16 16:43                           ` Martin Jambon
2007-11-16 16:46                             ` Till Varoquaux
2007-11-16 17:27                             ` Edgar Friendly
2007-11-16 17:47                               ` Martin Jambon
2007-11-16 17:54                                 ` Edgar Friendly
2007-11-16 18:10                                   ` Fernando Alegre
2007-11-16 19:18                                     ` David Allsopp
2007-11-16 19:32                                       ` Fernando Alegre
2007-11-16 19:50                                         ` Gerd Stolpmann
2007-11-16 17:31                             ` Fernando Alegre
2007-11-16 17:43                               ` Edgar Friendly
2007-11-16  0:46                   ` Christophe TROESTLER
2007-11-16  8:23                     ` Andrej Bauer [this message]
2007-11-16  8:58                       ` Jean-Christophe Filliâtre
2007-11-16  9:13                         ` Andrej Bauer
2007-11-16  9:48                           ` Christophe TROESTLER
2007-11-14 16:57       ` Edgar Friendly
2007-11-14 21:04         ` Pierre Weis
2007-11-14 22:09           ` Edgar Friendly
2007-11-15  0:17         ` Jacques Garrigue
2007-11-15  6:23           ` Edgar Friendly
2007-11-15 10:53             ` Vincent Hanquez
2007-11-15 13:48               ` Jacques Carette
2007-11-15 14:43                 ` Jon Harrop
2007-11-15 16:54                   ` Martin Jambon
2007-11-14 16:09   ` Edgar Friendly
2007-11-14 16:20     ` Brian Hurt
2007-11-14 11:01 ` Gerd Stolpmann
2007-11-14 10:57   ` Jon Harrop
2007-11-14 14:37 ` Zheng Li

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=473D5380.2010508@fmf.uni-lj.si \
    --to=andrej.bauer@fmf.uni-lj.si \
    --cc=Andrej.Bauer@andrej.com \
    --cc=Christophe.Troestler+ocaml@umh.ac.be \
    --cc=caml-list@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).