@cortex-js/compute-engine 0.35.6 → 0.50.1
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.
- package/README.md +121 -5
- package/dist/compute-engine.esm.js +55594 -51135
- package/dist/compute-engine.min.esm.js +1081 -78
- package/dist/compute-engine.min.umd.js +1081 -78
- package/dist/compute-engine.umd.js +53638 -49162
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.umd.js +2 -2
- package/dist/math-json.umd.js +2 -2
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/configuration-change.d.ts +1 -1
- package/dist/types/common/fuzzy-string-match.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/interruptible.d.ts +1 -1
- package/dist/types/common/one-of.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/type/ast-nodes.d.ts +1 -1
- package/dist/types/common/type/boxed-type.d.ts +1 -1
- package/dist/types/common/type/lexer.d.ts +1 -1
- package/dist/types/common/type/parse.d.ts +1 -1
- package/dist/types/common/type/parser.d.ts +8 -1
- package/dist/types/common/type/primitive.d.ts +2 -1
- package/dist/types/common/type/reduce.d.ts +1 -1
- package/dist/types/common/type/serialize.d.ts +1 -1
- package/dist/types/common/type/subtype.d.ts +1 -1
- package/dist/types/common/type/type-builder.d.ts +1 -1
- package/dist/types/common/type/types.d.ts +1 -1
- package/dist/types/common/type/utils.d.ts +3 -2
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +4 -22
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +66 -76
- package/dist/types/compute-engine/boxed-expression/apply.d.ts +4 -4
- package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +15 -6
- package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +72 -6
- package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +8 -8
- package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +5 -8
- package/dist/types/compute-engine/boxed-expression/box.d.ts +63 -8
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +13 -12
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +44 -43
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +31 -30
- package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +18 -18
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +5 -37
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +5 -4
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +34 -33
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +34 -33
- package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +8 -8
- package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/compare.d.ts +7 -4
- package/dist/types/compute-engine/boxed-expression/constants.d.ts +6 -0
- package/dist/types/compute-engine/boxed-expression/expand.d.ts +4 -5
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +9 -9
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +7 -7
- package/dist/types/compute-engine/boxed-expression/flatten.d.ts +4 -13
- package/dist/types/compute-engine/boxed-expression/hold.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +21 -0
- package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -0
- package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +4 -0
- package/dist/types/compute-engine/boxed-expression/match.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/negate.d.ts +4 -4
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +8 -8
- package/dist/types/compute-engine/boxed-expression/order.d.ts +14 -14
- package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +41 -0
- package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +18 -0
- package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +12 -35
- package/dist/types/compute-engine/boxed-expression/predicates.d.ts +2 -0
- package/dist/types/compute-engine/boxed-expression/product.d.ts +1 -66
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +51 -51
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +6 -3
- package/dist/types/compute-engine/boxed-expression/sgn.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/simplify.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +8 -8
- package/dist/types/compute-engine/boxed-expression/solve.d.ts +3 -11
- package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +7 -7
- package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +31 -0
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +13 -13
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +10 -10
- package/dist/types/compute-engine/collection-utils.d.ts +4 -4
- package/dist/types/compute-engine/compilation/base-compiler.d.ts +3 -3
- package/dist/types/compute-engine/compilation/compile-expression.d.ts +25 -0
- package/dist/types/compute-engine/compilation/glsl-target.d.ts +12 -41
- package/dist/types/compute-engine/compilation/gpu-target.d.ts +50 -0
- package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +11 -11
- package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +7 -7
- package/dist/types/compute-engine/compilation/interval-wgsl-target.d.ts +54 -0
- package/dist/types/compute-engine/compilation/javascript-target.d.ts +6 -6
- package/dist/types/compute-engine/compilation/python-target.d.ts +61 -0
- package/dist/types/compute-engine/compilation/types.d.ts +38 -22
- package/dist/types/compute-engine/compilation/wgsl-target.d.ts +41 -0
- package/dist/types/compute-engine/cost-function.d.ts +3 -3
- package/dist/types/compute-engine/engine-assumptions.d.ts +6 -0
- package/dist/types/compute-engine/engine-cache.d.ts +6 -0
- package/dist/types/compute-engine/engine-common-symbols.d.ts +6 -0
- package/dist/types/compute-engine/engine-compilation-targets.d.ts +17 -0
- package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +15 -0
- package/dist/types/compute-engine/engine-declarations.d.ts +19 -0
- package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +44 -0
- package/dist/types/compute-engine/engine-extension-contracts.d.ts +9 -0
- package/dist/types/compute-engine/engine-latex-dictionary-state.d.ts +13 -0
- package/dist/types/compute-engine/engine-library-bootstrap.d.ts +6 -0
- package/dist/types/compute-engine/engine-numeric-configuration.d.ts +34 -0
- package/dist/types/compute-engine/engine-parse-entrypoint.d.ts +7 -0
- package/dist/types/compute-engine/engine-runtime-state.d.ts +19 -0
- package/dist/types/compute-engine/engine-scope.d.ts +13 -0
- package/dist/types/compute-engine/engine-sequences.d.ts +14 -0
- package/dist/types/compute-engine/engine-simplification-rules.d.ts +15 -0
- package/dist/types/compute-engine/engine-startup-coordinator.d.ts +28 -0
- package/dist/types/compute-engine/engine-type-resolver.d.ts +12 -0
- package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +13 -0
- package/dist/types/compute-engine/free-functions.d.ts +20 -0
- package/dist/types/compute-engine/function-utils.d.ts +10 -10
- package/dist/types/compute-engine/global-types.d.ts +5 -3301
- package/dist/types/compute-engine/index.d.ts +156 -112
- package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
- package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
- package/dist/types/compute-engine/interval/index.d.ts +1 -1
- package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
- package/dist/types/compute-engine/interval/types.d.ts +1 -1
- package/dist/types/compute-engine/interval/util.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +4 -80
- package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +83 -0
- package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +28 -0
- package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +23 -33
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +8 -8
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +15 -15
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/types.d.ts +73 -53
- package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -2
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +4 -4
- package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
- package/dist/types/compute-engine/library/complex.d.ts +1 -1
- package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +19 -6
- package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/library/logic-analysis.d.ts +19 -32
- package/dist/types/compute-engine/library/logic.d.ts +1 -5
- package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/random-expression.d.ts +2 -2
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/statistics.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/type-handlers.d.ts +4 -0
- package/dist/types/compute-engine/library/utils.d.ts +12 -12
- package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +5 -5
- package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +5 -5
- package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +5 -5
- package/dist/types/compute-engine/numeric-value/types.d.ts +2 -3
- package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/expression.d.ts +3 -3
- package/dist/types/compute-engine/numerics/interval.d.ts +2 -2
- package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +4 -4
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/numerics/special-functions.d.ts +120 -1
- package/dist/types/compute-engine/numerics/statistics.d.ts +1 -2
- package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
- package/dist/types/compute-engine/numerics/types.d.ts +3 -1
- package/dist/types/compute-engine/oeis.d.ts +3 -3
- package/dist/types/compute-engine/sequence.d.ts +13 -13
- package/dist/types/compute-engine/symbolic/antiderivative.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/derivative.d.ts +3 -3
- package/dist/types/compute-engine/symbolic/distribute.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/fu-cost.d.ts +6 -6
- package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +46 -46
- package/dist/types/compute-engine/symbolic/fu.d.ts +4 -4
- package/dist/types/compute-engine/symbolic/logic-utils.d.ts +54 -0
- package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +4 -4
- package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/simplify-log.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +5 -0
- package/dist/types/compute-engine/symbolic/simplify-power.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/simplify-product.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +65 -4
- package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +2 -2
- package/dist/types/compute-engine/tensor/tensor-fields.d.ts +42 -42
- package/dist/types/compute-engine/tensor/tensors.d.ts +4 -4
- package/dist/types/compute-engine/types-definitions.d.ts +900 -0
- package/dist/types/compute-engine/types-engine.d.ts +375 -0
- package/dist/types/compute-engine/types-evaluation.d.ts +67 -0
- package/dist/types/compute-engine/types-expression.d.ts +1655 -0
- package/dist/types/compute-engine/types-kernel-evaluation.d.ts +164 -0
- package/dist/types/compute-engine/types-kernel-serialization.d.ts +147 -0
- package/dist/types/compute-engine/types-serialization.d.ts +23 -0
- package/dist/types/compute-engine/types.d.ts +2 -2
- package/dist/types/compute-engine.d.ts +16 -3
- package/dist/types/math-json/symbols.d.ts +1 -1
- package/dist/types/math-json/types.d.ts +3 -3
- package/dist/types/math-json/utils.d.ts +31 -31
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +8 -1
- package/dist/types/compute-engine/boxed-expression/terms.d.ts +0 -10
- package/dist/types/compute-engine/library/invisible-operator.d.ts +0 -4
- package/dist/types/compute-engine/library/logic-utils.d.ts +0 -54
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/* 0.50.1 */
|
|
2
|
+
import type { OneOf } from '../common/one-of';
|
|
3
|
+
import type { MathJsonSymbol, MathJsonNumberObject } from '../math-json';
|
|
4
|
+
import type { Type, TypeString, TypeResolver } from '../common/type/types';
|
|
5
|
+
import type { BoxedType } from '../common/type/boxed-type';
|
|
6
|
+
import type { ConfigurationChangeListener } from '../common/configuration-change';
|
|
7
|
+
import type { ExactNumericValueData, NumericValue, NumericValueData } from './numeric-value/types';
|
|
8
|
+
import type { BigNum, IBigNum, Rational } from './numerics/types';
|
|
9
|
+
import type { LatexDictionaryEntry, LatexString, ParseLatexOptions } from './latex-syntax/types';
|
|
10
|
+
import type { IndexedLatexDictionary } from './latex-syntax/dictionary/definitions';
|
|
11
|
+
import type { Expression, ExpressionInput } from './types-expression';
|
|
12
|
+
import type { Metadata, CanonicalOptions, FormOption, BoxedSubstitution } from './types-serialization';
|
|
13
|
+
import type { AngularUnit, SymbolDefinition, OperatorDefinition, ValueDefinition, BoxedDefinition, SequenceDefinition, SequenceStatus, SequenceInfo, OEISSequenceInfo, OEISOptions } from './types-definitions';
|
|
14
|
+
import type { AssumeResult, Rule as KernelRule, BoxedRule as KernelBoxedRule, BoxedRuleSet as KernelBoxedRuleSet, RuleStep as KernelRuleStep, AssignValue as KernelAssignValue, Scope as KernelScope, EvalContext as KernelEvalContext } from './types-kernel-evaluation';
|
|
15
|
+
import type { LanguageTarget, CompilationResult } from './compilation/types';
|
|
16
|
+
type Rule = KernelRule<Expression, ExpressionInput, IComputeEngine>;
|
|
17
|
+
type BoxedRule = KernelBoxedRule<Expression, IComputeEngine>;
|
|
18
|
+
type BoxedRuleSet = KernelBoxedRuleSet<Expression, IComputeEngine>;
|
|
19
|
+
type RuleStep = KernelRuleStep<Expression>;
|
|
20
|
+
type AssignValue = KernelAssignValue<Expression, ExpressionInput, IComputeEngine>;
|
|
21
|
+
type Scope = KernelScope<BoxedDefinition>;
|
|
22
|
+
type EvalContext = KernelEvalContext<Expression, BoxedDefinition>;
|
|
23
|
+
/** @internal */
|
|
24
|
+
export interface IComputeEngine extends IBigNum {
|
|
25
|
+
latexDictionary: readonly LatexDictionaryEntry[];
|
|
26
|
+
/** @private */
|
|
27
|
+
_indexedLatexDictionary: IndexedLatexDictionary;
|
|
28
|
+
decimalSeparator: LatexString;
|
|
29
|
+
readonly True: Expression;
|
|
30
|
+
readonly False: Expression;
|
|
31
|
+
readonly Pi: Expression;
|
|
32
|
+
readonly E: Expression;
|
|
33
|
+
readonly Nothing: Expression;
|
|
34
|
+
readonly Zero: Expression;
|
|
35
|
+
readonly One: Expression;
|
|
36
|
+
readonly Half: Expression;
|
|
37
|
+
readonly NegativeOne: Expression;
|
|
38
|
+
/** ImaginaryUnit */
|
|
39
|
+
readonly I: Expression;
|
|
40
|
+
readonly NaN: Expression;
|
|
41
|
+
readonly PositiveInfinity: Expression;
|
|
42
|
+
readonly NegativeInfinity: Expression;
|
|
43
|
+
readonly ComplexInfinity: Expression;
|
|
44
|
+
/** @internal */
|
|
45
|
+
readonly _BIGNUM_NAN: BigNum;
|
|
46
|
+
/** @internal */
|
|
47
|
+
readonly _BIGNUM_ZERO: BigNum;
|
|
48
|
+
/** @internal */
|
|
49
|
+
readonly _BIGNUM_ONE: BigNum;
|
|
50
|
+
/** @internal */
|
|
51
|
+
readonly _BIGNUM_TWO: BigNum;
|
|
52
|
+
/** @internal */
|
|
53
|
+
readonly _BIGNUM_HALF: BigNum;
|
|
54
|
+
/** @internal */
|
|
55
|
+
readonly _BIGNUM_PI: BigNum;
|
|
56
|
+
/** @internal */
|
|
57
|
+
readonly _BIGNUM_NEGATIVE_ONE: BigNum;
|
|
58
|
+
readonly context: EvalContext;
|
|
59
|
+
contextStack: ReadonlyArray<EvalContext>;
|
|
60
|
+
/** @internal */
|
|
61
|
+
_evalContextStack: EvalContext[];
|
|
62
|
+
/** @internal */
|
|
63
|
+
_isVerifying: boolean;
|
|
64
|
+
/** @internal */
|
|
65
|
+
readonly isVerifying: boolean;
|
|
66
|
+
/** @internal */
|
|
67
|
+
readonly _typeResolver: TypeResolver;
|
|
68
|
+
/** Absolute time beyond which evaluation should not proceed
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
_deadline?: number;
|
|
72
|
+
/** Time remaining before _deadline
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
_timeRemaining: number;
|
|
76
|
+
/** @internal */
|
|
77
|
+
_generation: number;
|
|
78
|
+
timeLimit: number;
|
|
79
|
+
iterationLimit: number;
|
|
80
|
+
recursionLimit: number;
|
|
81
|
+
chop(n: number): number;
|
|
82
|
+
chop(n: BigNum): BigNum | 0;
|
|
83
|
+
chop(n: number | BigNum): number | BigNum;
|
|
84
|
+
bignum: (a: string | number | bigint | BigNum) => BigNum;
|
|
85
|
+
complex: (a: number | Complex, b?: number) => Complex;
|
|
86
|
+
/** @internal */
|
|
87
|
+
_numericValue(value: number | bigint | OneOf<[BigNum | NumericValueData | ExactNumericValueData]>): NumericValue;
|
|
88
|
+
set precision(p: number | 'machine' | 'auto');
|
|
89
|
+
get precision(): number;
|
|
90
|
+
tolerance: number;
|
|
91
|
+
angularUnit: AngularUnit;
|
|
92
|
+
costFunction: (expr: Expression) => number;
|
|
93
|
+
/** The rules used by `.simplify()` when no explicit `rules` option is passed.
|
|
94
|
+
* Initialized to the built-in simplification rules.
|
|
95
|
+
* Users can `push()` additional rules or replace the entire array. */
|
|
96
|
+
simplificationRules: Rule[];
|
|
97
|
+
strict: boolean;
|
|
98
|
+
box(expr: NumericValue | ExpressionInput, options?: {
|
|
99
|
+
form?: FormOption;
|
|
100
|
+
scope?: Scope;
|
|
101
|
+
}): Expression;
|
|
102
|
+
function(name: string, ops: ReadonlyArray<ExpressionInput>, options?: {
|
|
103
|
+
metadata?: Metadata;
|
|
104
|
+
form?: FormOption;
|
|
105
|
+
scope?: Scope;
|
|
106
|
+
}): Expression;
|
|
107
|
+
/**
|
|
108
|
+
* This is a primitive to create a boxed function.
|
|
109
|
+
*
|
|
110
|
+
* In general, consider using `ce.box()` or `ce.function()` or
|
|
111
|
+
* `canonicalXXX()` instead.
|
|
112
|
+
*
|
|
113
|
+
* The caller must ensure that the arguments are in canonical form:
|
|
114
|
+
* - arguments are `canonical()`
|
|
115
|
+
* - arguments are sorted
|
|
116
|
+
* - arguments are flattened and desequenced
|
|
117
|
+
*
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
_fn(name: string, ops: ReadonlyArray<Expression>, options?: {
|
|
121
|
+
metadata?: Metadata;
|
|
122
|
+
canonical?: boolean;
|
|
123
|
+
scope?: Scope;
|
|
124
|
+
}): Expression;
|
|
125
|
+
/** @internal Compile a boxed expression. */
|
|
126
|
+
_compile(expr: Expression, options?: Record<string, unknown>): CompilationResult;
|
|
127
|
+
/** Register a custom compilation target. */
|
|
128
|
+
registerCompilationTarget(name: string, target: LanguageTarget<Expression>): void;
|
|
129
|
+
/** Get a registered compilation target by name. */
|
|
130
|
+
getCompilationTarget(name: string): LanguageTarget<Expression> | undefined;
|
|
131
|
+
/** Return the names of all registered compilation targets. */
|
|
132
|
+
listCompilationTargets(): string[];
|
|
133
|
+
/** Remove a registered compilation target. */
|
|
134
|
+
unregisterCompilationTarget(name: string): void;
|
|
135
|
+
/** @internal Fu trigonometric simplification algorithm */
|
|
136
|
+
_fuAlgorithm(expr: Expression, options?: Record<string, unknown>): RuleStep | undefined;
|
|
137
|
+
number(value: number | bigint | string | NumericValue | MathJsonNumberObject | BigNum | Complex | Rational, options?: {
|
|
138
|
+
metadata?: Metadata;
|
|
139
|
+
canonical?: CanonicalOptions;
|
|
140
|
+
}): Expression;
|
|
141
|
+
symbol(sym: string, options?: {
|
|
142
|
+
canonical?: CanonicalOptions;
|
|
143
|
+
metadata?: Metadata;
|
|
144
|
+
}): Expression;
|
|
145
|
+
string(s: string, metadata?: Metadata): Expression;
|
|
146
|
+
error(message: string | string[], where?: string): Expression;
|
|
147
|
+
typeError(expectedType: Type, actualType: undefined | Type | BoxedType, where?: ExpressionInput): Expression;
|
|
148
|
+
hold(expr: ExpressionInput): Expression;
|
|
149
|
+
tuple(...elements: ReadonlyArray<number>): Expression;
|
|
150
|
+
tuple(...elements: ReadonlyArray<Expression>): Expression;
|
|
151
|
+
type(type: Type | TypeString | BoxedType): BoxedType;
|
|
152
|
+
rules(rules: Rule | ReadonlyArray<Rule | BoxedRule> | BoxedRuleSet | undefined | null, options?: {
|
|
153
|
+
canonical?: boolean;
|
|
154
|
+
}): BoxedRuleSet;
|
|
155
|
+
getRuleSet(id?: 'harmonization' | 'solve-univariate' | 'standard-simplification'): BoxedRuleSet | undefined;
|
|
156
|
+
parse(latex: null, options?: Partial<ParseLatexOptions> & {
|
|
157
|
+
form?: FormOption;
|
|
158
|
+
}): null;
|
|
159
|
+
parse(latex: LatexString, options?: Partial<ParseLatexOptions> & {
|
|
160
|
+
form?: FormOption;
|
|
161
|
+
}): Expression;
|
|
162
|
+
parse(latex: LatexString | null, options?: Partial<ParseLatexOptions> & {
|
|
163
|
+
form?: FormOption;
|
|
164
|
+
}): Expression | null;
|
|
165
|
+
pushScope(scope?: Scope, name?: string): void;
|
|
166
|
+
popScope(): void;
|
|
167
|
+
/**
|
|
168
|
+
*
|
|
169
|
+
* When a new eval context is created, it has slots for the local variables
|
|
170
|
+
* from the current lexical scope. It also copies the current set of
|
|
171
|
+
* assumptions.
|
|
172
|
+
*
|
|
173
|
+
* Need a pointer to the current lexical scope (may have a scope chain without an evaluation context). Each lexical scope includes a pointer to the parent scope (it's a DAG).
|
|
174
|
+
*
|
|
175
|
+
* If a function is "scoped" (has a `scoped` flag), create a new lexical scope
|
|
176
|
+
* when the function is canonicalized, store the scope with the function
|
|
177
|
+
* definition (if the function has a lazy flag, and a canonical handler, it
|
|
178
|
+
* can behave like a scoped function, but a scoped flag is convenient,
|
|
179
|
+
* it would still evaluate the arguments).
|
|
180
|
+
*
|
|
181
|
+
* Note: if an expression is not canonical, evaluating it return itself.
|
|
182
|
+
* This is important to support arguments that are just symbol names
|
|
183
|
+
* (they are not canonicalized).
|
|
184
|
+
*
|
|
185
|
+
* When the function expression is evaluated, if it is "scoped", push the
|
|
186
|
+
* scope associated with the function (maybe not?) and a matching eval
|
|
187
|
+
* context, including all the symbols in the lexical scope (including
|
|
188
|
+
* constants). Need some way to indicate that a symbol maps to an argument
|
|
189
|
+
* (in value definition?).
|
|
190
|
+
*
|
|
191
|
+
* When searching the value of a symbol, start with the current
|
|
192
|
+
* eval context, then the previous one.
|
|
193
|
+
*
|
|
194
|
+
* When looking for a definition, start with the lexical scope of the
|
|
195
|
+
* current eval context, then the parent lexical context.
|
|
196
|
+
*
|
|
197
|
+
* @internal */
|
|
198
|
+
_pushEvalContext(scope: Scope, name?: string): void;
|
|
199
|
+
/** @internal */
|
|
200
|
+
_popEvalContext(): void;
|
|
201
|
+
/**
|
|
202
|
+
* Temporarily sets the lexical scope to the provided scope, then
|
|
203
|
+
* executes the function `f` in that scope and returns the result.
|
|
204
|
+
* @internal */
|
|
205
|
+
_inScope<T>(scope: Scope | undefined, f: () => T): T;
|
|
206
|
+
/**
|
|
207
|
+
* For internal use. Use `ce.declare()` instead.
|
|
208
|
+
* @internal */
|
|
209
|
+
_declareSymbolValue(name: MathJsonSymbol, def: Partial<ValueDefinition>, scope?: Scope): BoxedDefinition;
|
|
210
|
+
/**
|
|
211
|
+
* For internal use. Use `ce.declare()` instead.
|
|
212
|
+
* @internal */
|
|
213
|
+
_declareSymbolOperator(name: string, def: OperatorDefinition, scope?: Scope): BoxedDefinition;
|
|
214
|
+
/**
|
|
215
|
+
* Use `ce.box(id)` instead
|
|
216
|
+
* @internal */
|
|
217
|
+
_getSymbolValue(id: MathJsonSymbol): Expression | undefined;
|
|
218
|
+
/**
|
|
219
|
+
* Use `ce.assign(id, value)` instead.
|
|
220
|
+
* @internal */
|
|
221
|
+
_setSymbolValue(id: MathJsonSymbol, value: Expression | boolean | number | undefined): void;
|
|
222
|
+
/**
|
|
223
|
+
* Set a value directly in the current context's values map.
|
|
224
|
+
* Used for assumptions so values are properly scoped.
|
|
225
|
+
* @internal */
|
|
226
|
+
_setCurrentContextValue(id: MathJsonSymbol, value: Expression | boolean | number | undefined): void;
|
|
227
|
+
/** A list of the function calls to the current evaluation context */
|
|
228
|
+
trace: ReadonlyArray<string>;
|
|
229
|
+
lookupContext(id: MathJsonSymbol): undefined | EvalContext;
|
|
230
|
+
/** @internal */
|
|
231
|
+
_swapContext(context: EvalContext): void;
|
|
232
|
+
lookupDefinition(id: MathJsonSymbol): undefined | BoxedDefinition;
|
|
233
|
+
assign(ids: {
|
|
234
|
+
[id: MathJsonSymbol]: AssignValue;
|
|
235
|
+
}): IComputeEngine;
|
|
236
|
+
assign(id: MathJsonSymbol, value: AssignValue): IComputeEngine;
|
|
237
|
+
assign(arg1: MathJsonSymbol | {
|
|
238
|
+
[id: MathJsonSymbol]: AssignValue;
|
|
239
|
+
}, arg2?: AssignValue): IComputeEngine;
|
|
240
|
+
declareType(name: string, type: Type, options?: {
|
|
241
|
+
alias?: boolean;
|
|
242
|
+
}): void;
|
|
243
|
+
declare(symbols: {
|
|
244
|
+
[id: MathJsonSymbol]: Type | TypeString | Partial<SymbolDefinition>;
|
|
245
|
+
}): IComputeEngine;
|
|
246
|
+
declare(id: MathJsonSymbol, def: Type | TypeString | Partial<SymbolDefinition>, scope?: Scope): IComputeEngine;
|
|
247
|
+
declare(arg1: MathJsonSymbol | {
|
|
248
|
+
[id: MathJsonSymbol]: Type | TypeString | Partial<SymbolDefinition>;
|
|
249
|
+
}, arg2?: Type | TypeString | Partial<SymbolDefinition>, arg3?: Scope): IComputeEngine;
|
|
250
|
+
assume(predicate: Expression): AssumeResult;
|
|
251
|
+
/**
|
|
252
|
+
* Declare a sequence with a recurrence relation.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```typescript
|
|
256
|
+
* // Fibonacci sequence
|
|
257
|
+
* ce.declareSequence('F', {
|
|
258
|
+
* base: { 0: 0, 1: 1 },
|
|
259
|
+
* recurrence: 'F_{n-1} + F_{n-2}',
|
|
260
|
+
* });
|
|
261
|
+
* ce.parse('F_{10}').evaluate(); // → 55
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
declareSequence(name: string, def: SequenceDefinition): IComputeEngine;
|
|
265
|
+
/**
|
|
266
|
+
* Get the status of a sequence definition.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```typescript
|
|
270
|
+
* ce.parse('F_0 := 0').evaluate();
|
|
271
|
+
* ce.getSequenceStatus('F');
|
|
272
|
+
* // → { status: 'pending', hasBase: true, hasRecurrence: false, baseIndices: [0] }
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
getSequenceStatus(name: string): SequenceStatus;
|
|
276
|
+
/**
|
|
277
|
+
* Get information about a defined sequence.
|
|
278
|
+
* Returns `undefined` if the symbol is not a sequence.
|
|
279
|
+
*/
|
|
280
|
+
getSequence(name: string): SequenceInfo | undefined;
|
|
281
|
+
/**
|
|
282
|
+
* List all defined sequences.
|
|
283
|
+
* Returns an array of sequence names.
|
|
284
|
+
*/
|
|
285
|
+
listSequences(): string[];
|
|
286
|
+
/**
|
|
287
|
+
* Check if a symbol is a defined sequence.
|
|
288
|
+
*/
|
|
289
|
+
isSequence(name: string): boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Clear the memoization cache for a sequence.
|
|
292
|
+
* If no name is provided, clears caches for all sequences.
|
|
293
|
+
*/
|
|
294
|
+
clearSequenceCache(name?: string): void;
|
|
295
|
+
/**
|
|
296
|
+
* Get the memoization cache for a sequence.
|
|
297
|
+
* Returns a Map of index → value, or `undefined` if not a sequence or memoization is disabled.
|
|
298
|
+
*
|
|
299
|
+
* For single-index sequences, keys are numbers.
|
|
300
|
+
* For multi-index sequences, keys are comma-separated strings (e.g., '5,2').
|
|
301
|
+
*/
|
|
302
|
+
getSequenceCache(name: string): Map<number | string, Expression> | undefined;
|
|
303
|
+
/**
|
|
304
|
+
* Generate a list of sequence terms from start to end (inclusive).
|
|
305
|
+
*
|
|
306
|
+
* @param name - The sequence name
|
|
307
|
+
* @param start - Starting index (inclusive)
|
|
308
|
+
* @param end - Ending index (inclusive)
|
|
309
|
+
* @param step - Step size (default: 1)
|
|
310
|
+
* @returns Array of BoxedExpressions, or undefined if not a sequence
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```typescript
|
|
314
|
+
* ce.declareSequence('F', { base: { 0: 0, 1: 1 }, recurrence: 'F_{n-1} + F_{n-2}' });
|
|
315
|
+
* ce.getSequenceTerms('F', 0, 10);
|
|
316
|
+
* // → [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
getSequenceTerms(name: string, start: number, end: number, step?: number): Expression[] | undefined;
|
|
320
|
+
/**
|
|
321
|
+
* Look up sequences in OEIS by their terms.
|
|
322
|
+
*
|
|
323
|
+
* @param terms - Array of sequence terms to search for
|
|
324
|
+
* @param options - Optional configuration (timeout, maxResults)
|
|
325
|
+
* @returns Promise resolving to array of matching sequences
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* const results = await ce.lookupOEIS([0, 1, 1, 2, 3, 5, 8, 13]);
|
|
330
|
+
* // → [{ id: 'A000045', name: 'Fibonacci numbers', ... }]
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
lookupOEIS(terms: (number | Expression)[], options?: OEISOptions): Promise<OEISSequenceInfo[]>;
|
|
334
|
+
/**
|
|
335
|
+
* Check if a defined sequence matches an OEIS sequence.
|
|
336
|
+
*
|
|
337
|
+
* @param name - Name of the defined sequence
|
|
338
|
+
* @param count - Number of terms to check (default: 10)
|
|
339
|
+
* @param options - Optional configuration
|
|
340
|
+
* @returns Promise with match results including OEIS matches and generated terms
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```typescript
|
|
344
|
+
* ce.declareSequence('F', { base: { 0: 0, 1: 1 }, recurrence: 'F_{n-1} + F_{n-2}' });
|
|
345
|
+
* const result = await ce.checkSequenceOEIS('F', 10);
|
|
346
|
+
* // → { matches: [{ id: 'A000045', name: 'Fibonacci numbers', ... }], terms: [0, 1, 1, ...] }
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
checkSequenceOEIS(name: string, count?: number, options?: OEISOptions): Promise<{
|
|
350
|
+
matches: OEISSequenceInfo[];
|
|
351
|
+
terms: number[];
|
|
352
|
+
}>;
|
|
353
|
+
forget(symbol?: MathJsonSymbol | MathJsonSymbol[]): void;
|
|
354
|
+
ask(pattern: Expression): BoxedSubstitution[];
|
|
355
|
+
verify(query: Expression): boolean | undefined;
|
|
356
|
+
/** @internal */
|
|
357
|
+
_shouldContinueExecution(): boolean;
|
|
358
|
+
/** @internal */
|
|
359
|
+
_checkContinueExecution(): void;
|
|
360
|
+
/** @internal */
|
|
361
|
+
_cache<T>(name: string, build: () => T, purge?: (t: T) => T | undefined): T;
|
|
362
|
+
/** @internal */
|
|
363
|
+
_reset(): void;
|
|
364
|
+
/** @internal */
|
|
365
|
+
listenToConfigurationChange(tracker: ConfigurationChangeListener): () => void;
|
|
366
|
+
}
|
|
367
|
+
declare module './types-expression' {
|
|
368
|
+
interface ExpressionComputeEngine extends IComputeEngine {
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
declare module './types-definitions' {
|
|
372
|
+
interface ComputeEngine extends IComputeEngine {
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/* 0.50.1 */
|
|
2
|
+
import type { IComputeEngine as ComputeEngine } from './types-engine';
|
|
3
|
+
import type { Expression, ExpressionInput } from './types-expression';
|
|
4
|
+
import type { Assumption as KernelAssumption, AssumeResult, AssignValue as KernelAssignValue, BoxedRule as KernelBoxedRule, BoxedRuleSet as KernelBoxedRuleSet, EvaluateOptions as KernelEvaluateOptions, EvalContext as KernelEvalContext, ExpressionMapInterface as KernelExpressionMapInterface, Rule as KernelRule, RuleConditionFunction as KernelRuleConditionFunction, RuleFunction as KernelRuleFunction, RuleReplaceFunction as KernelRuleReplaceFunction, RuleStep as KernelRuleStep, RuleSteps as KernelRuleSteps, Scope as KernelScope } from './types-kernel-evaluation';
|
|
5
|
+
export type { AssumeResult };
|
|
6
|
+
/**
|
|
7
|
+
* Options for evaluating boxed expressions.
|
|
8
|
+
*
|
|
9
|
+
* This is the compute-engine-specialized form of the generic kernel type.
|
|
10
|
+
*
|
|
11
|
+
* @category Boxed Expression
|
|
12
|
+
*/
|
|
13
|
+
export type EvaluateOptions = KernelEvaluateOptions<Expression>;
|
|
14
|
+
/**
|
|
15
|
+
* Map-like interface keyed by boxed expressions.
|
|
16
|
+
*
|
|
17
|
+
* @category Assumptions
|
|
18
|
+
*/
|
|
19
|
+
export type ExpressionMapInterface<U> = KernelExpressionMapInterface<U, Expression>;
|
|
20
|
+
/** A single rule application step with provenance. */
|
|
21
|
+
export type RuleStep = KernelRuleStep<Expression>;
|
|
22
|
+
/** A list of rule application steps. */
|
|
23
|
+
export type RuleSteps = KernelRuleSteps<Expression>;
|
|
24
|
+
/**
|
|
25
|
+
* Assumption predicates bound to this compute engine.
|
|
26
|
+
*
|
|
27
|
+
* @category Assumptions
|
|
28
|
+
*/
|
|
29
|
+
export type Assumption = KernelAssumption<Expression, ComputeEngine>;
|
|
30
|
+
/**
|
|
31
|
+
* Rule replacement callback specialized to boxed expressions.
|
|
32
|
+
*
|
|
33
|
+
* @category Rules
|
|
34
|
+
*/
|
|
35
|
+
export type RuleReplaceFunction = KernelRuleReplaceFunction<Expression>;
|
|
36
|
+
/**
|
|
37
|
+
* Rule condition callback with access to the compute engine.
|
|
38
|
+
*
|
|
39
|
+
* @category Rules
|
|
40
|
+
*/
|
|
41
|
+
export type RuleConditionFunction = KernelRuleConditionFunction<Expression, ComputeEngine>;
|
|
42
|
+
/**
|
|
43
|
+
* Dynamic rule callback.
|
|
44
|
+
*
|
|
45
|
+
* @category Rules
|
|
46
|
+
*/
|
|
47
|
+
export type RuleFunction = KernelRuleFunction<Expression>;
|
|
48
|
+
/**
|
|
49
|
+
* Rule declaration specialized to boxed expression and compute engine types.
|
|
50
|
+
*
|
|
51
|
+
* @category Rules
|
|
52
|
+
*/
|
|
53
|
+
export type Rule = KernelRule<Expression, ExpressionInput, ComputeEngine>;
|
|
54
|
+
/** A boxed/normalized rule form. */
|
|
55
|
+
export type BoxedRule = KernelBoxedRule<Expression, ComputeEngine>;
|
|
56
|
+
/** Collection of boxed rules. */
|
|
57
|
+
export type BoxedRuleSet = KernelBoxedRuleSet<Expression, ComputeEngine>;
|
|
58
|
+
/**
|
|
59
|
+
* Assignable value for `ce.assign()`.
|
|
60
|
+
*
|
|
61
|
+
* @category Compute Engine
|
|
62
|
+
*/
|
|
63
|
+
export type AssignValue = KernelAssignValue<Expression, ExpressionInput, ComputeEngine>;
|
|
64
|
+
/** Lexical scope specialized to boxed definitions. */
|
|
65
|
+
export type Scope = KernelScope<BoxedDefinition>;
|
|
66
|
+
/** Evaluation context specialized to this engine/runtime model. */
|
|
67
|
+
export type EvalContext = KernelEvalContext<Expression, BoxedDefinition>;
|