Inconsistency in definition of arithmetic predicates in R7RS small

12 views
Skip to first unread message

Daphne Preston-Kendal

unread,
Feb 12, 2024, 6:16:42 AMFeb 12
to scheme-re...@googlegroups.com
Hello,

This issue has been known about for a while and it appears (as far as I can tell) that WG1 has decided to take no action about it, but I would like to check this.

To quote Will Clinger, who (I believe) found this issue:

The R7RS specification of [`real?`] contradicts itself by saying "`(real? z)` is true if and only if `(zero? (imag-part z))` is true" while giving the following two examples drawn from the R6RS standard, where they serve to emphasize that "(real? z) is true if and only if (zero? (imag-part z)) and (exact? (imag-part z)) are both true." […] That has implications for `integer?` and `rational?` because integers must be rational and rationals must be real.

<https://github.com/larcenists/larceny/wiki/R7RSstrictArithmetic>

Since WG2 has resolved to make R7RS Large more compatible with R6RS where possible, we would likely tend to prefer the R6RS interpretation (i.e. the one from the example, rather than the description). However, this has not yet been extensively discussed within the WG.

I ran the examples from the spec on the same set of R7RS small impls I referred to in my other mail:
• Implement the R6RS/example semantics: Chibi, Gambit, Gerbil, Guile, Loko
• Implement the described (‘R5RS’) semantics: Gauche, MIT/GNU Scheme, STklos
• Parse error: Picrin

If WG1 members have any comments, I would be grateful to hear them — or if WG1 would like to resolve the inconsistency itself, that would also be good

Best wishes


Daphne

Marc Feeley

unread,
Feb 12, 2024, 6:42:11 AMFeb 12
to scheme-re...@googlegroups.com
On this point I think the R7RS spec is wrong and the R6RS spec is right. The spec should be "`(real? z)` is true if and only if `(eqv? 0 (imag-part z))` is true”.

Marc
> --
> You received this message because you are subscribed to the Google Groups "scheme-reports-wg1" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to scheme-reports-...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/scheme-reports-wg1/55AB01A0-2DE2-4D89-9FEC-779A93DE33EF%40nonceword.org.
>


Daphne Preston-Kendal

unread,
Feb 12, 2024, 12:05:24 PMFeb 12
to scheme-re...@googlegroups.com
I received the following response from Brad Lucier.

> On 12 Feb 2024, at 18:02, Lucier, Bradley J <bradley.j...@purdue.edu> wrote:
>
>> On Feb 12, 2024, at 6:16 AM, Daphne Preston-Kendal <d...@nonceword.org> wrote:
>>
>> If WG1 members have any comments, I would be grateful to hear them — or if WG1 would like to resolve the inconsistency itself, that would also be good
>
> (I can no longer post email from my wg1-subscribed email address, luc...@math.purdue.edu, so I’m sending this to you directly.)
>
> I put the ballot question, with votes and comments at the end of this email, from https://small.r7rs.org/wiki/WG1Ballot5Results/.
>
> In retrospect, I find that the vote conflates various questions that should have been separated, whether 1.+0.i should be real and whether there should be a real-valued? procedure. In reviewing my old emails, it seems I said I was “an old guy” (it’s now 12 years later!) and confused and got a bit grumpy.
>
> My opinion is still that (real? 1.+0.i) should be #f. Whether people might find a procedure named real-valued? useful is a separate question. (I guess I felt strongly about the first question, and had no opinion about the second, so I voted “no” without further comment.)
>
> So I agree with Marc Feeley’s comment.
>
> Brad
>
>
> #286 Numeric *-valued procedures for R5RS and R6RS-base compatibility
[the remainder of this mail quoted from https://small.r7rs.org/ticket/286 –dpk]
> Real-valued?, rational-valued?, and integer-valued? test whether a given number object can be coerced to the specified type without loss of numerical accuracy. They are equivalent to the versions of real?, rational?, and integer? that exist in R5RS.
> Specifically, the behavior of these predicates differs from the behavior of real?, rational?, and integer? on complex number objects whose imaginary part is inexact zero.
> These procedures provide R6RS base compatibility as well.
> • Vote yes to add *-valued procedures;
> • Vote no to leave out the *-valued procedures;
> • Vote r5rs to leave them out and revert real?, rational?, and integer? to R5RS semantics
> • vote r5rs+strictly to do what r5rs does, and also add strictly-*? procedures to provide the R6RS semantics of real?, rational?, and integer?.
> • Options: yes, no, undecided
> • Default: no
> • Voters:
> • Cowan: r5rs
> • Ganz: r5rs
> • Gleckler: r5rs, no, r5rs+strictly
> • Hsu: yes
> • Lucier: no
> • Medernach: r5rs+strictly, r5rs, yes, undecided
> • Shinn: no, undecided
> • SnellPym: r5rs+strictly, r5rs, yes, no
> • Results: r5rs, no, r5rs+strictly, yes, undecided
> • Ratios: 5:2, 3:2, 5:1, 5:1
> • Rationales:
> CowanIt's inconsistent to vote for the R6RS-base library without providing these. In addition, the R5RS library can and should export them as real, rational, and complex. This is one of the places where we made a silent change to the semantics of a procedure (silent in the sense that code will behave differently without any warning), and there should be an easy way to recover the old semantics.GanzThe example given is too narrow to support both sets of predicates.GlecklerThese names are awful. I'll never be able to remember that real-valued?' means something different than real?', and even if I do, I won't remember which one is which. I'm sure others will have the same problem. If we come up with better names, I might be willing to vote yes. After John's edit: The "strictly-*" names don't make things any less confusing, so I'm voting to revert to r5rs or at least to leave out the new names.ShinnIf nothing else the names are too confusing - the difference is too small, and I don't think people will be able to keep these straight.

Arthur A. Gleckler

unread,
Feb 12, 2024, 1:52:11 PMFeb 12
to scheme-reports-wg1
On Mon, Feb 12, 2024 at 9:05 AM Daphne Preston-Kendal <d...@nonceword.org> wrote:
I received the following response from Brad Lucier.

> On 12 Feb 2024, at 18:02, Lucier, Bradley J <bradley.j...@purdue.edu> wrote:

> My opinion is still that (real? 1.+0.i) should be #f.  Whether people might find a procedure named real-valued? useful is a separate question.  (I guess I felt strongly about the first question, and had no opinion about the second, so I voted “no” without further comment.)
>
> So I agree with Marc Feeley’s comment.

I agree.  If the imaginary part is inexact, we don't know whether it's actually zero.

Emmanuel Medernach

unread,
Feb 17, 2024, 3:57:36 AMFeb 17
to scheme-re...@googlegroups.com
I also agree, this seems like the Right Thing to do.

Emmanuel

Alex Shinn

unread,
Feb 22, 2024, 9:17:34 PMFeb 22
to scheme-re...@googlegroups.com
For the record I agree.  When the cited ballot was made, we had already switched to R6RS semantics.
That ballot was specifically about adding the -valued? procedures, which I think are way too confusing so I voted 'no'.
For completeness an 'r5rs' option was also provided, to revert the R6RS semantics and go back to pure R5RS.
A majority of members preferred to revert to R5RS compatibility, which was reasonable given our charter.

At any rate, I don't think we can change this now.

--
Alex

--
You received this message because you are subscribed to the Google Groups "scheme-reports-wg1" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scheme-reports-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages