[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ISSUE: GCD-LCM-ZERO-ARGS



Issue:         GCD-LCM-ZERO-ARGS
References:    CLtl pg.202 and Document 86-003 pg.3
Category:      CHANGE
Edit history:  Revision 1 by Skona Brittain 03/22/87
               Revision 2 by Skona Brittain 01/06/89
               Revision 3 by Skona Brittain 04/28/89 (removed references to
                                                     cases of no args to lcm)

Problem Description:

These functions are not well-defined for sets of arguments 
that include the number zero.


Proposal (GCD-LCM-ZERO-ARGS:NOT-ALLOWED):

The arguments to lcm and gcd must be positive integers.


Test Case:

(lcm 1 0) would be an error instead of having the value 0.


Rationale:

Having the least common multiple of a set of numbers be less than 
the least common multiple of a proper subset of that set 
violates monotonicity.  For example, monotonicity is violated by 
      (lcm 1 0) < (lcm 1)   and   (lcm 0) < (lcm).
Increasing the restrictions on the candidates for the lcm should 
only be able to increase the value of the least qualifying one.
What the first example is saying is that the the least multiple 
of 1 is 1 but the least number that is a multiple of both 1 and 0
is 0.  This is patently ridiculous.  Any reasoning that says that
0 is the lcm of 1 & 0 would also say that 0 is the lcm of 1 alone,
since 0 would be considered a multiple of 1 and is less than 1.  
Furthermore, it would say that 0 is the result of the lcm operation 
on any set of arguments at all.  Although this would be mathematically 
consistent, it would not make lcm a very useful operator.

The root of the problem is that it is unnatural to apply lcm or 
gcd to anything but natural numbers.  Negative numbers are not 
having much of an effect because they are just being treated as
if they were their absolute values, i.e. the negativity of negative 
arguments is ignored, but zero really screws things up.  If it is 
desired that zero be an allowed argument, it should also just be ignored, 
(i.e passed over, the way nil in an association list is passed over) 


Current Practice:

I know of no implementations that currently implement this change.


Cost to Users:

Very slight.


Cost to Implementors:

Very slight.  Should lead to a reduction in code, since most algorithms 
for computing gcd and lcm are for positive integers anyway.


Benefits:

see Esthetics.


Esthetics:

Mathematical correctness is much more aesthetic than its alternatives.


Discussion: