From 3bbe7414442df7dc4a1750a97b7a4facac1d7c5d Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Mon, 28 Sep 2026 20:12:44 +0000 Subject: [PATCH] An interval whose ends are reversed meets nothing (3; 1) holds no number, and membership in it was decided so, but its intersection with another interval returned the other interval, as the union rightly does: (3; 1) /\ [0; 5] was [0; 5]. It is empty now, and a closed interval at one point meets the other in that point or nothing. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --- BREAKING-CHANGES.md | 11 +++++++++++ .../Entity/Omni/Sets/SetOperators.Intersection.cs | 7 +++++-- .../Tests/UnitTests/Core/Sets/IntervalAndInterval.cs | 11 +++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md index edd19a65c..824af398e 100644 --- a/BREAKING-CHANGES.md +++ b/BREAKING-CHANGES.md @@ -672,6 +672,17 @@ a listed index set, and over any other an object whose membership is decided by | `union({k, 2 k}, k in {1, 2, 3})` | `UnhandledParseException` — `union` was a name, and `union(` a juxtaposition that does not parse | `{ 1, 2, 4, 3, 6 }` | | `0.1 in intersection([0; 1/n), n in ZZ+)` | `UnhandledParseException` | `False` | | `complement({1, 2}, {1, 2, 3})` | `UnhandledParseException` | `{ 3 }` | + +### An interval whose ends are reversed meets nothing + +`(3; 1)` holds no number, and membership in it was decided so, but its meeting with another interval +was the other interval: the intersection returned it where the union rightly does. It is empty +now, and a closed interval at one point meets the other in that point or in nothing. + +| Input | Was (2.5.0) | Now | +|---|---|---| +| `"(3; 1) /\ [0; 5]".ToEntity().InnerSimplified` | `[0; 5]` — wrong | `{ }` | + ### An exponential of a multiple of a logarithm is integrated as the power it is `e^(k ln(q))` is `q^k` — the definition of the principal power, for every complex `q` other than diff --git a/Sources/AngouriMath/Core/Entity/Omni/Sets/SetOperators.Intersection.cs b/Sources/AngouriMath/Core/Entity/Omni/Sets/SetOperators.Intersection.cs index 24dda2218..154fa9384 100644 --- a/Sources/AngouriMath/Core/Entity/Omni/Sets/SetOperators.Intersection.cs +++ b/Sources/AngouriMath/Core/Entity/Omni/Sets/SetOperators.Intersection.cs @@ -45,10 +45,13 @@ B.Left.Evaled is not Real bLeft || return A.LeftClosed && B.RightClosed ? new FiniteSet(A.Left) : Empty; if (bLeft == aRight) return A.RightClosed && B.LeftClosed ? new FiniteSet(B.Left) : Empty; + // An interval whose ends are reversed holds nothing, and one closed at a single + // point holds that point, so that is what it meets the other in. Returning the other + // interval is what the union does, and is right there: (3; 1) /\ [0; 5] was [0; 5]. if (aLeft >= aRight) - return B; + return aLeft == aRight && A.LeftClosed && A.RightClosed ? IntersectFiniteSetAndSet(new FiniteSet(A.Left), B) : Empty; if (bLeft >= bRight) - return A; + return bLeft == bRight && B.LeftClosed && B.RightClosed ? IntersectFiniteSetAndSet(new FiniteSet(B.Left), A) : Empty; if (aLeft > bRight) return Empty; if (bLeft > aRight) diff --git a/Sources/Tests/UnitTests/Core/Sets/IntervalAndInterval.cs b/Sources/Tests/UnitTests/Core/Sets/IntervalAndInterval.cs index 39735efed..9ebcf71ad 100644 --- a/Sources/Tests/UnitTests/Core/Sets/IntervalAndInterval.cs +++ b/Sources/Tests/UnitTests/Core/Sets/IntervalAndInterval.cs @@ -71,5 +71,16 @@ private void CannotSimplify(Entity act) [Fact] public void Subtraction4() => TestInt(D.SetSubtract(E), (Interval)D); [Fact] public void Subtraction5() => TestInt(A.SetSubtract(F), Interval(2, true, 3, false)); [Fact] public void Subtraction6() => TestInt(F.SetSubtract(A), Interval(5, false, 6, true)); + + /// + /// An interval whose ends are reversed holds nothing: it meets nothing, and adds nothing to + /// a union. The meeting used to be the other interval. + /// + [Theory] + [InlineData("(3; 1) /\\ [0; 5]", "{}")] + [InlineData("[0; 5] /\\ (3; 1)", "{}")] + [InlineData("(3; 1) \\/ [0; 5]", "[0; 5]")] + public void AReversedIntervalHoldsNothing(string expression, string expected) + => TestArb(MathS.FromString(expression), MathS.FromString(expected).InnerSimplified); } }