diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md index 2d8c7ac2b..78faf2182 100644 --- a/BREAKING-CHANGES.md +++ b/BREAKING-CHANGES.md @@ -704,6 +704,19 @@ and `13` is not, every `n` from `24` is `4 a + 9 b` and `23` is not | `exists a in ZZ* : exists b in ZZ* : 13 = 3 a + 8 b` | `UnhandledParseException` (left as written when quantifiers arrived) | `False` | | `forall n in ZZ : n >= 14 implies (exists a in ZZ* : exists b in ZZ* : n = 3 a + 8 b)` | `UnhandledParseException` (left as written when quantifiers arrived) | `True` | +### The modulus of a whole number is a whole number + +With the facts in scope making `s` a whole number, `|s| in ZZ` and `|s| in ZZ*` are `True`, and +`|s| in ZZ+` is `not s = 0`, which the quantifiers then decide. So Sullivan and Mackey's Ex 7.2.6, +where `f(z) = |2 z + 1|` is a function from `ZZ` to their `N`, is `True`, since `2 z + 1 = 0` has no +whole root, while `|z|` fails at `0` and `|z^2 - 4|` at `2` +([#1409](https://github.com/asc-community/AngouriMath/issues/1409)). + +| Input | Was (2.5.0) | Now | +|---|---|---| +| `forall z in ZZ : abs(2 z + 1) in ZZ+` | `UnhandledParseException` (left as written when quantifiers arrived) | `True` | +| `forall z in ZZ : abs(z - 3) in ZZ*` | `UnhandledParseException` (left as written when quantifiers arrived) | `True` | + ### An antiderivative built through an even root says where the root is real The linear-radical substitution, `u = (a x + b)^(1/q)`, and the general substitution for an even diff --git a/Sources/AngouriMath/Functions/Boolean/QuantifierFacts.cs b/Sources/AngouriMath/Functions/Boolean/QuantifierFacts.cs index 3b0599edb..fd70011d0 100644 --- a/Sources/AngouriMath/Functions/Boolean/QuantifierFacts.cs +++ b/Sources/AngouriMath/Functions/Boolean/QuantifierFacts.cs @@ -260,7 +260,8 @@ internal static bool PrimeDividesItsBinomial(Entity p, Entity k) /// /// s in S for a set of whole numbers, as the comparison it is where the facts in scope /// make s a whole number: s >= 0 in ZZ*, s >= 1 in ZZ+, and - /// True in ZZ. otherwise. Sullivan and Mackey's Prob + /// True in ZZ; and |s| as not s = 0 in ZZ+ and True in the + /// other two. otherwise. Sullivan and Mackey's Prob /// 4.11.6 asks for a z in ZZ* with x - y = z or y - x = z, for whole /// x and y: the witnesses are x - y and y - x, one of which is /// not negative. @@ -277,6 +278,17 @@ internal static bool PrimeDividesItsBinomial(Entity p, Entity k) SpecialSet.PositiveIntegers => element >= Integer.One, _ => null, }; + // The modulus of a whole quantity is whole and not negative, and positive where the + // quantity is not zero: |2 z + 1| is in ZZ+ for every whole z, since 2 z + 1 = 0 has + // no whole root. Sullivan and Mackey's Ex 7.2.6, where f(z) = |2 z + 1| is a function + // from ZZ to their N. https://github.com/asc-community/AngouriMath/issues/1409 + if (element is Absf(var quantity) && IsWholePolynomial(quantity)) + return set switch + { + SpecialSet.Integers or SpecialSet.NonNegativeIntegers => Entity.Boolean.True, + SpecialSet.PositiveIntegers => !quantity.Equalizes(Integer.Zero), + _ => null, + }; // A whole quantity over a whole number m is whole where m divides it, and then has // the sign of the quantity: (13 - 3 a)/8 in ZZ* is 8 divides 13 - 3 a and // 13 - 3 a >= 0. That is what an equation 13 = 3 a + 8 b leaves of b, so the diff --git a/Sources/Tests/UnitTests/Core/QuantifierTest.cs b/Sources/Tests/UnitTests/Core/QuantifierTest.cs index b8e9f2100..adc69bcdd 100644 --- a/Sources/Tests/UnitTests/Core/QuantifierTest.cs +++ b/Sources/Tests/UnitTests/Core/QuantifierTest.cs @@ -144,6 +144,14 @@ public void DecidedOverAFiniteSet(string statement, string expected) [InlineData("forall x in ZZ : forall y in ZZ : exists z in ZZ* : x - y = z or y - x = z", "True")] [InlineData("forall x in ZZ : forall y in ZZ : exists z in ZZ+ : x - y = z or y - x = z", "False")] [InlineData("forall x in RR : forall y in RR : exists z in ZZ* : x - y = z or y - x = z", "False")] + // Ex 7.2.6: f(z) = |2 z + 1| is a function from ZZ to Sullivan and Mackey's N, which is + // ZZ+, since the modulus of a whole number is one, and 2 z + 1 = 0 has no whole root. + // |z| is not, at 0, nor |z^2 - 4|, at 2. + [InlineData("forall z in ZZ : abs(2 z + 1) in ZZ+", "True")] + [InlineData("forall z in ZZ : abs(z) in ZZ+", "False")] + [InlineData("forall z in ZZ : abs(z^2 - 4) in ZZ+", "False")] + [InlineData("forall z in ZZ : abs(z - 3) in ZZ*", "True")] + [InlineData("forall n in ZZ+ : abs(n) in ZZ+", "True")] // Prob 4.11.5: a square is not the greatest square, for y = x^2 + 1 is past every x, and // a term in x is a witness for every x at once. Where none of the terms tried works, a // single member may still decide it: x = 0 is below every square.