Skip to content

Commit 2c160f0

Browse files
The modulus of a whole number is a whole number (#1589)
With the facts in scope making s whole, |s| in ZZ and |s| in ZZ* are True, and |s| in ZZ+ is not s = 0, which the quantifiers then decide. Sullivan and Mackey's Ex 7.2.6, f(z) = |2 z + 1| from ZZ to their N, is True, since 2 z + 1 = 0 has no whole root. 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 6f11bb2 commit 2c160f0

3 files changed

Lines changed: 34 additions & 1 deletion

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,19 @@ and `13` is not, every `n` from `24` is `4 a + 9 b` and `23` is not
718718
| `exists a in ZZ* : exists b in ZZ* : 13 = 3 a + 8 b` | `UnhandledParseException` (left as written when quantifiers arrived) | `False` |
719719
| `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` |
720720

721+
### The modulus of a whole number is a whole number
722+
723+
With the facts in scope making `s` a whole number, `|s| in ZZ` and `|s| in ZZ*` are `True`, and
724+
`|s| in ZZ+` is `not s = 0`, which the quantifiers then decide. So Sullivan and Mackey's Ex 7.2.6,
725+
where `f(z) = |2 z + 1|` is a function from `ZZ` to their `N`, is `True`, since `2 z + 1 = 0` has no
726+
whole root, while `|z|` fails at `0` and `|z^2 - 4|` at `2`
727+
([#1409](https://github.com/asc-community/AngouriMath/issues/1409)).
728+
729+
| Input | Was (2.5.0) | Now |
730+
|---|---|---|
731+
| `forall z in ZZ : abs(2 z + 1) in ZZ+` | `UnhandledParseException` (left as written when quantifiers arrived) | `True` |
732+
| `forall z in ZZ : abs(z - 3) in ZZ*` | `UnhandledParseException` (left as written when quantifiers arrived) | `True` |
733+
721734
### An antiderivative built through an even root says where the root is real
722735

723736
The linear-radical substitution, `u = (a x + b)^(1/q)`, and the general substitution for an even

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ internal static bool PrimeDividesItsBinomial(Entity p, Entity k)
282282
/// <summary>
283283
/// <c>s in S</c> for a set of whole numbers, as the comparison it is where the facts in scope
284284
/// make <c>s</c> a whole number: <c>s &gt;= 0</c> in <c>ZZ*</c>, <c>s &gt;= 1</c> in <c>ZZ+</c>, and
285-
/// <c>True</c> in <c>ZZ</c>. <see langword="null"/> otherwise. Sullivan and Mackey's Prob
285+
/// <c>True</c> in <c>ZZ</c>; and <c>|s|</c> as <c>not s = 0</c> in <c>ZZ+</c> and <c>True</c> in the
286+
/// other two. <see langword="null"/> otherwise. Sullivan and Mackey's Prob
286287
/// 4.11.6 asks for a <c>z</c> in <c>ZZ*</c> with <c>x - y = z</c> or <c>y - x = z</c>, for whole
287288
/// <c>x</c> and <c>y</c>: the witnesses are <c>x - y</c> and <c>y - x</c>, one of which is
288289
/// not negative.
@@ -299,6 +300,17 @@ internal static bool PrimeDividesItsBinomial(Entity p, Entity k)
299300
SpecialSet.PositiveIntegers => element >= Integer.One,
300301
_ => null,
301302
};
303+
// The modulus of a whole quantity is whole and not negative, and positive where the
304+
// quantity is not zero: |2 z + 1| is in ZZ+ for every whole z, since 2 z + 1 = 0 has
305+
// no whole root. Sullivan and Mackey's Ex 7.2.6, where f(z) = |2 z + 1| is a function
306+
// from ZZ to their N. https://github.com/asc-community/AngouriMath/issues/1409
307+
if (element is Absf(var quantity) && IsWholePolynomial(quantity))
308+
return set switch
309+
{
310+
SpecialSet.Integers or SpecialSet.NonNegativeIntegers => Entity.Boolean.True,
311+
SpecialSet.PositiveIntegers => !quantity.Equalizes(Integer.Zero),
312+
_ => null,
313+
};
302314
// A whole quantity over a whole number m is whole where m divides it, and then has
303315
// the sign of the quantity: (13 - 3 a)/8 in ZZ* is 8 divides 13 - 3 a and
304316
// 13 - 3 a >= 0. That is what an equation 13 = 3 a + 8 b leaves of b, so the

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ public void DecidedOverAFiniteSet(string statement, string expected)
144144
[InlineData("forall x in ZZ : forall y in ZZ : exists z in ZZ* : x - y = z or y - x = z", "True")]
145145
[InlineData("forall x in ZZ : forall y in ZZ : exists z in ZZ+ : x - y = z or y - x = z", "False")]
146146
[InlineData("forall x in RR : forall y in RR : exists z in ZZ* : x - y = z or y - x = z", "False")]
147+
// Ex 7.2.6: f(z) = |2 z + 1| is a function from ZZ to Sullivan and Mackey's N, which is
148+
// ZZ+, since the modulus of a whole number is one, and 2 z + 1 = 0 has no whole root.
149+
// |z| is not, at 0, nor |z^2 - 4|, at 2.
150+
[InlineData("forall z in ZZ : abs(2 z + 1) in ZZ+", "True")]
151+
[InlineData("forall z in ZZ : abs(z) in ZZ+", "False")]
152+
[InlineData("forall z in ZZ : abs(z^2 - 4) in ZZ+", "False")]
153+
[InlineData("forall z in ZZ : abs(z - 3) in ZZ*", "True")]
154+
[InlineData("forall n in ZZ+ : abs(n) in ZZ+", "True")]
147155
// Prob 4.11.5: a square is not the greatest square, for y = x^2 + 1 is past every x, and
148156
// a term in x is a witness for every x at once. Where none of the terms tried works, a
149157
// single member may still decide it: x = 0 is below every square.

0 commit comments

Comments
 (0)