@cortex-js/compute-engine 0.55.0 → 0.55.2
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/dist/compile.esm.js +1564 -1412
- package/dist/compile.min.esm.js +29 -29
- package/dist/compile.min.umd.cjs +29 -29
- package/dist/compile.umd.cjs +1564 -1412
- package/dist/compute-engine.esm.js +741 -486
- package/dist/compute-engine.min.esm.js +65 -65
- package/dist/compute-engine.min.umd.cjs +65 -65
- package/dist/compute-engine.umd.cjs +741 -486
- package/dist/core.esm.js +740 -485
- package/dist/core.min.esm.js +63 -63
- package/dist/core.min.umd.cjs +63 -63
- package/dist/core.umd.cjs +740 -485
- package/dist/interval.esm.js +1564 -1412
- package/dist/interval.min.esm.js +6 -6
- package/dist/interval.min.umd.cjs +6 -6
- package/dist/interval.umd.cjs +1564 -1412
- package/dist/latex-syntax.esm.js +673 -492
- package/dist/latex-syntax.min.esm.js +6 -6
- package/dist/latex-syntax.min.umd.cjs +6 -6
- package/dist/latex-syntax.umd.cjs +673 -492
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.umd.cjs +2 -2
- package/dist/math-json.umd.cjs +2 -2
- package/dist/numerics.esm.js +2 -2
- package/dist/numerics.min.esm.js +2 -2
- package/dist/numerics.min.umd.cjs +2 -2
- package/dist/numerics.umd.cjs +2 -2
- 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 -1
- package/dist/types/common/type/parser.d.ts +1 -1
- package/dist/types/common/type/primitive.d.ts +1 -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 +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 +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -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 +1 -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 +1 -1
- 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/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 +1 -1
- 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/rules.d.ts +1 -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 +1 -1
- package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
- package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/gpu-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
- 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 +1 -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 +1 -1
- 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/global-types.d.ts +1 -1
- package/dist/types/compute-engine/index.d.ts +1 -1
- 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/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-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 +3 -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 +1 -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 +11 -1
- 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 -1
- 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 +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/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 +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 +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 +1 -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/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 +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 +1 -1
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
- 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 +1 -1
- package/dist/types/compute-engine/types-definitions.d.ts +1 -1
- package/dist/types/compute-engine/types-engine.d.ts +1 -1
- package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
- package/dist/types/compute-engine/types-expression.d.ts +1 -1
- package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
- package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
- 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/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 +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Compute Engine 0.55.
|
|
1
|
+
/** Compute Engine 0.55.2 */
|
|
2
2
|
|
|
3
3
|
// node_modules/complex-esm/dist/src/complex.js
|
|
4
4
|
var cosh = Math.cosh || function(x) {
|
|
@@ -9526,6 +9526,452 @@ function expressionToDictionaryValue(expr2) {
|
|
|
9526
9526
|
return expr2;
|
|
9527
9527
|
}
|
|
9528
9528
|
|
|
9529
|
+
// src/compute-engine/latex-syntax/dictionary/definitions-logic.ts
|
|
9530
|
+
var DEFINITIONS_LOGIC = [
|
|
9531
|
+
// Constants
|
|
9532
|
+
{
|
|
9533
|
+
name: "True",
|
|
9534
|
+
kind: "symbol",
|
|
9535
|
+
latexTrigger: ["\\top"]
|
|
9536
|
+
// ⊤ U+22A4
|
|
9537
|
+
},
|
|
9538
|
+
{
|
|
9539
|
+
kind: "symbol",
|
|
9540
|
+
latexTrigger: "\\mathrm{True}",
|
|
9541
|
+
parse: "True"
|
|
9542
|
+
},
|
|
9543
|
+
{
|
|
9544
|
+
kind: "symbol",
|
|
9545
|
+
latexTrigger: "\\operatorname{True}",
|
|
9546
|
+
parse: "True"
|
|
9547
|
+
},
|
|
9548
|
+
{
|
|
9549
|
+
kind: "symbol",
|
|
9550
|
+
latexTrigger: "\\mathsf{T}",
|
|
9551
|
+
parse: "True"
|
|
9552
|
+
},
|
|
9553
|
+
{
|
|
9554
|
+
name: "False",
|
|
9555
|
+
kind: "symbol",
|
|
9556
|
+
latexTrigger: ["\\bot"]
|
|
9557
|
+
// ⊥ U+22A5
|
|
9558
|
+
},
|
|
9559
|
+
{
|
|
9560
|
+
kind: "symbol",
|
|
9561
|
+
latexTrigger: "\\operatorname{False}",
|
|
9562
|
+
parse: "False"
|
|
9563
|
+
},
|
|
9564
|
+
{
|
|
9565
|
+
kind: "symbol",
|
|
9566
|
+
latexTrigger: "\\mathsf{F}",
|
|
9567
|
+
parse: "False"
|
|
9568
|
+
},
|
|
9569
|
+
// Operators
|
|
9570
|
+
// Logic operators have lower precedence than comparisons (245)
|
|
9571
|
+
// so that `x = 1 \lor x = 2` parses as `(x = 1) \lor (x = 2)`
|
|
9572
|
+
// See https://github.com/cortex-js/compute-engine/issues/243
|
|
9573
|
+
{
|
|
9574
|
+
name: "And",
|
|
9575
|
+
kind: "infix",
|
|
9576
|
+
latexTrigger: ["\\land"],
|
|
9577
|
+
precedence: 235
|
|
9578
|
+
// serialize: '\\land',
|
|
9579
|
+
},
|
|
9580
|
+
{ kind: "infix", latexTrigger: ["\\wedge"], parse: "And", precedence: 235 },
|
|
9581
|
+
{ kind: "infix", latexTrigger: "\\&", parse: "And", precedence: 235 },
|
|
9582
|
+
{
|
|
9583
|
+
kind: "infix",
|
|
9584
|
+
latexTrigger: "\\operatorname{and}",
|
|
9585
|
+
parse: "And",
|
|
9586
|
+
precedence: 235
|
|
9587
|
+
},
|
|
9588
|
+
{
|
|
9589
|
+
name: "Or",
|
|
9590
|
+
kind: "infix",
|
|
9591
|
+
latexTrigger: ["\\lor"],
|
|
9592
|
+
precedence: 230
|
|
9593
|
+
},
|
|
9594
|
+
{ kind: "infix", latexTrigger: ["\\vee"], parse: "Or", precedence: 230 },
|
|
9595
|
+
{ kind: "infix", latexTrigger: "\\parallel", parse: "Or", precedence: 230 },
|
|
9596
|
+
{
|
|
9597
|
+
kind: "infix",
|
|
9598
|
+
latexTrigger: "\\operatorname{or}",
|
|
9599
|
+
parse: "Or",
|
|
9600
|
+
precedence: 230
|
|
9601
|
+
},
|
|
9602
|
+
{
|
|
9603
|
+
name: "Xor",
|
|
9604
|
+
kind: "infix",
|
|
9605
|
+
latexTrigger: ["\\veebar"],
|
|
9606
|
+
precedence: 232
|
|
9607
|
+
},
|
|
9608
|
+
// Possible alt: \oplus ⊕ U+2295
|
|
9609
|
+
{
|
|
9610
|
+
name: "Not",
|
|
9611
|
+
kind: "prefix",
|
|
9612
|
+
latexTrigger: ["\\lnot"],
|
|
9613
|
+
precedence: 880
|
|
9614
|
+
},
|
|
9615
|
+
{
|
|
9616
|
+
kind: "prefix",
|
|
9617
|
+
latexTrigger: ["\\neg"],
|
|
9618
|
+
parse: "Not",
|
|
9619
|
+
precedence: 880
|
|
9620
|
+
},
|
|
9621
|
+
{
|
|
9622
|
+
name: "Nand",
|
|
9623
|
+
kind: "infix",
|
|
9624
|
+
latexTrigger: ["\\barwedge"],
|
|
9625
|
+
precedence: 232
|
|
9626
|
+
// serialize: '\\mid',
|
|
9627
|
+
},
|
|
9628
|
+
{
|
|
9629
|
+
name: "Nor",
|
|
9630
|
+
kind: "infix",
|
|
9631
|
+
latexTrigger: ["\u22BD"],
|
|
9632
|
+
// bar vee
|
|
9633
|
+
precedence: 232
|
|
9634
|
+
// serialize: '\\downarrow',
|
|
9635
|
+
},
|
|
9636
|
+
// Functions
|
|
9637
|
+
{
|
|
9638
|
+
kind: "function",
|
|
9639
|
+
symbolTrigger: "and",
|
|
9640
|
+
parse: "And"
|
|
9641
|
+
},
|
|
9642
|
+
{
|
|
9643
|
+
kind: "function",
|
|
9644
|
+
symbolTrigger: "or",
|
|
9645
|
+
parse: "Or"
|
|
9646
|
+
},
|
|
9647
|
+
{
|
|
9648
|
+
kind: "function",
|
|
9649
|
+
symbolTrigger: "not",
|
|
9650
|
+
parse: "Not"
|
|
9651
|
+
},
|
|
9652
|
+
// Relations
|
|
9653
|
+
{
|
|
9654
|
+
name: "Implies",
|
|
9655
|
+
kind: "infix",
|
|
9656
|
+
precedence: 220,
|
|
9657
|
+
associativity: "right",
|
|
9658
|
+
latexTrigger: ["\\implies"],
|
|
9659
|
+
serialize: "\\implies"
|
|
9660
|
+
},
|
|
9661
|
+
{
|
|
9662
|
+
latexTrigger: ["\\Rightarrow"],
|
|
9663
|
+
kind: "infix",
|
|
9664
|
+
precedence: 220,
|
|
9665
|
+
associativity: "right",
|
|
9666
|
+
parse: "Implies"
|
|
9667
|
+
},
|
|
9668
|
+
{
|
|
9669
|
+
latexTrigger: ["\\rightarrow"],
|
|
9670
|
+
kind: "infix",
|
|
9671
|
+
precedence: 220,
|
|
9672
|
+
associativity: "right",
|
|
9673
|
+
parse: "Implies"
|
|
9674
|
+
},
|
|
9675
|
+
{
|
|
9676
|
+
latexTrigger: ["\\Longrightarrow"],
|
|
9677
|
+
kind: "infix",
|
|
9678
|
+
precedence: 220,
|
|
9679
|
+
associativity: "right",
|
|
9680
|
+
parse: "Implies"
|
|
9681
|
+
},
|
|
9682
|
+
{
|
|
9683
|
+
latexTrigger: ["\\longrightarrow"],
|
|
9684
|
+
kind: "infix",
|
|
9685
|
+
precedence: 220,
|
|
9686
|
+
associativity: "right",
|
|
9687
|
+
parse: "Implies"
|
|
9688
|
+
},
|
|
9689
|
+
{
|
|
9690
|
+
// Non-strict mode: => for implies
|
|
9691
|
+
latexTrigger: ["=", ">"],
|
|
9692
|
+
kind: "infix",
|
|
9693
|
+
precedence: 220,
|
|
9694
|
+
associativity: "right",
|
|
9695
|
+
parse: (parser, lhs, until) => {
|
|
9696
|
+
if (parser.options.strict !== false) return null;
|
|
9697
|
+
const rhs = parser.parseExpression({ ...until, minPrec: 220 });
|
|
9698
|
+
if (rhs === null) return null;
|
|
9699
|
+
return ["Implies", lhs, rhs];
|
|
9700
|
+
}
|
|
9701
|
+
},
|
|
9702
|
+
{
|
|
9703
|
+
name: "Equivalent",
|
|
9704
|
+
// MathML: identical to, Mathematica: Congruent
|
|
9705
|
+
latexTrigger: ["\\iff"],
|
|
9706
|
+
kind: "infix",
|
|
9707
|
+
associativity: "right",
|
|
9708
|
+
precedence: 219
|
|
9709
|
+
},
|
|
9710
|
+
{
|
|
9711
|
+
latexTrigger: ["\\Leftrightarrow"],
|
|
9712
|
+
kind: "infix",
|
|
9713
|
+
associativity: "right",
|
|
9714
|
+
precedence: 219,
|
|
9715
|
+
parse: "Equivalent"
|
|
9716
|
+
},
|
|
9717
|
+
{
|
|
9718
|
+
latexTrigger: ["\\leftrightarrow"],
|
|
9719
|
+
kind: "infix",
|
|
9720
|
+
associativity: "right",
|
|
9721
|
+
precedence: 219,
|
|
9722
|
+
parse: "Equivalent"
|
|
9723
|
+
},
|
|
9724
|
+
{
|
|
9725
|
+
latexTrigger: ["\\Longleftrightarrow"],
|
|
9726
|
+
kind: "infix",
|
|
9727
|
+
associativity: "right",
|
|
9728
|
+
precedence: 219,
|
|
9729
|
+
parse: "Equivalent"
|
|
9730
|
+
},
|
|
9731
|
+
{
|
|
9732
|
+
latexTrigger: ["\\longleftrightarrow"],
|
|
9733
|
+
kind: "infix",
|
|
9734
|
+
associativity: "right",
|
|
9735
|
+
precedence: 219,
|
|
9736
|
+
parse: "Equivalent"
|
|
9737
|
+
},
|
|
9738
|
+
{
|
|
9739
|
+
// Non-strict mode: <=> for equivalence
|
|
9740
|
+
latexTrigger: ["<", "=", ">"],
|
|
9741
|
+
kind: "infix",
|
|
9742
|
+
precedence: 219,
|
|
9743
|
+
associativity: "right",
|
|
9744
|
+
parse: (parser, lhs, until) => {
|
|
9745
|
+
if (parser.options.strict !== false) return null;
|
|
9746
|
+
const rhs = parser.parseExpression({ ...until, minPrec: 219 });
|
|
9747
|
+
if (rhs === null) return null;
|
|
9748
|
+
return ["Equivalent", lhs, rhs];
|
|
9749
|
+
}
|
|
9750
|
+
},
|
|
9751
|
+
{
|
|
9752
|
+
latexTrigger: ["\\equiv"],
|
|
9753
|
+
kind: "infix",
|
|
9754
|
+
associativity: "right",
|
|
9755
|
+
precedence: 219,
|
|
9756
|
+
parse: (parser, lhs, terminator) => {
|
|
9757
|
+
const rhs = parser.parseExpression({ ...terminator, minPrec: 219 });
|
|
9758
|
+
const index = parser.index;
|
|
9759
|
+
const modulus = parser.parseExpression({ ...terminator, minPrec: 219 });
|
|
9760
|
+
if (modulus !== null && operator(modulus) === "Mod")
|
|
9761
|
+
return ["Congruent", lhs, rhs, missingIfEmpty(operand(modulus, 1))];
|
|
9762
|
+
parser.index = index;
|
|
9763
|
+
return ["Equivalent", lhs, missingIfEmpty(rhs)];
|
|
9764
|
+
}
|
|
9765
|
+
},
|
|
9766
|
+
{
|
|
9767
|
+
name: "Proves",
|
|
9768
|
+
kind: "infix",
|
|
9769
|
+
latexTrigger: ["\\vdash"],
|
|
9770
|
+
precedence: 220,
|
|
9771
|
+
associativity: "right",
|
|
9772
|
+
serialize: "\\vdash"
|
|
9773
|
+
},
|
|
9774
|
+
{
|
|
9775
|
+
name: "Entails",
|
|
9776
|
+
kind: "infix",
|
|
9777
|
+
latexTrigger: ["\\vDash"],
|
|
9778
|
+
precedence: 220,
|
|
9779
|
+
associativity: "right",
|
|
9780
|
+
serialize: "\\vDash"
|
|
9781
|
+
},
|
|
9782
|
+
{
|
|
9783
|
+
name: "Satisfies",
|
|
9784
|
+
kind: "infix",
|
|
9785
|
+
latexTrigger: ["\\models"],
|
|
9786
|
+
precedence: 220,
|
|
9787
|
+
associativity: "right",
|
|
9788
|
+
serialize: "\\models"
|
|
9789
|
+
},
|
|
9790
|
+
// Quantifiers: for all, exists
|
|
9791
|
+
{
|
|
9792
|
+
name: "ForAll",
|
|
9793
|
+
kind: "prefix",
|
|
9794
|
+
latexTrigger: ["\\forall"],
|
|
9795
|
+
precedence: 200,
|
|
9796
|
+
// Has to be lower than COMPARISON_PRECEDENCE
|
|
9797
|
+
serialize: serializeQuantifier("\\forall"),
|
|
9798
|
+
parse: parseQuantifier("ForAll")
|
|
9799
|
+
},
|
|
9800
|
+
{
|
|
9801
|
+
name: "Exists",
|
|
9802
|
+
kind: "prefix",
|
|
9803
|
+
latexTrigger: ["\\exists"],
|
|
9804
|
+
precedence: 200,
|
|
9805
|
+
// Has to be lower than COMPARISON_PRECEDENCE,
|
|
9806
|
+
serialize: serializeQuantifier("\\exists"),
|
|
9807
|
+
parse: parseQuantifier("Exists")
|
|
9808
|
+
},
|
|
9809
|
+
{
|
|
9810
|
+
name: "ExistsUnique",
|
|
9811
|
+
kind: "prefix",
|
|
9812
|
+
latexTrigger: ["\\exists", "!"],
|
|
9813
|
+
precedence: 200,
|
|
9814
|
+
// Has to be lower than COMPARISON_PRECEDENCE,
|
|
9815
|
+
serialize: serializeQuantifier("\\exists!"),
|
|
9816
|
+
parse: parseQuantifier("ExistsUnique")
|
|
9817
|
+
},
|
|
9818
|
+
{
|
|
9819
|
+
name: "NotForAll",
|
|
9820
|
+
kind: "prefix",
|
|
9821
|
+
latexTrigger: ["\\lnot", "\\forall"],
|
|
9822
|
+
precedence: 200,
|
|
9823
|
+
// Has to be lower than COMPARISON_PRECEDENCE
|
|
9824
|
+
serialize: serializeQuantifier("\\lnot\\forall"),
|
|
9825
|
+
parse: parseQuantifier("NotForAll")
|
|
9826
|
+
},
|
|
9827
|
+
{
|
|
9828
|
+
name: "NotExists",
|
|
9829
|
+
kind: "prefix",
|
|
9830
|
+
latexTrigger: ["\\lnot", "\\exists"],
|
|
9831
|
+
precedence: 200,
|
|
9832
|
+
// Has to be lower than COMPARISON_PRECEDENCE,
|
|
9833
|
+
serialize: serializeQuantifier("\\lnot\\exists"),
|
|
9834
|
+
parse: parseQuantifier("NotExists")
|
|
9835
|
+
},
|
|
9836
|
+
{
|
|
9837
|
+
name: "KroneckerDelta",
|
|
9838
|
+
kind: "prefix",
|
|
9839
|
+
latexTrigger: ["\\delta", "_"],
|
|
9840
|
+
precedence: 200,
|
|
9841
|
+
serialize: (serializer, expr2) => {
|
|
9842
|
+
const args = operands(expr2);
|
|
9843
|
+
if (args.length === 0) return "\\delta";
|
|
9844
|
+
if (args.every((x) => symbol(x)))
|
|
9845
|
+
return `\\delta_{${args.map((arg) => serializer.serialize(arg)).join("")}}`;
|
|
9846
|
+
return `\\delta_{${args.map((arg) => serializer.serialize(arg)).join(", ")}}`;
|
|
9847
|
+
},
|
|
9848
|
+
parse: (parser) => {
|
|
9849
|
+
const group = parser.parseGroup();
|
|
9850
|
+
if (group === null) {
|
|
9851
|
+
const token = parser.parseToken();
|
|
9852
|
+
if (!token) return null;
|
|
9853
|
+
return ["KroneckerDelta", token];
|
|
9854
|
+
}
|
|
9855
|
+
const seq = getSequence(group);
|
|
9856
|
+
if (seq && seq.length <= 2) return ["KroneckerDelta", ...seq];
|
|
9857
|
+
if (operator(group) === "InvisibleOperator")
|
|
9858
|
+
return ["KroneckerDelta", ...operands(group)];
|
|
9859
|
+
if (group !== null) return ["KroneckerDelta", group];
|
|
9860
|
+
return null;
|
|
9861
|
+
}
|
|
9862
|
+
},
|
|
9863
|
+
// Iverson brackets. Also called the "indicator function"
|
|
9864
|
+
// Must have a single argument, a relational expression, i.e.
|
|
9865
|
+
// `[ a = b ]` or `[ x \leq 0 ]`
|
|
9866
|
+
// Otherwise, it gets rejected, it could be something else, like a list or
|
|
9867
|
+
// tuple.
|
|
9868
|
+
{
|
|
9869
|
+
name: "Boole",
|
|
9870
|
+
kind: "matchfix",
|
|
9871
|
+
openTrigger: "[",
|
|
9872
|
+
closeTrigger: "]",
|
|
9873
|
+
// serialize: (serializer: Serializer, expr: MathJsonExpression) => {
|
|
9874
|
+
// const args = ops(expr);
|
|
9875
|
+
// return `[${serializer.serialize(arg)}]`;
|
|
9876
|
+
// },
|
|
9877
|
+
parse: (_parser, body) => {
|
|
9878
|
+
const h = operator(body);
|
|
9879
|
+
if (!h) return null;
|
|
9880
|
+
if (!DEFINITIONS_INEQUALITIES.some((x) => x.name === h)) return null;
|
|
9881
|
+
return ["Boole", body];
|
|
9882
|
+
}
|
|
9883
|
+
},
|
|
9884
|
+
{
|
|
9885
|
+
kind: "matchfix",
|
|
9886
|
+
openTrigger: "\\llbracket",
|
|
9887
|
+
closeTrigger: "\\rrbracket",
|
|
9888
|
+
parse: (_parser, body) => {
|
|
9889
|
+
const h = operator(body);
|
|
9890
|
+
if (!h) return null;
|
|
9891
|
+
if (!DEFINITIONS_INEQUALITIES.some((x) => x.name === h)) return null;
|
|
9892
|
+
return ["Boole", body];
|
|
9893
|
+
}
|
|
9894
|
+
},
|
|
9895
|
+
// Predicate application in First-Order Logic.
|
|
9896
|
+
// ["Predicate", "P", "x", "y"] serializes to "P(x, y)"
|
|
9897
|
+
{
|
|
9898
|
+
name: "Predicate",
|
|
9899
|
+
serialize: (serializer, expr2) => {
|
|
9900
|
+
const args = operands(expr2);
|
|
9901
|
+
if (args.length === 0) return "";
|
|
9902
|
+
const pred = args[0];
|
|
9903
|
+
const predStr = typeof pred === "string" ? pred : serializer.serialize(pred);
|
|
9904
|
+
if (args.length === 1) return predStr;
|
|
9905
|
+
const argStrs = args.slice(1).map((arg) => serializer.serialize(arg));
|
|
9906
|
+
return `${predStr}(${argStrs.join(", ")})`;
|
|
9907
|
+
}
|
|
9908
|
+
}
|
|
9909
|
+
];
|
|
9910
|
+
function serializeQuantifier(quantifierSymbol) {
|
|
9911
|
+
return (serializer, expr2) => {
|
|
9912
|
+
const args = operands(expr2);
|
|
9913
|
+
if (args.length === 0) return quantifierSymbol;
|
|
9914
|
+
if (args.length === 1)
|
|
9915
|
+
return `${quantifierSymbol} ${serializer.serialize(args[0])}`;
|
|
9916
|
+
const boundVar = serializer.serialize(args[0]);
|
|
9917
|
+
const body = serializer.serialize(args[1]);
|
|
9918
|
+
return `${quantifierSymbol} ${boundVar}, ${body}`;
|
|
9919
|
+
};
|
|
9920
|
+
}
|
|
9921
|
+
function tightBindingCondition(p, terminator) {
|
|
9922
|
+
return p.peek === "\\to" || p.peek === "\\rightarrow" || p.peek === "\\implies" || p.peek === "\\Rightarrow" || p.peek === "\\iff" || p.peek === "\\Leftrightarrow" || p.peek === "\\land" || p.peek === "\\wedge" || p.peek === "\\lor" || p.peek === "\\vee" || (terminator.condition?.(p) ?? false);
|
|
9923
|
+
}
|
|
9924
|
+
function parseQuantifier(kind) {
|
|
9925
|
+
return (parser, terminator) => {
|
|
9926
|
+
const index = parser.index;
|
|
9927
|
+
const useTightBinding = parser.options.quantifierScope !== "loose";
|
|
9928
|
+
const symbol2 = parser.parseSymbol(terminator);
|
|
9929
|
+
if (symbol2) {
|
|
9930
|
+
parser.skipSpace();
|
|
9931
|
+
if (parser.match(",") || parser.match("\\mid") || parser.match(".") || parser.match(":") || parser.match("\\colon")) {
|
|
9932
|
+
const bodyTerminator = useTightBinding ? {
|
|
9933
|
+
...terminator,
|
|
9934
|
+
condition: (p) => tightBindingCondition(p, terminator)
|
|
9935
|
+
} : terminator;
|
|
9936
|
+
parser.enterQuantifierScope();
|
|
9937
|
+
const body2 = parser.parseExpression(bodyTerminator);
|
|
9938
|
+
parser.exitQuantifierScope();
|
|
9939
|
+
return [kind, symbol2, missingIfEmpty(body2)];
|
|
9940
|
+
}
|
|
9941
|
+
parser.enterQuantifierScope();
|
|
9942
|
+
const body = parser.parseEnclosure();
|
|
9943
|
+
parser.exitQuantifierScope();
|
|
9944
|
+
if (body) return [kind, symbol2, missingIfEmpty(body)];
|
|
9945
|
+
}
|
|
9946
|
+
parser.index = index;
|
|
9947
|
+
const condTerminator = {
|
|
9948
|
+
...terminator,
|
|
9949
|
+
condition: (p) => p.peek === ":" || p.peek === "\\colon" || (terminator.condition?.(p) ?? false)
|
|
9950
|
+
};
|
|
9951
|
+
const condition = parser.parseExpression(condTerminator);
|
|
9952
|
+
if (condition === null) return null;
|
|
9953
|
+
parser.skipSpace();
|
|
9954
|
+
if (parser.matchAny([",", "\\mid", ":", "\\colon"])) {
|
|
9955
|
+
const bodyTerminator = useTightBinding ? {
|
|
9956
|
+
...terminator,
|
|
9957
|
+
condition: (p) => tightBindingCondition(p, terminator)
|
|
9958
|
+
} : terminator;
|
|
9959
|
+
parser.enterQuantifierScope();
|
|
9960
|
+
const body = parser.parseExpression(bodyTerminator);
|
|
9961
|
+
parser.exitQuantifierScope();
|
|
9962
|
+
return [kind, condition, missingIfEmpty(body)];
|
|
9963
|
+
}
|
|
9964
|
+
if (parser.match("(")) {
|
|
9965
|
+
parser.enterQuantifierScope();
|
|
9966
|
+
const body = parser.parseExpression(terminator);
|
|
9967
|
+
parser.exitQuantifierScope();
|
|
9968
|
+
if (!parser.match(")")) return null;
|
|
9969
|
+
return [kind, condition, missingIfEmpty(body)];
|
|
9970
|
+
}
|
|
9971
|
+
return null;
|
|
9972
|
+
};
|
|
9973
|
+
}
|
|
9974
|
+
|
|
9529
9975
|
// src/compute-engine/latex-syntax/dictionary/definitions-core.ts
|
|
9530
9976
|
function parseSequence(parser, terminator, lhs, prec, sep) {
|
|
9531
9977
|
if (terminator && terminator.minPrec >= prec) return null;
|
|
@@ -10136,6 +10582,120 @@ var DEFINITIONS_CORE = [
|
|
|
10136
10582
|
precedence: 21,
|
|
10137
10583
|
parse: (parser, lhs, until) => parseWhereExpression(parser, lhs, until)
|
|
10138
10584
|
},
|
|
10585
|
+
// \text{and} — logical conjunction infix
|
|
10586
|
+
{
|
|
10587
|
+
latexTrigger: ["\\text"],
|
|
10588
|
+
kind: "infix",
|
|
10589
|
+
associativity: "right",
|
|
10590
|
+
precedence: 235,
|
|
10591
|
+
// Same as \land
|
|
10592
|
+
parse: (parser, lhs, until) => {
|
|
10593
|
+
const start = parser.index;
|
|
10594
|
+
if (!matchTextKeyword(parser, "and")) {
|
|
10595
|
+
parser.index = start;
|
|
10596
|
+
return null;
|
|
10597
|
+
}
|
|
10598
|
+
const rhs = parser.parseExpression({ ...until, minPrec: 235 });
|
|
10599
|
+
return ["And", lhs, rhs ?? "Nothing"];
|
|
10600
|
+
}
|
|
10601
|
+
},
|
|
10602
|
+
// \text{or} — logical disjunction infix
|
|
10603
|
+
{
|
|
10604
|
+
latexTrigger: ["\\text"],
|
|
10605
|
+
kind: "infix",
|
|
10606
|
+
associativity: "right",
|
|
10607
|
+
precedence: 230,
|
|
10608
|
+
// Same as \lor
|
|
10609
|
+
parse: (parser, lhs, until) => {
|
|
10610
|
+
const start = parser.index;
|
|
10611
|
+
if (!matchTextKeyword(parser, "or")) {
|
|
10612
|
+
parser.index = start;
|
|
10613
|
+
return null;
|
|
10614
|
+
}
|
|
10615
|
+
const rhs = parser.parseExpression({ ...until, minPrec: 230 });
|
|
10616
|
+
return ["Or", lhs, rhs ?? "Nothing"];
|
|
10617
|
+
}
|
|
10618
|
+
},
|
|
10619
|
+
// \text{iff} — biconditional (if and only if)
|
|
10620
|
+
{
|
|
10621
|
+
latexTrigger: ["\\text"],
|
|
10622
|
+
kind: "infix",
|
|
10623
|
+
associativity: "right",
|
|
10624
|
+
precedence: 219,
|
|
10625
|
+
// Same as \iff
|
|
10626
|
+
parse: (parser, lhs, until) => {
|
|
10627
|
+
const start = parser.index;
|
|
10628
|
+
if (!matchTextKeyword(parser, "iff")) {
|
|
10629
|
+
parser.index = start;
|
|
10630
|
+
return null;
|
|
10631
|
+
}
|
|
10632
|
+
const rhs = parser.parseExpression({ ...until, minPrec: 219 });
|
|
10633
|
+
return ["Equivalent", lhs, rhs ?? "Nothing"];
|
|
10634
|
+
}
|
|
10635
|
+
},
|
|
10636
|
+
// \text{if and only if} — verbose biconditional
|
|
10637
|
+
{
|
|
10638
|
+
latexTrigger: ["\\text"],
|
|
10639
|
+
kind: "infix",
|
|
10640
|
+
associativity: "right",
|
|
10641
|
+
precedence: 219,
|
|
10642
|
+
parse: (parser, lhs, until) => {
|
|
10643
|
+
const start = parser.index;
|
|
10644
|
+
if (!matchTextKeyword(parser, "if and only if")) {
|
|
10645
|
+
parser.index = start;
|
|
10646
|
+
return null;
|
|
10647
|
+
}
|
|
10648
|
+
const rhs = parser.parseExpression({ ...until, minPrec: 219 });
|
|
10649
|
+
return ["Equivalent", lhs, rhs ?? "Nothing"];
|
|
10650
|
+
}
|
|
10651
|
+
},
|
|
10652
|
+
// \text{such that} — constraint separator (like : in set-builder notation)
|
|
10653
|
+
{
|
|
10654
|
+
latexTrigger: ["\\text"],
|
|
10655
|
+
kind: "infix",
|
|
10656
|
+
associativity: "right",
|
|
10657
|
+
precedence: 21,
|
|
10658
|
+
// Low precedence to capture full condition (same as 'where')
|
|
10659
|
+
parse: (parser, lhs, until) => {
|
|
10660
|
+
const start = parser.index;
|
|
10661
|
+
if (!matchTextKeyword(parser, "such that")) {
|
|
10662
|
+
parser.index = start;
|
|
10663
|
+
return null;
|
|
10664
|
+
}
|
|
10665
|
+
const rhs = parser.parseExpression({ ...until, minPrec: 21 });
|
|
10666
|
+
return ["Colon", lhs, rhs ?? "Nothing"];
|
|
10667
|
+
}
|
|
10668
|
+
},
|
|
10669
|
+
// \text{for all} — universal quantifier
|
|
10670
|
+
{
|
|
10671
|
+
latexTrigger: ["\\text"],
|
|
10672
|
+
kind: "prefix",
|
|
10673
|
+
precedence: 200,
|
|
10674
|
+
// Same as \forall
|
|
10675
|
+
parse: (parser, until) => {
|
|
10676
|
+
const start = parser.index;
|
|
10677
|
+
if (!matchTextKeyword(parser, "for all")) {
|
|
10678
|
+
parser.index = start;
|
|
10679
|
+
return null;
|
|
10680
|
+
}
|
|
10681
|
+
return parseQuantifier("ForAll")(parser, until);
|
|
10682
|
+
}
|
|
10683
|
+
},
|
|
10684
|
+
// \text{there exists} — existential quantifier
|
|
10685
|
+
{
|
|
10686
|
+
latexTrigger: ["\\text"],
|
|
10687
|
+
kind: "prefix",
|
|
10688
|
+
precedence: 200,
|
|
10689
|
+
// Same as \exists
|
|
10690
|
+
parse: (parser, until) => {
|
|
10691
|
+
const start = parser.index;
|
|
10692
|
+
if (!matchTextKeyword(parser, "there exists")) {
|
|
10693
|
+
parser.index = start;
|
|
10694
|
+
return null;
|
|
10695
|
+
}
|
|
10696
|
+
return parseQuantifier("Exists")(parser, until);
|
|
10697
|
+
}
|
|
10698
|
+
},
|
|
10139
10699
|
// Block serializer — used by both `where` and semicolon blocks
|
|
10140
10700
|
{
|
|
10141
10701
|
name: "Block",
|
|
@@ -10251,6 +10811,39 @@ var DEFINITIONS_CORE = [
|
|
|
10251
10811
|
parser.parseExpression(until) ?? "Nothing"
|
|
10252
10812
|
]
|
|
10253
10813
|
},
|
|
10814
|
+
// Text serializer — reconstructs \text{...} with inline $...$ for math
|
|
10815
|
+
{
|
|
10816
|
+
name: "Text",
|
|
10817
|
+
serialize: (serializer, expr2) => {
|
|
10818
|
+
const args = operands(expr2);
|
|
10819
|
+
if (args.length === 0) return "";
|
|
10820
|
+
let firstStr = -1;
|
|
10821
|
+
let lastStr = -1;
|
|
10822
|
+
for (let i = 0; i < args.length; i++) {
|
|
10823
|
+
if (stringValue(args[i]) !== null) {
|
|
10824
|
+
if (firstStr < 0) firstStr = i;
|
|
10825
|
+
lastStr = i;
|
|
10826
|
+
}
|
|
10827
|
+
}
|
|
10828
|
+
if (firstStr < 0)
|
|
10829
|
+
return joinLatex(args.map((a) => serializer.serialize(a)));
|
|
10830
|
+
const parts = [];
|
|
10831
|
+
for (let i = 0; i < firstStr; i++)
|
|
10832
|
+
parts.push(serializer.serialize(args[i]));
|
|
10833
|
+
let textContent = "";
|
|
10834
|
+
for (let i = firstStr; i <= lastStr; i++) {
|
|
10835
|
+
const s = stringValue(args[i]);
|
|
10836
|
+
if (s !== null) textContent += sanitizeLatex(s);
|
|
10837
|
+
else if (operator(args[i]) === "Annotated" || operator(args[i]) === "Text")
|
|
10838
|
+
textContent += serializer.serialize(args[i]);
|
|
10839
|
+
else textContent += "$" + serializer.serialize(args[i]) + "$";
|
|
10840
|
+
}
|
|
10841
|
+
parts.push("\\text{" + textContent + "}");
|
|
10842
|
+
for (let i = lastStr + 1; i < args.length; i++)
|
|
10843
|
+
parts.push(serializer.serialize(args[i]));
|
|
10844
|
+
return joinLatex(parts);
|
|
10845
|
+
}
|
|
10846
|
+
},
|
|
10254
10847
|
{
|
|
10255
10848
|
name: "String",
|
|
10256
10849
|
latexTrigger: ["\\text"],
|
|
@@ -10641,9 +11234,10 @@ function parseTextRun(parser, style) {
|
|
|
10641
11234
|
} else if (parser.match("\\textcolor")) {
|
|
10642
11235
|
const pos = parser.index;
|
|
10643
11236
|
const color = parser.parseStringGroup();
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
11237
|
+
if (color !== null) {
|
|
11238
|
+
flush();
|
|
11239
|
+
const body2 = parseTextRun(parser);
|
|
11240
|
+
runs.push(["Annotated", body2, dictionaryFromEntries({ color })]);
|
|
10647
11241
|
} else {
|
|
10648
11242
|
parser.index = pos;
|
|
10649
11243
|
text += "\\textcolor";
|
|
@@ -10661,6 +11255,7 @@ function parseTextRun(parser, style) {
|
|
|
10661
11255
|
const expr2 = parser.parseExpression() ?? "Nothing";
|
|
10662
11256
|
parser.skipSpace();
|
|
10663
11257
|
if (parser.match("<$>")) {
|
|
11258
|
+
flush();
|
|
10664
11259
|
runs.push(expr2);
|
|
10665
11260
|
} else {
|
|
10666
11261
|
text += "$";
|
|
@@ -10671,6 +11266,7 @@ function parseTextRun(parser, style) {
|
|
|
10671
11266
|
const expr2 = parser.parseExpression() ?? "Nothing";
|
|
10672
11267
|
parser.skipSpace();
|
|
10673
11268
|
if (parser.match("<$$>")) {
|
|
11269
|
+
flush();
|
|
10674
11270
|
runs.push(expr2);
|
|
10675
11271
|
} else {
|
|
10676
11272
|
text += "$$";
|
|
@@ -11021,14 +11617,20 @@ function matchTextKeyword(parser, keyword) {
|
|
|
11021
11617
|
}
|
|
11022
11618
|
while (parser.match("<space>")) {
|
|
11023
11619
|
}
|
|
11024
|
-
let
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11620
|
+
for (let i = 0; i < keyword.length; i++) {
|
|
11621
|
+
if (keyword[i] === " ") {
|
|
11622
|
+
if (!parser.match("<space>")) {
|
|
11623
|
+
parser.index = start;
|
|
11624
|
+
return false;
|
|
11625
|
+
}
|
|
11626
|
+
while (parser.match("<space>")) {
|
|
11627
|
+
}
|
|
11030
11628
|
} else {
|
|
11031
|
-
|
|
11629
|
+
if (parser.peek !== keyword[i]) {
|
|
11630
|
+
parser.index = start;
|
|
11631
|
+
return false;
|
|
11632
|
+
}
|
|
11633
|
+
parser.nextToken();
|
|
11032
11634
|
}
|
|
11033
11635
|
}
|
|
11034
11636
|
while (parser.match("<space>")) {
|
|
@@ -11037,10 +11639,6 @@ function matchTextKeyword(parser, keyword) {
|
|
|
11037
11639
|
parser.index = start;
|
|
11038
11640
|
return false;
|
|
11039
11641
|
}
|
|
11040
|
-
if (text !== keyword) {
|
|
11041
|
-
parser.index = start;
|
|
11042
|
-
return false;
|
|
11043
|
-
}
|
|
11044
11642
|
return true;
|
|
11045
11643
|
}
|
|
11046
11644
|
function matchKeyword(parser, keyword) {
|
|
@@ -11318,452 +11916,6 @@ var DEFINITIONS_ALGEBRA = [
|
|
|
11318
11916
|
}
|
|
11319
11917
|
];
|
|
11320
11918
|
|
|
11321
|
-
// src/compute-engine/latex-syntax/dictionary/definitions-logic.ts
|
|
11322
|
-
var DEFINITIONS_LOGIC = [
|
|
11323
|
-
// Constants
|
|
11324
|
-
{
|
|
11325
|
-
name: "True",
|
|
11326
|
-
kind: "symbol",
|
|
11327
|
-
latexTrigger: ["\\top"]
|
|
11328
|
-
// ⊤ U+22A4
|
|
11329
|
-
},
|
|
11330
|
-
{
|
|
11331
|
-
kind: "symbol",
|
|
11332
|
-
latexTrigger: "\\mathrm{True}",
|
|
11333
|
-
parse: "True"
|
|
11334
|
-
},
|
|
11335
|
-
{
|
|
11336
|
-
kind: "symbol",
|
|
11337
|
-
latexTrigger: "\\operatorname{True}",
|
|
11338
|
-
parse: "True"
|
|
11339
|
-
},
|
|
11340
|
-
{
|
|
11341
|
-
kind: "symbol",
|
|
11342
|
-
latexTrigger: "\\mathsf{T}",
|
|
11343
|
-
parse: "True"
|
|
11344
|
-
},
|
|
11345
|
-
{
|
|
11346
|
-
name: "False",
|
|
11347
|
-
kind: "symbol",
|
|
11348
|
-
latexTrigger: ["\\bot"]
|
|
11349
|
-
// ⊥ U+22A5
|
|
11350
|
-
},
|
|
11351
|
-
{
|
|
11352
|
-
kind: "symbol",
|
|
11353
|
-
latexTrigger: "\\operatorname{False}",
|
|
11354
|
-
parse: "False"
|
|
11355
|
-
},
|
|
11356
|
-
{
|
|
11357
|
-
kind: "symbol",
|
|
11358
|
-
latexTrigger: "\\mathsf{F}",
|
|
11359
|
-
parse: "False"
|
|
11360
|
-
},
|
|
11361
|
-
// Operators
|
|
11362
|
-
// Logic operators have lower precedence than comparisons (245)
|
|
11363
|
-
// so that `x = 1 \lor x = 2` parses as `(x = 1) \lor (x = 2)`
|
|
11364
|
-
// See https://github.com/cortex-js/compute-engine/issues/243
|
|
11365
|
-
{
|
|
11366
|
-
name: "And",
|
|
11367
|
-
kind: "infix",
|
|
11368
|
-
latexTrigger: ["\\land"],
|
|
11369
|
-
precedence: 235
|
|
11370
|
-
// serialize: '\\land',
|
|
11371
|
-
},
|
|
11372
|
-
{ kind: "infix", latexTrigger: ["\\wedge"], parse: "And", precedence: 235 },
|
|
11373
|
-
{ kind: "infix", latexTrigger: "\\&", parse: "And", precedence: 235 },
|
|
11374
|
-
{
|
|
11375
|
-
kind: "infix",
|
|
11376
|
-
latexTrigger: "\\operatorname{and}",
|
|
11377
|
-
parse: "And",
|
|
11378
|
-
precedence: 235
|
|
11379
|
-
},
|
|
11380
|
-
{
|
|
11381
|
-
name: "Or",
|
|
11382
|
-
kind: "infix",
|
|
11383
|
-
latexTrigger: ["\\lor"],
|
|
11384
|
-
precedence: 230
|
|
11385
|
-
},
|
|
11386
|
-
{ kind: "infix", latexTrigger: ["\\vee"], parse: "Or", precedence: 230 },
|
|
11387
|
-
{ kind: "infix", latexTrigger: "\\parallel", parse: "Or", precedence: 230 },
|
|
11388
|
-
{
|
|
11389
|
-
kind: "infix",
|
|
11390
|
-
latexTrigger: "\\operatorname{or}",
|
|
11391
|
-
parse: "Or",
|
|
11392
|
-
precedence: 230
|
|
11393
|
-
},
|
|
11394
|
-
{
|
|
11395
|
-
name: "Xor",
|
|
11396
|
-
kind: "infix",
|
|
11397
|
-
latexTrigger: ["\\veebar"],
|
|
11398
|
-
precedence: 232
|
|
11399
|
-
},
|
|
11400
|
-
// Possible alt: \oplus ⊕ U+2295
|
|
11401
|
-
{
|
|
11402
|
-
name: "Not",
|
|
11403
|
-
kind: "prefix",
|
|
11404
|
-
latexTrigger: ["\\lnot"],
|
|
11405
|
-
precedence: 880
|
|
11406
|
-
},
|
|
11407
|
-
{
|
|
11408
|
-
kind: "prefix",
|
|
11409
|
-
latexTrigger: ["\\neg"],
|
|
11410
|
-
parse: "Not",
|
|
11411
|
-
precedence: 880
|
|
11412
|
-
},
|
|
11413
|
-
{
|
|
11414
|
-
name: "Nand",
|
|
11415
|
-
kind: "infix",
|
|
11416
|
-
latexTrigger: ["\\barwedge"],
|
|
11417
|
-
precedence: 232
|
|
11418
|
-
// serialize: '\\mid',
|
|
11419
|
-
},
|
|
11420
|
-
{
|
|
11421
|
-
name: "Nor",
|
|
11422
|
-
kind: "infix",
|
|
11423
|
-
latexTrigger: ["\u22BD"],
|
|
11424
|
-
// bar vee
|
|
11425
|
-
precedence: 232
|
|
11426
|
-
// serialize: '\\downarrow',
|
|
11427
|
-
},
|
|
11428
|
-
// Functions
|
|
11429
|
-
{
|
|
11430
|
-
kind: "function",
|
|
11431
|
-
symbolTrigger: "and",
|
|
11432
|
-
parse: "And"
|
|
11433
|
-
},
|
|
11434
|
-
{
|
|
11435
|
-
kind: "function",
|
|
11436
|
-
symbolTrigger: "or",
|
|
11437
|
-
parse: "Or"
|
|
11438
|
-
},
|
|
11439
|
-
{
|
|
11440
|
-
kind: "function",
|
|
11441
|
-
symbolTrigger: "not",
|
|
11442
|
-
parse: "Not"
|
|
11443
|
-
},
|
|
11444
|
-
// Relations
|
|
11445
|
-
{
|
|
11446
|
-
name: "Implies",
|
|
11447
|
-
kind: "infix",
|
|
11448
|
-
precedence: 220,
|
|
11449
|
-
associativity: "right",
|
|
11450
|
-
latexTrigger: ["\\implies"],
|
|
11451
|
-
serialize: "\\implies"
|
|
11452
|
-
},
|
|
11453
|
-
{
|
|
11454
|
-
latexTrigger: ["\\Rightarrow"],
|
|
11455
|
-
kind: "infix",
|
|
11456
|
-
precedence: 220,
|
|
11457
|
-
associativity: "right",
|
|
11458
|
-
parse: "Implies"
|
|
11459
|
-
},
|
|
11460
|
-
{
|
|
11461
|
-
latexTrigger: ["\\rightarrow"],
|
|
11462
|
-
kind: "infix",
|
|
11463
|
-
precedence: 220,
|
|
11464
|
-
associativity: "right",
|
|
11465
|
-
parse: "Implies"
|
|
11466
|
-
},
|
|
11467
|
-
{
|
|
11468
|
-
latexTrigger: ["\\Longrightarrow"],
|
|
11469
|
-
kind: "infix",
|
|
11470
|
-
precedence: 220,
|
|
11471
|
-
associativity: "right",
|
|
11472
|
-
parse: "Implies"
|
|
11473
|
-
},
|
|
11474
|
-
{
|
|
11475
|
-
latexTrigger: ["\\longrightarrow"],
|
|
11476
|
-
kind: "infix",
|
|
11477
|
-
precedence: 220,
|
|
11478
|
-
associativity: "right",
|
|
11479
|
-
parse: "Implies"
|
|
11480
|
-
},
|
|
11481
|
-
{
|
|
11482
|
-
// Non-strict mode: => for implies
|
|
11483
|
-
latexTrigger: ["=", ">"],
|
|
11484
|
-
kind: "infix",
|
|
11485
|
-
precedence: 220,
|
|
11486
|
-
associativity: "right",
|
|
11487
|
-
parse: (parser, lhs, until) => {
|
|
11488
|
-
if (parser.options.strict !== false) return null;
|
|
11489
|
-
const rhs = parser.parseExpression({ ...until, minPrec: 220 });
|
|
11490
|
-
if (rhs === null) return null;
|
|
11491
|
-
return ["Implies", lhs, rhs];
|
|
11492
|
-
}
|
|
11493
|
-
},
|
|
11494
|
-
{
|
|
11495
|
-
name: "Equivalent",
|
|
11496
|
-
// MathML: identical to, Mathematica: Congruent
|
|
11497
|
-
latexTrigger: ["\\iff"],
|
|
11498
|
-
kind: "infix",
|
|
11499
|
-
associativity: "right",
|
|
11500
|
-
precedence: 219
|
|
11501
|
-
},
|
|
11502
|
-
{
|
|
11503
|
-
latexTrigger: ["\\Leftrightarrow"],
|
|
11504
|
-
kind: "infix",
|
|
11505
|
-
associativity: "right",
|
|
11506
|
-
precedence: 219,
|
|
11507
|
-
parse: "Equivalent"
|
|
11508
|
-
},
|
|
11509
|
-
{
|
|
11510
|
-
latexTrigger: ["\\leftrightarrow"],
|
|
11511
|
-
kind: "infix",
|
|
11512
|
-
associativity: "right",
|
|
11513
|
-
precedence: 219,
|
|
11514
|
-
parse: "Equivalent"
|
|
11515
|
-
},
|
|
11516
|
-
{
|
|
11517
|
-
latexTrigger: ["\\Longleftrightarrow"],
|
|
11518
|
-
kind: "infix",
|
|
11519
|
-
associativity: "right",
|
|
11520
|
-
precedence: 219,
|
|
11521
|
-
parse: "Equivalent"
|
|
11522
|
-
},
|
|
11523
|
-
{
|
|
11524
|
-
latexTrigger: ["\\longleftrightarrow"],
|
|
11525
|
-
kind: "infix",
|
|
11526
|
-
associativity: "right",
|
|
11527
|
-
precedence: 219,
|
|
11528
|
-
parse: "Equivalent"
|
|
11529
|
-
},
|
|
11530
|
-
{
|
|
11531
|
-
// Non-strict mode: <=> for equivalence
|
|
11532
|
-
latexTrigger: ["<", "=", ">"],
|
|
11533
|
-
kind: "infix",
|
|
11534
|
-
precedence: 219,
|
|
11535
|
-
associativity: "right",
|
|
11536
|
-
parse: (parser, lhs, until) => {
|
|
11537
|
-
if (parser.options.strict !== false) return null;
|
|
11538
|
-
const rhs = parser.parseExpression({ ...until, minPrec: 219 });
|
|
11539
|
-
if (rhs === null) return null;
|
|
11540
|
-
return ["Equivalent", lhs, rhs];
|
|
11541
|
-
}
|
|
11542
|
-
},
|
|
11543
|
-
{
|
|
11544
|
-
latexTrigger: ["\\equiv"],
|
|
11545
|
-
kind: "infix",
|
|
11546
|
-
associativity: "right",
|
|
11547
|
-
precedence: 219,
|
|
11548
|
-
parse: (parser, lhs, terminator) => {
|
|
11549
|
-
const rhs = parser.parseExpression({ ...terminator, minPrec: 219 });
|
|
11550
|
-
const index = parser.index;
|
|
11551
|
-
const modulus = parser.parseExpression({ ...terminator, minPrec: 219 });
|
|
11552
|
-
if (modulus !== null && operator(modulus) === "Mod")
|
|
11553
|
-
return ["Congruent", lhs, rhs, missingIfEmpty(operand(modulus, 1))];
|
|
11554
|
-
parser.index = index;
|
|
11555
|
-
return ["Equivalent", lhs, missingIfEmpty(rhs)];
|
|
11556
|
-
}
|
|
11557
|
-
},
|
|
11558
|
-
{
|
|
11559
|
-
name: "Proves",
|
|
11560
|
-
kind: "infix",
|
|
11561
|
-
latexTrigger: ["\\vdash"],
|
|
11562
|
-
precedence: 220,
|
|
11563
|
-
associativity: "right",
|
|
11564
|
-
serialize: "\\vdash"
|
|
11565
|
-
},
|
|
11566
|
-
{
|
|
11567
|
-
name: "Entails",
|
|
11568
|
-
kind: "infix",
|
|
11569
|
-
latexTrigger: ["\\vDash"],
|
|
11570
|
-
precedence: 220,
|
|
11571
|
-
associativity: "right",
|
|
11572
|
-
serialize: "\\vDash"
|
|
11573
|
-
},
|
|
11574
|
-
{
|
|
11575
|
-
name: "Satisfies",
|
|
11576
|
-
kind: "infix",
|
|
11577
|
-
latexTrigger: ["\\models"],
|
|
11578
|
-
precedence: 220,
|
|
11579
|
-
associativity: "right",
|
|
11580
|
-
serialize: "\\models"
|
|
11581
|
-
},
|
|
11582
|
-
// Quantifiers: for all, exists
|
|
11583
|
-
{
|
|
11584
|
-
name: "ForAll",
|
|
11585
|
-
kind: "prefix",
|
|
11586
|
-
latexTrigger: ["\\forall"],
|
|
11587
|
-
precedence: 200,
|
|
11588
|
-
// Has to be lower than COMPARISON_PRECEDENCE
|
|
11589
|
-
serialize: serializeQuantifier("\\forall"),
|
|
11590
|
-
parse: parseQuantifier("ForAll")
|
|
11591
|
-
},
|
|
11592
|
-
{
|
|
11593
|
-
name: "Exists",
|
|
11594
|
-
kind: "prefix",
|
|
11595
|
-
latexTrigger: ["\\exists"],
|
|
11596
|
-
precedence: 200,
|
|
11597
|
-
// Has to be lower than COMPARISON_PRECEDENCE,
|
|
11598
|
-
serialize: serializeQuantifier("\\exists"),
|
|
11599
|
-
parse: parseQuantifier("Exists")
|
|
11600
|
-
},
|
|
11601
|
-
{
|
|
11602
|
-
name: "ExistsUnique",
|
|
11603
|
-
kind: "prefix",
|
|
11604
|
-
latexTrigger: ["\\exists", "!"],
|
|
11605
|
-
precedence: 200,
|
|
11606
|
-
// Has to be lower than COMPARISON_PRECEDENCE,
|
|
11607
|
-
serialize: serializeQuantifier("\\exists!"),
|
|
11608
|
-
parse: parseQuantifier("ExistsUnique")
|
|
11609
|
-
},
|
|
11610
|
-
{
|
|
11611
|
-
name: "NotForAll",
|
|
11612
|
-
kind: "prefix",
|
|
11613
|
-
latexTrigger: ["\\lnot", "\\forall"],
|
|
11614
|
-
precedence: 200,
|
|
11615
|
-
// Has to be lower than COMPARISON_PRECEDENCE
|
|
11616
|
-
serialize: serializeQuantifier("\\lnot\\forall"),
|
|
11617
|
-
parse: parseQuantifier("NotForAll")
|
|
11618
|
-
},
|
|
11619
|
-
{
|
|
11620
|
-
name: "NotExists",
|
|
11621
|
-
kind: "prefix",
|
|
11622
|
-
latexTrigger: ["\\lnot", "\\exists"],
|
|
11623
|
-
precedence: 200,
|
|
11624
|
-
// Has to be lower than COMPARISON_PRECEDENCE,
|
|
11625
|
-
serialize: serializeQuantifier("\\lnot\\exists"),
|
|
11626
|
-
parse: parseQuantifier("NotExists")
|
|
11627
|
-
},
|
|
11628
|
-
{
|
|
11629
|
-
name: "KroneckerDelta",
|
|
11630
|
-
kind: "prefix",
|
|
11631
|
-
latexTrigger: ["\\delta", "_"],
|
|
11632
|
-
precedence: 200,
|
|
11633
|
-
serialize: (serializer, expr2) => {
|
|
11634
|
-
const args = operands(expr2);
|
|
11635
|
-
if (args.length === 0) return "\\delta";
|
|
11636
|
-
if (args.every((x) => symbol(x)))
|
|
11637
|
-
return `\\delta_{${args.map((arg) => serializer.serialize(arg)).join("")}}`;
|
|
11638
|
-
return `\\delta_{${args.map((arg) => serializer.serialize(arg)).join(", ")}}`;
|
|
11639
|
-
},
|
|
11640
|
-
parse: (parser) => {
|
|
11641
|
-
const group = parser.parseGroup();
|
|
11642
|
-
if (group === null) {
|
|
11643
|
-
const token = parser.parseToken();
|
|
11644
|
-
if (!token) return null;
|
|
11645
|
-
return ["KroneckerDelta", token];
|
|
11646
|
-
}
|
|
11647
|
-
const seq = getSequence(group);
|
|
11648
|
-
if (seq && seq.length <= 2) return ["KroneckerDelta", ...seq];
|
|
11649
|
-
if (operator(group) === "InvisibleOperator")
|
|
11650
|
-
return ["KroneckerDelta", ...operands(group)];
|
|
11651
|
-
if (group !== null) return ["KroneckerDelta", group];
|
|
11652
|
-
return null;
|
|
11653
|
-
}
|
|
11654
|
-
},
|
|
11655
|
-
// Iverson brackets. Also called the "indicator function"
|
|
11656
|
-
// Must have a single argument, a relational expression, i.e.
|
|
11657
|
-
// `[ a = b ]` or `[ x \leq 0 ]`
|
|
11658
|
-
// Otherwise, it gets rejected, it could be something else, like a list or
|
|
11659
|
-
// tuple.
|
|
11660
|
-
{
|
|
11661
|
-
name: "Boole",
|
|
11662
|
-
kind: "matchfix",
|
|
11663
|
-
openTrigger: "[",
|
|
11664
|
-
closeTrigger: "]",
|
|
11665
|
-
// serialize: (serializer: Serializer, expr: MathJsonExpression) => {
|
|
11666
|
-
// const args = ops(expr);
|
|
11667
|
-
// return `[${serializer.serialize(arg)}]`;
|
|
11668
|
-
// },
|
|
11669
|
-
parse: (_parser, body) => {
|
|
11670
|
-
const h = operator(body);
|
|
11671
|
-
if (!h) return null;
|
|
11672
|
-
if (!DEFINITIONS_INEQUALITIES.some((x) => x.name === h)) return null;
|
|
11673
|
-
return ["Boole", body];
|
|
11674
|
-
}
|
|
11675
|
-
},
|
|
11676
|
-
{
|
|
11677
|
-
kind: "matchfix",
|
|
11678
|
-
openTrigger: "\\llbracket",
|
|
11679
|
-
closeTrigger: "\\rrbracket",
|
|
11680
|
-
parse: (_parser, body) => {
|
|
11681
|
-
const h = operator(body);
|
|
11682
|
-
if (!h) return null;
|
|
11683
|
-
if (!DEFINITIONS_INEQUALITIES.some((x) => x.name === h)) return null;
|
|
11684
|
-
return ["Boole", body];
|
|
11685
|
-
}
|
|
11686
|
-
},
|
|
11687
|
-
// Predicate application in First-Order Logic.
|
|
11688
|
-
// ["Predicate", "P", "x", "y"] serializes to "P(x, y)"
|
|
11689
|
-
{
|
|
11690
|
-
name: "Predicate",
|
|
11691
|
-
serialize: (serializer, expr2) => {
|
|
11692
|
-
const args = operands(expr2);
|
|
11693
|
-
if (args.length === 0) return "";
|
|
11694
|
-
const pred = args[0];
|
|
11695
|
-
const predStr = typeof pred === "string" ? pred : serializer.serialize(pred);
|
|
11696
|
-
if (args.length === 1) return predStr;
|
|
11697
|
-
const argStrs = args.slice(1).map((arg) => serializer.serialize(arg));
|
|
11698
|
-
return `${predStr}(${argStrs.join(", ")})`;
|
|
11699
|
-
}
|
|
11700
|
-
}
|
|
11701
|
-
];
|
|
11702
|
-
function serializeQuantifier(quantifierSymbol) {
|
|
11703
|
-
return (serializer, expr2) => {
|
|
11704
|
-
const args = operands(expr2);
|
|
11705
|
-
if (args.length === 0) return quantifierSymbol;
|
|
11706
|
-
if (args.length === 1)
|
|
11707
|
-
return `${quantifierSymbol} ${serializer.serialize(args[0])}`;
|
|
11708
|
-
const boundVar = serializer.serialize(args[0]);
|
|
11709
|
-
const body = serializer.serialize(args[1]);
|
|
11710
|
-
return `${quantifierSymbol} ${boundVar}, ${body}`;
|
|
11711
|
-
};
|
|
11712
|
-
}
|
|
11713
|
-
function tightBindingCondition(p, terminator) {
|
|
11714
|
-
return p.peek === "\\to" || p.peek === "\\rightarrow" || p.peek === "\\implies" || p.peek === "\\Rightarrow" || p.peek === "\\iff" || p.peek === "\\Leftrightarrow" || p.peek === "\\land" || p.peek === "\\wedge" || p.peek === "\\lor" || p.peek === "\\vee" || (terminator.condition?.(p) ?? false);
|
|
11715
|
-
}
|
|
11716
|
-
function parseQuantifier(kind) {
|
|
11717
|
-
return (parser, terminator) => {
|
|
11718
|
-
const index = parser.index;
|
|
11719
|
-
const useTightBinding = parser.options.quantifierScope !== "loose";
|
|
11720
|
-
const symbol2 = parser.parseSymbol(terminator);
|
|
11721
|
-
if (symbol2) {
|
|
11722
|
-
parser.skipSpace();
|
|
11723
|
-
if (parser.match(",") || parser.match("\\mid") || parser.match(".") || parser.match(":") || parser.match("\\colon")) {
|
|
11724
|
-
const bodyTerminator = useTightBinding ? {
|
|
11725
|
-
...terminator,
|
|
11726
|
-
condition: (p) => tightBindingCondition(p, terminator)
|
|
11727
|
-
} : terminator;
|
|
11728
|
-
parser.enterQuantifierScope();
|
|
11729
|
-
const body2 = parser.parseExpression(bodyTerminator);
|
|
11730
|
-
parser.exitQuantifierScope();
|
|
11731
|
-
return [kind, symbol2, missingIfEmpty(body2)];
|
|
11732
|
-
}
|
|
11733
|
-
parser.enterQuantifierScope();
|
|
11734
|
-
const body = parser.parseEnclosure();
|
|
11735
|
-
parser.exitQuantifierScope();
|
|
11736
|
-
if (body) return [kind, symbol2, missingIfEmpty(body)];
|
|
11737
|
-
}
|
|
11738
|
-
parser.index = index;
|
|
11739
|
-
const condTerminator = {
|
|
11740
|
-
...terminator,
|
|
11741
|
-
condition: (p) => p.peek === ":" || p.peek === "\\colon" || (terminator.condition?.(p) ?? false)
|
|
11742
|
-
};
|
|
11743
|
-
const condition = parser.parseExpression(condTerminator);
|
|
11744
|
-
if (condition === null) return null;
|
|
11745
|
-
parser.skipSpace();
|
|
11746
|
-
if (parser.matchAny([",", "\\mid", ":", "\\colon"])) {
|
|
11747
|
-
const bodyTerminator = useTightBinding ? {
|
|
11748
|
-
...terminator,
|
|
11749
|
-
condition: (p) => tightBindingCondition(p, terminator)
|
|
11750
|
-
} : terminator;
|
|
11751
|
-
parser.enterQuantifierScope();
|
|
11752
|
-
const body = parser.parseExpression(bodyTerminator);
|
|
11753
|
-
parser.exitQuantifierScope();
|
|
11754
|
-
return [kind, condition, missingIfEmpty(body)];
|
|
11755
|
-
}
|
|
11756
|
-
if (parser.match("(")) {
|
|
11757
|
-
parser.enterQuantifierScope();
|
|
11758
|
-
const body = parser.parseExpression(terminator);
|
|
11759
|
-
parser.exitQuantifierScope();
|
|
11760
|
-
if (!parser.match(")")) return null;
|
|
11761
|
-
return [kind, condition, missingIfEmpty(body)];
|
|
11762
|
-
}
|
|
11763
|
-
return null;
|
|
11764
|
-
};
|
|
11765
|
-
}
|
|
11766
|
-
|
|
11767
11919
|
// src/compute-engine/latex-syntax/dictionary/definitions-sets.ts
|
|
11768
11920
|
function parseIntervalBody(body, openLeft, openRight) {
|
|
11769
11921
|
if (isEmptySequence(body)) return null;
|
|
@@ -16268,7 +16420,7 @@ var ZWJ2 = "\\u{200D}";
|
|
|
16268
16420
|
var FLAG_SEQUENCE = "\\p{RI}\\p{RI}";
|
|
16269
16421
|
var TAG_MOD = `(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})`;
|
|
16270
16422
|
var EMOJI_MOD = `(?:\\p{EMod}|${VS16}${KEYCAP}?|${TAG_MOD})`;
|
|
16271
|
-
var EMOJI_NOT_SYMBOL = `(?:(?=\\P{XIDC})\\p{Emoji})`;
|
|
16423
|
+
var EMOJI_NOT_SYMBOL = `(?:(?=\\P{XIDC})(?=[^\\x23\\x2a\\x30-\\x39])\\p{Emoji})`;
|
|
16272
16424
|
var ZWJ_ELEMENT = `(?:${EMOJI_NOT_SYMBOL}${EMOJI_MOD}*|\\p{Emoji}${EMOJI_MOD}+|${FLAG_SEQUENCE})`;
|
|
16273
16425
|
var POSSIBLE_EMOJI = `(?:${ZWJ_ELEMENT})(${ZWJ2}${ZWJ_ELEMENT})*`;
|
|
16274
16426
|
var SOME_EMOJI = new RegExp(`(?:${POSSIBLE_EMOJI})+`, "u");
|
|
@@ -16977,7 +17129,9 @@ function parseSymbolToken(parser, options) {
|
|
|
16977
17129
|
}
|
|
16978
17130
|
return c;
|
|
16979
17131
|
}
|
|
16980
|
-
|
|
17132
|
+
const raw = parser.peek;
|
|
17133
|
+
if (raw && /^[\p{XIDC}\p{M}]/u.test(raw)) return parser.nextToken();
|
|
17134
|
+
return null;
|
|
16981
17135
|
}
|
|
16982
17136
|
function parseSymbolBody(parser) {
|
|
16983
17137
|
let id = matchPrefixedSymbol(parser);
|
|
@@ -18267,6 +18421,29 @@ var _Parser = class __Parser {
|
|
|
18267
18421
|
this.index = start;
|
|
18268
18422
|
return null;
|
|
18269
18423
|
}
|
|
18424
|
+
/**
|
|
18425
|
+
* Speculatively check if any \text infix entry (e.g. "and", "or", "where")
|
|
18426
|
+
* would match the upcoming tokens. This is used to prevent InvisibleOperator
|
|
18427
|
+
* from consuming \text{keyword} as a text run when the keyword is actually
|
|
18428
|
+
* an infix operator that was skipped due to precedence constraints.
|
|
18429
|
+
*
|
|
18430
|
+
* Returns true if any entry's parse function would succeed (non-null result).
|
|
18431
|
+
* The parser index is always restored to its original position.
|
|
18432
|
+
*/
|
|
18433
|
+
wouldMatchTextInfix(opDefs) {
|
|
18434
|
+
const start = this.index;
|
|
18435
|
+
for (const [def, n] of opDefs) {
|
|
18436
|
+
if (def.kind !== "infix") continue;
|
|
18437
|
+
this.index = start + n;
|
|
18438
|
+
const result = def.parse(this, "Nothing", { minPrec: 0 });
|
|
18439
|
+
if (result !== null) {
|
|
18440
|
+
this.index = start;
|
|
18441
|
+
return true;
|
|
18442
|
+
}
|
|
18443
|
+
}
|
|
18444
|
+
this.index = start;
|
|
18445
|
+
return false;
|
|
18446
|
+
}
|
|
18270
18447
|
/**
|
|
18271
18448
|
* This returns an array of arguments (as in a function application),
|
|
18272
18449
|
* or null if there is no match.
|
|
@@ -18892,6 +19069,7 @@ var _Parser = class __Parser {
|
|
|
18892
19069
|
if (isDelimiterCommand(this))
|
|
18893
19070
|
return this.error("unexpected-delimiter", start);
|
|
18894
19071
|
if (command[0] !== "\\") {
|
|
19072
|
+
this.nextToken();
|
|
18895
19073
|
return this.error(
|
|
18896
19074
|
["unexpected-token", { str: tokensToString(command) }],
|
|
18897
19075
|
start
|
|
@@ -19020,25 +19198,28 @@ var _Parser = class __Parser {
|
|
|
19020
19198
|
if (result === null && until.minPrec <= INVISIBLE_OP_PRECEDENCE) {
|
|
19021
19199
|
const opDefs = this.peekDefinitions("operator");
|
|
19022
19200
|
if (opDefs.length === 0 || opDefs.every(([def]) => def.latexTrigger === "\\text")) {
|
|
19023
|
-
|
|
19024
|
-
...until,
|
|
19025
|
-
minPrec: INVISIBLE_OP_PRECEDENCE + 1
|
|
19026
|
-
});
|
|
19027
|
-
if (rhs !== null) {
|
|
19028
|
-
if (operator(lhs) === "InvisibleOperator") {
|
|
19029
|
-
if (operator(rhs) === "InvisibleOperator")
|
|
19030
|
-
result = [
|
|
19031
|
-
"InvisibleOperator",
|
|
19032
|
-
...operands(lhs),
|
|
19033
|
-
...operands(rhs)
|
|
19034
|
-
];
|
|
19035
|
-
else result = ["InvisibleOperator", ...operands(lhs), rhs];
|
|
19036
|
-
} else if (operator(rhs) === "InvisibleOperator") {
|
|
19037
|
-
result = ["InvisibleOperator", lhs, ...operands(rhs)];
|
|
19038
|
-
} else result = ["InvisibleOperator", lhs, rhs];
|
|
19201
|
+
if (opDefs.length > 0 && this.wouldMatchTextInfix(opDefs)) {
|
|
19039
19202
|
} else {
|
|
19040
|
-
|
|
19041
|
-
|
|
19203
|
+
const rhs = this.parseExpression({
|
|
19204
|
+
...until,
|
|
19205
|
+
minPrec: INVISIBLE_OP_PRECEDENCE + 1
|
|
19206
|
+
});
|
|
19207
|
+
if (rhs !== null) {
|
|
19208
|
+
if (operator(lhs) === "InvisibleOperator") {
|
|
19209
|
+
if (operator(rhs) === "InvisibleOperator")
|
|
19210
|
+
result = [
|
|
19211
|
+
"InvisibleOperator",
|
|
19212
|
+
...operands(lhs),
|
|
19213
|
+
...operands(rhs)
|
|
19214
|
+
];
|
|
19215
|
+
else result = ["InvisibleOperator", ...operands(lhs), rhs];
|
|
19216
|
+
} else if (operator(rhs) === "InvisibleOperator") {
|
|
19217
|
+
result = ["InvisibleOperator", lhs, ...operands(rhs)];
|
|
19218
|
+
} else result = ["InvisibleOperator", lhs, rhs];
|
|
19219
|
+
} else {
|
|
19220
|
+
if (result === null) {
|
|
19221
|
+
result = this.options.parseUnexpectedToken?.(lhs, this) ?? null;
|
|
19222
|
+
}
|
|
19042
19223
|
}
|
|
19043
19224
|
}
|
|
19044
19225
|
}
|
|
@@ -37863,6 +38044,10 @@ var CALCULUS_LIBRARY = [
|
|
|
37863
38044
|
scoped: true,
|
|
37864
38045
|
lazy: true,
|
|
37865
38046
|
signature: "(expression, variable:symbol, variables:symbol+) -> expression",
|
|
38047
|
+
type: ([body]) => {
|
|
38048
|
+
if (body && body.type.matches("number")) return body.type;
|
|
38049
|
+
return void 0;
|
|
38050
|
+
},
|
|
37866
38051
|
canonical: (ops, { engine: ce, scope }) => {
|
|
37867
38052
|
if (isSymbol2(ops[0]) && ops[0].canonical.operatorDefinition) {
|
|
37868
38053
|
const vars = ops.slice(1);
|
|
@@ -42434,6 +42619,18 @@ function canonicalInvisibleOperator(ops, { engine: ce }) {
|
|
|
42434
42619
|
}
|
|
42435
42620
|
}
|
|
42436
42621
|
ops = flattenInvisibleOperator(ops);
|
|
42622
|
+
if (ops.some((op) => isFunction2(op, "Text") || isString(op))) {
|
|
42623
|
+
const runs = [];
|
|
42624
|
+
for (const op of ops) {
|
|
42625
|
+
if (isFunction2(op, "Text")) {
|
|
42626
|
+
runs.push(...op.ops);
|
|
42627
|
+
} else if (op.operator !== "HorizontalSpacing") {
|
|
42628
|
+
runs.push(op.canonical);
|
|
42629
|
+
}
|
|
42630
|
+
}
|
|
42631
|
+
return ce._fn("Text", runs);
|
|
42632
|
+
}
|
|
42633
|
+
ops = combineFunctionApplications(ce, ops);
|
|
42437
42634
|
{
|
|
42438
42635
|
const significant = ops.filter((x) => x.operator !== "HorizontalSpacing");
|
|
42439
42636
|
if (significant.length === 2) {
|
|
@@ -42448,7 +42645,7 @@ function canonicalInvisibleOperator(ops, { engine: ce }) {
|
|
|
42448
42645
|
}
|
|
42449
42646
|
ops = flatten(ops);
|
|
42450
42647
|
if (ops.every(
|
|
42451
|
-
(x) => x.isValid && (x.type.isUnknown || x.type.matches("number") || x.isIndexedCollection && !isString(x))
|
|
42648
|
+
(x) => x.isValid && (x.type.isUnknown || x.type.type === "any" || x.type.type === "expression" || x.type.matches("number") || x.isIndexedCollection && !isString(x))
|
|
42452
42649
|
)) {
|
|
42453
42650
|
return ce._fn("Multiply", ops);
|
|
42454
42651
|
}
|
|
@@ -42463,6 +42660,40 @@ function flattenInvisibleOperator(ops) {
|
|
|
42463
42660
|
}
|
|
42464
42661
|
return ys;
|
|
42465
42662
|
}
|
|
42663
|
+
function combineFunctionApplications(ce, ops) {
|
|
42664
|
+
const result = [];
|
|
42665
|
+
let i = 0;
|
|
42666
|
+
while (i < ops.length) {
|
|
42667
|
+
const op = ops[i];
|
|
42668
|
+
if (i < ops.length - 1 && isSymbol2(op) && isFunction2(ops[i + 1], "Delimiter")) {
|
|
42669
|
+
const symName = op.symbol;
|
|
42670
|
+
const def = ce.lookupDefinition(symName);
|
|
42671
|
+
const delim = ops[i + 1];
|
|
42672
|
+
if (def && (isOperatorDef(def) || def.value?.type?.matches("function"))) {
|
|
42673
|
+
let args = delim.op1 ? isFunction2(delim.op1, "Sequence") ? delim.op1.ops : [delim.op1] : [];
|
|
42674
|
+
args = flatten(args);
|
|
42675
|
+
result.push(ce.function(symName, args));
|
|
42676
|
+
i += 2;
|
|
42677
|
+
continue;
|
|
42678
|
+
}
|
|
42679
|
+
if (delim.op1 && isFunction2(delim.op1, "Sequence")) {
|
|
42680
|
+
let args = delim.op1.ops;
|
|
42681
|
+
args = flatten(args);
|
|
42682
|
+
if (args.length > 1) {
|
|
42683
|
+
if (!def) ce.declare(symName, "function");
|
|
42684
|
+
else if (!isOperatorDef(def) && def.value?.type?.isUnknown)
|
|
42685
|
+
op.canonical.infer("function");
|
|
42686
|
+
result.push(ce.function(symName, args));
|
|
42687
|
+
i += 2;
|
|
42688
|
+
continue;
|
|
42689
|
+
}
|
|
42690
|
+
}
|
|
42691
|
+
}
|
|
42692
|
+
result.push(ops[i]);
|
|
42693
|
+
i++;
|
|
42694
|
+
}
|
|
42695
|
+
return result;
|
|
42696
|
+
}
|
|
42466
42697
|
function asInteger(expr2) {
|
|
42467
42698
|
if (isNumber(expr2)) {
|
|
42468
42699
|
const n = expr2.re;
|
|
@@ -43466,7 +43697,21 @@ var CORE_LIBRARY = [
|
|
|
43466
43697
|
},
|
|
43467
43698
|
Text: {
|
|
43468
43699
|
description: "A sequence of strings, annotated expressions and other Text expressions",
|
|
43469
|
-
signature: "(any*) ->
|
|
43700
|
+
signature: "(any*) -> string",
|
|
43701
|
+
evaluate: (ops, { engine: ce }) => {
|
|
43702
|
+
if (ops.length === 0) return ce.string("");
|
|
43703
|
+
const parts = [];
|
|
43704
|
+
for (const op of ops) {
|
|
43705
|
+
const unwrapped = op.operator === "Annotated" ? op.op1 : op;
|
|
43706
|
+
if (isString(unwrapped)) parts.push(unwrapped.string);
|
|
43707
|
+
else {
|
|
43708
|
+
const evaluated = unwrapped.evaluate();
|
|
43709
|
+
if (isString(evaluated)) parts.push(evaluated.string);
|
|
43710
|
+
else parts.push(evaluated.toString());
|
|
43711
|
+
}
|
|
43712
|
+
}
|
|
43713
|
+
return ce.string(parts.join(""));
|
|
43714
|
+
}
|
|
43470
43715
|
}
|
|
43471
43716
|
},
|
|
43472
43717
|
{
|
|
@@ -43561,7 +43806,16 @@ var CORE_LIBRARY = [
|
|
|
43561
43806
|
if (!isSymbol2(symbol2)) {
|
|
43562
43807
|
symbol2 = checkType(ce, lhs, "symbol");
|
|
43563
43808
|
}
|
|
43564
|
-
|
|
43809
|
+
const canonRhs = args[1].canonical;
|
|
43810
|
+
const result = ce._fn("Assign", [symbol2, canonRhs]);
|
|
43811
|
+
const symbolName2 = sym(symbol2);
|
|
43812
|
+
if (symbolName2 && isFunction2(canonRhs, "Function")) {
|
|
43813
|
+
if (!ce.lookupDefinition(symbolName2)) ce.symbol(symbolName2);
|
|
43814
|
+
const def = ce.lookupDefinition(symbolName2);
|
|
43815
|
+
if (def && isValueDef(def) && def.value.inferredType)
|
|
43816
|
+
def.value.type = ce.type("function");
|
|
43817
|
+
}
|
|
43818
|
+
return result;
|
|
43565
43819
|
},
|
|
43566
43820
|
evaluate: ([op1, op2], { engine: ce }) => {
|
|
43567
43821
|
if (isFunction2(op1, "Subscript") && sym(op1.op1)) {
|
|
@@ -43758,6 +44012,7 @@ var CORE_LIBRARY = [
|
|
|
43758
44012
|
description: "Simplify an expression.",
|
|
43759
44013
|
lazy: true,
|
|
43760
44014
|
signature: "(any) -> expression",
|
|
44015
|
+
type: ([x]) => x?.type ?? void 0,
|
|
43761
44016
|
canonical: (ops, { engine: ce }) => ce._fn("Simplify", checkArity(ce, ops, 1)),
|
|
43762
44017
|
evaluate: ([x]) => x.simplify() ?? void 0
|
|
43763
44018
|
},
|
|
@@ -67833,14 +68088,14 @@ var ComputeEngine = class _ComputeEngine {
|
|
|
67833
68088
|
_setDefaultEngineFactory(() => new ComputeEngine());
|
|
67834
68089
|
|
|
67835
68090
|
// src/compute-engine.ts
|
|
67836
|
-
var version = "0.55.
|
|
68091
|
+
var version = "0.55.2";
|
|
67837
68092
|
ComputeEngine._latexSyntaxFactory = () => new LatexSyntax();
|
|
67838
68093
|
_setDefaultEngineFactory(
|
|
67839
68094
|
() => new ComputeEngine({ latexSyntax: new LatexSyntax() })
|
|
67840
68095
|
);
|
|
67841
68096
|
globalThis[/* @__PURE__ */ Symbol.for("io.cortexjs.compute-engine")] = {
|
|
67842
68097
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
67843
|
-
version: "0.55.
|
|
68098
|
+
version: "0.55.2"
|
|
67844
68099
|
};
|
|
67845
68100
|
export {
|
|
67846
68101
|
DEFINITIONS_ALGEBRA as ALGEBRA_DICTIONARY,
|