@cortex-js/compute-engine 0.4.2 → 0.4.3

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 (132) hide show
  1. package/README.md +2 -2
  2. package/dist/compute-engine.esm.js +22446 -16214
  3. package/dist/compute-engine.js +22449 -16222
  4. package/dist/compute-engine.min.esm.js +2 -7
  5. package/dist/compute-engine.min.js +2 -7
  6. package/dist/math-json.esm.js +4336 -10528
  7. package/dist/math-json.js +4353 -10531
  8. package/dist/math-json.min.esm.js +2 -7
  9. package/dist/math-json.min.js +2 -7
  10. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  11. package/dist/types/common/signals.d.ts +90 -0
  12. package/dist/types/compute-engine/assume.d.ts +21 -6
  13. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +107 -0
  14. package/dist/types/compute-engine/boxed-expression/box.d.ts +56 -0
  15. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +39 -0
  16. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +8 -0
  17. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +2 -0
  18. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +93 -0
  19. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +83 -0
  20. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +21 -0
  21. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +23 -0
  22. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +98 -0
  23. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +74 -0
  24. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +12 -0
  25. package/dist/types/compute-engine/boxed-expression/order.d.ts +52 -0
  26. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +15 -0
  27. package/dist/types/compute-engine/boxed-expression/utils.d.ts +37 -0
  28. package/dist/types/compute-engine/compute-engine.d.ts +233 -97
  29. package/dist/types/compute-engine/cost-function.d.ts +3 -0
  30. package/dist/types/compute-engine/dictionary/arithmetic-add.d.ts +11 -0
  31. package/dist/types/compute-engine/dictionary/arithmetic-divide.d.ts +9 -0
  32. package/dist/types/compute-engine/dictionary/arithmetic-multiply.d.ts +17 -0
  33. package/dist/types/compute-engine/dictionary/arithmetic-power.d.ts +9 -0
  34. package/dist/types/compute-engine/dictionary/arithmetic.d.ts +2 -12
  35. package/dist/types/compute-engine/dictionary/collections.d.ts +1 -1
  36. package/dist/types/compute-engine/dictionary/core.d.ts +2 -2
  37. package/dist/types/compute-engine/dictionary/dictionary.d.ts +18 -11
  38. package/dist/types/compute-engine/dictionary/logic.d.ts +1 -1
  39. package/dist/types/compute-engine/dictionary/polynomials.d.ts +2 -0
  40. package/dist/types/compute-engine/dictionary/relational-operator.d.ts +2 -0
  41. package/dist/types/compute-engine/dictionary/sets.d.ts +1 -1
  42. package/dist/types/compute-engine/dictionary/trigonometry.d.ts +2 -2
  43. package/dist/types/compute-engine/domain-utils.d.ts +30 -0
  44. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +2 -0
  45. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +2 -0
  46. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +2 -0
  47. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +4 -0
  48. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +2 -0
  49. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +2 -0
  50. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +2 -0
  51. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +2 -0
  52. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +2 -0
  53. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +2 -0
  54. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +57 -0
  55. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +23 -0
  56. package/dist/types/compute-engine/latex-syntax/parse.d.ts +198 -0
  57. package/dist/types/compute-engine/latex-syntax/public.d.ts +550 -0
  58. package/dist/types/{common → compute-engine/latex-syntax}/serialize-number.d.ts +2 -3
  59. package/dist/types/{latex-syntax → compute-engine/latex-syntax}/serializer-style.d.ts +2 -1
  60. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +43 -0
  61. package/dist/types/{latex-syntax/core → compute-engine/latex-syntax}/tokenizer.d.ts +2 -2
  62. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +3 -0
  63. package/dist/types/compute-engine/numerics/numeric-decimal.d.ts +12 -0
  64. package/dist/types/compute-engine/numerics/numeric.d.ts +35 -0
  65. package/dist/types/compute-engine/numerics/primes.d.ts +2 -0
  66. package/dist/types/compute-engine/public.d.ts +1076 -434
  67. package/dist/types/compute-engine/rules.d.ts +16 -6
  68. package/dist/types/compute-engine/simplify-rules.d.ts +17 -0
  69. package/dist/types/compute-engine/symbolic/expand.d.ts +11 -0
  70. package/dist/types/compute-engine/symbolic/flatten.d.ts +7 -0
  71. package/dist/types/compute-engine/symbolic/negate.d.ts +12 -0
  72. package/dist/types/compute-engine/symbolic/polynomials.d.ts +52 -0
  73. package/dist/types/compute-engine/symbolic/product.d.ts +45 -0
  74. package/dist/types/compute-engine/symbolic/sum.d.ts +25 -0
  75. package/dist/types/compute-engine/symbolic/utils.d.ts +47 -0
  76. package/dist/types/compute-engine.d.ts +3 -5
  77. package/dist/types/math-json/math-json-format.d.ts +101 -0
  78. package/dist/types/math-json/utils.d.ts +97 -0
  79. package/dist/types/math-json.d.ts +5 -3
  80. package/package.json +27 -26
  81. package/dist/cortex.esm.js +0 -20989
  82. package/dist/cortex.js +0 -21011
  83. package/dist/cortex.min.esm.js +0 -7
  84. package/dist/cortex.min.js +0 -7
  85. package/dist/types/common/debug.d.ts +0 -28
  86. package/dist/types/common/utils.d.ts +0 -153
  87. package/dist/types/compute-engine/canonical-forms.d.ts +0 -74
  88. package/dist/types/compute-engine/dictionary/domains.d.ts +0 -26
  89. package/dist/types/compute-engine/dictionary/utils.d.ts +0 -5
  90. package/dist/types/compute-engine/domains.d.ts +0 -4
  91. package/dist/types/compute-engine/evaluate.d.ts +0 -13
  92. package/dist/types/compute-engine/expression-map.d.ts +0 -11
  93. package/dist/types/compute-engine/internal-compute-engine.d.ts +0 -108
  94. package/dist/types/compute-engine/numeric-complex.d.ts +0 -2
  95. package/dist/types/compute-engine/numeric-decimal.d.ts +0 -12
  96. package/dist/types/compute-engine/numeric.d.ts +0 -21
  97. package/dist/types/compute-engine/numerical-eval.d.ts +0 -5
  98. package/dist/types/compute-engine/order.d.ts +0 -18
  99. package/dist/types/compute-engine/patterns.d.ts +0 -22
  100. package/dist/types/compute-engine/predicates.d.ts +0 -42
  101. package/dist/types/compute-engine/simplify.d.ts +0 -6
  102. package/dist/types/compute-engine/utils.d.ts +0 -15
  103. package/dist/types/cortex/formatter.d.ts +0 -165
  104. package/dist/types/cortex/parse-cortex.d.ts +0 -5
  105. package/dist/types/cortex/reserved-words.d.ts +0 -1
  106. package/dist/types/cortex/serialize-cortex.d.ts +0 -14
  107. package/dist/types/cortex.d.ts +0 -8
  108. package/dist/types/latex-syntax/definitions-algebra.d.ts +0 -2
  109. package/dist/types/latex-syntax/definitions-arithmetic.d.ts +0 -3
  110. package/dist/types/latex-syntax/definitions-calculus.d.ts +0 -2
  111. package/dist/types/latex-syntax/definitions-core.d.ts +0 -3
  112. package/dist/types/latex-syntax/definitions-inequalities.d.ts +0 -2
  113. package/dist/types/latex-syntax/definitions-other.d.ts +0 -3
  114. package/dist/types/latex-syntax/definitions-sets.d.ts +0 -2
  115. package/dist/types/latex-syntax/definitions-symbols.d.ts +0 -3
  116. package/dist/types/latex-syntax/definitions-trigonometry.d.ts +0 -3
  117. package/dist/types/latex-syntax/definitions.d.ts +0 -40
  118. package/dist/types/latex-syntax/latex-syntax.d.ts +0 -27
  119. package/dist/types/latex-syntax/parse.d.ts +0 -138
  120. package/dist/types/latex-syntax/public.d.ts +0 -456
  121. package/dist/types/latex-syntax/serializer.d.ts +0 -26
  122. package/dist/types/latex-syntax/utils.d.ts +0 -10
  123. package/dist/types/point-free-parser/characters.d.ts +0 -25
  124. package/dist/types/point-free-parser/combinators.d.ts +0 -46
  125. package/dist/types/point-free-parser/core-combinators.d.ts +0 -78
  126. package/dist/types/point-free-parser/grammar.d.ts +0 -12
  127. package/dist/types/point-free-parser/identifier-parsers.d.ts +0 -7
  128. package/dist/types/point-free-parser/numeric-parsers.d.ts +0 -8
  129. package/dist/types/point-free-parser/parsers.d.ts +0 -130
  130. package/dist/types/point-free-parser/string-parsers.d.ts +0 -29
  131. package/dist/types/point-free-parser/whitespace-parsers.d.ts +0 -17
  132. package/dist/types/public.d.ts +0 -163
