@cortex-js/compute-engine 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/compute-engine.esm.js +4312 -3783
  2. package/dist/compute-engine.min.esm.js +2 -2
  3. package/dist/compute-engine.min.js +2 -2
  4. package/dist/math-json.esm.js +48 -13
  5. package/dist/math-json.min.esm.js +2 -2
  6. package/dist/math-json.min.js +2 -2
  7. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  8. package/dist/types/common/signals.d.ts +1 -1
  9. package/dist/types/compute-engine/assume.d.ts +1 -1
  10. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +6 -5
  11. package/dist/types/compute-engine/boxed-expression/box.d.ts +3 -5
  12. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +3 -3
  13. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +32 -6
  14. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
  15. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +5 -3
  16. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +3 -3
  17. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +3 -3
  18. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -3
  19. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +5 -5
  20. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +4 -4
  21. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  22. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  23. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  24. package/dist/types/compute-engine/boxed-expression/utils.d.ts +3 -3
  25. package/dist/types/compute-engine/compute-engine.d.ts +10 -8
  26. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  27. package/dist/types/compute-engine/dictionary/arithmetic-add.d.ts +2 -2
  28. package/dist/types/compute-engine/dictionary/arithmetic-divide.d.ts +1 -1
  29. package/dist/types/compute-engine/dictionary/arithmetic-multiply.d.ts +1 -1
  30. package/dist/types/compute-engine/dictionary/arithmetic-power.d.ts +1 -1
  31. package/dist/types/compute-engine/dictionary/arithmetic.d.ts +1 -1
  32. package/dist/types/compute-engine/dictionary/collections.d.ts +1 -1
  33. package/dist/types/compute-engine/dictionary/core.d.ts +1 -1
  34. package/dist/types/compute-engine/dictionary/dictionary.d.ts +1 -1
  35. package/dist/types/compute-engine/dictionary/logic.d.ts +1 -1
  36. package/dist/types/compute-engine/dictionary/polynomials.d.ts +1 -1
  37. package/dist/types/compute-engine/dictionary/relational-operator.d.ts +1 -1
  38. package/dist/types/compute-engine/dictionary/sets.d.ts +1 -1
  39. package/dist/types/compute-engine/dictionary/trigonometry.d.ts +1 -1
  40. package/dist/types/compute-engine/domain-utils.d.ts +1 -1
  41. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  42. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  43. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  44. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  45. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
  46. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  47. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  48. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  49. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  50. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  51. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -2
  52. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +2 -2
  53. package/dist/types/compute-engine/latex-syntax/parse.d.ts +10 -9
  54. package/dist/types/compute-engine/latex-syntax/public.d.ts +23 -24
  55. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  56. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  57. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  58. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  59. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  60. package/dist/types/compute-engine/numerics/numeric-decimal.d.ts +1 -1
  61. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  62. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  63. package/dist/types/compute-engine/public.d.ts +72 -76
  64. package/dist/types/compute-engine/rules.d.ts +1 -1
  65. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  66. package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
  67. package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
  68. package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
  69. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  70. package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
  71. package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
  72. package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
  73. package/dist/types/compute-engine.d.ts +3 -2
  74. package/dist/types/math-json/math-json-format.d.ts +1 -1
  75. package/dist/types/math-json/utils.d.ts +3 -4
  76. package/dist/types/math-json.d.ts +2 -2
  77. package/package.json +6 -7
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const DEFINITIONS_TRIGONOMETRY: LatexDictionary;
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { WarningSignal } from '../../../common/signals';
3
3
  export declare type CommonEntry = {
4
4
  name?: string;
@@ -7,7 +7,6 @@ export declare type CommonEntry = {
7
7
  export declare type SymbolEntry = CommonEntry & {
8
8
  kind: 'symbol';
9
9
  precedence: number;
10
- arguments: 'group' | 'implicit' | '';
11
10
  optionalLatexArg: number;
12
11
  requiredLatexArg: number;
13
12
  parse: SymbolParseHandler;
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { Serializer } from './serializer';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
4
  import { WarningSignalHandler } from '../../common/signals';
@@ -16,7 +16,7 @@ export declare class LatexSyntax {
16
16
  onError?: WarningSignalHandler;
17
17
  });
18
18
  updateOptions(opt: Partial<NumberFormattingOptions> & Partial<ParseLatexOptions> & Partial<SerializeLatexOptions>): void;
19
- static getDictionary(domain?: DictionaryCategory | 'all'): Readonly<LatexDictionary>;
19
+ static getDictionary(category?: DictionaryCategory | 'all'): Readonly<LatexDictionary>;
20
20
  parse(latex: LatexString): Expression;
21
21
  serialize(expr: Expression): LatexString;
22
22
  get serializer(): Serializer;
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { ParseLatexOptions, LatexToken, NumberFormattingOptions, Delimiter, Terminator, Parser } from './public';
3
3
  import { IndexedLatexDictionary, InfixEntry, PostfixEntry, PrefixEntry, SymbolEntry } from './dictionary/definitions';
4
4
  import { WarningSignalHandler } from '../../common/signals';
@@ -79,11 +79,13 @@ export declare class _Parser implements Parser {
79
79
  matchPrefixOperator(until?: Terminator): Expression | null;
80
80
  matchInfixOperator(lhs: Expression, until?: Terminator): Expression | null;
81
81
  /**
82
- * 'group' : will look for an argument inside a pair of `()`
83
- * 'implicit': either an expression inside a pair of `()`, or just a primary
82
+ * - 'enclosure' : will look for an argument inside an enclosure (open/close fence)
83
+ * - 'implicit': either an expression inside a pair of `()`, or just a primary
84
84
  * (i.e. we interpret `\cos x + 1` as `\cos(x) + 1`)
85
+ * - 'group': the arguments follow until an end of group, `<}>`. This is the
86
+ * case for example for `\displaystyle`
85
87
  */
86
- matchArguments(kind: undefined | '' | 'group' | 'implicit'): Expression[] | null;
88
+ matchArguments(kind: undefined | '' | 'enclosure' | 'implicit' | 'group'): Expression[] | null;
87
89
  /** If matches the normalized open delimiter, returns the
88
90
  * expected closing delimiter.
89
91
  *
@@ -103,7 +105,8 @@ export declare class _Parser implements Parser {
103
105
  /**
104
106
  * A symbol can be:
105
107
  * - a constant: `\pi`
106
- * - a variable: `x`
108
+ * - a single-letter variable: `x`
109
+ * - a multi-letter variable: `\mathit{speed}` or `\mathrm{speed}`
107
110
  * - a function with explicit arguments `f(x)`
108
111
  * - a function with implicit arguments: `\cos x`
109
112
  * - a command: `\frac{2}{3}`
@@ -133,9 +136,7 @@ export declare class _Parser implements Parser {
133
136
  */
134
137
  matchSupsub(lhs: Expression | null): Expression | null;
135
138
  matchPostfix(lhs: Expression | null): Expression | null;
136
- matchString(until: {
137
- tokens: LatexToken[];
138
- } & Partial<Terminator>): string;
139
+ matchString(until: Partial<Terminator>): string;
139
140
  matchEnvironmentName(command: '\\begin' | '\\end', envName: string): boolean;
140
141
  /**
141
142
  * Match an expression in a tabular format,
@@ -192,7 +193,7 @@ export declare class _Parser implements Parser {
192
193
  */
193
194
  matchExpression(until?: Partial<Terminator>): Expression | null;
194
195
  /**
195
- * Add latex or other requested metadata to the expression
196
+ * Add LaTeX or other requested metadata to the expression
196
197
  */
197
198
  decorate(expr: Expression | null, start: number): Expression | null;
198
199
  }
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { Expression } from '../../math-json/math-json-format';
3
3
  import type { IComputeEngine } from '../public';
4
4
  /**
@@ -165,6 +165,7 @@ export declare type SymbolEntry = BaseEntry & {
165
165
  precedence?: number;
166
166
  /**
167
167
  * Indicate if this symbol can be followed by arguments.
168
+ *
168
169
  * The presence of arguments will indicate that the arguments should be
169
170
  * applied to the symbol. Otherwise, the invisible operator is applied
170
171
  * to the symbol and the arguments.
@@ -172,14 +173,14 @@ export declare type SymbolEntry = BaseEntry & {
172
173
  * If `arguments` is `"group"`:
173
174
  *
174
175
  * "f(x)" -> `["f", "x"]`
175
- * "f x" -> `["multiply", "f", "x"]`
176
+ * "f x" -> `["Multiply", "f", "x"]`
176
177
  *
177
178
  * If `arguments` is `""`:
178
179
  *
179
- * "f(x)" -> `["multiply", "f", ["group", "x"]]`
180
- * "f x" -> `["multiply", "f", "x"]`
180
+ * "f(x)" -> `["Multiply", "f", "x"]`
181
+ * "f x" -> `["Multiply", "f", "x"]`
181
182
  *
182
- * If `arguments` is `"group/primary"` and the symbol is followed either
183
+ * If `arguments` is `"implicit"` and the symbol is followed either
183
184
  * by a group or by a primary (prefix + symbol + subsupfix + postfix).
184
185
  * Used for trig functions. i.e. `\sin x` vs `\sin(x)`:
185
186
  *
@@ -187,9 +188,7 @@ export declare type SymbolEntry = BaseEntry & {
187
188
  * "f x" -> `["f", "x"]`
188
189
  *
189
190
  */
190
- arguments?: 'group' | 'implicit' | '';
191
191
  /**
192
- * Applicable when `kind` is `"symbol"`.
193
192
  *
194
193
  * If a LaTeX command (i.e. the trigger starts with `\`, e.g. `\sqrt`)
195
194
  * indicates the number of optional arguments expected (indicate with
@@ -200,7 +199,6 @@ export declare type SymbolEntry = BaseEntry & {
200
199
  */
201
200
  optionalLatexArg?: number;
202
201
  /**
203
- * Applicable when `kind` is `"symbol"`.
204
202
  *
205
203
  * If a LaTeX command (i.e. the trigger starts with `\`, e.g. `\frac`)
206
204
  * indicates the number of required arguments expected (indicated with
@@ -217,7 +215,6 @@ export declare type SymbolEntry = BaseEntry & {
217
215
  */
218
216
  export declare type DefaultEntry = BaseEntry & {
219
217
  precedence?: number;
220
- arguments?: 'group' | 'implicit' | '';
221
218
  optionalLatexArg?: number;
222
219
  requiredLatexArg?: number;
223
220
  parse?: Expression | SymbolParseHandler;
@@ -280,22 +277,22 @@ export declare type ParseLatexOptions = {
280
277
  */
281
278
  parseNumbers: boolean;
282
279
  /**
283
- * The `parseUnknownToken` function is invoked when a token (`a`,
284
- * `\alpha`...) is encountered at a position where a symbol or a function
285
- * could be parsed.
280
+ * This handler is invoked when the parser encounter a set of tokens
281
+ * at a position that could be a symbol or function.
282
+ *
283
+ * The `symbol` argument is one or more tokens.
286
284
  *
287
- * If it returns `symbol` or `function`, the token is interpreted as a symbol
288
- * or function, respectively.
285
+ * The handler can return:
289
286
  *
290
- * If a `function` and the token is followed by an apply function operator
291
- * (typically, parentheses), parse them as arguments to the function.
287
+ * - `symbol` to indicate the string represent a constant or variable.
292
288
  *
293
- * If `skip`, the token is skipped as if it was not present. This is
294
- * convenient for purely presentational commands, such as `\displaystyle`.
289
+ * - `function` to indicate the string is a function name. If an apply
290
+ * function operator (typically, parentheses) follow, parse them as arguments
291
+ * to the function.
295
292
  *
296
- * If `error`, an error condition is raised.
293
+ * - `error`, an error condition is raised.
297
294
  */
298
- parseUnknownToken: (token: LatexToken, parser: Parser) => 'symbol' | 'function' | 'skip' | 'error';
295
+ parseUnknownSymbol: (symbol: string, parser: Parser) => 'symbol' | 'function' | 'unknown';
299
296
  /**
300
297
  * If true, the expression will be decorated with the LaTeX
301
298
  * fragments corresponding to each elements of the expression.
@@ -515,16 +512,18 @@ export interface Parser {
515
512
  /** If the next tokens correspond to an optional LaTeX argument,
516
513
  * enclosed with `[` and `]` return the content of the argument
517
514
  * as an expression and advance the index past the closing `]`.
515
+ *
518
516
  * Otherwise, return `null`.
519
517
  */
520
518
  matchOptionalLatexArgument(): Expression | null;
521
519
  matchRequiredLatexArgument(): Expression | null;
522
520
  /**
523
- * 'group' : will look for an argument inside a pair of `()`
524
- * 'implicit': either an expression inside a pair of `()`, or just a primary
525
- * (i.e. we interpret `\cos x + 1` as `\cos(x) + 1`)
521
+ * - 'enclosure' : will look for an argument inside an enclosure (an open/close fence)
522
+ * - 'group': arguments follow directly the symbol, until an end of group token `<}>`
523
+ * - 'implicit': either an expression inside a pair of `()`, or just a primary
524
+ * (i.e. we interpret `\cos x + 1` as `\cos(x) + 1`)
526
525
  */
527
- matchArguments(kind: '' | 'group' | 'implicit'): Expression[] | null;
526
+ matchArguments(kind: '' | 'group' | 'implicit' | 'enclosure'): Expression[] | null;
528
527
  /** If matches the normalized open delimiter, returns the
529
528
  * expected closing delimiter.
530
529
  *
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { NumberFormattingOptions } from './public';
3
3
  export declare function serializeNumber(expr: Expression | null, options: NumberFormattingOptions): string;
4
4
  export declare function serializeEngineeringNotationNumber(value: number, options: NumberFormattingOptions): string;
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare function getApplyFunctionStyle(_expr: Expression, _level: number): 'paren' | 'leftright' | 'big' | 'none';
3
3
  export declare function getGroupStyle(_expr: Expression, _level: number): 'paren' | 'leftright' | 'big' | 'none';
4
4
  export declare function getRootStyle(_expr: Expression | null, level: number): 'radical' | 'quotient' | 'solidus';
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { NumberFormattingOptions, LatexString, SerializeLatexOptions } from './public';
3
3
  import { IndexedLatexDictionary, SymbolEntry } from './dictionary/definitions';
4
4
  import { WarningSignalHandler } from '../../common/signals';
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  * ## Reference
3
3
  * TeX source code:
4
4
  * {@link http://tug.org/texlive/devsrc/Build/source/texk/web2c/tex.web | Tex.web}
@@ -1,3 +1,3 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare function gamma(c: Complex): Complex;
3
3
  export declare function lngamma(c: Complex): Complex;
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { IComputeEngine } from '../public';
3
3
  export declare function gcd(a: Decimal, b: Decimal): Decimal;
4
4
  export declare function lcm(a: Decimal, b: Decimal): Decimal;
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const MACHINE_PRECISION: number;
3
3
  export declare const MACHINE_TOLERANCE_BITS = 7;
4
4
  export declare const MACHINE_TOLERANCE: number;
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare function isPrime(n: number): boolean | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  * The most important classes are {@link ComputeEngine} and
3
3
  * {@link BoxedExpression}.
4
4
  *
@@ -122,13 +122,59 @@ export declare type BoxedRule = [
122
122
  condition: undefined | ((wildcards: Substitution) => boolean)
123
123
  ];
124
124
  export declare type BoxedRuleSet = Set<BoxedRule>;
125
+ export declare type ParametricDomainFunction = 'Function' | 'Union' | 'List' | 'Record' | 'Tuple' | 'Intersection' | 'Range' | 'Interval' | 'Optional' | 'Some' | 'Head' | 'Symbol' | 'Literal';
126
+ export declare type ParametricDomain = [
127
+ ParametricDomainFunction,
128
+ ...DomainExpression[]
129
+ ];
130
+ export declare type DomainExpression = string | ParametricDomain;
125
131
  /**
126
132
  * Domains can be defined as a union or intersection of domains:
127
133
  * - `["Union", "Number", "Boolean"]` A number or a boolean.
128
134
  * - `["SetMinus", "Number", 1]` Any number except "1".
129
135
  *
130
136
  */
131
- export declare type DomainExpression = BoxedExpression;
137
+ export interface Domain extends BoxedExpression {
138
+ isSubdomainOf(dom: Domain | string): boolean;
139
+ isMemberOf(expr: BoxedExpression): boolean;
140
+ readonly domainExpression: DomainExpression;
141
+ codomain: Domain | null;
142
+ readonly isNothing: boolean;
143
+ is(s: BoxedExpression): boolean;
144
+ readonly isBoolean: boolean;
145
+ readonly isNumeric: boolean;
146
+ readonly isFunction: boolean;
147
+ readonly isPredicate: boolean;
148
+ /**
149
+ * If true, when all the arguments are numeric, the result of the
150
+ * evaluation is numeric. Numeric is any value with a domain of `Number`.
151
+ *
152
+ * Example of numeric functions: `Add`, `Multiply`, `Power`, `Abs`
153
+ *
154
+ * Default: false
155
+ */
156
+ readonly isNumericFunction: boolean;
157
+ readonly isRealFunction: boolean;
158
+ /**
159
+ * If true, when all the arguments are boolean, the result of the
160
+ * evaluation is a boolean. Boolean is any value with a domain of `MaybeBoolean`.
161
+ *
162
+ * Example of logic functions: `And`, `Or`, `Not`, `Implies`
163
+ *
164
+ * **Default:** false
165
+ */
166
+ readonly isLogicOperator: boolean;
167
+ /**
168
+ * The function represent a relation between the first argument and
169
+ * the second argument, and evaluates to a boolean indicating if the relation
170
+ * is satisfied.
171
+ *
172
+ * For example, `Equal`, `Less`, `Approx`, etc...
173
+ *
174
+ * **Default:** false
175
+ */
176
+ readonly isRelationalOperator: boolean;
177
+ }
132
178
  /**
133
179
  * Options to control the serialization to MathJSON when using `BoxedExpression.json`.
134
180
  */
@@ -216,7 +262,7 @@ export interface BoxedExpression {
216
262
  * @category Object Methods
217
263
  *
218
264
  */
219
- is(rhs: any): boolean;
265
+ is(rhs: unknown): boolean;
220
266
  /** @internal */
221
267
  get hash(): number;
222
268
  /** An optional short description of the symbol or function head.
@@ -468,12 +514,6 @@ export interface BoxedExpression {
468
514
  *
469
515
  */
470
516
  get string(): string | null;
471
- /** True if this domain is a subset of domain `d`
472
- *
473
- * @category Expression Properties
474
- *
475
- */
476
- isSubsetOf(d: BoxedExpression | string): undefined | boolean;
477
517
  /** True if the value of this expression is a number.
478
518
  *
479
519
  * `isExtendedComplex || isNaN` = `isReal || isImaginary || isInfinity || isNaN`
@@ -693,11 +733,17 @@ export interface BoxedExpression {
693
733
  * first in commutative functions
694
734
  */
695
735
  get complexity(): number;
696
- /** The domain of this expression, using the value of the expression,
697
- * definitions associated with this expression and assumptions if necessary */
698
- get domain(): BoxedExpression;
736
+ /** The domain of this expression. */
737
+ get domain(): Domain;
699
738
  /** Symbols that represent a variable, can have their domain modified */
700
- set domain(domain: BoxedExpression | string);
739
+ set domain(domain: Domain | string);
740
+ /** The domain of the value of this expression, using the value of the expression,
741
+ * definitions associated with this expression and assumptions if necessary.
742
+ *
743
+ * For symbols, the `domain` and `valueDomain` are the same. For functions,
744
+ * the `valueDomain` is the codomain of the function.
745
+ */
746
+ get valueDomain(): Domain;
701
747
  /** For symbols and functions, a possible definition associated with the expression */
702
748
  get functionDefinition(): BoxedFunctionDefinition | undefined;
703
749
  get symbolDefinition(): BoxedSymbolDefinition | undefined;
@@ -975,9 +1021,14 @@ export declare type BaseDefinition = {
975
1021
  *
976
1022
  * For symbols, this is the domain of their value.
977
1023
  *
978
- * For functions, this is the domain of their result (aka codomain)
1024
+ * For functions, this is the signature of the function
1025
+ *
1026
+ * When `domain` is a handler, calculate the domain (or signature) based on
1027
+ * the arguments (for expressions others than functions, `args` is an empty
1028
+ * array). If the function cannot be applied to the arguments, return
1029
+ * `null`.
979
1030
  */
980
- domain?: BoxedExpression | string;
1031
+ domain?: Domain | DomainExpression | string | ((ce: IComputeEngine, args: BoxedExpression[]) => Domain | DomainExpression);
981
1032
  };
982
1033
  export declare type BoxedBaseDefinition = {
983
1034
  name: string;
@@ -990,7 +1041,7 @@ export declare type BoxedBaseDefinition = {
990
1041
  * This field is usually undefined, but its value is set by `getDefinition()`
991
1042
  */
992
1043
  scope: RuntimeScope | undefined;
993
- domain?: BoxedExpression;
1044
+ domain?: Domain | ((ce: IComputeEngine, args: BoxedExpression[]) => Domain | DomainExpression);
994
1045
  _purge(): undefined;
995
1046
  };
996
1047
  /**
@@ -1053,34 +1104,6 @@ export declare type FunctionDefinitionFlags = {
1053
1104
  * **Default**: `false`
1054
1105
  */
1055
1106
  involution: boolean;
1056
- /**
1057
- * If true, when all the arguments are numeric, the result of the
1058
- * evaluation is numeric. Numeric is any value with a domain of `Number`.
1059
- *
1060
- * Example of numeric functions: `Add`, `Multiply`, `Power`, `Abs`
1061
- *
1062
- * Default: false
1063
- */
1064
- numeric: boolean;
1065
- /**
1066
- * If true, when all the arguments are boolean, the result of the
1067
- * evaluation is a boolean. Boolean is any value with a domain of `MaybeBoolean`.
1068
- *
1069
- * Example of logic functions: `And`, `Or`, `Not`, `Implies`
1070
- *
1071
- * **Default:** false
1072
- */
1073
- logic: boolean;
1074
- /**
1075
- * The function represent a relation between the first argument and
1076
- * the second argument, and evaluates to a boolean indicating if the relation
1077
- * is satisfied.
1078
- *
1079
- * For example, `Equal`, `Less`, `Approx`, etc...
1080
- *
1081
- * **Default:** false
1082
- */
1083
- relationalOperator: boolean;
1084
1107
  /** If true, the value of this function is always the same for a given
1085
1108
  * set of arguments and it has no side effects.
1086
1109
  *
@@ -1252,31 +1275,6 @@ export declare type FunctionDefinition = BaseDefinition & Partial<FunctionDefini
1252
1275
  *
1253
1276
  */
1254
1277
  N?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined;
1255
- /**
1256
- *
1257
- * Calculate the domain of the result, based on the value of the arguments.
1258
- *
1259
- * If the domain of the result is always the same, use the `domain` property
1260
- * instead.
1261
- *
1262
- * The argument `args` represent the arguments of the function.
1263
- *
1264
- * The return value is `null` if the input arguments cannot be handled by
1265
- * this definition.
1266
- *
1267
- * Otherwise, the return value is the domain of the result.
1268
- *
1269
- * Return `"Nothing"` if the arguments are acceptable, but the evaluation
1270
- * will fail, for example in some cases if there are missing arguments.
1271
- *
1272
- * This function is used to select the correct definition when there are
1273
- * multiple definitions for the same function name.
1274
- *
1275
- * For example it allows to distinguish between a `Add` function that
1276
- * applies to numbers and an `Add` function that applies to tensors.
1277
- *
1278
- */
1279
- evalDomain?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | string | null;
1280
1278
  /** Dimensional analysis
1281
1279
  * @experimental
1282
1280
  */
@@ -1295,7 +1293,6 @@ export declare type BoxedFunctionDefinition = BoxedBaseDefinition & FunctionDefi
1295
1293
  simplify?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined;
1296
1294
  evaluate?: BoxedLambdaExpression | ((ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined);
1297
1295
  N?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined;
1298
- evalDomain?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | string | null;
1299
1296
  evalDimension?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression;
1300
1297
  sgn?: (ce: IComputeEngine, args: BoxedExpression[]) => -1 | 0 | 1 | undefined;
1301
1298
  compile?: (expr: BoxedExpression) => CompiledExpression;
@@ -1361,7 +1358,7 @@ export declare type SymbolDefinition = BaseDefinition & Partial<SymbolFlags> & P
1361
1358
  * `Pi`, the actual value depends on the `precision` setting of the
1362
1359
  * `ComputeEngine` */
1363
1360
  value?: LatexString | SemiBoxedExpression | ((ce: IComputeEngine) => SemiBoxedExpression | null);
1364
- domain?: string | BoxedExpression;
1361
+ domain?: string | Domain;
1365
1362
  };
1366
1363
  export interface BoxedSymbolDefinition extends BoxedBaseDefinition, Partial<SymbolFlags>, SymbolDefinitionFlags {
1367
1364
  get value(): BoxedExpression | undefined;
@@ -1427,7 +1424,7 @@ export interface IComputeEngine {
1427
1424
  readonly iterationLimit: number;
1428
1425
  /** @experimental */
1429
1426
  readonly recursionLimit: number;
1430
- defaultDomain: null | BoxedExpression;
1427
+ defaultDomain: null | Domain;
1431
1428
  /** {@inheritDoc NumericMode} */
1432
1429
  numericMode: NumericMode;
1433
1430
  tolerance: number;
@@ -1452,7 +1449,7 @@ export interface IComputeEngine {
1452
1449
  /**
1453
1450
  * Return `undefined` if no definition exist for this `head.
1454
1451
  */
1455
- getFunctionDefinition(head: string, wikidata?: string): undefined | BoxedFunctionDefinition;
1452
+ getFunctionDefinition(head: string, args?: BoxedExpression[]): undefined | BoxedFunctionDefinition;
1456
1453
  /**
1457
1454
  * Returned a boxed expression from the input.
1458
1455
  *
@@ -1466,7 +1463,7 @@ export interface IComputeEngine {
1466
1463
  /** Return a canonical boxed string */
1467
1464
  string(s: string, metadata?: Metadata): BoxedExpression;
1468
1465
  /** Return a canonical boxed domain */
1469
- domain(domain: BoxedExpression | string, metadata?: Metadata): BoxedExpression;
1466
+ domain(domain: SemiBoxedExpression | Domain | string, metadata?: Metadata): Domain;
1470
1467
  /** Return a canonical expression.
1471
1468
  *
1472
1469
  * Note that the result may not be a function, or may have a different
@@ -1577,7 +1574,7 @@ export interface IComputeEngine {
1577
1574
  *
1578
1575
  *
1579
1576
  */
1580
- assume(symbol: LatexString | SemiBoxedExpression, domain: BoxedExpression): AssumeResult;
1577
+ assume(symbol: LatexString | SemiBoxedExpression, domain: Domain): AssumeResult;
1581
1578
  assume(predicate: LatexString | SemiBoxedExpression): AssumeResult;
1582
1579
  assume(arg1: LatexString | SemiBoxedExpression, arg2?: BoxedExpression): AssumeResult;
1583
1580
  /** Remove all assumptions about one or more symbols */
@@ -1614,4 +1611,3 @@ export interface IComputeEngine {
1614
1611
  /** @internal */
1615
1612
  _unregister(expr: BoxedExpression): void;
1616
1613
  }
1617
- export declare function getVars(expr: BoxedExpression): string[];
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare function boxRules(ce: IComputeEngine, rs: Iterable<Rule>): BoxedRuleSet;
3
3
  /**
4
4
  * Apply the rules in the ruleset and return a modified expression.
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  /**
3
3
  * A set of simplification rules.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  /**
3
3
  * Return the expansion of ['Multiply', lhs, rhs]
4
4
  * - lhs = 'a + b', rhs = '2'
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  /**
3
3
  * Flatten the arguments.
4
4
  * If `expr` was canonical, the result it canonical.
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  /**
3
3
  * Distribute `Negate` (multiply by -1) if expr is a number literal, an
4
4
  * addition or another `Negate`.
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  /**
3
3
  * Coefficient of a univariate (single variable) polynomial.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  /**
3
3
  * Group terms in a product by common term.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare class Sum {
3
3
  private engine;
4
4
  private _literal;
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  /**
3
3
  * If expression is a product or a division, collect all the terms with a
4
4
  * negative exponents in the denominator, and all the terms
@@ -1,3 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export { ComputeEngine } from './compute-engine/compute-engine';
3
- export declare const version = "0.5.0";
3
+ export declare const version = "0.6.0";
4
+ export { getVars } from './compute-engine/boxed-expression/utils';
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  /** A human readable string to annotate an expression, since JSON does not
3
3
  * allow comments in its encoding */
4
4
  comment?: string;
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  /**
3
3
  * These constants are the 'primitive' functions and constants that are used
4
4
  * for some basic manipulations such as parsing, and transforming to canonical
@@ -53,6 +53,8 @@ export declare function headName(expr: Expression | null): string;
53
53
  export declare function op(expr: Expression | null, n: number): Expression | null;
54
54
  export declare function nops(expr: Expression): number;
55
55
  export declare function symbol(expr: Expression | null): string | null;
56
+ export declare function string(expr: Expression | null): string | null;
57
+ export declare function dictionary(expr: Expression | null): null | Record<string, Expression>;
56
58
  export declare function machineValue(expr: Expression | null): number | null;
57
59
  /**
58
60
  * Return a rational (numer over denom) representation of the expression,
@@ -77,9 +79,6 @@ export declare function applyRecursively(expr: Expression, fn: (x: Expression) =
77
79
  * Apply a function to the arguments of a function and return an array of T
78
80
  */
79
81
  export declare function mapArgs<T>(expr: Expression, fn: (x: Expression) => T): T[];
80
- export declare function dictionary(expr: Expression): {
81
- [key: string]: Expression;
82
- } | null;
83
82
  /**
84
83
  * Return num as a number if it's a valid JSON number (that is
85
84
  * a valid JavaScript number but not NaN or +/-Infinity) or
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export { isAtomic, isSymbolObject, isStringObject, isFunctionObject, isDictionaryObject, stringValue as getStringValue, head, headName, symbol, tail, applyRecursively, mapArgs, op, nops, dictionary as getDictionary, asValidJSONNumber, } from './math-json/utils';
3
3
  export type { LatexToken, ParseHandler, SerializeHandler, LatexDictionaryEntry, LatexDictionary, ParseLatexOptions, SerializeLatexOptions, NumberFormattingOptions, } from './compute-engine/latex-syntax/public';
4
- export declare const version = "0.5.0";
4
+ export declare const version = "0.6.0";