Skip to content

A union with an empty interval is the other set - #1636

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
a-reversed-interval-adds-nothing
Sep 30, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
a-reversed-interval-adds-nothing

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

UniteIntervalAndInterval joined two intervals wherever one ended where the other began, before it asked whether either was empty. [1; 0] is empty, and it ends at 0, where [0; 1] begins, so [0; 1] \/ [1; 0] was joined into { 1 }. The peer session found this on #1633, where a union was the obvious way to write the segment between an integral's limits.

The function now asks about emptiness first:

  • An interval with numeric ends that is empty adds nothing. Its left end is above its right, or the two ends are one point with an end open.
  • Two intervals are joined where they touch only when neither can be empty. That holds for numeric ends in order, a single point closed at both ends, or an end at an infinity, which lies beyond any end the other can have. So (-oo; x] \/ [x; +oo) is still RR, and [a; b] \/ [b; c], where either may be empty, is left as written.
  • A closed point's union was computed and its result discarded. It is returned now.
Simplify of 2.5.0 now
[0; 1] \/ [1; 0] { 1 } — wrong [0; 1]
[3; 1] \/ [1; 2] [3; 2], which is empty — wrong [1; 2]
[a; b] \/ [b; a] { b } — wrong as written
[a; b] \/ [b; c] [a; c] — wrong where a > b or b > c as written
(-oo; x] \/ [x; +oo) RR RR

AnEmptyIntervalAddsNothingTest decides each union by membership, at points on both sides of every end, rather than reading its printed shape. It also pins the symbolic cases.

Suite on net10.0, at 1c52ec44 on master fac6ce16: 14196 passed, none failed. The head, 2c74c073, differs from it only in its commit message. Every target framework builds.
Gate: allocation matches the baseline on all 19 gated benchmarks.

Closes #1634.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Two intervals were joined wherever one ended where the other began, before
either was asked whether it was empty: [0; 1] \/ [1; 0] became { 1 },
[3; 1] \/ [1; 2] the empty [3; 2], and [a; b] \/ [b; a] became { b }. An
empty interval now adds nothing, and two intervals with ends that are not
numbers are joined only where neither can be empty -- an end at an
infinity, or a single point closed at both ends -- so [a; b] \/ [b; c] is
left as written. A closed point's union was computed and discarded; it is
returned now.

Closes #1634.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Rafael-SOWNet Rafael-SOWNet added this to the 2.6.0 milestone Sep 30, 2026
@Rafael-SOWNet
Rafael-SOWNet merged commit e8b2039 into master Sep 30, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The union of an interval and its reversal is one point: [0; 1] \/ [1; 0] is { 1 }

1 participant