@cortex-js/compute-engine 0.57.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/compile.esm.js +2376 -501
- package/dist/compile.min.esm.js +316 -68
- package/dist/compile.min.umd.cjs +316 -68
- package/dist/compile.umd.cjs +2376 -501
- package/dist/compute-engine.esm.js +15717 -12444
- package/dist/compute-engine.min.esm.js +331 -83
- package/dist/compute-engine.min.umd.cjs +330 -82
- package/dist/compute-engine.umd.cjs +15717 -12444
- package/dist/core.esm.js +15716 -12443
- package/dist/core.min.esm.js +329 -81
- package/dist/core.min.umd.cjs +329 -81
- package/dist/core.umd.cjs +15716 -12443
- package/dist/identities.esm.js +1921 -0
- package/dist/identities.min.esm.js +2 -0
- package/dist/identities.min.umd.cjs +4 -0
- package/dist/identities.umd.cjs +1946 -0
- package/dist/interval.esm.js +779 -339
- package/dist/interval.min.esm.js +8 -8
- package/dist/interval.min.umd.cjs +8 -8
- package/dist/interval.umd.cjs +779 -339
- package/dist/latex-syntax.esm.js +971 -608
- package/dist/latex-syntax.min.esm.js +7 -7
- package/dist/latex-syntax.min.umd.cjs +7 -7
- package/dist/latex-syntax.umd.cjs +971 -608
- package/dist/math-json.esm.js +8 -12
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.umd.cjs +2 -2
- package/dist/math-json.umd.cjs +8 -12
- package/dist/numerics.esm.js +1382 -226
- package/dist/numerics.min.esm.js +16 -5
- package/dist/numerics.min.umd.cjs +16 -5
- package/dist/numerics.umd.cjs +1382 -226
- package/dist/types/big-decimal/big-decimal.d.ts +1 -1
- package/dist/types/big-decimal/index.d.ts +1 -1
- package/dist/types/big-decimal/transcendentals.d.ts +1 -1
- package/dist/types/big-decimal/utils.d.ts +1 -1
- 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 -208
- package/dist/types/common/type/parser.d.ts +124 -2
- package/dist/types/common/type/primitive.d.ts +5 -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 +18 -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 +1 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compile.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +13 -6
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +3 -1
- package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +7 -1
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/constraint-subject.d.ts +140 -0
- package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +34 -12
- package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/predicates.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/rule-index.d.ts +112 -0
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +2 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/stochastic-equal.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
- package/dist/types/compute-engine/collection-utils.d.ts +1 -1
- package/dist/types/compute-engine/compilation/base-compiler.d.ts +8 -1
- package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
- package/dist/types/compute-engine/compilation/constant-folding.d.ts +16 -1
- package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/gpu-target.d.ts +58 -5
- package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +4 -4
- package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/types.d.ts +1 -1
- package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
- package/dist/types/compute-engine/engine-cache.d.ts +1 -1
- package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
- package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
- package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
- package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
- package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
- package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
- package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
- package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
- package/dist/types/compute-engine/engine-runtime-state.d.ts +4 -1
- package/dist/types/compute-engine/engine-scope.d.ts +1 -1
- package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
- package/dist/types/compute-engine/engine-simplification-rules.d.ts +10 -2
- package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
- package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
- package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
- package/dist/types/compute-engine/free-functions.d.ts +1 -1
- package/dist/types/compute-engine/function-utils.d.ts +1 -1
- package/dist/types/compute-engine/fungrim/loader.d.ts +13 -0
- package/dist/types/compute-engine/fungrim/types.d.ts +160 -0
- package/dist/types/compute-engine/global-types.d.ts +1 -1
- package/dist/types/compute-engine/index.d.ts +63 -2
- 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 +10 -2
- package/dist/types/compute-engine/interval/index.d.ts +2 -2
- 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/default-dictionary.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-colors.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-units.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +4 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +3 -2
- package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -11
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/colors.d.ts +1 -1
- package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
- package/dist/types/compute-engine/library/complex.d.ts +13 -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/fractals.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- 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/quantity-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/sets.d.ts +27 -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 +1 -1
- package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
- package/dist/types/compute-engine/library/units.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +7 -1
- package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
- package/dist/types/compute-engine/numerics/bernoulli.d.ts +39 -0
- package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
- package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
- package/dist/types/compute-engine/numerics/linear-algebra.d.ts +1 -1
- 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 +12 -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/random.d.ts +23 -0
- package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/numerics/special-functions.d.ts +78 -10
- package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
- package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
- package/dist/types/compute-engine/numerics/types.d.ts +1 -1
- package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
- package/dist/types/compute-engine/oeis.d.ts +1 -1
- package/dist/types/compute-engine/sequence.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensors.d.ts +3 -3
- package/dist/types/compute-engine/types-definitions.d.ts +1 -1
- package/dist/types/compute-engine/types-engine.d.ts +52 -3
- package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
- package/dist/types/compute-engine/types-expression.d.ts +85 -14
- package/dist/types/compute-engine/types-kernel-evaluation.d.ts +32 -1
- package/dist/types/compute-engine/types-kernel-serialization.d.ts +45 -3
- package/dist/types/compute-engine/types-serialization.d.ts +1 -1
- package/dist/types/compute-engine/types.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +1 -1
- package/dist/types/core.d.ts +1 -1
- package/dist/types/identities.d.ts +3 -0
- package/dist/types/interval.d.ts +1 -1
- package/dist/types/latex-syntax.d.ts +2 -2
- package/dist/types/math-json/symbols.d.ts +1 -1
- package/dist/types/math-json/types.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +1 -1
- package/dist/types/math-json.d.ts +2 -2
- package/dist/types/numerics.d.ts +1 -1
- package/package.json +9 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.59.0 */
|
|
2
2
|
import { BoxedType } from '../../common/type/boxed-type';
|
|
3
3
|
import type { OperatorDefinition, Expression, BoxedOperatorDefinition, CollectionHandlers, CompiledExpression, EvaluateOptions, IComputeEngine as ComputeEngine, Sign } from '../global-types';
|
|
4
4
|
export declare class _BoxedOperatorDefinition implements BoxedOperatorDefinition {
|
|
@@ -19,6 +19,12 @@ export declare class _BoxedOperatorDefinition implements BoxedOperatorDefinition
|
|
|
19
19
|
scoped: boolean;
|
|
20
20
|
signature: BoxedType;
|
|
21
21
|
inferredSignature: boolean;
|
|
22
|
+
/** True if this operator definition was created from a user-defined
|
|
23
|
+
* function literal (e.g. via `ce.assign('f', ce.parse('x \\mapsto x^2'))`).
|
|
24
|
+
* Used to enable auto-broadcasting when applied to indexed collections.
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
_isLambda: boolean;
|
|
22
28
|
type?: (ops: ReadonlyArray<Expression>, options: {
|
|
23
29
|
engine: ComputeEngine;
|
|
24
30
|
}) => BoxedType | Type | TypeString | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.59.0 */
|
|
2
2
|
import type { Type, TypeString } from '../../common/type/types';
|
|
3
3
|
import type { OneOf } from '../../common/one-of';
|
|
4
4
|
import { BoxedType } from '../../common/type/boxed-type';
|
|
@@ -164,8 +164,8 @@ export declare class BoxedSymbol extends _BoxedExpression implements SymbolInter
|
|
|
164
164
|
get isIndexedCollection(): boolean;
|
|
165
165
|
get isLazyCollection(): boolean;
|
|
166
166
|
contains(rhs: Expression): boolean | undefined;
|
|
167
|
-
get count(): number;
|
|
168
|
-
get isEmptyCollection(): boolean;
|
|
167
|
+
get count(): number | undefined;
|
|
168
|
+
get isEmptyCollection(): boolean | undefined;
|
|
169
169
|
get isFiniteCollection(): boolean | undefined;
|
|
170
170
|
each(): Generator<Expression>;
|
|
171
171
|
at(index: number): Expression | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.59.0 */
|
|
2
2
|
import type { IComputeEngine as ComputeEngine, TensorDataType, Metadata, BoxedBaseDefinition, BoxedOperatorDefinition, BoxedSubstitution, EvaluateOptions, Expression, SimplifyOptions, PatternMatchOptions, Tensor, TensorInterface } from '../global-types';
|
|
3
3
|
import { BoxedType } from '../../common/type/boxed-type';
|
|
4
4
|
import { NumericValue } from '../numeric-value/types';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.59.0 */
|
|
2
2
|
export declare function canonicalForm(expr: Expression, forms: CanonicalOptions, scope?: Scope): Expression;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/* 0.59.0 */
|
|
2
|
+
/**
|
|
3
|
+
* Constraint subjects (FUNGRIM-PLAN-3-ASSUMPTIONS.md §2).
|
|
4
|
+
*
|
|
5
|
+
* The assumptions system keys facts not just on bare symbols, but on a small
|
|
6
|
+
* algebra of "subjects": a symbol, or one of the four part-extractors
|
|
7
|
+
* (`Real`, `Imaginary`, `Abs`, `Argument`) applied to exactly a bare symbol.
|
|
8
|
+
*
|
|
9
|
+
* This module is a leaf: it only imports types from `global-types` and the
|
|
10
|
+
* runtime type guards. Do not add imports that could create cycles.
|
|
11
|
+
*/
|
|
12
|
+
/** The "part" of a symbol that a constraint subject refers to. */
|
|
13
|
+
export type SubjectPart = 'self' | 're' | 'im' | 'abs' | 'arg';
|
|
14
|
+
/**
|
|
15
|
+
* A constraint subject: either a symbol itself (`part: 'self'`) or a
|
|
16
|
+
* part-extractor (`Real`, `Imaginary`, `Abs`, `Argument`) applied to a
|
|
17
|
+
* bare symbol.
|
|
18
|
+
*/
|
|
19
|
+
export type Subject = {
|
|
20
|
+
symbol: string;
|
|
21
|
+
part: SubjectPart;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Recognize a canonical subject term:
|
|
25
|
+
* - a bare symbol → `{ symbol, part: 'self' }`
|
|
26
|
+
* - `Real(x)`, `Imaginary(x)`, `Abs(x)`, `Argument(x)` where `x` is a bare
|
|
27
|
+
* symbol → `{ symbol: x, part: 're'|'im'|'abs'|'arg' }`
|
|
28
|
+
*
|
|
29
|
+
* Nothing deeper is recognized: `Real(z + w)` is **not** a subject, nor is
|
|
30
|
+
* `Abs(Real(z))`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function subjectOf(expr: Expression): Subject | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* A stable string key for a subject, for indexing: `"self:x"`, `"re:s"`,
|
|
35
|
+
* `"im:tau"`, `"abs:q"`, `"arg:z"`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function subjectKey(subject: Subject): string;
|
|
38
|
+
/** Convert a `string | Subject` argument to a `Subject` ('self' part). */
|
|
39
|
+
export declare function toSubject(subjectOrSymbol: string | Subject): Subject;
|
|
40
|
+
/**
|
|
41
|
+
* True if `expr` is exactly the subject term for `subject` (a bare symbol
|
|
42
|
+
* for `part: 'self'`, or the corresponding part-extractor applied to the
|
|
43
|
+
* symbol otherwise).
|
|
44
|
+
*/
|
|
45
|
+
export declare function matchesSubject(expr: Expression, subject: Subject): boolean;
|
|
46
|
+
/** Numeric (real, finite) value of a number literal term, or undefined. */
|
|
47
|
+
export declare function finiteNumericValue(term: Expression | undefined): number | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Extract the bound contribution of a single normalized inequality
|
|
50
|
+
* assumption — `Less(lhs, 0)` or `LessEqual(lhs, 0)` — for `subject`.
|
|
51
|
+
*
|
|
52
|
+
* Recognized lhs shapes (mirroring the historical symbol-only logic, with
|
|
53
|
+
* the bare symbol generalized to a subject term):
|
|
54
|
+
*
|
|
55
|
+
* - `Negate(subject)` → lower bound 0 (i.e. `subject > 0` / `subject ≥ 0`)
|
|
56
|
+
* - `subject` → upper bound 0
|
|
57
|
+
* - `Add(..., Negate(subject), ..., k…)` with numeric terms summing to
|
|
58
|
+
* `k ≠ 0` → lower bound `k`
|
|
59
|
+
* - `Add(..., subject, ..., k…)` with numeric terms summing to `k ≠ 0` →
|
|
60
|
+
* upper bound `-k`
|
|
61
|
+
*
|
|
62
|
+
* Returns `undefined` if the assumption carries no bound for `subject`.
|
|
63
|
+
*
|
|
64
|
+
* NOTE: as in the historical implementation, non-numeric extra terms in an
|
|
65
|
+
* `Add` are ignored when summing the constant. Callers should treat the
|
|
66
|
+
* result as a best-effort bound (this matches the pre-existing behavior of
|
|
67
|
+
* `getInequalityBoundsFromAssumptions`).
|
|
68
|
+
*/
|
|
69
|
+
export declare function boundsFromNormalizedInequality(assumption: Expression, subject: Subject): IntervalBounds | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Merge `from` into `into`, keeping the tightest bounds.
|
|
72
|
+
*
|
|
73
|
+
* Semantics match the historical accumulation in
|
|
74
|
+
* `getInequalityBoundsFromAssumptions`: a candidate replaces the current
|
|
75
|
+
* bound only when it is strictly tighter (`isGreater`/`isLess` returning
|
|
76
|
+
* exactly `true`); ties keep the existing strictness.
|
|
77
|
+
*/
|
|
78
|
+
export declare function mergeTightestBounds(into: IntervalBounds, from: IntervalBounds): void;
|
|
79
|
+
/** Facts indexed for a single subject. */
|
|
80
|
+
export type SubjectFacts = {
|
|
81
|
+
bounds: IntervalBounds;
|
|
82
|
+
/** Values `v` for which `NotEqual(subject, v)` is assumed. */
|
|
83
|
+
notEqual: Expression[];
|
|
84
|
+
};
|
|
85
|
+
/** Membership facts for a single symbol. */
|
|
86
|
+
export type MembershipFacts = {
|
|
87
|
+
/** Set expressions `S` for which `Element(symbol, S)` is assumed. */
|
|
88
|
+
in: Expression[];
|
|
89
|
+
/** Set expressions `S` for which `NotElement(symbol, S)` is assumed. */
|
|
90
|
+
notIn: Expression[];
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* A derived, read-only index over the scoped assumptions `ExpressionMap`.
|
|
94
|
+
*
|
|
95
|
+
* The `ExpressionMap` remains the single source of truth; this index is
|
|
96
|
+
* rebuilt lazily whenever the assumptions change (see `getFactIndex`).
|
|
97
|
+
* Consumers must treat it as immutable.
|
|
98
|
+
*/
|
|
99
|
+
export type FactIndex = {
|
|
100
|
+
bySubject: Map<string, SubjectFacts>;
|
|
101
|
+
membership: Map<string, MembershipFacts>;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Lazily-built, cached index over the current context's assumptions.
|
|
105
|
+
*
|
|
106
|
+
* - Returns a shared empty index (cheaply, with no cache machinery) when
|
|
107
|
+
* there are no assumptions — hot paths with zero assumptions pay only an
|
|
108
|
+
* emptiness check.
|
|
109
|
+
* - Otherwise, the index is cached per engine and invalidated when
|
|
110
|
+
* `ce._generation` changes (bumped by `assume()`, `forget()`,
|
|
111
|
+
* declarations…), when the assumptions map object changes (scope
|
|
112
|
+
* push/pop), or when the number of stored assumptions changes (direct
|
|
113
|
+
* `.set()`/`.delete()` on the map).
|
|
114
|
+
*
|
|
115
|
+
* The returned index must be treated as read-only.
|
|
116
|
+
*/
|
|
117
|
+
export declare function getFactIndex(ce: ComputeEngine): FactIndex;
|
|
118
|
+
/**
|
|
119
|
+
* Fast emptiness check for the assumptions store. The P3 query hooks
|
|
120
|
+
* (relational operators, sgn fallbacks, membership lookups, symbol
|
|
121
|
+
* predicates) are gated on this so that zero-assumption engines pay only
|
|
122
|
+
* an (empty) iterator check before any subject or index work.
|
|
123
|
+
*/
|
|
124
|
+
export declare function hasAssumptions(ce: ComputeEngine): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Decide a comparison of a subject against the numeric constant `k` from
|
|
127
|
+
* the subject's assumed interval bounds (design §5.1a).
|
|
128
|
+
*
|
|
129
|
+
* Strict three-valued discipline (design §5.2): returns `true` only when
|
|
130
|
+
* the bounds entail the comparison, `false` only when they refute it, and
|
|
131
|
+
* `undefined` otherwise.
|
|
132
|
+
*/
|
|
133
|
+
export declare function decideComparisonFromBounds(bounds: IntervalBounds, k: number, query: 'less' | 'lessEqual' | 'greater' | 'greaterEqual'): boolean | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* Derive a `Sign` from assumed interval bounds (design §5.1b — the
|
|
136
|
+
* `Real`/`Imaginary`/`Abs`/`Argument` sgn fallbacks).
|
|
137
|
+
*
|
|
138
|
+
* Returns a sign only when the bounds entail it; `undefined` otherwise.
|
|
139
|
+
*/
|
|
140
|
+
export declare function signFromBounds(bounds: IntervalBounds): Sign | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.59.0 */
|
|
2
2
|
export declare function choose(n: number, k: number): number;
|
|
3
3
|
/** Attempt to transform the expression (h, ops) into a sum */
|
|
4
4
|
export declare function expandFunction(ce: ComputeEngine, h: string, ops: ReadonlyArray<Expression>): Expression | null;
|
|
@@ -1,21 +1,43 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.59.0 */
|
|
2
|
+
import { type Subject } from './constraint-subject';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Extract interval bounds for `symbol` from a condition expression.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* Unlike `getInequalityBoundsFromAssumptions` (which reads the engine's
|
|
7
|
+
* assumption DB), this function operates directly on an AST shape:
|
|
8
|
+
*
|
|
9
|
+
* - bare comparisons (`Less`, `LessEqual`, `Greater`, `GreaterEqual`),
|
|
10
|
+
* including chained forms like `Less(a, x, b)`
|
|
11
|
+
* - `And(c1, c2, ...)` of supported shapes
|
|
12
|
+
* - `When(e, cond)` — unwraps to `cond`
|
|
13
|
+
* - `Multiply(f, When(...), ...)` — the Desmos parse shape for
|
|
14
|
+
* `f(x)\{a < x < b\}`; bounds from each `When` factor are merged
|
|
15
|
+
*
|
|
16
|
+
* Returns `undefined` if `expr` doesn't carry interval information for
|
|
17
|
+
* `symbol`, or if the information is not a simple lower-upper pair.
|
|
18
|
+
*/
|
|
19
|
+
export declare function extractIntervalBounds(expr: Expression, symbol: string): IntervalBounds | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Get inequality bounds for a subject from the assumption database.
|
|
22
|
+
*
|
|
23
|
+
* For example, if `x > 4` is assumed, this returns `{ lower: 4, lowerStrict: true }`.
|
|
24
|
+
* If `x <= 10` is assumed, this returns `{ upper: 10, upperStrict: false }`.
|
|
25
|
+
*
|
|
26
|
+
* The subject may be a bare symbol (pass the symbol name, or a `Subject`
|
|
27
|
+
* with `part: 'self'`) or a part-extractor of a symbol, e.g.
|
|
28
|
+
* `{ symbol: 's', part: 're' }` for facts about `Real(s)`
|
|
29
|
+
* (see `constraint-subject.ts`).
|
|
7
30
|
*
|
|
8
31
|
* Note: Assumptions are normalized to forms like:
|
|
9
32
|
* - `x > 4` becomes `Less(Add(Negate(x), 4), 0)` i.e., `4 - x < 0`
|
|
10
33
|
* - `x > 0` becomes `Less(Negate(x), 0)` i.e., `-x < 0`
|
|
34
|
+
* - `Re(s) > 1` becomes `Less(Add(Negate(Real(s)), 1), 0)`
|
|
35
|
+
*
|
|
36
|
+
* The result is derived from the cached fact index (see `getFactIndex`),
|
|
37
|
+
* so repeated queries against unchanged assumptions cost a lookup.
|
|
11
38
|
*
|
|
12
39
|
* @param ce - The compute engine instance
|
|
13
|
-
* @param
|
|
14
|
-
* @returns
|
|
40
|
+
* @param subject - The symbol name or `Subject` to query
|
|
41
|
+
* @returns The `IntervalBounds` (same shape used by `extractIntervalBounds`).
|
|
15
42
|
*/
|
|
16
|
-
export declare function getInequalityBoundsFromAssumptions(ce: ComputeEngine,
|
|
17
|
-
lowerBound?: Expression;
|
|
18
|
-
lowerStrict?: boolean;
|
|
19
|
-
upperBound?: Expression;
|
|
20
|
-
upperStrict?: boolean;
|
|
21
|
-
};
|
|
43
|
+
export declare function getInequalityBoundsFromAssumptions(ce: ComputeEngine, subject: string | Subject): IntervalBounds;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.59.0 */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.59.0 */
|
|
2
2
|
export declare function isPrime(expr: Expression): boolean | undefined;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/* 0.59.0 */
|
|
2
|
+
* Operator-indexed rule dispatch (FUNGRIM-PLAN-2-RULES.md §2.1, Feature A).
|
|
3
|
+
*
|
|
4
|
+
* This is an INTERNAL side table: the public `BoxedRuleSet` type is
|
|
5
|
+
* unchanged. The index is keyed (via a `WeakMap`) on the identity of the
|
|
6
|
+
* boxed `rules` array, so engine-cached rule sets (which produce a fresh
|
|
7
|
+
* array on each cache invalidation) get one index build per cache
|
|
8
|
+
* generation, with no extra invalidation plumbing.
|
|
9
|
+
*
|
|
10
|
+
* ## Soundness
|
|
11
|
+
*
|
|
12
|
+
* The index partitions rules into:
|
|
13
|
+
* - `byHead`: rules whose match pattern has a literal, head-faithful
|
|
14
|
+
* operator — only tried when the subject expression's operator (or one of
|
|
15
|
+
* its cross-head compatible operators, see `HEAD_COMPAT`) selects that
|
|
16
|
+
* bucket;
|
|
17
|
+
* - `alwaysTry`: rules that may apply to expressions of any shape.
|
|
18
|
+
*
|
|
19
|
+
* The classification must exactly mirror the cross-head special cases in
|
|
20
|
+
* `match.ts`, otherwise the index could skip a rule that would have fired.
|
|
21
|
+
* Each special case is annotated below with the `match.ts` location it
|
|
22
|
+
* mirrors. Anything unclassifiable is conservatively `alwaysTry`.
|
|
23
|
+
*
|
|
24
|
+
* This module is a LEAF module: it imports only types from `global-types`
|
|
25
|
+
* and the runtime type guards. Do not add imports that could create
|
|
26
|
+
* circular dependencies.
|
|
27
|
+
*/
|
|
28
|
+
import type { BoxedRule, Expression } from '../global-types';
|
|
29
|
+
/** A rule paired with its position in the original rule array. */
|
|
30
|
+
export type OrdinalRule = {
|
|
31
|
+
rule: BoxedRule;
|
|
32
|
+
ordinal: number;
|
|
33
|
+
};
|
|
34
|
+
export interface RuleIndex {
|
|
35
|
+
/** Rules whose match pattern has a literal, head-faithful operator,
|
|
36
|
+
* bucketed by that operator. Each bucket is in ascending ordinal order. */
|
|
37
|
+
byHead: ReadonlyMap<string, ReadonlyArray<OrdinalRule>>;
|
|
38
|
+
/** Functional rules, non-function-expression patterns, wildcard-headed
|
|
39
|
+
* patterns, and effective-variations rules with variant-capable
|
|
40
|
+
* arithmetic heads. In ascending ordinal order. */
|
|
41
|
+
alwaysTry: ReadonlyArray<OrdinalRule>;
|
|
42
|
+
/** `rules.length` at build time; staleness guard against in-place
|
|
43
|
+
* mutation of the rule array. */
|
|
44
|
+
count: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Pattern heads that `matchVariations()` (match.ts:333-440) can match across
|
|
48
|
+
* heads — e.g. expression `x` matches pattern `Add(0, x)`. A rule with one of
|
|
49
|
+
* these pattern heads and effective `useVariations` may match an expression
|
|
50
|
+
* of *any* operator, so it must be `alwaysTry` in that case.
|
|
51
|
+
*
|
|
52
|
+
* - 'Negate' — match.ts:353 (0 → -x)
|
|
53
|
+
* - 'Add' — match.ts:359 (x → 0+x; a-b → a+(-b))
|
|
54
|
+
* - 'Subtract' — match.ts:372 (a → a-0; -a → 0-a)
|
|
55
|
+
* - 'Multiply' — match.ts:385 (x → 1·x; -x → -1·x; x/a → (1/a)·x)
|
|
56
|
+
* - 'Divide' — match.ts:403 (x → x/1)
|
|
57
|
+
* - 'Square' — match.ts:409 (Power(x,2) → Square(x))
|
|
58
|
+
* - 'Exp' — match.ts:415 (Power(E,x) → Exp(x))
|
|
59
|
+
* - 'Power' — match.ts:421 (Square(x), Exp(x), x → Power(x,1))
|
|
60
|
+
*
|
|
61
|
+
* All other pattern heads return `null` from `matchVariations()`, i.e.
|
|
62
|
+
* non-arithmetic heads are safely indexable even under variations.
|
|
63
|
+
*/
|
|
64
|
+
export declare const VARIANT_CAPABLE: ReadonlySet<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Cross-head special cases in `matchOnce()` that are ALWAYS active
|
|
67
|
+
* (independent of `useVariations`): maps a subject expression's operator to
|
|
68
|
+
* the additional pattern-head buckets that must be consulted.
|
|
69
|
+
*
|
|
70
|
+
* - expr `Multiply` → pattern `Divide` — match.ts:158-197
|
|
71
|
+
* (`Multiply(Rational(1,n), x)` matches `Divide` patterns)
|
|
72
|
+
* - expr `Divide` → pattern `Power` — match.ts:199-218
|
|
73
|
+
* (`Divide(1, x)` matches `Power` patterns, i.e. x^-1)
|
|
74
|
+
* - expr `Root` → pattern `Power` — match.ts:220-236
|
|
75
|
+
* (`Root(x, n)` matches `Power` patterns, i.e. x^(1/n))
|
|
76
|
+
*
|
|
77
|
+
* Plus, handled directly in `candidateRules()`: a number literal must
|
|
78
|
+
* consult the `Divide` bucket — match.ts:142-156 (rational literals like
|
|
79
|
+
* `3/2` match `Divide` patterns).
|
|
80
|
+
*
|
|
81
|
+
* Also mirrored in classification (not here): a pattern head starting with
|
|
82
|
+
* `_` (wildcard operator) matches any function — match.ts:238-244 — so such
|
|
83
|
+
* rules are `alwaysTry`.
|
|
84
|
+
*/
|
|
85
|
+
export declare const HEAD_COMPAT: ReadonlyMap<string, ReadonlyArray<string>>;
|
|
86
|
+
/** Below this rule count, `getRuleIndex()` returns `undefined` and callers
|
|
87
|
+
* fall back to the plain linear scan (index overhead not worth it). */
|
|
88
|
+
export declare const DEFAULT_MIN_INDEX_SIZE = 8;
|
|
89
|
+
/**
|
|
90
|
+
* Get (build + memoize) the index for a boxed rule array.
|
|
91
|
+
*
|
|
92
|
+
* `variations` selects the classification used when the *call-level*
|
|
93
|
+
* `options.useVariations` is `true` (rule-level `useVariations` is folded in
|
|
94
|
+
* at build time for both indexes). Below `minSize` (default 8) returns
|
|
95
|
+
* `undefined` and callers fall back to the linear scan.
|
|
96
|
+
*/
|
|
97
|
+
export declare function getRuleIndex(rules: ReadonlyArray<BoxedRule>, variations: boolean, minSize?: number): RuleIndex | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Candidate rules for `expr`, in original declaration order, with
|
|
100
|
+
* ordinal > `fromOrdinal`.
|
|
101
|
+
*
|
|
102
|
+
* Implemented as an ordinal-merge of:
|
|
103
|
+
* - `alwaysTry`,
|
|
104
|
+
* - `byHead[expr.operator]`,
|
|
105
|
+
* - the `HEAD_COMPAT[expr.operator]` buckets, and
|
|
106
|
+
* - the `Divide` bucket when `expr` is a number literal (match.ts:142-156).
|
|
107
|
+
*
|
|
108
|
+
* A rule hinted with several `operators` may appear in more than one
|
|
109
|
+
* consulted bucket; duplicates are removed during the merge (distinct rules
|
|
110
|
+
* never share an ordinal).
|
|
111
|
+
*/
|
|
112
|
+
export declare function candidateRules(index: RuleIndex, expr: Expression, fromOrdinal: number): Generator<OrdinalRule>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.59.0 */
|
|
2
2
|
export declare const ConditionParent: {
|
|
3
3
|
boolean: string;
|
|
4
4
|
string: string;
|
|
@@ -102,6 +102,7 @@ export declare function checkConditions(x: Expression, conditions: string[]): bo
|
|
|
102
102
|
*/
|
|
103
103
|
export declare function boxRules(ce: ComputeEngine, rs: Rule | ReadonlyArray<Rule | BoxedRule> | BoxedRuleSet | undefined | null, options?: {
|
|
104
104
|
canonical?: boolean;
|
|
105
|
+
purpose?: RulePurpose;
|
|
105
106
|
}): BoxedRuleSet;
|
|
106
107
|
/**
|
|
107
108
|
* Apply a rule to an expression, assuming an incoming substitution
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.59.0 */
|
|
2
2
|
/** Assuming x in an expression in radians, convert to current angular unit. */
|
|
3
3
|
export declare function radiansToAngle(x: Expression | undefined): Expression | undefined;
|
|
4
4
|
export declare function evalTrig(name: string, op: Expression | undefined): Expression | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.59.0 */
|
|
2
2
|
import type { CompileTarget, TargetSource } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Base compiler class containing language-agnostic compilation logic
|
|
@@ -48,6 +48,13 @@ export declare class BaseCompiler {
|
|
|
48
48
|
* GLSL (no dynamic arrays, no push). A compile-time error is thrown.
|
|
49
49
|
* TODO(E3-GLSL): support GLSL multi-Element via a pre-declared fixed-size
|
|
50
50
|
* array or by unrolling when bounds are known at compile time.
|
|
51
|
+
*
|
|
52
|
+
* Known issue (imperative form): the IIFE generated by form (1) has no
|
|
53
|
+
* `return` statement, so `Loop(body, Element(i, Range(lo, hi)))` compiled
|
|
54
|
+
* to JS evaluates to `undefined` at runtime, while CE evaluation returns a
|
|
55
|
+
* `List` of body values. See `test/compute-engine/a1-c1-compile-parity.test.ts`
|
|
56
|
+
* ("Loop compiles in JS") for the verify-only test that locks in the
|
|
57
|
+
* current behavior.
|
|
51
58
|
*/
|
|
52
59
|
private static compileForLoop;
|
|
53
60
|
/**
|