Dear group,


Maybe others have mentioned this as well but I can't
recall having seen this anywhere.

I am not quite sure how to express this in Haskell
terms but here it goes anyway: Why is :% in Ratio
not hidden? 

By allowing a user program to construct elements of
the form (a:%b) one can create objects which lead to
inconsistencies if each of the following hold:
  (1)  for all a: not (a < a);
  (2)  for all a, b and c: if a < b and b < c then a < c.
  (3)  for all a: if a <= b and b <= a then a == b

Now Ratio defines (<=) and (<) as
 (x:%y) <= (x':%y')  =  x * y' <= x' * y
 (x:%y) <  (x':%y')  =  x * y' <  x' * y
According to these definitions and using pseudo notation
the following must hold:
 (-1:%1) < (0:%1) < (1:%-1) == (-1:%1),
The last equality follows from (3) and the fact that:
 (1:%-1) <= (-1:%1) and (-1:%1) <= (1:%-1).
Using (2) it now follows that (-1:%1) < (-1:%1) which
according to (1) should not be true.

According to the language definition (1:%-1) != (-1:%1).
Personally I think that built-in data types should obey
(1), (2) and (3). Maybe I am missing something.

Any comments?


Regards,


Marc van Dongen
-- 
     Marc van Dongen, CS Dept | phone:  +353 21 4903578
University College Cork, NUIC | Fax:    +353 21 4903113
  College Road, Cork, Ireland | Email: [EMAIL PROTECTED]

Reply via email to