Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,25 @@ too ([#1409](https://github.com/asc-community/AngouriMath/issues/1409)). `subset
| `{1, 3} in powerset(ZZ)` | `UnrecognizedFunctionParseException` | `True` |
| `card({1, {}})` | `#{ 1, { } }` — left as written | `2` |

### An integer range is listed, and a family of sets has a union and an intersection

`ZZ /\ [1; 10]` lists its members now — an integer set cut by a numeric interval with at most
4096 members in it is the finite set of them, the `[n] = {1, …, n}` of combinatorics being
`ZZ+ /\ [1; n]`; the reals and the complex numbers cut by an interval are the interval, and the
rationals stay as written. `union(A_k, k in I)` and `intersection(A_k, k in I)` are
`Entity.Set.IndexedUnionf` and `Entity.Set.IndexedIntersectionf`, binders like `sum`: folded over
a listed index set, and over any other an object whose membership is decided by the quantifiers
(`0 in intersection([0; 1/n), n in ZZ+)` is `True`). `complement(A, U)` is `U \ A`
([#1409](https://github.com/asc-community/AngouriMath/issues/1409)). `union`, `intersection` and
`complement` are keywords now, and were names.

| Input | Was (2.5.0) | Now |
|---|---|---|
| `ZZ /\ [1; 10]` | `ZZ /\ [1; 10]` — left as written | `{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }` |
| `RR /\ [0; 1]` | `RR /\ [0; 1]` — left as written | `[0; 1]` |
| `union({k, 2 k}, k in {1, 2, 3})` | `UnhandledParseException` — `union` was a name, and `union(` a juxtaposition that does not parse | `{ 1, 2, 4, 3, 6 }` |
| `0.1 in intersection([0; 1/n), n in ZZ+)` | `UnhandledParseException` | `False` |
| `complement({1, 2}, {1, 2, 3})` | `UnhandledParseException` | `{ 3 }` |
### An exponential of a multiple of a logarithm is integrated as the power it is

`e^(k ln(q))` is `q^k` — the definition of the principal power, for every complex `q` other than
Expand Down
3 changes: 3 additions & 0 deletions Sources/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed
[AngouriMath/Functions/NumberTheory/ResidueClasses.cs]
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

[Tests/UnitTests/Core/Sets/IndexedSetOperationTest.cs]
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

[Tests/UnitTests/Calculus/ExponentialOfALogarithmIntegralTest.cs]
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

Expand Down
30 changes: 30 additions & 0 deletions Sources/AngouriMath/Convenience/MathS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6262,6 +6262,36 @@ public static class Sets
/// </example>
public static Entity Subset(Entity sub, Entity super) => new Subsetf(sub, super);

/// <summary>
/// The union of a family of sets indexed by <paramref name="var"/> ranging over
/// <paramref name="over"/>: <c>union(A_i, i in I)</c>, the set of what is in some
/// <c>A_i</c>. Folded over a listed index set; a membership object otherwise.
/// </summary>
/// <example>
/// <code>
/// Console.WriteLine("union({k, 2 k}, k in {1, 2, 3})".ToEntity().Evaled);
/// </code>
/// Prints
/// <code>
/// { 1, 2, 4, 3, 6 }
/// </code>
/// </example>
public static Set IndexedUnion(Entity body, Entity var, Entity over) => new IndexedUnionf(var, over, body);

/// <summary>
/// The intersection of a family of sets indexed by <paramref name="var"/> ranging
/// over <paramref name="over"/>: <c>intersection(A_i, i in I)</c>, the set of what
/// is in every <c>A_i</c>.
/// </summary>
public static Set IndexedIntersection(Entity body, Entity var, Entity over) => new IndexedIntersectionf(var, over, body);

/// <summary>
/// The complement of <paramref name="set"/> relative to the universe
/// <paramref name="universe"/>, which is <c>universe \ set</c>: a complement is
/// always relative to a universe, there being no set of everything.
/// </summary>
public static Set Complement(Entity set, Entity universe) => universe.SetSubtract(set);

/// <returns>A set of all Complexes/>s</returns>
public static Set C => SpecialSet.Create(Domain.Complex);

Expand Down
3 changes: 3 additions & 0 deletions Sources/AngouriMath/Core/Antlr/AngouriMath.g
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,9 @@ atom returns[Entity value]
| 'phi(' args = function_arguments ')' { Assert("phi", 1, $args.list.Count); $value = MathS.NumberTheory.Phi($args.list[0]); }
| 'card(' args = function_arguments ')' { Assert("card", 1, $args.list.Count); $value = MathS.Sets.Card($args.list[0]); }
| 'powerset(' args = function_arguments ')' { Assert("powerset", 1, $args.list.Count); $value = MathS.Sets.PowerSet($args.list[0]); }
| 'union(' args = function_arguments ')' { Assert("union", 2, $args.list.Count); $value = $args.list[1] is Entity.Set.Inf { Element: Variable } unionRange ? MathS.Sets.IndexedUnion($args.list[0], unionRange.Element, unionRange.SupSet) : throw new InvalidArgumentParseException("union expects its second argument to say which name ranges over which set, as in union(A_i, i in I)"); }
| 'intersection(' args = function_arguments ')' { Assert("intersection", 2, $args.list.Count); $value = $args.list[1] is Entity.Set.Inf { Element: Variable } intersectionRange ? MathS.Sets.IndexedIntersection($args.list[0], intersectionRange.Element, intersectionRange.SupSet) : throw new InvalidArgumentParseException("intersection expects its second argument to say which name ranges over which set, as in intersection(A_i, i in I)"); }
| 'complement(' args = function_arguments ')' { Assert("complement", 2, $args.list.Count); $value = MathS.Sets.Complement($args.list[0], $args.list[1]); }
| 'floor(' args = function_arguments ')' { Assert("floor", 1, $args.list.Count); $value = MathS.Floor($args.list[0]); }
| 'ceil(' args = function_arguments ')' { Assert("ceil", 1, $args.list.Count); $value = MathS.Ceil($args.list[0]); }
/* SymPy's spelling, accepted so that an expression copied from there parses. Stringize
Expand Down
8 changes: 7 additions & 1 deletion Sources/AngouriMath/Core/Antlr/AngouriMath.interp

Large diffs are not rendered by default.

60 changes: 33 additions & 27 deletions Sources/AngouriMath/Core/Antlr/AngouriMath.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,17 @@ T__160=161
T__161=162
T__162=163
T__163=164
NEWLINE=165
NUMBER=166
SPECIALSET=167
BOOLEAN=168
NAN=169
VARIABLE=170
COMMENT=171
WS=172
T__164=165
T__165=166
T__166=167
NEWLINE=168
NUMBER=169
SPECIALSET=170
BOOLEAN=171
NAN=172
VARIABLE=173
COMMENT=174
WS=175
'!'=1
'^'=2
'-'=3
Expand Down Expand Up @@ -316,22 +319,25 @@ WS=172
'phi('=144
'card('=145
'powerset('=146
'floor('=147
'ceil('=148
'ceiling('=149
'round('=150
'min('=151
'max('=152
'argmax('=153
'argmin('=154
'gcd('=155
'lcm('=156
'binomial('=157
'trunc('=158
'erf('=159
'conjugate('=160
'domain('=161
'piecewise('=162
'apply('=163
'lambda('=164
'NaN'=169
'union('=147
'intersection('=148
'complement('=149
'floor('=150
'ceil('=151
'ceiling('=152
'round('=153
'min('=154
'max('=155
'argmax('=156
'argmin('=157
'gcd('=158
'lcm('=159
'binomial('=160
'trunc('=161
'erf('=162
'conjugate('=163
'domain('=164
'piecewise('=165
'apply('=166
'lambda('=167
'NaN'=172
Loading
Loading