|
| 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