Skip to content

Commit 3f38408

Browse files
PP is the set of primes, and min(S) the least member of a set (#1452)
* PP is the set of primes, and min(S) the least member of a set PP beside ZZ+: the primes {2, 3, 5, 7, ...}, \mathbb{P}, S.Primes, Domain.Prime as a codomain, at the bottom of the chain PP ⊂ ZZ+ ⊂ ZZ* ⊂ ZZ. Membership is decided for a whole number by trial division and left open past the machine word; PP /\ [a; b] lists its members where there are few enough, so card(PP /\ [1; n]) is the prime-counting function; the quantifiers meet an interval with PP at the next prime. min(S) with one argument that is a set is the least member of the set, and min(x, x in S and P) the least member of { x in S : P }, both decided for PP, ZZ+, ZZ* and their cuts by an interval or a bound: min(PP) is 2 and min(x, x in PP and x > 14) is 17. Neither prints with a name it was not written with. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura * max(x, x in PP and x < 14) is the previous prime, and a range takes any conjunction of bounds The greatest member of a set of whole numbers cut from above, the twin of the least: 13 for the primes below 14, 97 for PP /\ (-oo; 100], 4 for ZZ /\ (-oo; 5); max(PP) stays, there being no largest prime. The range of min and max is read from any conjunction with one membership among its conjuncts, so x in PP and x > 14 and x < 20 is { x in PP : x > 14 and x < 20 }, and the bounds on the name are read together as the interval they cut. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 27b98dd commit 3f38408

26 files changed

Lines changed: 992 additions & 434 deletions

‎BREAKING-CHANGES.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,30 @@ as written.
844844
| `forall n in ZZ* : not (7 divides 2^n + 1)` | `UnhandledParseException` | `True` |
845845
| `forall n in ZZ+ : 5 divides 7^n - 1` | `UnhandledParseException` | `False` |
846846

847+
### `PP` is the set of primes, and `min(S)` the least member of a set
848+
849+
`PP` is a special set beside `ZZ+` — the primes `{2, 3, 5, 7, ...}`, `\mathbb{P}` in LaTeX,
850+
`S.Primes` in SymPy, `Domain.Prime` as a codomain — and was a variable named `PP`, so
851+
`7 in PP` stays as written no more. Membership is decided for a whole number by trial division
852+
and left open past the machine word; `PP /\ [a; b]` lists its members where there are few
853+
enough, which makes `card(PP /\ [1; n])` the prime-counting function; `PP ⊂ ZZ+` heads the
854+
chain. `min(S)` with one argument that is a set is the least member of the set, where
855+
`min(PP)` was `PP` itself — a one-argument `min` was the argument — and `min(x, x in S and P)`
856+
is the least member of `{ x in S : P }`, where it was left as written; both decided for `PP`,
857+
`ZZ+`, `ZZ*` and their cuts by an interval or a bound, so `min(x, x in PP and x > 14)` is the next
858+
prime, `17` ([#1450](https://github.com/asc-community/AngouriMath/issues/1450)).
859+
860+
| Input | Was (2.5.0) | Now |
861+
|---|---|---|
862+
| `"7 in PP".ToEntity().Evaled` | `7 in PP` — `PP` a variable | `True` |
863+
| `"PP subset ZZ".ToEntity()` | `UnhandledParseException` — `subset` is new since | `True` on evaluation |
864+
| `"min(PP)".ToEntity().Evaled` | `PP` | `2` |
865+
| `"min(x, x in PP and x > 14)".ToEntity().Evaled` | as written | `17` |
866+
| `"card(PP intersect [1; 100])".ToEntity().Evaled` | `#(PP /\ [1; 100])` | `25` |
867+
| `"PP intersect [1; 30]".ToEntity().Evaled` | as written | `{ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 }` |
868+
| `"min(ZZ+)".ToEntity().Evaled` | `ZZ+` | `1` |
869+
| `"max(x, x in PP and x < 14)".ToEntity().Evaled` | as written | `13` |
870+
847871
### `binomial(n, k)` is a function
848872

849873
**Addition, not silent.** The binomial coefficient is a node, `Entity.Binomialf`, spelled

‎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/Sets/PrimeSetTest.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/Calculus/InverseHyperbolicSecantIntegralTest.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/Convenience/MathS.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6351,6 +6351,10 @@ public static class Sets
63516351
/// https://github.com/asc-community/AngouriMath/issues/1409</summary>
63526352
public static Set PositiveIntegers => SpecialSet.Create("ZZ+");
63536353

6354+
/// <summary>The prime numbers <c>{2, 3, 5, 7, ...}</c>, written <c>PP</c>.
6355+
/// https://github.com/asc-community/AngouriMath/issues/1450</summary>
6356+
public static Set Primes => SpecialSet.Create("PP");
6357+
63546358
/// <summary>
63556359
/// Creates a <see cref="FiniteSet"/> with given elements
63566360
/// </summary>

‎Sources/AngouriMath/Core/Antlr/AngouriMath.g‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,10 @@ atom returns[Entity value]
585585
| 'round(' args = function_arguments ')' { Assert("round", 1, $args.list.Count); $value = MathS.Round($args.list[0]); }
586586
/* min and max take any number of arguments, as they do everywhere else, and fold left
587587
into the binary node. One argument is that argument. */
588-
| 'min(' args = function_arguments ')' { AssertAtLeast("min", 1, $args.list.Count); $value = $args.list.Count == 2 && $args.list[1] is Entity.Set.Inf { Element: Variable } minRange ? MathS.Minimum($args.list[0], minRange.Element, minRange.SupSet) : $args.list.Aggregate((a, b) => MathS.Min(a, b)); }
589-
| 'max(' args = function_arguments ')' { AssertAtLeast("max", 1, $args.list.Count); $value = $args.list.Count == 2 && $args.list[1] is Entity.Set.Inf { Element: Variable } maxRange ? MathS.Maximum($args.list[0], maxRange.Element, maxRange.SupSet) : $args.list.Aggregate((a, b) => MathS.Max(a, b)); }
588+
/* min(S) is the least member of a set; min(x, x in S and P) the least of { x in S : P }, the
589+
conjunction read as the set builder reads it. https://github.com/asc-community/AngouriMath/issues/1450 */
590+
| 'min(' args = function_arguments ')' { AssertAtLeast("min", 1, $args.list.Count); $value = $args.list.Count == 1 && $args.list[0] is Entity.Set minSet ? MathS.Minimum(Variable.CreateUnique(minSet, "x"), Variable.CreateUnique(minSet, "x"), minSet) : $args.list.Count == 2 && AngouriMath.Functions.ExtremumOverSet.AsRange($args.list[1]) is var (minVar, minOver) ? MathS.Minimum($args.list[0], minVar, minOver) : $args.list.Aggregate((a, b) => MathS.Min(a, b)); }
591+
| 'max(' args = function_arguments ')' { AssertAtLeast("max", 1, $args.list.Count); $value = $args.list.Count == 1 && $args.list[0] is Entity.Set maxSet ? MathS.Maximum(Variable.CreateUnique(maxSet, "x"), Variable.CreateUnique(maxSet, "x"), maxSet) : $args.list.Count == 2 && AngouriMath.Functions.ExtremumOverSet.AsRange($args.list[1]) is var (maxVar, maxOver) ? MathS.Maximum($args.list[0], maxVar, maxOver) : $args.list.Aggregate((a, b) => MathS.Max(a, b)); }
590592
| 'argmax(' args = function_arguments ')' { Assert("argmax", 2, $args.list.Count); $value = $args.list[1] is Entity.Set.Inf { Element: Variable } argmaxRange ? MathS.Argmax($args.list[0], argmaxRange.Element, argmaxRange.SupSet) : throw new InvalidArgumentParseException("argmax expects its second argument to say which variable ranges over which set, as in argmax(f(t), t in S)"); }
591593
| 'argmin(' args = function_arguments ')' { Assert("argmin", 2, $args.list.Count); $value = $args.list[1] is Entity.Set.Inf { Element: Variable } argminRange ? MathS.Argmin($args.list[0], argminRange.Element, argminRange.SupSet) : throw new InvalidArgumentParseException("argmin expects its second argument to say which variable ranges over which set, as in argmin(f(t), t in S)"); }
592594
| 'gcd(' args = function_arguments ')' { AssertAtLeast("gcd", 1, $args.list.Count); $value = $args.list.Aggregate((a, b) => MathS.Gcd(a, b)); }
@@ -669,7 +671,7 @@ fragment EXPONENT: ('e'|'E') ('+'|'-')? ('0'..'9')+ ;
669671

670672
NUMBER: ('0'..'9')+ '.' ('0'..'9')* EXPONENT? 'i'? | '.'? ('0'..'9')+ EXPONENT? 'i'? | 'i' ;
671673

672-
SPECIALSET: ('CC' | 'RR' | 'QQ' | 'ZZ' | 'BB' | 'ZZ*' | 'ZZ+') ;
674+
SPECIALSET: ('CC' | 'RR' | 'QQ' | 'ZZ' | 'BB' | 'ZZ*' | 'ZZ+' | 'PP') ;
673675

674676
BOOLEAN: ('true' | 'True' | 'false' | 'False') ;
675677

0 commit comments

Comments
 (0)