Skip to content

Commit bc65529

Browse files
conj, arg and det are refused by name, as conjugate is (#2157)
A name the parser does not know, followed by a bracket, is read as a product, so arg(z) was the variable arg times z, and arg(z) = 1 solved to { 1 / arg }, a root of nothing. #733 refuses such names one at a time, and conjugate was on that list. conj and arg are the conjugate and the argument as other systems spell them, and det the determinant, which a Matrix has as a property but an expression cannot call. Each now throws UnrecognizedFunctionParseException naming itself. re and im stay products: MissingFunctionNamesRefusedTest already records that as a choice, since two letters is short enough to be a variable's name. A name is refused only with its bracket, so re, arg and det as variables, or followed by an operator, read as they did. The parser is regenerated from the grammar with the ANTLR jar and the post-processor, and its classes stay internal. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 4ae8d25 commit bc65529

9 files changed

Lines changed: 955 additions & 822 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,21 @@ is `null`. A row with symbols in it is tried at one value of them, and where it
154154
| `MathS.Equations("ln(x) + ln(y)", "x - y").Solve("x", "y")` | `[[-1, -1], [1, 1]]` | `[[1, 1]]`: `ln(-1) + ln(-1)` is `2 pi i` |
155155
| `MathS.Equations("sqrt(y) - x", "y - a").Solve("x", "y")` | `[[sqrt(a), (sqrt(a)) ^ 2], [-sqrt(a), (-sqrt(a)) ^ 2]]` | `null`: the second row is a solution only at `a = 0` |
156156

157+
### `conj`, `arg` and `det` are refused by name
158+
159+
**Not silent: these now throw `UnrecognizedFunctionParseException` where they parsed.** A name the parser does not
160+
know, followed by a bracket, is read as a product, so `arg(z)` was the variable `arg` times `z`, and `arg(z) = 1`
161+
solved to `{ 1 / arg }`. `conjugate` was already refused by name; `conj` and `arg` are the conjugate and the argument
162+
as other systems spell them, and `det` is the determinant, which a `Matrix` has as the property `Determinant` but an
163+
expression cannot call. `re` and `im` are still read as products, as before: two letters is short enough to be a
164+
variable's name ([#2136](https://github.com/asc-community/AngouriMath/issues/2136)).
165+
166+
| Input | Was (2.6.0) | Now |
167+
|---|---|---|
168+
| `"arg(z)".ToEntity()` | `arg * z` | throws `UnrecognizedFunctionParseException` |
169+
| `"conj(z)".ToEntity()` | `conj * z` | throws `UnrecognizedFunctionParseException` |
170+
| `"det([[1, 2], [3, 4]])".ToEntity()` | `det * [[1, 2], [3, 4]]` | throws `UnrecognizedFunctionParseException` |
171+
157172
### A system with more or fewer equations than unknowns is solved or declined
158173

159174
**Not silent: what was an exception is an answer or `null`.** `EquationSystem.Solve` threw

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,13 @@ atom returns[Entity value]
634634

635635
| 'trunc(' args = function_arguments ')' { $value = NotImplementedFunction("trunc", "rounding functions"); }
636636
| 'conjugate(' args = function_arguments ')' { $value = NotImplementedFunction("conjugate", "complex conjugate as a symbolic function"); }
637+
/* conj and arg are the conjugate and the argument as other systems spell them, and det the
638+
determinant, which exists on a matrix but not in an expression. Each was read as a product:
639+
arg(z) was arg * z. re and im are left as products, as MissingFunctionNamesRefusedTest
640+
records. https://github.com/asc-community/AngouriMath/issues/2136 */
641+
| 'conj(' args = function_arguments ')' { $value = NotImplementedFunction("conj", "complex conjugate as a symbolic function"); }
642+
| 'arg(' args = function_arguments ')' { $value = NotImplementedFunction("arg", "complex argument as a symbolic function"); }
643+
| 'det(' args = function_arguments ')' { $value = NotImplementedFunction("det", "determinant in an expression; a Matrix has the property Determinant"); }
637644
| 'domain(' args = function_arguments ')'
638645
{
639646
Assert("domain", 2, $args.list.Count);

‎Sources/AngouriMath/Core/Antlr/AngouriMath.interp‎

Lines changed: 7 additions & 1 deletion
Large diffs are not rendered by default.

‎Sources/AngouriMath/Core/Antlr/AngouriMath.tokens‎

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,17 @@ T__181=182
183183
T__182=183
184184
T__183=184
185185
T__184=185
186-
NEWLINE=186
187-
NUMBER=187
188-
SPECIALSET=188
189-
BOOLEAN=189
190-
NAN=190
191-
VARIABLE=191
192-
COMMENT=192
193-
WS=193
186+
T__185=186
187+
T__186=187
188+
T__187=188
189+
NEWLINE=189
190+
NUMBER=190
191+
SPECIALSET=191
192+
BOOLEAN=192
193+
NAN=193
194+
VARIABLE=194
195+
COMMENT=195
196+
WS=196
194197
'!'=1
195198
'^'=2
196199
'-'=3
@@ -372,8 +375,11 @@ WS=193
372375
'Chi('=179
373376
'trunc('=180
374377
'conjugate('=181
375-
'domain('=182
376-
'piecewise('=183
377-
'apply('=184
378-
'lambda('=185
379-
'NaN'=190
378+
'conj('=182
379+
'arg('=183
380+
'det('=184
381+
'domain('=185
382+
'piecewise('=186
383+
'apply('=187
384+
'lambda('=188
385+
'NaN'=193

‎Sources/AngouriMath/Core/Antlr/AngouriMathLexer.cs‎

Lines changed: 561 additions & 552 deletions
Large diffs are not rendered by default.

‎Sources/AngouriMath/Core/Antlr/AngouriMathLexer.interp‎

Lines changed: 10 additions & 1 deletion
Large diffs are not rendered by default.

‎Sources/AngouriMath/Core/Antlr/AngouriMathLexer.tokens‎

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,17 @@ T__181=182
183183
T__182=183
184184
T__183=184
185185
T__184=185
186-
NEWLINE=186
187-
NUMBER=187
188-
SPECIALSET=188
189-
BOOLEAN=189
190-
NAN=190
191-
VARIABLE=191
192-
COMMENT=192
193-
WS=193
186+
T__185=186
187+
T__186=187
188+
T__187=188
189+
NEWLINE=189
190+
NUMBER=190
191+
SPECIALSET=191
192+
BOOLEAN=192
193+
NAN=193
194+
VARIABLE=194
195+
COMMENT=195
196+
WS=196
194197
'!'=1
195198
'^'=2
196199
'-'=3
@@ -372,8 +375,11 @@ WS=193
372375
'Chi('=179
373376
'trunc('=180
374377
'conjugate('=181
375-
'domain('=182
376-
'piecewise('=183
377-
'apply('=184
378-
'lambda('=185
379-
'NaN'=190
378+
'conj('=182
379+
'arg('=183
380+
'det('=184
381+
'domain('=185
382+
'piecewise('=186
383+
'apply('=187
384+
'lambda('=188
385+
'NaN'=193

0 commit comments

Comments
 (0)