Skip to content

Commit cf54964

Browse files
Two unions of intervals meet piece by piece (#1591)
A union of intervals and listed sets met an interval piece by piece and another such union not at all, which is what a conjunction of two inequalities is solved to. Each piece of the one now meets the other. Sullivan and Mackey's Prob 4.11.22 is decided both ways: for positive x, (x^2 - 4)/(x^2 + 1) > 1 - 1/x implies (x^2 + 4)/(x^2 + 1) < 1 + 1/x, and the converse fails. Part of #1409. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 70ca79e commit cf54964

4 files changed

Lines changed: 57 additions & 0 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,20 @@ met piece by piece now ([#1409](https://github.com/asc-community/AngouriMath/iss
842842
| `{ x in RR : x^2 - 3 x + 2 >= 0 } = { y in RR : y <= 1 or y >= 2 }` | left as written | `True` |
843843
| `"({ 2 } \/ (-oo; 1] \/ (2; +oo)) /\ (1; 2)".ToEntity().Evaled` | left as written | `{ }` |
844844

845+
### Two unions of intervals meet piece by piece
846+
847+
A union of intervals and listed sets met an interval piece by piece, and another such union not
848+
at all: the meeting was left as written. That is what a conjunction of two inequalities is solved
849+
to, so a statement decided through one was left as written as well. Two such unions now meet
850+
piece by piece. So Sullivan and Mackey's Prob 4.11.22 is decided both ways: for positive `x`,
851+
`(x^2 - 4)/(x^2 + 1) > 1 - 1/x` implies `(x^2 + 4)/(x^2 + 1) < 1 + 1/x`, and the converse fails at
852+
`3` ([#1409](https://github.com/asc-community/AngouriMath/issues/1409)).
853+
854+
| Input | Was (2.5.0) | Now |
855+
|---|---|---|
856+
| `"((0; 1) \/ (3; 5)) /\ ((-1; 2) \/ (4; 6))".ToEntity().Evaled` | left as written | `(0; 1) \/ (4; 5)` |
857+
| `forall x in RR : x > 0 implies ((x^2 - 4)/(x^2 + 1) > 1 - 1/x implies (x^2 + 4)/(x^2 + 1) < 1 + 1/x)` | `UnhandledParseException` (left as written when quantifiers arrived) | `True` |
858+
845859
### The size of an infinite set is an aleph, and sizes compare
846860

847861
`card` of an infinite set is an aleph, `aleph(k)`, or a power of 2 of one: `card(ZZ)`, `card(QQ)`

‎Sources/AngouriMath/Functions/Evaluation/Evaluation.Omni/Evaluation.Omni.Classes.cs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ protected override Entity InnerSimplify(bool isExact)
181181
=> MathS.Union(MathS.Intersection(interval, left).InnerSimplified(isExact), MathS.Intersection(interval, right).InnerSimplified(isExact)).InnerSimplified(isExact),
182182
(Unionf(var left, var right) union, Interval interval) when MadeOfPieces(union)
183183
=> MathS.Union(MathS.Intersection(left, interval).InnerSimplified(isExact), MathS.Intersection(right, interval).InnerSimplified(isExact)).InnerSimplified(isExact),
184+
// Two such unions meet piece by piece as well, each piece of the one
185+
// meeting the other by the arms above. A conjunction of two inequalities
186+
// is solved to that: the x > 0 where x^2 - 5 x + 1 > 0 and not
187+
// x^2 - 3 x + 1 > 0 are ((0; a) \/ (b; +oo)) /\ ({ c, d } \/ (-oo; 0) \/ (c; d)),
188+
// which meet in nothing -- Sullivan and Mackey's Prob 4.11.22.
189+
// https://github.com/asc-community/AngouriMath/issues/1409
190+
(Unionf(var left, var right) union, Unionf other) when MadeOfPieces(union) && MadeOfPieces(other)
191+
=> MathS.Union(MathS.Intersection(left, other).InnerSimplified(isExact), MathS.Intersection(right, other).InnerSimplified(isExact)).InnerSimplified(isExact),
184192
// (A \ B) /\ C is (A /\ C) \ B, where A meets C first: the pre-image
185193
// (RR \ { -1 }) /\ (-oo; -1) is (-oo; -1) \ { -1 }, which is the interval.
186194
(SetMinusf(var from, var removed), Set other) when other is not SetMinusf

‎Sources/Tests/UnitTests/Core/QuantifierTest.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ public void DecidedOverAFiniteSet(string statement, string expected)
7878
// §4.2.1: the AGM inequality, and §4.9.5.
7979
[InlineData("forall x, y in RR : 2 x y <= x^2 + y^2", "True")]
8080
[InlineData("forall y in RR : y > 1 implies y^2 - 1 > 0", "True")]
81+
// Prob 4.11.22: for x > 0, (x^2 - 4)/(x^2 + 1) > 1 - 1/x is x^2 - 5 x + 1 > 0, which makes
82+
// (x^2 + 4)/(x^2 + 1) < 1 + 1/x, x^2 - 3 x + 1 > 0, and not the other way round, at 3.
83+
// The x where the first implication fails are where two unions of intervals meet.
84+
[InlineData("forall x in RR : x > 0 implies ((x^2 - 4)/(x^2 + 1) > 1 - 1/x implies (x^2 + 4)/(x^2 + 1) < 1 + 1/x)", "True")]
85+
[InlineData("forall x in RR : x > 0 implies ((x^2 + 4)/(x^2 + 1) < 1 + 1/x implies (x^2 - 4)/(x^2 + 1) > 1 - 1/x)", "False")]
8186
// Problem 4.11.1 over ZZ: P is 1 <= x <= 3, Q is 2 divides x, R is x^2 = 4.
8287
[InlineData("forall x in ZZ : (1 <= x and x <= 3) implies 2 divides x", "False")]
8388
[InlineData("exists x in ZZ : x^2 = 4 and 1 <= x and x <= 3", "True")]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// Copyright (c) 2019-2026 Angouri.
3+
// AngouriMath is licensed under MIT.
4+
// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
5+
// Website: https://am.angouri.org.
6+
//
7+
8+
using AngouriMath.Extensions;
9+
using Xunit;
10+
11+
namespace AngouriMath.Tests.Core.Sets
12+
{
13+
/// <summary>
14+
/// Two unions of intervals and listed sets meet piece by piece, which is what a conjunction of
15+
/// two inequalities is solved to: Sullivan and Mackey's Prob 4.11.22 asks whether one rational
16+
/// inequality implies another for every positive <c>x</c>, and the <c>x</c> where it fails are
17+
/// such a meeting. https://github.com/asc-community/AngouriMath/issues/1409
18+
/// </summary>
19+
[Trait("Area", "Core")]
20+
public sealed class UnionsMeetTest
21+
{
22+
[Theory]
23+
[InlineData("((0; 1) \\/ (3; 5)) /\\ ((-1; 2) \\/ (4; 6))", "(0; 1) \\/ (4; 5)")]
24+
[InlineData("((0; 1) \\/ (3; 5)) /\\ ([1; 3] \\/ {7})", "{ }")]
25+
[InlineData("((0; 1) \\/ {4}) /\\ ((1/2; 2) \\/ [4; 5))", "(1/2; 1) \\/ {4}")]
26+
[InlineData("((0; (5 - sqrt(21))/2) \\/ ((5 + sqrt(21))/2; +oo)) /\\ ({ (3 - sqrt(5))/2 } \\/ [(3 - sqrt(5))/2; (3 + sqrt(5))/2])", "{ }")]
27+
public void PieceByPiece(string meeting, string expected)
28+
=> Assert.Equal(expected.ToEntity().InnerSimplified, meeting.ToEntity().InnerSimplified);
29+
}
30+
}

0 commit comments

Comments
 (0)