29
78
Fork
You've already forked r7rs
2

Description of "equal?" #329

Open
opened 2026年04月24日 23:22:42 +02:00 by chaw · 5 comments
Member
Copy link

Should the description of the equal? predicate include a reference and/or more details on the unfolding of arguments into regular trees?

Should the description of the equal? predicate include a reference and/or more details on the unfolding of arguments into regular trees?
Member
Copy link

The R6RS uses the following wording:

The equal? predicate treats pairs and vectors as nodes with outgoing edges

That wording is more precise and I would support adding it to the description. I would also support a citation to Adam's and Dybvig's paper for an algorithm.

The R6RS uses the following wording: > The equal? predicate treats pairs and vectors as nodes with outgoing edges That wording is more precise and I would support adding it to the description. I would also support a citation to [Adam's and Dybvig's paper](https://michaeldadams.org/papers/efficient_equality/) for an algorithm.

@phm wrote in #329 (comment):

The R6RS uses the following wording:

The equal? predicate treats pairs and vectors as nodes with outgoing edges

That wording is more precise and I would support adding it to the description. I would also support a citation to Adam's and Dybvig's paper for an algorithm.

I think the confusion stems from the wording "ordered tree" and "regular tree", which appears to be a term from automata theory. However, I couldn't find a good explanation on internet.

A tree is called ordered if there is an order among the successors of each of its nodes. The above definition of tree naturally suggests an order among the successors, which can be used to make the tree ranked.

https://en.wikipedia.org/wiki/Tree_(graph_theory)

Can someone find out the source reference of the definitions of these terms?

On the other hand, the rationale behind the definition is quite intuitive. It basically says the implementation of equal? should use some memorization technique to prevent recursive calling equal? being stuck on infinite loop. Maybe there's other way to formalize this intuition in spec.

@phm wrote in https://codeberg.org/scheme/r7rs/issues/329#issuecomment-13785584: > The R6RS uses the following wording: > > > The equal? predicate treats pairs and vectors as nodes with outgoing edges > > That wording is more precise and I would support adding it to the description. I would also support a citation to [Adam's and Dybvig's paper](https://michaeldadams.org/papers/efficient_equality/) for an algorithm. I think the confusion stems from the wording "ordered tree" and "regular tree", which appears to be a term from automata theory. However, I couldn't find a good explanation on internet. > A tree is called ordered if there is an order among the successors of each of its nodes. The above definition of tree naturally suggests an order among the successors, which can be used to make the tree ranked. https://en.wikipedia.org/wiki/Tree_(graph_theory) Can someone find out the source reference of the definitions of these terms? On the other hand, the rationale behind the definition is quite intuitive. It basically says the implementation of `equal?` should use some memorization technique to prevent recursive calling `equal?` being stuck on infinite loop. Maybe there's other way to formalize this intuition in spec.
Member
Copy link

@readevalprintloop wrote in #329 (comment):

I think the confusion stems from the wording "ordered tree" and "regular tree", which appears to be a term from automata theory. However, I couldn't find a good explanation on internet.

The trees are certainly not "regular" in the sense of that Wikipedia article. The R7RS-Small just replaces it with "tree."

According to Bruno Courcelle (1983), "Fundamental Properties of Infinite Trees", a tree is regular if the set of its subtrees is finite. That makes sense, because a circular data structure will repeat and hence have a finite number of subtrees, so this probably the definition in mind.

@readevalprintloop wrote in https://codeberg.org/scheme/r7rs/issues/329#issuecomment-13792976: > I think the confusion stems from the wording "ordered tree" and "regular tree", which appears to be a term from automata theory. However, I couldn't find a good explanation on internet. The trees are certainly not "regular" in the sense of that Wikipedia article. The R7RS-Small just replaces it with "tree." According to [Bruno Courcelle (1983), "Fundamental Properties of Infinite Trees"](https://www.labri.fr/perso/courcell/Textes1/FundPropInfTrees.pdf), a tree is regular if the set of its subtrees is finite. That makes sense, because a circular data structure will repeat and hence have a finite number of subtrees, so this probably the definition in mind.
Member
Copy link

I have reverted the text to the R7RS-Small's "into (possibly infinite) trees" instead of "regular trees." I think that referring to them as "regular" is likely to cause confusion than to help.

I have reverted the text to the R7RS-Small's "into (possibly infinite) trees" instead of "regular trees." I think that referring to them as "regular" is likely to cause confusion than to help.
Member
Copy link

The precise definition is that equal? is the greatest equivalence relation such that the following holds: (equal? X Y) is true if and only if

  • X and Y are non-pairs or non-vectors and are considered equal (which is defined earlier),
  • X and Y are both pairs whose cars and cdrs are equal?, respectively,
  • X and Y are both vectors of the same length whose corresponding elements are equal?.
The precise definition is that `equal?` is the greatest equivalence relation such that the following holds: `(equal? X Y)` is true if and only if - `X` and `Y` are non-pairs or non-vectors and are considered equal (which is defined earlier), - `X` and `Y` are both pairs whose cars and cdrs are `equal?`, respectively, - `X` and `Y` are both vectors of the same length whose corresponding elements are `equal?`.
Sign in to join this conversation.
No Branch/Tag specified
main
pages
proc-draft
c-trichotomy
global-id-prop-ref
allow-van-tonder-like-expanders
No results found.
Labels
Clear labels
Batteries
Issues for the Batteries volume of the report, providing a standard library
Cleanup
Issues where inconsistencies or other infelicities have arisen
Consent Docket
Items which will be automatically be given a certain resolution if no objection is made by a certain date
Environments
Issues for the Environments volume of the report, providing OS interfaces and similar
Foundations
Issues for the Foundations volume of the report, related to the core language semantics
Macrological Fascicle
Meta
Procedural and organisational issues
Multiple proposals exist
Multiple competing, concrete proposals to resolve this issue exist (whether they are SRFI or still only pre-SRFI)
Pie-in-the-sky ideas
Ideas currently lacking any form of worked-out proposal
Problems without solutions
Problems we *must* solve but haven’t worked out any solution for yet
Procedural Fascicle
Public Comment
Publications
Issues related to the practicalities of making the report available
Question
For information and clarification
R6RS Compatibility
Issue touches on questions of R6RS compatibility
R7RS-small
Issues with the Small language Report
Resolution in draft
A resolution (not necessarily final) is specified in the current draft of the relevant fascicle
Specification exists
Proposals for which a viable, but incomplete specification text exists
SRFI/RnRS spec exists
A SRFI for this proposal exists, or a solution from another RnRS
Milestone
Clear milestone
No items
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
scheme/r7rs#329
Reference in a new issue
scheme/r7rs
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?