Skip to content

Commit 345914f

Browse files
An infinite base has its whole powers, and surjectivity is decided through the image (#1445)
(-oo)^3 was NaN -- a claim that the value does not exist -- and so were (-oo)^2 and (-oo)^(-1), while (+oo)^2 was +oo: the finite-base arms of Pow did not apply and the polar form had nothing to say. They are the extended reals' powers now, by parity for -oo and 0 for a negative exponent, so the image of (-oo; +oo) under a cube is (-oo; +oo), and the reals are read as that interval where a family's image is computed. With it, forall b in B : exists a in A : f(a) = b -- surjectivity onto B, Def 7.4.1 of the reference of #1409 -- is decided as B lying in the image of A under f, where that image evaluates: the cube is onto RR, the square is not and is onto [0; +oo), the exponential is onto (0; +oo), doubling is not onto ZZ. Item 6's remaining analytic row. #1409 Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 2f25792 commit 345914f

6 files changed

Lines changed: 95 additions & 2 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,21 @@ names are keywords now, and were names.
725725
| `preimage(x^2, x in RR, {1})` | `UnhandledParseException` | `{ 1, -1 }` |
726726
| `{ x in ZZ : x^2 in {1, 4} }` | `{ x in ZZ : x ^ 2 in { 1, 4 } }` — left as written | `{ 1, -1, 2, -2 }` |
727727

728+
### An infinite base has its whole powers, and surjectivity is decided through the image
729+
730+
`(-oo)^3` was `NaN` — a claim that the value does not exist — and so were `(-oo)^2` and
731+
`(-oo)^(-1)`, while `(+oo)^2` was `+oo`: the finite-base arms did not apply and the polar form
732+
had nothing to say. They are the extended reals' powers now, `-oo`, `+oo` and `0`, so the image of
733+
`(-oo; +oo)` under a cube is `(-oo; +oo)`; and `forall b in B : exists a in A : f(a) = b` — surjectivity
734+
onto `B`, Def 7.4.1 of the reference of [#1409](https://github.com/asc-community/AngouriMath/issues/1409)
735+
— is decided as `B` lying in the image of `A` under `f` where that image evaluates.
736+
737+
| Input | Was (2.5.0) | Now |
738+
|---|---|---|
739+
| `(-oo)^3` | `NaN` — wrong | `-oo` |
740+
| `(-oo)^2` | `NaN` — wrong | `+oo` |
741+
| `forall b in RR : exists a in RR : a^3 = b` | `UnhandledParseException` (quantifiers are new since; left as written when they arrived) | `True` |
742+
| `forall b in RR : exists a in RR : e^a = b` | `UnhandledParseException` | `False` |
728743
### The binomial coefficient's identities, and its sums in closed form
729744

730745
Pascal's rule, the chairperson identity and the symmetry are rewrite rules, each in the direction

‎Sources/.editorconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed
291291
[AngouriMath/Functions/NumberTheory/ResidueClasses.cs]
292292
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n
293293

294+
[Tests/UnitTests/Core/SurjectivityTest.cs]
295+
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n
296+
294297
[Tests/UnitTests/Core/BinomialIdentityTest.cs]
295298
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n
296299

‎Sources/AngouriMath/Core/Entity/Continuous/Number/Operators.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,17 @@ static Complex BinaryIntPow(Complex num, EInteger val)
498498
&& decimalPower.IsInteger() && decimalPower.Abs().CompareTo(EDecimal.FromInt32(1 << 20)) <= 0 => decimalPower.ToEInteger(),
499499
_ => null,
500500
};
501+
// An infinite real base to a whole power: (+oo)^n is +oo, (-oo)^n is +oo or -oo by
502+
// the parity of n, and either to a negative power is 0 -- the extended reals'
503+
// arithmetic, which the product of infinities already follows. It fell through
504+
// to the polar form and came back NaN, so the image of (-oo; +oo) under a cube
505+
// had no ends. https://github.com/asc-community/AngouriMath/issues/1409
506+
if (@base is Real { EDecimal: var infinite } && infinite.IsInfinity() && pow is { } wholeOfInfinity && !wholeOfInfinity.IsZero)
507+
{
508+
if (wholeOfInfinity.Sign < 0)
509+
return Integer.Zero;
510+
return infinite.IsNegative && !wholeOfInfinity.IsEven ? Real.NegativeInfinity : Real.PositiveInfinity;
511+
}
501512
if (@base.IsFinite && pow is { })
502513
{
503514
// A real base that is not exact -- a decimal, which is what a numerical

‎Sources/AngouriMath/Functions/Boolean/Quantifiers.cs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ internal enum Kind { All, Some, Unique }
8181
set = new FiniteSet(Entity.Boolean.True, Entity.Boolean.False);
8282
if (!body.ContainsNode(x))
8383
return Closed(kind, set, body);
84+
// forall b in B : exists a in A : f(a) = b is the statement that B lies in the image
85+
// of A under f -- surjectivity onto B (the reference's Def 7.4.1) -- and the image is
86+
// a set the library computes: listed over a listed A, an interval by interval
87+
// arithmetic, so the subset decision settles it where the image evaluates.
88+
// https://github.com/asc-community/AngouriMath/issues/1409
89+
if (kind == Kind.All && body is Existsf(Variable a, Set domain, Equalsf(var lhs, var rhs))
90+
&& (lhs == x && !rhs.ContainsNode(x) && rhs.ContainsNode(a) ? rhs : rhs == x && !lhs.ContainsNode(x) && lhs.ContainsNode(a) ? lhs : null) is { } map)
91+
{
92+
var image = new IndexedUnionf(a, domain, new FiniteSet(map)).InnerSimplified(isExact);
93+
if (image is not IndexedUnionf && image is Set imageSet && Core.Sets.SetOperators.Subset(set, imageSet, isExact) is { } covered)
94+
return covered;
95+
}
8496
// An equation whose two sides differ by a polynomial that expands to nothing holds
8597
// at every member, whatever the set: (x + 1)^2 = x^2 + 2 x + 1 is True of each.
8698
if (body is Equalsf(var left, var right) && IsIdentity(left, right))

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,11 @@ protected override Entity InnerSimplify(bool isExact)
203203
// one occurrence and the operations it has images for (#1423): the
204204
// reference's 9c/5 + 32 on (0, 100) is (32, 212). Where the arithmetic has
205205
// no image the substitution leaves an expression, and the family stays.
206-
if (this is IndexedUnionf && over is Interval && body is FiniteSet { Count: 1 } image
206+
// The reals are the interval (-oo; +oo) for this purpose.
207+
var overAsInterval = over is SpecialSet.Reals ? new Interval(Real.NegativeInfinity, false, Real.PositiveInfinity, false) : over;
208+
if (this is IndexedUnionf && overAsInterval is Interval && body is FiniteSet { Count: 1 } image
207209
&& image.First() is var f && f.Nodes.Count(node => node == Var) == 1
208-
&& f.Substitute(Var, over).InnerSimplified(isExact) is Set imaged)
210+
&& f.Substitute(Var, overAsInterval).InnerSimplified(isExact) is Set imaged)
209211
return imaged;
210212
if (over is FiniteSet indices)
211213
{
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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;
9+
using AngouriMath.Extensions;
10+
using Xunit;
11+
using static AngouriMath.Entity;
12+
13+
namespace AngouriMath.Tests.Core
14+
{
15+
/// <summary>
16+
/// <c>forall b in B : exists a in A : f(a) = b</c> -- surjectivity onto <c>B</c>, Def 7.4.1 of the
17+
/// reference (Sullivan and Mackey) -- is the statement that <c>B</c> lies in the image of
18+
/// <c>A</c> under <c>f</c>, and is decided where the image evaluates: listed over a listed
19+
/// <c>A</c>, an interval by interval arithmetic. The cube is onto the reals because
20+
/// <c>(-oo; +oo)^3</c> is <c>(-oo; +oo)</c>, which needed <c>(-oo)^3</c> to be <c>-oo</c>
21+
/// rather than <c>NaN</c>. <see href="https://github.com/asc-community/AngouriMath/issues/1409"/>
22+
/// </summary>
23+
[Trait("Area", "Core")]
24+
public sealed class SurjectivityTest
25+
{
26+
[Theory]
27+
[InlineData("forall b in RR : exists a in RR : a^3 = b", "True")]
28+
[InlineData("forall b in RR : exists a in RR : 2 a + 1 = b", "True")]
29+
[InlineData("forall b in RR : exists a in RR : a^2 = b", "False")]
30+
[InlineData("forall b in [0; +oo) : exists a in RR : a^2 = b", "True")]
31+
[InlineData("forall b in RR : exists a in RR : e^a = b", "False")]
32+
[InlineData("forall b in (0; +oo) : exists a in RR : e^a = b", "True")]
33+
[InlineData("forall b in ZZ : exists a in ZZ : 2 a = b", "False")]
34+
[InlineData("forall b in {1, 4, 9} : exists a in {1, 2, 3} : a^2 = b", "True")]
35+
[InlineData("forall b in {1, 4, 9, 16} : exists a in {1, 2, 3} : a^2 = b", "False")]
36+
public void SurjectivityIsTheImageCoveringTheCodomain(string statement, string expected)
37+
=> Assert.Equal(expected.ToEntity(), statement.ToEntity().Evaled);
38+
39+
/// <summary>The extended reals' whole powers: by parity for <c>-oo</c>, and <c>0</c> for a negative exponent. Each was <c>NaN</c>.</summary>
40+
[Theory]
41+
[InlineData("(-oo)^3", "-oo")]
42+
[InlineData("(-oo)^2", "+oo")]
43+
[InlineData("(-oo)^(-1)", "0")]
44+
[InlineData("(+oo)^3", "+oo")]
45+
[InlineData("(-oo; +oo)^3", "(-oo; +oo)")]
46+
[InlineData("image(x^3, x in RR)", "(-oo; +oo)")]
47+
public void AnInfiniteBaseHasItsWholePowers(string expression, string expected)
48+
=> Assert.Equal(expected.ToEntity().Evaled, expression.ToEntity().Evaled);
49+
}
50+
}

0 commit comments

Comments
 (0)