@@ -0,0 +1,90 @@
1
+ /* 0.4.3 */
2
+ export declare type SignalCode = RuntimeSignalCode | ('invalid-name' | 'expected-predicate' | 'expected-symbol' | 'operator-requires-one-operand' | 'postfix-operator-requires-one-operand' | 'prefix-operator-requires-one-operand' | 'unbalanced-symbols' | 'expected-argument' | 'unexpected-command' | 'cyclic-definition' | 'invalid-supersets' | 'expected-supersets' | 'unknown-domain' | 'duplicate-wikidata' | 'invalid-dictionary-entry' | 'syntax-error');
3
+ export declare type SignalMessage = SignalCode | [SignalCode, ...any[]];
4
+ export declare type SignalOrigin = {
5
+ url?: string;
6
+ source?: string;
7
+ offset?: number;
8
+ line?: number;
9
+ column?: number;
10
+ around?: string;
11
+ };
12
+ export declare type Signal = {
13
+ severity?: 'warning' | 'error';
14
+ /** An error/warning code or, a code with one or more arguments specific to
15
+ * the signal code.
16
+ */
17
+ message: SignalMessage;
18
+ /** If applicable, the head of the function about which the
19
+ * signal was raised
20
+ */
21
+ head?: string;
22
+ /** Location where the signal was raised. */
23
+ origin?: SignalOrigin;
24
+ };
25
+ export declare type ErrorSignal = Signal & {
26
+ severity: 'error';
27
+ };
28
+ export declare class CortexError extends Error {
29
+ constructor(errorSignal: Signal);
30
+ toString(): string;
31
+ }
32
+ export declare type WarningSignal = Signal & {
33
+ severity: 'warning';
34
+ };
35
+ export declare type WarningSignalHandler = (warnings: WarningSignal[]) => void;
36
+ /**
37
+ * The error codes can be used in an `ErrorCode` expression:
38
+ *
39
+ * `["ErrorCode", "'syntax-error'", arg1]`
40
+ *
41
+ * It evaluates to a localized, human-readable string.
42
+ *
43
+ *
44
+ * * `unknown-symbol`: a symbol was encountered which does not have a
45
+ * definition.
46
+ *
47
+ * * `unknown-operator`: a presumed operator was encountered which does not
48
+ * have a definition.
49
+ *
50
+ * * `unknown-function`: a LaTeX command was encountered which does not
51
+ * have a definition.
52
+ *
53
+ * * `unexpected-command`: a LaTeX command was encountered when only a string
54
+ * was expected
55
+ *
56
+ * * `unexpected-superscript`: a superscript was encountered in an unexpected
57
+ * context, or no `powerFunction` was defined. By default, superscript can
58
+ * be applied to numbers, symbols or expressions, but not to operators (e.g.
59
+ * `2+^34`) or to punctuation.
60
+ *
61
+ * * `unexpected-subscript`: a subscript was encountered in an unexpected
62
+ * context or no 'subscriptFunction` was defined. By default, subscripts
63
+ * are not expected on numbers, operators or symbols. Some commands (e.g. `\sum`)
64
+ * do expected a subscript.
65
+ *
66
+ * * `unexpected-sequence`: some adjacent elements were encountered (for
67
+ * example `xy`), but no `invisibleOperator` is defined, therefore the elements
68
+ * can't be combined. The default `invisibleOperator` is `Multiply`, but you
69
+ * can also use `list`.
70
+ *
71
+ * * `expected-argument`: a LaTeX command that requires one or more argument
72
+ * was encountered without the required arguments.
73
+ *
74
+ * * `expected-operand`: an operator was encountered without its required
75
+ * operands.
76
+ *
77
+ * * `non-associative-operator`: an operator which is not associative was
78
+ * encountered in an associative context, for example: `a < b < c` (assuming
79
+ * `<` is defined as non-associative)
80
+ *
81
+ * * `postfix-operator-requires-one-operand`: a postfix operator which requires
82
+ * a single argument was encountered with no arguments or more than one argument
83
+ *
84
+ * * `prefix-operator-requires-one-operand`: a prefix operator which requires
85
+ * a single argument was encountered with no arguments or more than one argument
86
+ *
87
+ * * `base-out-of-range`: The base is expected to be between 2 and 36.
88
+ *
89
+ */
90
+ export declare type ErrorCode = 'expected-argument' | 'unexpected-argument' | 'expected-operator' | 'expected-operand' | 'invalid-name' | 'invalid-dictionary-entry' | 'unknown-symbol' | 'unknown-operator' | 'unknown-function' | 'unknown-command' | 'unexpected-command' | 'unbalanced-symbols' | 'unexpected-superscript' | 'unexpected-subscript' | 'unexpected-sequence' | 'non-associative-operator' | 'function-has-too-many-arguments' | 'function-has-too-few-arguments' | 'operator-requires-one-operand' | 'infix-operator-requires-two-operands' | 'prefix-operator-requires-one-operand' | 'postfix-operator-requires-one-operand' | 'associative-function-has-too-few-arguments' | 'commutative-function-has-too-few-arguments' | 'threadable-function-has-too-few-arguments' | 'hold-first-function-has-too-few-arguments' | 'hold-rest-function-has-too-few-arguments' | 'base-out-of-range' | 'syntax-error';
@@ -1,6 +1,21 @@
1
- /* 0.4.2 */
2
- import { ComputeEngine, Numeric } from './public';
3
- export declare function internalIs(engine: ComputeEngine, proposition: Expression): boolean | undefined;
4
- export declare function normalizeProposition<T extends number = Numeric>(proposition: Expression<T>): [Expression<T>, boolean];
5
- export declare function internalAssume<T extends number = Numeric>(engine: ComputeEngine<T>, proposition: Expression<T>): 'contradiction' | 'tautology' | 'ok';
6
- export declare function forget<T extends number = Numeric>(engine: ComputeEngine<T>, arg: Expression<T>): void;
1
+ /* 0.4.3 */
2
+ /**
3
+ * Add an assumption, in the form of a predicate, for example:
4
+ *
5
+ * - `x = 5`
6
+ * - `x ℕ`
7
+ * - `x > 3`
8
+ * - `x + y = 5`
9
+ *
10
+ * Some assumptions are handled separately, specifically, those that can
11
+ * be represented as a symbol definition (equality to an expression,
12
+ * membership to Integer, RealNumber, etc..., >0, <=0, etc...). The result
13
+ * of these are stored directly in the current scope's symbols dictionary
14
+ * (and an entry for the symbol is created if necessary).
15
+ *
16
+ * Predicates that involve multiple symbols are simplified (for example
17
+ * `x + y = 5` becomes `x + y - 5 = 0`, then stored in the `assumptions` of the
18
+ * current context).
19
+ *
20
+ */
21
+ export declare function assume(_proposition: BoxedExpression): AssumeResult;
@@ -0,0 +1,107 @@
1
+ /* 0.4.3 */
2
+ import type { Complex } from 'complex.js';
3
+ import { Expression } from '../../math-json/math-json-format';
4
+ import { BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSymbolDefinition, EvaluateOptions, IComputeEngine, LatexString, Metadata, NOptions, PatternMatchOption, SemiBoxedExpression, SimplifyOptions, Substitution } from '../public';
5
+ /**
6
+ * AbstractBoxedExpression
7
+ */
8
+ export declare abstract class AbstractBoxedExpression implements BoxedExpression {
9
+ abstract get json(): Expression;
10
+ abstract get head(): BoxedExpression | string;
11
+ abstract isSame(rhs: BoxedExpression): boolean;
12
+ abstract isEqual(rhs: BoxedExpression): boolean;
13
+ abstract get isCanonical(): boolean;
14
+ abstract set isCanonical(_val: boolean);
15
+ abstract get hash(): number;
16
+ abstract match(rhs: BoxedExpression, options?: PatternMatchOption): Substitution | null;
17
+ readonly engine: IComputeEngine;
18
+ /** Authentic LaTeX, obtained from a source, i.e. from parsing, not generated
19
+ * synthetically */
20
+ protected _latex?: string;
21
+ protected _wikidata?: string;
22
+ constructor(ce: IComputeEngine, metadata?: Metadata);
23
+ /** Object.toJSON(), called by JSON.Stringify */
24
+ toJSON(): string;
25
+ /** Object.toString() */
26
+ toString(): string;
27
+ /** Object.valueOf(): return a primitive value for the object */
28
+ valueOf(): any;
29
+ /** Object.is() */
30
+ is(rhs: any): boolean;
31
+ has(_v: string | string[]): boolean;
32
+ get description(): string[];
33
+ get url(): string;
34
+ _purge(): undefined;
35
+ get isPure(): boolean;
36
+ get isLiteral(): boolean;
37
+ get latex(): LatexString;
38
+ set latex(val: LatexString);
39
+ get wikidata(): string;
40
+ set wikidata(val: string);
41
+ get complexity(): number;
42
+ get ops(): null | BoxedExpression[];
43
+ get nops(): number;
44
+ get op1(): BoxedExpression;
45
+ get op2(): BoxedExpression;
46
+ get op3(): BoxedExpression;
47
+ get symbolDefinition(): BoxedSymbolDefinition | undefined;
48
+ get functionDefinition(): BoxedFunctionDefinition | undefined;
49
+ _repairDefinition(): void;
50
+ get keys(): IterableIterator<string> | null;
51
+ get keysCount(): number;
52
+ getKey(_key: string): BoxedExpression | undefined;
53
+ hasKey(_key: string): boolean;
54
+ get machineValue(): number | null;
55
+ get rationalValue(): [numer: number, denom: number] | [null, null];
56
+ get decimalValue(): Decimal | null;
57
+ get complexValue(): Complex | null;
58
+ get asFloat(): number | null;
59
+ get asSmallInteger(): number | null;
60
+ get asRational(): [number, number] | [null, null];
61
+ get sgn(): -1 | 0 | 1 | undefined | null;
62
+ get symbol(): string | null;
63
+ get isMissing(): boolean;
64
+ get value(): BoxedExpression | undefined;
65
+ set value(_value: BoxedExpression | undefined);
66
+ get numericValue(): BoxedExpression | undefined;
67
+ isSubsetOf(_d: BoxedExpression | string): undefined | boolean;
68
+ get domain(): BoxedExpression;
69
+ set domain(_domain: BoxedExpression);
70
+ get string(): string | null;
71
+ isLess(_rhs: BoxedExpression): boolean | undefined;
72
+ isLessEqual(_rhs: BoxedExpression): boolean | undefined;
73
+ isGreater(_rhs: BoxedExpression): boolean | undefined;
74
+ isGreaterEqual(_rhs: BoxedExpression): boolean | undefined;
75
+ get isZero(): boolean | undefined;
76
+ get isNotZero(): boolean | undefined;
77
+ get isPositive(): boolean | undefined;
78
+ get isNonNegative(): boolean | undefined;
79
+ get isNegative(): boolean | undefined;
80
+ get isNonPositive(): boolean | undefined;
81
+ get isInfinity(): boolean | undefined;
82
+ get isNaN(): boolean | undefined;
83
+ get isFinite(): boolean | undefined;
84
+ get isNumber(): boolean | undefined;
85
+ get isInteger(): boolean | undefined;
86
+ get isRational(): boolean | undefined;
87
+ get isAlgebraic(): boolean | undefined;
88
+ get isReal(): boolean | undefined;
89
+ get isExtendedReal(): boolean | undefined;
90
+ get isComplex(): boolean | undefined;
91
+ get isImaginary(): boolean | undefined;
92
+ get isExtendedComplex(): boolean | undefined;
93
+ get isOne(): boolean | undefined;
94
+ get isNegativeOne(): boolean | undefined;
95
+ get isEven(): boolean | undefined;
96
+ get isOdd(): boolean | undefined;
97
+ get isPrime(): boolean | undefined;
98
+ get isComposite(): boolean | undefined;
99
+ get canonical(): BoxedExpression;
100
+ apply(_fn: (x: BoxedExpression) => SemiBoxedExpression, _head?: string): BoxedExpression;
101
+ evaluate(options?: EvaluateOptions): BoxedExpression;
102
+ simplify(_options?: SimplifyOptions): BoxedExpression;
103
+ N(_options?: NOptions): BoxedExpression;
104
+ replace(_rules: BoxedRuleSet): null | BoxedExpression;
105
+ subs(_sub: Substitution): BoxedExpression;
106
+ solve(_vars: Iterable<string>): null | BoxedExpression[];
107
+ }
@@ -0,0 +1,56 @@
1
+ /* 0.4.3 */
2
+ import { Decimal } from 'decimal.js';
3
+ import { IComputeEngine, SemiBoxedExpression, BoxedExpression, Metadata } from '../public';
4
+ import { Expression, MathJsonNumber } from '../../math-json/math-json-format';
5
+ /**
6
+ * Notes about the boxed form:
7
+ *
8
+ * [1] Expression with a head of `Number`, `String`, `Symbol` and `Dictionary`
9
+ * are converted to the corresponding atomic expression.
10
+ *
11
+ * [2] Expressions with a head of `Complex` are converted to a (complex) number
12
+ * or a `Add`/`Multiply` expression.
13
+ *
14
+ * The precedence of `Complex` (for serialization) is sometimes the
15
+ * precedence of `Add` (when re and im != 0), sometimes the precedence of
16
+ * `Multiply` (when im or re === 0). Using a number or an explicit
17
+ * `Add`/`Multiply` expression avoids this ambiguity.
18
+ *
19
+ * [3] An expression with a `Rational` head is converted to a rational number.
20
+ *
21
+ * [4] A `Negate` function applied to a number literal is converted to a number.
22
+ *
23
+ *
24
+ * Note that `Negate` is only distributed over addition. In practice, having
25
+ * `Negate` factored on multiply/divide is more useful to detect patterns.
26
+ *
27
+ * Note that the `box()` function should only be called from `ComputeEngine`
28
+ *
29
+ */
30
+ export declare function box(ce: IComputeEngine, expr: Decimal | Complex | [num: number, denom: number] | SemiBoxedExpression): BoxedExpression;
31
+ /**
32
+ * Return a boxed number representing `num`.
33
+ *
34
+ * This function tries to avoid creating a boxed number if `num` corresponds
35
+ * to a common value for which we have a shared instance (-1, 0, NaN, etc...)
36
+ *
37
+ *
38
+ * Note that `boxNumber()` should only be called from `ComputeEngine`
39
+ */
40
+ export declare function boxNumber(ce: IComputeEngine, num: MathJsonNumber | BoxedExpression | number | Complex | Decimal | [numer: number, denom: number], metadata?: Metadata): BoxedExpression | null;
41
+ /**
42
+ * Note that `boxDomain()` should only be called from `ComputeEngine`
43
+ */
44
+ export declare function boxDomain(ce: IComputeEngine, dom: string | BoxedExpression, metadata?: Metadata): BoxedExpression;
45
+ /**
46
+ * Given a head (either as a string or a lambda expression)
47
+ * and a set of arguments, return a boxed function expression.
48
+ *
49
+ * If available, preserve LaTeX and wikidata metadata in the boxed expression.
50
+ *
51
+ * The result is *not* a canonical expression.
52
+ *
53
+ * Note that `boxFunction()` should only be called from `ComputeEngine` or
54
+ * `box()`
55
+ */
56
+ export declare function boxFunction(ce: IComputeEngine, head: string, ops: Expression[], metadata?: Metadata): BoxedExpression;
@@ -0,0 +1,39 @@
1
+ /* 0.4.3 */
2
+ import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata, PatternMatchOption } from '../public';
3
+ import { AbstractBoxedExpression } from './abstract-boxed-expression';
4
+ /**
5
+ * BoxedDictionary
6
+ */
7
+ export declare class BoxedDictionary extends AbstractBoxedExpression {
8
+ private _value;
9
+ private _isCanonical;
10
+ constructor(ce: IComputeEngine, dict: {
11
+ [key: string]: SemiBoxedExpression;
12
+ }, metadata?: Metadata);
13
+ _purge(): undefined;
14
+ get hash(): number;
15
+ get complexity(): number;
16
+ get head(): 'Dictionary';
17
+ get isPure(): boolean;
18
+ getKey(key: string): BoxedExpression | undefined;
19
+ hasKey(key: string): boolean;
20
+ get keys(): IterableIterator<string>;
21
+ get keysCount(): number;
22
+ has(x: string | string[]): boolean;
23
+ get domain(): BoxedExpression;
24
+ get json(): Expression;
25
+ /** Structural equality */
26
+ isSame(rhs: BoxedExpression): boolean;
27
+ match(rhs: BoxedExpression, _options?: PatternMatchOption): Substitution | null;
28
+ /** Mathematical equality */
29
+ isEqual(rhs: BoxedExpression): boolean;
30
+ apply(fn: (x: BoxedExpression) => SemiBoxedExpression, head?: string): BoxedExpression;
31
+ evaluate(options?: EvaluateOptions): BoxedExpression;
32
+ get isCanonical(): boolean;
33
+ set isCanonical(val: boolean);
34
+ get canonical(): BoxedExpression;
35
+ simplify(options?: SimplifyOptions): BoxedExpression;
36
+ N(options?: NOptions): BoxedExpression;
37
+ replace(rules: BoxedRuleSet, options?: ReplaceOptions): null | BoxedExpression;
38
+ subs(sub: Substitution): BoxedExpression;
39
+ }
@@ -0,0 +1,8 @@
1
+ /* 0.4.3 */
2
+ import { BoxedExpression, IComputeEngine, Metadata } from '../public';
3
+ export declare class Domain extends BoxedSymbol {
4
+ constructor(ce: IComputeEngine, dom: string, metadata?: Metadata);
5
+ get head(): string;
6
+ get domain(): BoxedExpression;
7
+ isSubsetOf(dom: BoxedExpression | string): boolean;
8
+ }
@@ -0,0 +1,2 @@
1
+ /* 0.4.3 */
2
+ export declare function makeFunctionDefinition(engine: IComputeEngine, def: FunctionDefinition): BoxedFunctionDefinition;
@@ -0,0 +1,93 @@
1
+ /* 0.4.3 */
2
+ import { Expression } from '../../math-json/math-json-format';
3
+ import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOption } from '../public';
4
+ /**
5
+ * BoxedFunction
6
+ */
7
+ export declare class BoxedFunction extends AbstractBoxedExpression {
8
+ private _head;
9
+ private _ops;
10
+ private _def;
11
+ private _isCanonical;
12
+ private _isPure;
13
+ /** The cached values of applying the tail to the head.
14
+ * If the function is not pure, it is never cached.
15
+ */
16
+ private _value;
17
+ private _numericValue;
18
+ private _hash;
19
+ constructor(ce: IComputeEngine, head: string | BoxedExpression, ops: BoxedExpression[], metadata?: Metadata);
20
+ get hash(): number;
21
+ _purge(): undefined;
22
+ get wikidata(): string;
23
+ get description(): string[];
24
+ get url(): string;
25
+ get complexity(): number;
26
+ get head(): string | BoxedExpression;
27
+ get value(): BoxedExpression | undefined;
28
+ get numericValue(): BoxedExpression | undefined;
29
+ get isPure(): boolean;
30
+ get isLiteral(): boolean;
31
+ get ops(): BoxedExpression[];
32
+ get nops(): number;
33
+ get op1(): BoxedExpression;
34
+ get op2(): BoxedExpression;
35
+ get op3(): BoxedExpression;
36
+ get functionDefinition(): BoxedFunctionDefinition | undefined;
37
+ _repairDefinition(): void;
38
+ /** Domain of the value of the function */
39
+ get domain(): BoxedExpression;
40
+ isLess(rhs: BoxedExpression): boolean | undefined;
41
+ isLessEqual(rhs: BoxedExpression): boolean | undefined;
42
+ isGreater(rhs: BoxedExpression): boolean | undefined;
43
+ isGreaterEqual(rhs: BoxedExpression): boolean | undefined;
44
+ get isZero(): boolean | undefined;
45
+ get isNotZero(): boolean | undefined;
46
+ get isOne(): boolean | undefined;
47
+ get isNegativeOne(): boolean | undefined;
48
+ get isPositive(): boolean | undefined;
49
+ get isNonPositive(): boolean | undefined;
50
+ get isNegative(): boolean | undefined;
51
+ get isNonNegative(): boolean | undefined;
52
+ get isNumber(): boolean | undefined;
53
+ get isInteger(): boolean | undefined;
54
+ get isRational(): boolean | undefined;
55
+ get isAlgebraic(): boolean | undefined;
56
+ get isReal(): boolean | undefined;
57
+ get isExtendedReal(): boolean | undefined;
58
+ get isComplex(): boolean | undefined;
59
+ get isImaginary(): boolean | undefined;
60
+ get json(): Expression;
61
+ has(x: string | string[]): boolean;
62
+ /** `isSame` is structural/symbolic equality */
63
+ isSame(rhs: BoxedExpression): boolean;
64
+ match(rhs: BoxedExpression, options?: PatternMatchOption): Substitution | null;
65
+ /** `isEqual` is mathematical equality */
66
+ isEqual(rhs: BoxedExpression): boolean;
67
+ get sgn(): -1 | 0 | 1 | undefined | null;
68
+ map<T = BoxedExpression>(fn: (x: BoxedExpression) => T): IterableIterator<T>;
69
+ get isCanonical(): boolean;
70
+ set isCanonical(val: boolean);
71
+ get canonical(): BoxedExpression;
72
+ apply(fn: (x: BoxedExpression) => SemiBoxedExpression, head?: string): BoxedExpression;
73
+ simplify(options?: SimplifyOptions): BoxedExpression;
74
+ evaluate(options?: EvaluateOptions): BoxedExpression;
75
+ N(options?: NOptions): BoxedExpression;
76
+ solve(_vars: Iterable<string>): null | BoxedExpression[];
77
+ replace(rules: BoxedRuleSet, options?: ReplaceOptions): BoxedExpression | null;
78
+ subs(sub: Substitution): BoxedExpression;
79
+ }
80
+ export declare function lambda(fn: BoxedExpression, args: BoxedExpression[]): BoxedExpression;
81
+ export declare function ungroup(expr: BoxedExpression): BoxedExpression;
82
+ /** Apply the function `f` to elements of `xs`, except to the elements
83
+ * described by `skip`:
84
+ * - `all`: don't apply f to any elements
85
+ * - `none`: apply `f` to all elements
86
+ * - `first`: apply `f` to all elements except the first
87
+ * - `rest`: apply `f` to the first element, skip the others
88
+ * - 'last': apply `f` to all elements except the last
89
+ * - 'most': apply `f` to the last elements, skip the others
90
+ *
91
+ * If `f` returns `null`, the element is not added to the result
92
+ */
93
+ export declare function holdMap(xs: BoxedExpression[], skip: 'all' | 'none' | 'first' | 'rest' | 'last' | 'most', f: (BoxedExpression: any) => BoxedExpression | null): BoxedExpression[];
@@ -0,0 +1,83 @@
1
+ /* 0.4.3 */
2
+ import { Complex } from 'complex.js';
3
+ import { Expression } from '../../math-json/math-json-format';
4
+ import { BoxedExpression, IComputeEngine, Metadata, NOptions, PatternMatchOption, SimplifyOptions, Substitution } from '../public';
5
+ import { AbstractBoxedExpression } from './abstract-boxed-expression';
6
+ /**
7
+ * BoxedNumber
8
+ */
9
+ export declare class BoxedNumber extends AbstractBoxedExpression {
10
+ protected readonly _value: number | Decimal | Complex | [numer: number, denom: number];
11
+ private _domain;
12
+ private _head;
13
+ private _hash;
14
+ protected _isCanonical: boolean;
15
+ /**
16
+ * By the time the constructor is called, the `value` should have been
17
+ * screened for cases where it's a well-known value (0, NaN, +Infinity, etc...)
18
+ * or non-normal (complex number with im = 0, rational with denom = 1, etc...)
19
+ * This is done in `ce.boxNumber()`. In general, use `ce.boxNumber()` rather
20
+ * than calling the constructor directly.
21
+ */
22
+ constructor(ce: IComputeEngine, value: string | number | Decimal | Complex | [numer: number, denom: number], metadata?: Metadata);
23
+ get hash(): number;
24
+ get head(): string;
25
+ get isPure(): boolean;
26
+ get isLiteral(): boolean;
27
+ get isCanonical(): boolean;
28
+ set isCanonical(val: boolean);
29
+ get numericValue(): BoxedExpression | undefined;
30
+ get machineValue(): number | null;
31
+ get decimalValue(): Decimal | null;
32
+ get complexValue(): Complex | null;
33
+ get rationalValue(): [numer: number, denom: number] | [null, null];
34
+ get asFloat(): number | null;
35
+ get asSmallInteger(): number | null;
36
+ get asRational(): [number, number] | [null, null];
37
+ get domain(): BoxedExpression;
38
+ get json(): Expression;
39
+ get sgn(): -1 | 0 | 1 | undefined | null;
40
+ isSame(rhs: BoxedExpression): boolean;
41
+ isEqual(rhs: BoxedExpression): boolean;
42
+ match(rhs: BoxedExpression, options?: PatternMatchOption): Substitution | null;
43
+ /** Compare this with another BoxedNumber.
44
+ * `rhs` must be a BoxedNumber. Use `isEqualWithTolerance(rhs.numericValue)`
45
+ * if necessary.
46
+ */
47
+ isEqualWithTolerance(rhs: BoxedExpression, tolerance: number): boolean;
48
+ isLess(rhs: BoxedExpression): boolean | undefined;
49
+ isLessEqual(rhs: BoxedExpression): boolean | undefined;
50
+ isGreater(rhs: BoxedExpression): boolean | undefined;
51
+ isGreaterEqual(rhs: BoxedExpression): boolean | undefined;
52
+ /** x > 0, same as `isGreater(0)` */
53
+ get isPositive(): boolean | undefined;
54
+ /** x >= 0, same as `isGreaterEqual(0)` */
55
+ get isNonNegative(): boolean | undefined;
56
+ /** x < 0, same as `isLess(0)` */
57
+ get isNegative(): boolean | undefined;
58
+ /** x <= 0, same as `isLessEqual(0)` */
59
+ get isNonPositive(): boolean | undefined;
60
+ get isZero(): boolean;
61
+ get isNotZero(): boolean;
62
+ get isOne(): boolean;
63
+ get isNegativeOne(): boolean;
64
+ get isOdd(): boolean | undefined;
65
+ get isEven(): boolean | undefined;
66
+ get isPrime(): boolean | undefined;
67
+ get isComposite(): boolean | undefined;
68
+ get isInfinity(): boolean;
69
+ get isNaN(): boolean;
70
+ get isFinite(): boolean;
71
+ get isNumber(): true;
72
+ get isInteger(): boolean;
73
+ get isRational(): boolean;
74
+ get isAlgebraic(): boolean | undefined;
75
+ get isReal(): boolean;
76
+ get isExtendedReal(): boolean;
77
+ get isComplex(): boolean | undefined;
78
+ get isImaginary(): boolean | undefined;
79
+ get isExtendedComplex(): boolean | undefined;
80
+ get canonical(): BoxedExpression;
81
+ simplify(_options?: SimplifyOptions): BoxedExpression;
82
+ N(_options?: NOptions): BoxedExpression;
83
+ }
@@ -0,0 +1,21 @@
1
+ /* 0.4.3 */
2
+ import { AbstractBoxedExpression } from './abstract-boxed-expression';
3
+ import { BoxedExpression, IComputeEngine, LatexString, Metadata, Pattern, PatternMatchOption, SemiBoxedExpression, Substitution } from '../public';
4
+ export declare class BoxedPattern extends AbstractBoxedExpression implements Pattern {
5
+ _pattern: BoxedExpression;
6
+ _canonicalPattern: BoxedExpression | undefined;
7
+ constructor(ce: IComputeEngine, pattern: LatexString | SemiBoxedExpression, metadata?: Metadata);
8
+ get hash(): number;
9
+ _purge(): undefined;
10
+ get json(): Expression;
11
+ get head(): string | BoxedExpression;
12
+ get domain(): BoxedExpression;
13
+ get isCanonical(): boolean;
14
+ set isCanonical(_val: boolean);
15
+ isSame(rhs: BoxedExpression): boolean;
16
+ isEqual(rhs: BoxedExpression): boolean;
17
+ match(expr: BoxedExpression, options?: PatternMatchOption): Substitution | null;
18
+ test(expr: BoxedExpression, options?: PatternMatchOption): boolean;
19
+ count(exprs: Iterable<BoxedExpression>, options?: PatternMatchOption): number;
20
+ subs(sub: Substitution): BoxedPattern;
21
+ }
@@ -0,0 +1,23 @@
1
+ /* 0.4.3 */
2
+ import { AbstractBoxedExpression } from './abstract-boxed-expression';
3
+ import { BoxedExpression, IComputeEngine, Metadata, PatternMatchOption, Substitution } from '../public';
4
+ /**
5
+ * BoxedString
6
+ */
7
+ export declare class BoxedString extends AbstractBoxedExpression {
8
+ private readonly _string;
9
+ constructor(ce: IComputeEngine, expr: string, metadata?: Metadata);
10
+ get hash(): number;
11
+ get json(): Expression;
12
+ get head(): string;
13
+ get isPure(): boolean;
14
+ get isLiteral(): boolean;
15
+ get isCanonical(): boolean;
16
+ set isCanonical(_va: boolean);
17
+ get domain(): BoxedExpression;
18
+ get complexity(): number;
19
+ get string(): string;
20
+ isEqual(rhs: BoxedExpression): boolean;
21
+ isSame(rhs: BoxedExpression): boolean;
22
+ match(rhs: BoxedExpression, _options?: PatternMatchOption): Substitution | null;
23
+ }
@@ -0,0 +1,98 @@
1
+ /* 0.4.3 */
2
+ export declare function domainToFlags(dom: BoxedExpression | undefined | null): Partial<SymbolFlags>;
3
+ export declare class BoxedSymbolDefinitionImpl implements BoxedSymbolDefinition {
4
+ private _engine;
5
+ private _value;
6
+ readonly name: string;
7
+ wikidata?: string;
8
+ description?: string | string[];
9
+ readonly scope: RuntimeScope | undefined;
10
+ private _domain;
11
+ private _number;
12
+ private _integer;
13
+ private _rational;
14
+ private _algebraic;
15
+ private _real;
16
+ private _extendedReal;
17
+ private _complex;
18
+ private _extendedComplex;
19
+ private _imaginary;
20
+ private _positive;
21
+ private _nonPositive;
22
+ private _negative;
23
+ private _nonNegative;
24
+ private _zero;
25
+ private _notZero;
26
+ private _one;
27
+ private _negativeOne;
28
+ private _infinity;
29
+ private _NaN;
30
+ private _finite;
31
+ private _even;
32
+ private _odd;
33
+ private _prime;
34
+ private _composite;
35
+ private _at;
36
+ at?: (index: string | number) => undefined | BoxedExpression;
37
+ readonly constant: boolean;
38
+ readonly hold: boolean;
39
+ private _def;
40
+ prototype?: BoxedFunctionDefinition;
41
+ self?: any;
42
+ constructor(ce: IComputeEngine, def: SymbolDefinition);
43
+ _purge(): undefined;
44
+ get value(): BoxedExpression | undefined;
45
+ set value(val: BoxedExpression | undefined);
46
+ get domain(): BoxedExpression | undefined;
47
+ set domain(domain: BoxedExpression | undefined | string);
48
+ updateFlags(flags: Partial<SymbolFlags>): void;
49
+ setProps(props: Omit<Partial<BoxedSymbolDefinition>, 'domain' | 'value'>): void;
50
+ get number(): boolean | undefined;
51
+ set number(val: boolean | undefined);
52
+ get integer(): boolean | undefined;
53
+ set integer(val: boolean | undefined);
54
+ get rational(): boolean | undefined;
55
+ set rational(val: boolean | undefined);
56
+ get algebraic(): boolean | undefined;
57
+ set algebraic(val: boolean | undefined);
58
+ get real(): boolean | undefined;
59
+ set real(val: boolean | undefined);
60
+ get extendedReal(): boolean | undefined;
61
+ set extendedReal(val: boolean | undefined);
62
+ get complex(): boolean | undefined;
63
+ set complex(val: boolean | undefined);
64
+ get extendedComplex(): boolean | undefined;
65
+ set extendedComplex(val: boolean | undefined);
66
+ get imaginary(): boolean | undefined;
67
+ set imaginary(val: boolean | undefined);
68
+ get positive(): boolean | undefined;
69
+ set positive(val: boolean | undefined);
70
+ get nonPositive(): boolean | undefined;
71
+ set nonPositive(val: boolean | undefined);
72
+ get negative(): boolean | undefined;
73
+ set negative(val: boolean | undefined);
74
+ get nonNegative(): boolean | undefined;
75
+ set nonNegative(val: boolean | undefined);
76
+ get zero(): boolean | undefined;
77
+ set zero(val: boolean | undefined);
78
+ get notZero(): boolean | undefined;
79
+ set notZero(val: boolean | undefined);
80
+ get one(): boolean | undefined;
81
+ set one(val: boolean | undefined);
82
+ get negativeOne(): boolean | undefined;
83
+ set negativeOne(val: boolean | undefined);
84
+ get infinity(): boolean | undefined;
85
+ set infinity(val: boolean | undefined);
86
+ get finite(): boolean | undefined;
87
+ set finite(val: boolean | undefined);
88
+ get NaN(): boolean | undefined;
89
+ set NaN(val: boolean | undefined);
90
+ get even(): boolean | undefined;
91
+ set even(val: boolean | undefined);
92
+ get odd(): boolean | undefined;
93
+ set odd(val: boolean | undefined);
94
+ get prime(): boolean | undefined;
95
+ set prime(val: boolean | undefined);
96
+ get composite(): boolean | undefined;
97
+ set composite(val: boolean | undefined);
98
+ }