@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,164 @@
|
|
|
1
|
+
/* 0.50.1 */
|
|
2
|
+
import type { TypeReference } from '../common/type/types';
|
|
3
|
+
import type { BoxedType } from '../common/type/boxed-type';
|
|
4
|
+
import type { LatexString } from './latex-syntax/types';
|
|
5
|
+
import type { BoxedSubstitution } from './types-kernel-serialization';
|
|
6
|
+
/** @category Assumptions */
|
|
7
|
+
export interface Assumption<Expr = unknown, CE = unknown> {
|
|
8
|
+
isPositive: boolean | undefined;
|
|
9
|
+
isNonNegative: boolean | undefined;
|
|
10
|
+
isNegative: boolean | undefined;
|
|
11
|
+
isNonPositive: boolean | undefined;
|
|
12
|
+
isNumber: boolean | undefined;
|
|
13
|
+
isInteger: boolean | undefined;
|
|
14
|
+
isRational: boolean | undefined;
|
|
15
|
+
isReal: boolean | undefined;
|
|
16
|
+
isComplex: boolean | undefined;
|
|
17
|
+
isImaginary: boolean | undefined;
|
|
18
|
+
isFinite: boolean | undefined;
|
|
19
|
+
isInfinite: boolean | undefined;
|
|
20
|
+
isNaN: boolean | undefined;
|
|
21
|
+
isZero: boolean | undefined;
|
|
22
|
+
matches(t: BoxedType): boolean | undefined;
|
|
23
|
+
isGreater(other: Expr): boolean | undefined;
|
|
24
|
+
isGreaterEqual(other: Expr): boolean | undefined;
|
|
25
|
+
isLess(other: Expr): boolean | undefined;
|
|
26
|
+
isLessEqual(other: Expr): boolean | undefined;
|
|
27
|
+
isEqual(other: Expr): boolean | undefined;
|
|
28
|
+
toExpression(ce: CE, x: MathJsonSymbol): Expr;
|
|
29
|
+
}
|
|
30
|
+
/** @category Assumptions */
|
|
31
|
+
export interface ExpressionMapInterface<U, Expr = unknown> {
|
|
32
|
+
has(expr: Expr): boolean;
|
|
33
|
+
get(expr: Expr): U | undefined;
|
|
34
|
+
set(expr: Expr, value: U): void;
|
|
35
|
+
delete(expr: Expr): void;
|
|
36
|
+
clear(): void;
|
|
37
|
+
[Symbol.iterator](): IterableIterator<[Expr, U]>;
|
|
38
|
+
entries(): IterableIterator<[Expr, U]>;
|
|
39
|
+
}
|
|
40
|
+
/** @category Assumptions */
|
|
41
|
+
export type AssumeResult = 'internal-error' | 'not-a-predicate' | 'contradiction' | 'tautology' | 'ok';
|
|
42
|
+
/** Options for `Expression.evaluate()`
|
|
43
|
+
*
|
|
44
|
+
* @category Boxed Expression
|
|
45
|
+
*/
|
|
46
|
+
export type EvaluateOptions<Expr = unknown> = {
|
|
47
|
+
/**
|
|
48
|
+
* If `true`, the evaluation returns a numeric approximation of the expression,
|
|
49
|
+
* when possible.
|
|
50
|
+
*
|
|
51
|
+
* If `false`, the evaluation returns an exact value, when possible.
|
|
52
|
+
*
|
|
53
|
+
* **Default**: `false`
|
|
54
|
+
*/
|
|
55
|
+
numericApproximation: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* If `false`, and the result is a lazy collection, the collection remains
|
|
58
|
+
* lazy and is not materialized.
|
|
59
|
+
*
|
|
60
|
+
* If `true`, and the collection is finite, it is fully materialized.
|
|
61
|
+
*
|
|
62
|
+
* If an integer, evaluate at most that many elements.
|
|
63
|
+
*
|
|
64
|
+
* If a pair of integers `[n, m]`, and the collection is finite, evaluate
|
|
65
|
+
* the first `n` and last `m` elements.
|
|
66
|
+
*
|
|
67
|
+
* **Default**: `false`
|
|
68
|
+
*/
|
|
69
|
+
materialization: boolean | number | [number, number];
|
|
70
|
+
/** Cancellation signal for long-running evaluations. */
|
|
71
|
+
signal: AbortSignal;
|
|
72
|
+
/**
|
|
73
|
+
* Temporary named argument bindings used while evaluating this expression.
|
|
74
|
+
*/
|
|
75
|
+
withArguments: Record<MathJsonSymbol, Expr>;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Given an expression and set of wildcards, return a replacement expression.
|
|
79
|
+
*
|
|
80
|
+
* @category Rules
|
|
81
|
+
*/
|
|
82
|
+
export type RuleReplaceFunction<Expr = unknown> = (expr: Expr, wildcards: BoxedSubstitution<Expr>) => Expr | undefined;
|
|
83
|
+
/** @category Rules */
|
|
84
|
+
export type RuleConditionFunction<Expr = unknown, CE = unknown> = (wildcards: BoxedSubstitution<Expr>, ce: CE) => boolean;
|
|
85
|
+
/** @category Rules */
|
|
86
|
+
export type RuleFunction<Expr = unknown> = (expr: Expr) => undefined | Expr | RuleStep<Expr>;
|
|
87
|
+
/** @category Rules */
|
|
88
|
+
export type RuleStep<Expr = unknown> = {
|
|
89
|
+
value: Expr;
|
|
90
|
+
because: string;
|
|
91
|
+
};
|
|
92
|
+
/** @category Rules */
|
|
93
|
+
export type RuleSteps<Expr = unknown> = RuleStep<Expr>[];
|
|
94
|
+
/**
|
|
95
|
+
* A rule describes how to transform an expression matching `match`
|
|
96
|
+
* into a new expression produced by `replace`.
|
|
97
|
+
*
|
|
98
|
+
* - `x-1` \( \to \) `1-x`
|
|
99
|
+
* - `(x+1)(x-1)` \( \to \) `x^2-1`
|
|
100
|
+
*
|
|
101
|
+
* Match and replace patterns can be provided as LaTeX strings or expressions.
|
|
102
|
+
* Rules can also be implemented with callback functions.
|
|
103
|
+
*
|
|
104
|
+
* ## Wildcards
|
|
105
|
+
*
|
|
106
|
+
* In expression patterns:
|
|
107
|
+
* - `_` matches one expression.
|
|
108
|
+
* - `_x`, `_a`, ... match one expression and bind it by name.
|
|
109
|
+
* - `__x` matches one or more expressions.
|
|
110
|
+
* - `___x` matches zero or more expressions.
|
|
111
|
+
*
|
|
112
|
+
* ## Variations
|
|
113
|
+
*
|
|
114
|
+
* If `useVariations` is true, rules may match equivalent variants
|
|
115
|
+
* (for example matching `x` against `a + x`).
|
|
116
|
+
*
|
|
117
|
+
* @category Rules
|
|
118
|
+
*/
|
|
119
|
+
export type Rule<Expr = unknown, SemiExpr = unknown, CE = unknown> = string | RuleFunction<Expr> | {
|
|
120
|
+
match?: LatexString | SemiExpr | Expr;
|
|
121
|
+
replace: LatexString | SemiExpr | RuleReplaceFunction<Expr> | RuleFunction<Expr>;
|
|
122
|
+
condition?: LatexString | RuleConditionFunction<Expr, CE>;
|
|
123
|
+
useVariations?: boolean;
|
|
124
|
+
id?: string;
|
|
125
|
+
onBeforeMatch?: (rule: Rule<Expr, SemiExpr, CE>, expr: Expr) => void;
|
|
126
|
+
onMatch?: (rule: Rule<Expr, SemiExpr, CE>, expr: Expr, replace: Expr | RuleStep<Expr>) => void;
|
|
127
|
+
};
|
|
128
|
+
/** @category Rules */
|
|
129
|
+
export type BoxedRule<Expr = unknown, CE = unknown> = {
|
|
130
|
+
readonly _tag: 'boxed-rule';
|
|
131
|
+
match: undefined | Expr;
|
|
132
|
+
replace: Expr | RuleReplaceFunction<Expr> | RuleFunction<Expr>;
|
|
133
|
+
condition: undefined | RuleConditionFunction<Expr, CE>;
|
|
134
|
+
useVariations?: boolean;
|
|
135
|
+
id?: string;
|
|
136
|
+
onBeforeMatch?: (rule: Rule<Expr, unknown, CE>, expr: Expr) => void;
|
|
137
|
+
onMatch?: (rule: Rule<Expr, unknown, CE>, expr: Expr, replace: Expr | RuleStep<Expr>) => void;
|
|
138
|
+
};
|
|
139
|
+
/** @category Rules */
|
|
140
|
+
export type BoxedRuleSet<Expr = unknown, CE = unknown> = {
|
|
141
|
+
rules: ReadonlyArray<BoxedRule<Expr, CE>>;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* The argument of `ce.assign()` can be a primitive, an expression,
|
|
145
|
+
* or a function that computes an expression from arguments.
|
|
146
|
+
*
|
|
147
|
+
* @category Compute Engine
|
|
148
|
+
*/
|
|
149
|
+
export type AssignValue<Expr = unknown, SemiExpr = unknown, CE = unknown> = boolean | number | bigint | SemiExpr | ((args: ReadonlyArray<Expr>, options: EvaluateOptions<Expr> & {
|
|
150
|
+
engine: CE;
|
|
151
|
+
}) => Expr) | undefined;
|
|
152
|
+
/** @category Definitions */
|
|
153
|
+
export type Scope<Binding = unknown> = {
|
|
154
|
+
parent: Scope<Binding> | null;
|
|
155
|
+
bindings: Map<string, Binding>;
|
|
156
|
+
types?: Record<string, TypeReference>;
|
|
157
|
+
};
|
|
158
|
+
/** @category Compute Engine */
|
|
159
|
+
export type EvalContext<Expr = unknown, Binding = unknown> = {
|
|
160
|
+
lexicalScope: Scope<Binding>;
|
|
161
|
+
assumptions: ExpressionMapInterface<boolean, Expr>;
|
|
162
|
+
values: Record<string, Expr | undefined>;
|
|
163
|
+
name: undefined | string;
|
|
164
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/* 0.50.1 */
|
|
2
|
+
export type Hold = 'none' | 'all' | 'first' | 'rest' | 'last' | 'most';
|
|
3
|
+
/**
|
|
4
|
+
* Options to control serialization to MathJSON when using
|
|
5
|
+
* `Expression.toMathJson()`.
|
|
6
|
+
*
|
|
7
|
+
* @category Serialization
|
|
8
|
+
*/
|
|
9
|
+
export type JsonSerializationOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* If true, serialization applies readability transforms.
|
|
12
|
+
* Example: `["Power", "x", 2]` -> `["Square", "x"]`.
|
|
13
|
+
*/
|
|
14
|
+
prettify: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Function names to exclude from prettified output.
|
|
17
|
+
* Excluded functions are replaced by equivalent non-prettified forms.
|
|
18
|
+
*/
|
|
19
|
+
exclude: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Which expression kinds can use shorthand output.
|
|
22
|
+
*
|
|
23
|
+
* **Default**: `["all"]`
|
|
24
|
+
*/
|
|
25
|
+
shorthands: ('all' | 'number' | 'symbol' | 'function' | 'string' | 'dictionary')[];
|
|
26
|
+
/**
|
|
27
|
+
* Metadata fields to include. When metadata is included, shorthand notation
|
|
28
|
+
* is disabled for affected nodes.
|
|
29
|
+
*/
|
|
30
|
+
metadata: ('all' | 'wikidata' | 'latex')[];
|
|
31
|
+
/**
|
|
32
|
+
* If true, detect and serialize repeating decimals (for example `0.(3)`).
|
|
33
|
+
*
|
|
34
|
+
* **Default**: `true`
|
|
35
|
+
*/
|
|
36
|
+
repeatingDecimal: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Maximum significant digits to serialize.
|
|
39
|
+
* - `"max"`: all available digits
|
|
40
|
+
* - `"auto"`: use compute-engine precision
|
|
41
|
+
*
|
|
42
|
+
* **Default**: `"auto"`
|
|
43
|
+
*/
|
|
44
|
+
fractionalDigits: 'auto' | 'max' | number;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Control how a pattern is matched to an expression.
|
|
48
|
+
*
|
|
49
|
+
* ## Wildcards
|
|
50
|
+
* - Universal (`_` or `_name`): exactly one element
|
|
51
|
+
* - Sequence (`__` or `__name`): one or more elements
|
|
52
|
+
* - Optional Sequence (`___` or `___name`): zero or more elements
|
|
53
|
+
*
|
|
54
|
+
* @category Pattern Matching
|
|
55
|
+
*/
|
|
56
|
+
export type PatternMatchOptions<T = unknown> = {
|
|
57
|
+
/**
|
|
58
|
+
* Preset bindings for named wildcards. Useful to enforce consistency
|
|
59
|
+
* across repeated wildcard occurrences.
|
|
60
|
+
*/
|
|
61
|
+
substitution?: BoxedSubstitution<T>;
|
|
62
|
+
/**
|
|
63
|
+
* If true, match recursively in sub-expressions; otherwise only at
|
|
64
|
+
* the top level.
|
|
65
|
+
*/
|
|
66
|
+
recursive?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* If true, allow structurally equivalent variations to match.
|
|
69
|
+
* If false, require structural identity.
|
|
70
|
+
*/
|
|
71
|
+
useVariations?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* If true (default), commutative operators may match with permuted operands.
|
|
74
|
+
* If false, operand order must match exactly.
|
|
75
|
+
*/
|
|
76
|
+
matchPermutations?: boolean;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Options for `Expression.replace()`.
|
|
80
|
+
*
|
|
81
|
+
* @category Boxed Expression
|
|
82
|
+
*/
|
|
83
|
+
export type ReplaceOptions = {
|
|
84
|
+
/**
|
|
85
|
+
* If true, apply rules to all sub-expressions.
|
|
86
|
+
* If false, only the top-level expression is considered.
|
|
87
|
+
*/
|
|
88
|
+
recursive: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* If true, stop after the first matching rule.
|
|
91
|
+
* If false, continue applying remaining rules.
|
|
92
|
+
*/
|
|
93
|
+
once: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* If true, rules may match equivalent variants.
|
|
96
|
+
* Can be powerful but may introduce recursion hazards.
|
|
97
|
+
*/
|
|
98
|
+
useVariations: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* If true (default), commutative matches may permute operands.
|
|
101
|
+
* If false, matching is order-sensitive.
|
|
102
|
+
*/
|
|
103
|
+
matchPermutations: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Repeat rule application up to this limit when `once` is false.
|
|
106
|
+
*/
|
|
107
|
+
iterationLimit: number;
|
|
108
|
+
/**
|
|
109
|
+
* Canonicalization policy after replacement.
|
|
110
|
+
*/
|
|
111
|
+
canonical: CanonicalOptions;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Canonical normalization transforms.
|
|
115
|
+
*
|
|
116
|
+
* @category Boxed Expression
|
|
117
|
+
*/
|
|
118
|
+
export type CanonicalForm = 'InvisibleOperator' | 'Number' | 'Multiply' | 'Add' | 'Power' | 'Divide' | 'Flatten' | 'Order';
|
|
119
|
+
/** @category Boxed Expression */
|
|
120
|
+
export type CanonicalOptions = boolean | CanonicalForm | CanonicalForm[];
|
|
121
|
+
/**
|
|
122
|
+
* Controls how expressions are created.
|
|
123
|
+
*
|
|
124
|
+
* @category Boxed Expression
|
|
125
|
+
*/
|
|
126
|
+
export type FormOption = 'canonical' | 'structural' | 'raw' | CanonicalForm | CanonicalForm[];
|
|
127
|
+
/**
|
|
128
|
+
* Metadata that can be associated with a MathJSON expression.
|
|
129
|
+
*
|
|
130
|
+
* @category Boxed Expression
|
|
131
|
+
*/
|
|
132
|
+
export type Metadata = {
|
|
133
|
+
latex?: string | undefined;
|
|
134
|
+
wikidata?: string | undefined;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* A substitution maps wildcard symbols to bound values.
|
|
138
|
+
*
|
|
139
|
+
* @category Pattern Matching
|
|
140
|
+
*/
|
|
141
|
+
export type Substitution<T = unknown> = {
|
|
142
|
+
[symbol: string]: T;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* @category Pattern Matching
|
|
146
|
+
*/
|
|
147
|
+
export type BoxedSubstitution<T = unknown> = Substitution<T>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* 0.50.1 */
|
|
2
|
+
import type { BoxedSubstitution as KernelBoxedSubstitution, CanonicalForm, CanonicalOptions, FormOption, Hold, JsonSerializationOptions, Metadata, PatternMatchOptions as KernelPatternMatchOptions, ReplaceOptions, Substitution as KernelSubstitution } from './types-kernel-serialization';
|
|
3
|
+
export type { Hold, JsonSerializationOptions, ReplaceOptions, CanonicalForm, CanonicalOptions, FormOption, Metadata, };
|
|
4
|
+
/**
|
|
5
|
+
* A substitution describes the values of the wildcards in a pattern so that
|
|
6
|
+
* the pattern is equal to a target expression.
|
|
7
|
+
*
|
|
8
|
+
* A substitution can also be considered a more constrained version of a
|
|
9
|
+
* rule whose `match` is always a symbol.
|
|
10
|
+
*
|
|
11
|
+
* @category Pattern Matching
|
|
12
|
+
*/
|
|
13
|
+
export type Substitution<T = ExpressionInput> = KernelSubstitution<T>;
|
|
14
|
+
/**
|
|
15
|
+
* @category Pattern Matching
|
|
16
|
+
*/
|
|
17
|
+
export type BoxedSubstitution<T = Expression> = KernelBoxedSubstitution<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Control how a pattern is matched to an expression.
|
|
20
|
+
*
|
|
21
|
+
* @category Pattern Matching
|
|
22
|
+
*/
|
|
23
|
+
export type PatternMatchOptions<T = Expression> = KernelPatternMatchOptions<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
export
|
|
1
|
+
/* 0.50.1 */
|
|
2
|
+
export type { MathJsonExpression, MathJsonAttributes, MathJsonNumberObject, MathJsonSymbolObject, MathJsonStringObject, MathJsonFunctionObject, DictionaryValue, MathJsonDictionaryObject, ExpressionObject, MathJsonSymbol, } from '../math-json/types';
|
|
3
3
|
export * from '../common/type/boxed-type';
|
|
4
4
|
export * from '../common/type/types';
|
|
5
5
|
export type * from './latex-syntax/types';
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.50.1 */
|
|
2
2
|
export { ComputeEngine } from './compute-engine/index';
|
|
3
|
-
export * from './compute-engine/types';
|
|
4
|
-
export type { CompileTarget, CompiledOperators, CompiledFunctions, CompilationOptions,
|
|
3
|
+
export type * from './compute-engine/types';
|
|
4
|
+
export type { CompileTarget, CompiledOperators, CompiledFunctions, CompilationOptions, CompilationResult, LanguageTarget, TargetSource, CompiledFunction, } from './compute-engine/compilation/types';
|
|
5
5
|
export { JavaScriptTarget } from './compute-engine/compilation/javascript-target';
|
|
6
|
+
export { GPUShaderTarget } from './compute-engine/compilation/gpu-target';
|
|
6
7
|
export { GLSLTarget } from './compute-engine/compilation/glsl-target';
|
|
8
|
+
export { WGSLTarget } from './compute-engine/compilation/wgsl-target';
|
|
9
|
+
export { PythonTarget } from './compute-engine/compilation/python-target';
|
|
10
|
+
export { IntervalJavaScriptTarget } from './compute-engine/compilation/interval-javascript-target';
|
|
11
|
+
export { IntervalGLSLTarget } from './compute-engine/compilation/interval-glsl-target';
|
|
12
|
+
export { IntervalWGSLTarget } from './compute-engine/compilation/interval-wgsl-target';
|
|
7
13
|
export { BaseCompiler } from './compute-engine/compilation/base-compiler';
|
|
14
|
+
export { parse, simplify, evaluate, N, assign, expand, expandAll, factor, solve, compile, getDefaultEngine, } from './compute-engine/free-functions';
|
|
15
|
+
export { isExpression, isNumber, isSymbol, isFunction, isString, isTensor, isDictionary, isCollection, isIndexedCollection, isBoxedExpression, isBoxedNumber, isBoxedSymbol, isBoxedFunction, isBoxedString, isBoxedTensor, } from './compute-engine/boxed-expression/type-guards';
|
|
16
|
+
export type { BoxedNumber } from './compute-engine/boxed-expression/boxed-number';
|
|
17
|
+
export type { BoxedSymbol } from './compute-engine/boxed-expression/boxed-symbol';
|
|
18
|
+
export type { BoxedFunction } from './compute-engine/boxed-expression/boxed-function';
|
|
19
|
+
export type { BoxedString } from './compute-engine/boxed-expression/boxed-string';
|
|
20
|
+
export type { BoxedTensor } from './compute-engine/boxed-expression/boxed-tensor';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.50.1 */
|
|
2
2
|
* The following properties can be added to any MathJSON expression
|
|
3
3
|
* to provide additional information about the expression.
|
|
4
4
|
*
|
|
@@ -99,7 +99,7 @@ export type MathJsonStringObject = {
|
|
|
99
99
|
} & MathJsonAttributes;
|
|
100
100
|
/** @category MathJSON */
|
|
101
101
|
export type MathJsonFunctionObject = {
|
|
102
|
-
fn: [MathJsonSymbol, ...
|
|
102
|
+
fn: [MathJsonSymbol, ...MathJsonExpression[]];
|
|
103
103
|
} & MathJsonAttributes;
|
|
104
104
|
/** @category MathJSON */
|
|
105
105
|
export type DictionaryValue = boolean | number | string | ExpressionObject | ReadonlyArray<DictionaryValue>;
|
|
@@ -119,4 +119,4 @@ export type ExpressionObject = MathJsonNumberObject | MathJsonStringObject | Mat
|
|
|
119
119
|
*
|
|
120
120
|
* @category MathJSON
|
|
121
121
|
*/
|
|
122
|
-
export type
|
|
122
|
+
export type MathJsonExpression = ExpressionObject | number | MathJsonSymbol | string | readonly [MathJsonSymbol, ...MathJsonExpression[]];
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
export declare const MISSING:
|
|
3
|
-
export declare function isNumberExpression(expr:
|
|
4
|
-
export declare function isNumberObject(expr:
|
|
5
|
-
export declare function isSymbolObject(expr:
|
|
6
|
-
export declare function isStringObject(expr:
|
|
7
|
-
export declare function isDictionaryObject(expr:
|
|
8
|
-
export declare function isFunctionObject(expr:
|
|
9
|
-
export declare function isExpressionObject(expr:
|
|
1
|
+
/* 0.50.1 */
|
|
2
|
+
export declare const MISSING: MathJsonExpression;
|
|
3
|
+
export declare function isNumberExpression(expr: MathJsonExpression | null): expr is number | string | MathJsonNumberObject;
|
|
4
|
+
export declare function isNumberObject(expr: MathJsonExpression | null): expr is MathJsonNumberObject;
|
|
5
|
+
export declare function isSymbolObject(expr: MathJsonExpression | null): expr is MathJsonSymbolObject;
|
|
6
|
+
export declare function isStringObject(expr: MathJsonExpression | null): expr is MathJsonStringObject;
|
|
7
|
+
export declare function isDictionaryObject(expr: MathJsonExpression | null): expr is MathJsonDictionaryObject;
|
|
8
|
+
export declare function isFunctionObject(expr: MathJsonExpression | null): expr is MathJsonFunctionObject;
|
|
9
|
+
export declare function isExpressionObject(expr: MathJsonExpression | null): expr is ExpressionObject;
|
|
10
10
|
/**
|
|
11
11
|
* Returns true if `expr` has at least one recognized metadata property
|
|
12
12
|
* (`latex` or `wikidata`) with a non-undefined value.
|
|
13
13
|
*/
|
|
14
|
-
export declare function hasMetaData(expr:
|
|
14
|
+
export declare function hasMetaData(expr: MathJsonExpression | null): expr is ExpressionObject & Partial<MathJsonAttributes>;
|
|
15
15
|
/** If expr is a string literal, return it.
|
|
16
16
|
*
|
|
17
17
|
* A string literal is a JSON string that begins and ends with
|
|
18
18
|
* **U+0027 APOSTROPHE** : **`'`** or an object literal with a `str` key.
|
|
19
19
|
*/
|
|
20
|
-
export declare function stringValue(expr:
|
|
21
|
-
export declare function stripText(expr:
|
|
20
|
+
export declare function stringValue(expr: MathJsonExpression | null | undefined): string | null;
|
|
21
|
+
export declare function stripText(expr: MathJsonExpression | null | undefined): MathJsonExpression | null;
|
|
22
22
|
/**
|
|
23
23
|
* The operator of a function is symbol.
|
|
24
24
|
*
|
|
@@ -27,24 +27,24 @@ export declare function stripText(expr: Expression | null | undefined): Expressi
|
|
|
27
27
|
* Examples:
|
|
28
28
|
* * `["Negate", 5]` -> `"Negate"`
|
|
29
29
|
*/
|
|
30
|
-
export declare function operator(expr:
|
|
30
|
+
export declare function operator(expr: MathJsonExpression | null | undefined): MathJsonSymbol;
|
|
31
31
|
/**
|
|
32
32
|
* Return the arguments of a function, or an empty array if not a function
|
|
33
33
|
* or no arguments.
|
|
34
34
|
*/
|
|
35
|
-
export declare function operands(expr:
|
|
35
|
+
export declare function operands(expr: MathJsonExpression | null | undefined): ReadonlyArray<MathJsonExpression>;
|
|
36
36
|
/** Return the nth operand of a function expression */
|
|
37
|
-
export declare function operand(expr:
|
|
38
|
-
export declare function nops(expr:
|
|
39
|
-
export declare function unhold(expr:
|
|
40
|
-
export declare function symbol(expr:
|
|
41
|
-
export declare function dictionaryFromExpression(expr:
|
|
42
|
-
export declare function dictionaryFromEntries(dict: Record<string,
|
|
37
|
+
export declare function operand(expr: MathJsonExpression | null, n: 1 | 2 | 3): MathJsonExpression | null;
|
|
38
|
+
export declare function nops(expr: MathJsonExpression | null | undefined): number;
|
|
39
|
+
export declare function unhold(expr: MathJsonExpression | null): MathJsonExpression | null;
|
|
40
|
+
export declare function symbol(expr: MathJsonExpression | null | undefined): string | null;
|
|
41
|
+
export declare function dictionaryFromExpression(expr: MathJsonExpression | null): null | MathJsonDictionaryObject;
|
|
42
|
+
export declare function dictionaryFromEntries(dict: Record<string, MathJsonExpression>): MathJsonExpression;
|
|
43
43
|
/**
|
|
44
44
|
* CAUTION: `machineValue()` will return a truncated value if the number
|
|
45
45
|
* has a precision outside of the machine range.
|
|
46
46
|
*/
|
|
47
|
-
export declare function machineValue(expr:
|
|
47
|
+
export declare function machineValue(expr: MathJsonExpression | null | undefined): number | null;
|
|
48
48
|
/**
|
|
49
49
|
* Return a rational (numer over denom) representation of the expression,
|
|
50
50
|
* if possible, `null` otherwise.
|
|
@@ -57,29 +57,29 @@ export declare function machineValue(expr: Expression | null | undefined): numbe
|
|
|
57
57
|
*
|
|
58
58
|
* The denominator is always > 0.
|
|
59
59
|
*/
|
|
60
|
-
export declare function rationalValue(expr:
|
|
60
|
+
export declare function rationalValue(expr: MathJsonExpression | undefined | null): [number, number] | null;
|
|
61
61
|
/**
|
|
62
62
|
* Apply a substitution to an expression.
|
|
63
63
|
*/
|
|
64
|
-
export declare function subs(expr:
|
|
65
|
-
[symbol: string]:
|
|
66
|
-
}):
|
|
64
|
+
export declare function subs(expr: MathJsonExpression, s: {
|
|
65
|
+
[symbol: string]: MathJsonExpression;
|
|
66
|
+
}): MathJsonExpression;
|
|
67
67
|
/**
|
|
68
68
|
* Apply a function to the arguments of a function and return an array of T
|
|
69
69
|
*/
|
|
70
|
-
export declare function mapArgs<T>(expr:
|
|
70
|
+
export declare function mapArgs<T>(expr: MathJsonExpression, fn: (x: MathJsonExpression) => T): T[];
|
|
71
71
|
/**
|
|
72
72
|
* Assuming that op is an associative operator, fold lhs or rhs
|
|
73
73
|
* if either are the same operator.
|
|
74
74
|
*/
|
|
75
|
-
export declare function foldAssociativeOperator(op: string, lhs:
|
|
75
|
+
export declare function foldAssociativeOperator(op: string, lhs: MathJsonExpression, rhs: MathJsonExpression): MathJsonExpression;
|
|
76
76
|
/** Return the elements of a sequence, or null if the expression is not a sequence. The sequence can be optionally enclosed by a`["Delimiter"]` expression */
|
|
77
|
-
export declare function getSequence(expr:
|
|
77
|
+
export declare function getSequence(expr: MathJsonExpression | null | undefined): ReadonlyArray<MathJsonExpression> | null;
|
|
78
78
|
/** `Nothing` or the empty sequence (`["Sequence"]`) */
|
|
79
|
-
export declare function isEmptySequence(expr:
|
|
80
|
-
export declare function missingIfEmpty(expr:
|
|
79
|
+
export declare function isEmptySequence(expr: MathJsonExpression | null | undefined): expr is null | undefined;
|
|
80
|
+
export declare function missingIfEmpty(expr: MathJsonExpression | null | undefined): MathJsonExpression;
|
|
81
81
|
/** The number of leaves (atomic expressions) in the expression */
|
|
82
|
-
export declare function countLeaves(expr:
|
|
82
|
+
export declare function countLeaves(expr: MathJsonExpression | null): number;
|
|
83
83
|
/** True if the string matches the expected pattern for a number */
|
|
84
84
|
export declare function matchesNumber(s: string): boolean;
|
|
85
85
|
/** True if the string matches the expected pattern for a symbol */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.50.1 */
|
|
2
2
|
export { isSymbolObject, isStringObject, isFunctionObject, stringValue, operator, operand, symbol, mapArgs, dictionaryFromExpression, } from './math-json/utils';
|
|
3
|
-
export declare const version = "0.
|
|
3
|
+
export declare const version = "0.50.1";
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.50.1",
|
|
3
3
|
"scripts": {
|
|
4
4
|
"doc": "bash ./scripts/doc.sh",
|
|
5
5
|
"build": "bash ./scripts/build.sh",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"snapshot": "bash ./scripts/test.sh snapshot",
|
|
12
12
|
"version": "bash ./scripts/version.sh",
|
|
13
13
|
"test": "bash ./scripts/test.sh",
|
|
14
|
+
"check:deps": "madge --circular --extensions ts src/compute-engine && echo 'No runtime circular dependencies found (type-only cycles are expected)'",
|
|
14
15
|
"lint": "eslint src --ext .ts --fix && prettier --write 'src/**/*.{ts,js,css,md}'",
|
|
15
16
|
"typecheck": "bash ./scripts/typecheck.sh"
|
|
16
17
|
},
|
|
@@ -47,6 +48,12 @@
|
|
|
47
48
|
"import": "./dist/compute-engine.min.esm.js",
|
|
48
49
|
"require": "./dist/compute-engine.min.umd.js",
|
|
49
50
|
"default": "./dist/compute-engine.min.esm.js"
|
|
51
|
+
},
|
|
52
|
+
"./math-json": {
|
|
53
|
+
"types": "./dist/types/math-json.d.ts",
|
|
54
|
+
"import": "./dist/math-json.min.esm.js",
|
|
55
|
+
"require": "./dist/math-json.min.umd.js",
|
|
56
|
+
"default": "./dist/math-json.min.esm.js"
|
|
50
57
|
}
|
|
51
58
|
},
|
|
52
59
|
"main": "./dist/compute-engine.min.esm.js",
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/* 0.35.6 */
|
|
2
|
-
export declare function evaluateAnd(args: ReadonlyArray<BoxedExpression>, { engine: ce }: {
|
|
3
|
-
engine: ComputeEngine;
|
|
4
|
-
}): BoxedExpression | undefined;
|
|
5
|
-
export declare function evaluateOr(args: ReadonlyArray<BoxedExpression>, { engine: ce }: {
|
|
6
|
-
engine: ComputeEngine;
|
|
7
|
-
}): BoxedExpression | undefined;
|
|
8
|
-
export declare function evaluateNot(args: ReadonlyArray<BoxedExpression>, { engine: ce }: {
|
|
9
|
-
engine: ComputeEngine;
|
|
10
|
-
}): BoxedExpression | undefined;
|
|
11
|
-
export declare function evaluateEquivalent(args: ReadonlyArray<BoxedExpression>, { engine: ce }: {
|
|
12
|
-
engine: ComputeEngine;
|
|
13
|
-
}): BoxedExpression | undefined;
|
|
14
|
-
export declare function evaluateImplies(args: ReadonlyArray<BoxedExpression>, { engine: ce }: {
|
|
15
|
-
engine: ComputeEngine;
|
|
16
|
-
}): BoxedExpression | undefined;
|
|
17
|
-
export declare function evaluateXor(args: ReadonlyArray<BoxedExpression>, { engine: ce }: {
|
|
18
|
-
engine: ComputeEngine;
|
|
19
|
-
}): BoxedExpression | undefined;
|
|
20
|
-
export declare function evaluateNand(args: ReadonlyArray<BoxedExpression>, { engine: ce }: {
|
|
21
|
-
engine: ComputeEngine;
|
|
22
|
-
}): BoxedExpression | undefined;
|
|
23
|
-
export declare function evaluateNor(args: ReadonlyArray<BoxedExpression>, { engine: ce }: {
|
|
24
|
-
engine: ComputeEngine;
|
|
25
|
-
}): BoxedExpression | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* Convert a boolean expression to Negation Normal Form (NNF).
|
|
28
|
-
* In NNF, negations only appear directly before variables (literals).
|
|
29
|
-
* This is a prerequisite for CNF/DNF conversion.
|
|
30
|
-
*/
|
|
31
|
-
export declare function toNNF(expr: BoxedExpression, ce: ComputeEngine): BoxedExpression;
|
|
32
|
-
/**
|
|
33
|
-
* Convert a boolean expression to Conjunctive Normal Form (CNF).
|
|
34
|
-
*/
|
|
35
|
-
export declare function toCNF(expr: BoxedExpression, ce: ComputeEngine): BoxedExpression;
|
|
36
|
-
/**
|
|
37
|
-
* Convert a boolean expression to Disjunctive Normal Form (DNF).
|
|
38
|
-
*/
|
|
39
|
-
export declare function toDNF(expr: BoxedExpression, ce: ComputeEngine): BoxedExpression;
|
|
40
|
-
/**
|
|
41
|
-
* Extract all propositional variables from a boolean expression.
|
|
42
|
-
* Returns a sorted array of unique variable names.
|
|
43
|
-
*/
|
|
44
|
-
export declare function extractVariables(expr: BoxedExpression): string[];
|
|
45
|
-
/**
|
|
46
|
-
* Evaluate a boolean expression with a given truth assignment.
|
|
47
|
-
* Returns True, False, or undefined if the expression cannot be evaluated.
|
|
48
|
-
*/
|
|
49
|
-
export declare function evaluateWithAssignment(expr: BoxedExpression, assignment: Record<string, boolean>, ce: ComputeEngine): BoxedExpression;
|
|
50
|
-
/**
|
|
51
|
-
* Generate all possible truth assignments for a list of variables.
|
|
52
|
-
* Each assignment is a Record mapping variable names to boolean values.
|
|
53
|
-
*/
|
|
54
|
-
export declare function generateAssignments(variables: string[]): Generator<Record<string, boolean>>;
|