gcd definition, apology for mistake

1996-11-09 Thread S.D.Mechveliani

Dear all,


I am very sorry for something like misprinting tragically in the 
classic  gcd  definition.  I had written

" gcd(a,b)  is the  *greatest*   by inclusion ideal  (d)  among the
  ones with the property of 
 (d) = {x*d | x <- R}   to be  *contained inside*
 (a)+(b) =  {x*a + y*b | x,y <- R} 
"
 
while the right definition is 

-
(D)
... least by inclusion ideal (d) among the ones that contain  (a)+(b)
----
-



This all concerns to the little discussion on whether it is good to
put  gcd(0,0) = 0   in Haskell.

Again,  gcd(0,0) = 0  does agree with this classic definition.

However, in the task where appear the expressions like  gcd(a,b),  
they usually consider the case  a=b=0  separately.

Again,  (D)  shows that for Rationals and the like domains  gcd  is
trivial:   a /= 0  =>  gcd(a,b) = 1.

So it looks strange speaking of gcd for rationals.



Sergey Mechveliani

[EMAIL PROTECTED]









The Haskell 1.3 compiler NHC13 is now available

1996-11-09 Thread Thomas Hallgren at home

Version 0.0 of NHC13, Nearly a Haskell 1.3 Compiler, by Niklas Rojemo,
is now available for download from

ftp://ftp.cs.chalmers.se/pub/haskell/nhc13

It has the following features

- Compiles Haskell 1.3
- Supports Fudgets
- Supports several kind of heap profiles:
producer
constructor
retainer
life-time
biographical
combinations of the above

Although NHC13 0.0 is probably not yet to be regarded as a mature
Haskell 1.3 compiler, it may still be of interest since it provides
some new kinds of heap profiles not found in any other Haskell 1.3
compiler. Finding space leaks or other undesired space behaviour using
(combinations of) retainer and biographical profiles can be much
simpler than with the traditional producer/constructor profiles.

Heap profiling also works for Fudgets programs.

The commands to use are

nhc13   the compiler
nhc13make   a version of hbcmake for nhc13
nhc13xmake  to compile Fudgets programs
hp2graphto convert heap profiling output to postscript

Manual pages with more details are included in the distributions.

Recent papers on heap profiling are

   Niklas Rojemo and Colin Runciman: "Lag, drag, void and use -
heap profiling and space-efficient compilation revisited".
In the proceedings of ICFP'96.

   Colin Runciman and Niklas Rojemo: "Two-pass heap profiling: a matter
of life and death". In the proceedings of IFL'96.

These are available from

ftp://ftp.cs.chalmers.se/pub/users/rojemo/icfp96.ps.gz
ftp://ftp.cs.chalmers.se/pub/users/rojemo/ifl96.ps.gz



Niklas Rojemo
Thomas Hallgren







Re: gcd(0,0), reply

1996-11-09 Thread Marnix Klooster

[If this whole 'gcd' discussion is getting 'too mathematical' for this list,
I propose to continue it by private e-mail with members of the Haskell
committee.  If so, please give me an e-mail address to contact.]

At 09:16 6-11-96 +0300, you wrote in reply to my 'Why not make "gcd 0 0 = 0"?':
>Hello,
>
>there was recently a letter on the subject like 
> " gcd(0,0) should be 0 ".
>Unfortunately, I had lost it and cannot citate.
>
>Here are simple considerations to prevent the confusion.
>
>(1)
>gcd(0,0) = 0   is all right.
>
>But setting this would hardly improve anything. For in mathematics, 
>they write  gcd(a,b)  (think, say, of  a/gcd(a,b) ) 
>only after the case  a=b=0  is considered separately or excluded
>by default.

But defining gcd(0,0)=0 is precisely what is needed, at least in your
example.  a/gcd(a,b) is not meaningful if gcd(a,b)=0, which is equivalent
(by this definition) to a=b=0.  Thus the case separation on a=b=0 follows
from gcd(a,b) being a denominator, not from a and b being zero as such.

>In other words, this would be is like setting 0/0 = 0.

I don't see the analogy at all.  Could you explain it?  I mean, I have not
yet seen a natural definition of division that extends naturally to the case
0/0.  Which is exactly what I propose for gcd(0,0).

>(2)
>The letter contained some discource on the subject. 
>Everything on gcd was explained by the classics:
>
>" gcd(a,b)  is the greatest by inclusion ideal  (d)  among the
>  ones with the property of 
>   (d) = {x*d | x <- R}   to be contained inside
>   (a)+(b) =  {x*a + y*b | x,y <- R} 
>"
>This was formutated so in order to fit not only the Integers.

I assume here R stands for the set of integers.  A kind reader of sci.math
e-mailed me with an explanation of this definition, which I wasn't aware of.
It is the most elegant definition of 'gcd' I have seen.  Let me quote his
explanation here:

>I believe the most elegant definition of the gcd and lcm is the
>following: if S is a set of integers, consider the subgroup of Z
>generated by S, that is, the set of all sums or differences of
>a finite number of elements of S. Now any subgroup of Z can be
>written in a unique way as
> mZ={mx:x@Z}(m>=0)
>so define the gcd of S to be the unique such m.

[snipped definition of lcm]

>This definition generalizes to Q and R. The difference is that
>a subgroup of Q or R is not necessarily of the above form. The
>gcd of an infinite set of rationals is not always defined (the
>lcm always is). The gcd of even a finite set of reals ({1,pi}
>for example) is not always defined.

Thus, according to this generally accepted definition, the gcd of {a,b} is
always defined for a,b in Q, and the above definition implies that gcd(0,0)
= 0.  So again I propose to define "gcd 0 0 = 0", and generalize the
definition to rationals, in the Haskell Prelude.

Note that the gcd of rationals can be computed using exactly the same
algorithm that is currently used for the gcd of integers.  Therefore my
proposal costs almost nothing, gaining a little generality.

>Now (1) follows trivially from this definition as well as 
>
>(3)
>(the author mentions the case of the rational numbers)
>
>Here we keep in mind that for the Rationals and "the like domains", 
>gcd is trivial:  
>  if  a /= 0  then  gcd(a,b) = 1.

Not so.  gcd(4/3, 10/3) = 2/3, according to your own definition.

>Sergey Mechveliani
>
>[EMAIL PROTECTED]

Groetjes,

 <><

Marnix
--
Marnix Klooster
[EMAIL PROTECTED]