[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: transitivity requirement on scheme comparison and rational?
(real? (if (= x 4.0) (sqrt x) 2))
may evaluate to #f or generate an error if the interval for x includes negative
values but the locally best approximation is 4.0. My impression is that if you
don't interpret = as "overlaps", < as "definitely <", etc., then most code
written without knowledge of interval arithmetic will break.
My impression is contrary to yours. I would not think very highly of an
implementation in which the expression above evaluates to #f or generates
an error. This expression would evaluate to #t in implementations that I
would consider reasonable.
I don't understand your comment at all, as it is directly countrary to my
understanding of the situation, which is that the reason = should not be
interpreted as "overlaps" and < as "definitely <" is that these
interpretations would break most code written without knowledge of interval
arithmetic. For example, the expression above *could* evaluate to #f if
= were interpreted to mean "overlaps" and real? were interpreted to mean
"definitely real". Thus your own example contradicts the very conclusion
you seem to be drawing from it.
Your example does illustrate, however, why a serious implementation of
interval arithmetic would have to work with intervals in the complex plane.
That shouldn't come as a surprise, and I don't think it has anything to do
with the point you're trying to make.
What were the nasty examples that break if inexact comparisons are not forced
to be transitive?
(real? (if (and (positive? x) (< x y)) (sqrt y) 2)) would not necessarily
evaluate to #t if < were not transitive. It seems to me that all of the
examples you have given to show that requiring transitivity leads to
weird behavior can easily be modified to show that not requiring
transitivity leads to weird behavior also.