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
22 changes: 22 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ The calculus nodes and the binders — `derivative`, `integral`, `limit`, `sum`,
names the node and says to compile `.Evaled` or `Simplify()` instead. The LINQ compiler said the bound variable was not
among the arguments.

### `factorize`, `nextprime`, `divisors`, `gradient`, `divergence` and `φ` are refused by name

**Not silent: these names followed by a bracket now throw `UnrecognizedFunctionParseException` where they were read as
products.** `factorize(360)` was `factorize * 360` and simplified to `360 * factorize`. The library has no node for any
of them, so each is refused with what to write today: in C#, `MathS.NumberTheory.Factorize(n)` for the prime factors of
an integer and `Factorize()` to factor an expression; `prime(primepi(n) + 1)` for the least prime above `n`;
`divisorsigma(0, n)` and `divisorsigma(1, n)` for the count and the sum of the divisors
([#2449](https://github.com/asc-community/AngouriMath/issues/2449)); `jacobian([f], [x, y])` for a gradient and
`trace(jacobian(F, [x, y]))` for a divergence ([#2182](https://github.com/asc-community/AngouriMath/issues/2182)).
Euler's totient is `phi(n)`, and `φ(n)` and `ϕ(n)` are refused. Each name without a bracket is still a variable.

| Input | Was (2.7.0) | Now |
|---|---|---|
| `"factorize(360)".ToEntity()` | `factorize * 360` | throws `UnrecognizedFunctionParseException` |
| `"nextprime(10)".ToEntity()` | `nextprime * 10` | throws `UnrecognizedFunctionParseException`: write `prime(primepi(n) + 1)` |
| `"divisors(12)".ToEntity()` | `divisors * 12` | throws `UnrecognizedFunctionParseException`: write `divisorsigma(0, n)` or `divisorsigma(1, n)` |
| `"φ(10)".ToEntity()` | `φ * 10` | throws `UnrecognizedFunctionParseException`: write `phi(n)` |
| `"ϕ(10)".ToEntity()` | `ϕ * 10` | throws `UnrecognizedFunctionParseException`: write `phi(n)` |
| `"gradient(x^2)".ToEntity()` | `gradient * x ^ 2` | throws `UnrecognizedFunctionParseException` |
| `"divergence(x)".ToEntity()` | `divergence * x` | throws `UnrecognizedFunctionParseException` |
| `"gradient(x^2*y, [x, y])".ToEntity()` | throws `UnhandledParseException` | throws `UnrecognizedFunctionParseException` |

---

### A system row that is not a solution declines the system
Expand Down
15 changes: 11 additions & 4 deletions Sources/AngouriMath/Convenience/MathS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6571,10 +6571,17 @@ internal static EDecimal DowncastingTolerance
/// (<a href="https://github.com/asc-community/AngouriMath/issues/373">#373</a>)
/// </para>
/// <para>
/// It is honoured only where an algorithm asks -- today that is the Gr&#246;bner
/// system solver. Everything else in the library bounds itself by ceilings of its
/// own that this does not reach, so setting it does not make an arbitrary call
/// bounded.
/// It is honoured only where an algorithm asks. Today that is the system solver --
/// its Gr&#246;bner path, and the ledger <see cref="Core.EquationSystem.Solve(Variable[])"/>
/// keeps over the whole call --, the rewrite graph wherever it runs:
/// <see cref="Core.Transformations.Transformation.EqualitySaturation(WorkBudget, Core.CostModel)"/>,
/// <see cref="Core.Transformations.Transformation.CanonicalizationOverGraph(WorkBudget)"/> and
/// <see cref="AreEqual(Entity, Entity, WorkBudget, Core.Transformations.Soundness, Core.Domain)"/>, and the proof that a written-out perfect
/// square is one, which <see cref="Entity.Factorize(int)"/> runs and
/// <see cref="Entity.Simplify(int)"/> offers as a candidate. <c>Simplify</c> itself
/// is not bounded by it, and nor is anything else in the library, each of which
/// bounds itself by ceilings of its own that this does not reach; so setting it does
/// not make an arbitrary call bounded.
/// </para>
/// </remarks>
/// <example>
Expand Down
11 changes: 11 additions & 0 deletions Sources/AngouriMath/Core/Antlr/AngouriMath.g
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,17 @@ atom returns[Entity value]
| 'factorial2(' args = function_arguments ')' { $value = NotAFunctionHere("factorial2", "the double factorial is the postfix n!!"); }
| 'fractionalpart(' args = function_arguments ')' { $value = NotAFunctionHere("fractionalpart", "write x mod 1, which is in [0, 1)"); }
| 'quotient(' args = function_arguments ')' { $value = NotAFunctionHere("quotient", "write floor(a / b)"); }
/* Names another system calls a function and this library has no node for, each refused
with what can be written today: factorize(360) was factorize * 360, and φ(10) was φ * 10.
factorize, nextprime and divisors: https://github.com/asc-community/AngouriMath/issues/2449.
gradient and divergence: https://github.com/asc-community/AngouriMath/issues/2182 */
| 'factorize(' args = function_arguments ')' { $value = NotImplementedFunction("factorize", "factorization node yet; in C#, MathS.NumberTheory.Factorize(n) gives the prime factors of an integer and Factorize() factors an expression"); }
| 'nextprime(' args = function_arguments ')' { $value = NotImplementedFunction("nextprime", "nextprime yet; prime(primepi(n) + 1) is the least prime greater than n"); }
| 'divisors(' args = function_arguments ')' { $value = NotImplementedFunction("divisors", "set of divisors yet; divisorsigma(0, n) counts them and divisorsigma(1, n) is their sum"); }
| 'gradient(' args = function_arguments ')' { $value = NotImplementedFunction("gradient", "gradient yet; jacobian([f], [x, y]) is the row of partial derivatives of f"); }
| 'divergence(' args = function_arguments ')' { $value = NotImplementedFunction("divergence", "divergence yet; trace(jacobian(F, [x, y])) is the divergence of F"); }
| 'φ(' args = function_arguments ')' { $value = NotAFunctionHere("φ", "Euler's totient is written phi(n)"); }
| 'ϕ(' args = function_arguments ')' { $value = NotAFunctionHere("ϕ", "Euler's totient is written phi(n)"); }
| 'domain(' args = function_arguments ')'
{
Assert("domain", 2, $args.list.Count);
Expand Down
16 changes: 15 additions & 1 deletion Sources/AngouriMath/Core/Antlr/AngouriMath.interp

Large diffs are not rendered by default.

40 changes: 27 additions & 13 deletions Sources/AngouriMath/Core/Antlr/AngouriMath.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,21 @@ T__226=227
T__227=228
T__228=229
T__229=230
NEWLINE=231
NUMBER=232
SPECIALSET=233
BOOLEAN=234
NAN=235
VARIABLE=236
COMMENT=237
WS=238
T__230=231
T__231=232
T__232=233
T__233=234
T__234=235
T__235=236
T__236=237
NEWLINE=238
NUMBER=239
SPECIALSET=240
BOOLEAN=241
NAN=242
VARIABLE=243
COMMENT=244
WS=245
'['=1
']'=2
'!'=3
Expand Down Expand Up @@ -462,8 +469,15 @@ WS=238
'factorial2('=224
'fractionalpart('=225
'quotient('=226
'domain('=227
'piecewise('=228
'apply('=229
'lambda('=230
'NaN'=235
'factorize('=227
'nextprime('=228
'divisors('=229
'gradient('=230
'divergence('=231
'φ('=232
'ϕ('=233
'domain('=234
'piecewise('=235
'apply('=236
'lambda('=237
'NaN'=242
Loading
Loading