@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.
Files changed (256) hide show
  1. package/dist/compile.esm.js +1564 -1412
  2. package/dist/compile.min.esm.js +29 -29
  3. package/dist/compile.min.umd.cjs +29 -29
  4. package/dist/compile.umd.cjs +1564 -1412
  5. package/dist/compute-engine.esm.js +741 -486
  6. package/dist/compute-engine.min.esm.js +65 -65
  7. package/dist/compute-engine.min.umd.cjs +65 -65
  8. package/dist/compute-engine.umd.cjs +741 -486
  9. package/dist/core.esm.js +740 -485
  10. package/dist/core.min.esm.js +63 -63
  11. package/dist/core.min.umd.cjs +63 -63
  12. package/dist/core.umd.cjs +740 -485
  13. package/dist/interval.esm.js +1564 -1412
  14. package/dist/interval.min.esm.js +6 -6
  15. package/dist/interval.min.umd.cjs +6 -6
  16. package/dist/interval.umd.cjs +1564 -1412
  17. package/dist/latex-syntax.esm.js +673 -492
  18. package/dist/latex-syntax.min.esm.js +6 -6
  19. package/dist/latex-syntax.min.umd.cjs +6 -6
  20. package/dist/latex-syntax.umd.cjs +673 -492
  21. package/dist/math-json.esm.js +2 -2
  22. package/dist/math-json.min.esm.js +2 -2
  23. package/dist/math-json.min.umd.cjs +2 -2
  24. package/dist/math-json.umd.cjs +2 -2
  25. package/dist/numerics.esm.js +2 -2
  26. package/dist/numerics.min.esm.js +2 -2
  27. package/dist/numerics.min.umd.cjs +2 -2
  28. package/dist/numerics.umd.cjs +2 -2
  29. package/dist/types/big-decimal/big-decimal.d.ts +1 -1
  30. package/dist/types/big-decimal/index.d.ts +1 -1
  31. package/dist/types/big-decimal/transcendentals.d.ts +1 -1
  32. package/dist/types/big-decimal/utils.d.ts +1 -1
  33. package/dist/types/common/ansi-codes.d.ts +1 -1
  34. package/dist/types/common/configuration-change.d.ts +1 -1
  35. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  36. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  37. package/dist/types/common/interruptible.d.ts +1 -1
  38. package/dist/types/common/one-of.d.ts +1 -1
  39. package/dist/types/common/signals.d.ts +1 -1
  40. package/dist/types/common/type/ast-nodes.d.ts +1 -1
  41. package/dist/types/common/type/boxed-type.d.ts +1 -1
  42. package/dist/types/common/type/lexer.d.ts +1 -1
  43. package/dist/types/common/type/parse.d.ts +1 -1
  44. package/dist/types/common/type/parser.d.ts +1 -1
  45. package/dist/types/common/type/primitive.d.ts +1 -1
  46. package/dist/types/common/type/reduce.d.ts +1 -1
  47. package/dist/types/common/type/serialize.d.ts +1 -1
  48. package/dist/types/common/type/subtype.d.ts +1 -1
  49. package/dist/types/common/type/type-builder.d.ts +1 -1
  50. package/dist/types/common/type/types.d.ts +1 -1
  51. package/dist/types/common/type/utils.d.ts +1 -1
  52. package/dist/types/common/utils.d.ts +1 -1
  53. package/dist/types/compile.d.ts +1 -1
  54. package/dist/types/compute-engine/assume.d.ts +1 -1
  55. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
  56. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
  59. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  60. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  61. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
  66. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  68. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  69. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
  70. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
  71. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  72. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
  73. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  74. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  75. package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
  76. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  77. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  78. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  79. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  80. package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
  81. package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +1 -1
  82. package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
  83. package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +1 -1
  84. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  85. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  86. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  87. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  88. package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +1 -1
  89. package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
  90. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  91. package/dist/types/compute-engine/boxed-expression/predicates.d.ts +1 -1
  92. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  93. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  94. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  95. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  96. package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
  97. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  98. package/dist/types/compute-engine/boxed-expression/stochastic-equal.d.ts +1 -1
  99. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  100. package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +1 -1
  101. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  102. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  103. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  104. package/dist/types/compute-engine/compilation/base-compiler.d.ts +1 -1
  105. package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
  106. package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
  107. package/dist/types/compute-engine/compilation/gpu-target.d.ts +1 -1
  108. package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
  109. package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
  110. package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
  111. package/dist/types/compute-engine/compilation/types.d.ts +1 -1
  112. package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
  113. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  114. package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
  115. package/dist/types/compute-engine/engine-cache.d.ts +1 -1
  116. package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
  117. package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
  118. package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
  119. package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
  120. package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
  121. package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
  122. package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
  123. package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
  124. package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
  125. package/dist/types/compute-engine/engine-scope.d.ts +1 -1
  126. package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
  127. package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
  128. package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
  129. package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
  130. package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
  131. package/dist/types/compute-engine/free-functions.d.ts +1 -1
  132. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  133. package/dist/types/compute-engine/global-types.d.ts +1 -1
  134. package/dist/types/compute-engine/index.d.ts +1 -1
  135. package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
  136. package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
  137. package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
  138. package/dist/types/compute-engine/interval/index.d.ts +1 -1
  139. package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
  140. package/dist/types/compute-engine/interval/types.d.ts +1 -1
  141. package/dist/types/compute-engine/interval/util.d.ts +1 -1
  142. package/dist/types/compute-engine/latex-syntax/dictionary/default-dictionary.d.ts +1 -1
  143. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  144. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  145. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  146. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  147. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  148. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  149. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +3 -1
  150. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  151. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  152. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  153. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  154. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  155. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  156. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-units.d.ts +1 -1
  157. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  158. package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +1 -1
  159. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  160. package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
  161. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  162. package/dist/types/compute-engine/latex-syntax/parse.d.ts +11 -1
  163. package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
  164. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  165. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  166. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  167. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  168. package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
  169. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  170. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  171. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  172. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  173. package/dist/types/compute-engine/library/colors.d.ts +1 -1
  174. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  175. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  176. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  177. package/dist/types/compute-engine/library/core.d.ts +1 -1
  178. package/dist/types/compute-engine/library/fractals.d.ts +1 -1
  179. package/dist/types/compute-engine/library/library.d.ts +1 -1
  180. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  181. package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
  182. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  183. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  184. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  185. package/dist/types/compute-engine/library/quantity-arithmetic.d.ts +1 -1
  186. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  187. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  188. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  189. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  190. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  191. package/dist/types/compute-engine/library/type-handlers.d.ts +1 -1
  192. package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
  193. package/dist/types/compute-engine/library/units.d.ts +1 -1
  194. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  195. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  196. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  197. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  198. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  199. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  200. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  201. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  202. package/dist/types/compute-engine/numerics/linear-algebra.d.ts +1 -1
  203. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  204. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  205. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  206. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  207. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  208. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  209. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  210. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  211. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  212. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  213. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  214. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  215. package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
  216. package/dist/types/compute-engine/oeis.d.ts +1 -1
  217. package/dist/types/compute-engine/sequence.d.ts +1 -1
  218. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  219. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  220. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  221. package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
  222. package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
  223. package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
  224. package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
  225. package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
  226. package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
  227. package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
  228. package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
  229. package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
  230. package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
  231. package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
  232. package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
  233. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
  234. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  235. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
  236. package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
  237. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  238. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  239. package/dist/types/compute-engine/types-definitions.d.ts +1 -1
  240. package/dist/types/compute-engine/types-engine.d.ts +1 -1
  241. package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
  242. package/dist/types/compute-engine/types-expression.d.ts +1 -1
  243. package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
  244. package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
  245. package/dist/types/compute-engine/types-serialization.d.ts +1 -1
  246. package/dist/types/compute-engine/types.d.ts +1 -1
  247. package/dist/types/compute-engine.d.ts +1 -1
  248. package/dist/types/core.d.ts +1 -1
  249. package/dist/types/interval.d.ts +1 -1
  250. package/dist/types/latex-syntax.d.ts +2 -2
  251. package/dist/types/math-json/symbols.d.ts +1 -1
  252. package/dist/types/math-json/types.d.ts +1 -1
  253. package/dist/types/math-json/utils.d.ts +1 -1
  254. package/dist/types/math-json.d.ts +2 -2
  255. package/dist/types/numerics.d.ts +1 -1
  256. package/package.json +1 -1
package/dist/core.umd.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /** ComputeEngineCore 0.55.0 */
1
+ /** ComputeEngineCore 0.55.2 */
2
2
  (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComputeEngineCore = {}));})(this, (function (exports) { 'use strict';
3
3
  var ComputeEngineCore = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -9573,6 +9573,452 @@ var ComputeEngineCore = (() => {
9573
9573
  return expr2;
9574
9574
  }
9575
9575
 
9576
+ // src/compute-engine/latex-syntax/dictionary/definitions-logic.ts
9577
+ var DEFINITIONS_LOGIC = [
9578
+ // Constants
9579
+ {
9580
+ name: "True",
9581
+ kind: "symbol",
9582
+ latexTrigger: ["\\top"]
9583
+ // ⊤ U+22A4
9584
+ },
9585
+ {
9586
+ kind: "symbol",
9587
+ latexTrigger: "\\mathrm{True}",
9588
+ parse: "True"
9589
+ },
9590
+ {
9591
+ kind: "symbol",
9592
+ latexTrigger: "\\operatorname{True}",
9593
+ parse: "True"
9594
+ },
9595
+ {
9596
+ kind: "symbol",
9597
+ latexTrigger: "\\mathsf{T}",
9598
+ parse: "True"
9599
+ },
9600
+ {
9601
+ name: "False",
9602
+ kind: "symbol",
9603
+ latexTrigger: ["\\bot"]
9604
+ // ⊥ U+22A5
9605
+ },
9606
+ {
9607
+ kind: "symbol",
9608
+ latexTrigger: "\\operatorname{False}",
9609
+ parse: "False"
9610
+ },
9611
+ {
9612
+ kind: "symbol",
9613
+ latexTrigger: "\\mathsf{F}",
9614
+ parse: "False"
9615
+ },
9616
+ // Operators
9617
+ // Logic operators have lower precedence than comparisons (245)
9618
+ // so that `x = 1 \lor x = 2` parses as `(x = 1) \lor (x = 2)`
9619
+ // See https://github.com/cortex-js/compute-engine/issues/243
9620
+ {
9621
+ name: "And",
9622
+ kind: "infix",
9623
+ latexTrigger: ["\\land"],
9624
+ precedence: 235
9625
+ // serialize: '\\land',
9626
+ },
9627
+ { kind: "infix", latexTrigger: ["\\wedge"], parse: "And", precedence: 235 },
9628
+ { kind: "infix", latexTrigger: "\\&", parse: "And", precedence: 235 },
9629
+ {
9630
+ kind: "infix",
9631
+ latexTrigger: "\\operatorname{and}",
9632
+ parse: "And",
9633
+ precedence: 235
9634
+ },
9635
+ {
9636
+ name: "Or",
9637
+ kind: "infix",
9638
+ latexTrigger: ["\\lor"],
9639
+ precedence: 230
9640
+ },
9641
+ { kind: "infix", latexTrigger: ["\\vee"], parse: "Or", precedence: 230 },
9642
+ { kind: "infix", latexTrigger: "\\parallel", parse: "Or", precedence: 230 },
9643
+ {
9644
+ kind: "infix",
9645
+ latexTrigger: "\\operatorname{or}",
9646
+ parse: "Or",
9647
+ precedence: 230
9648
+ },
9649
+ {
9650
+ name: "Xor",
9651
+ kind: "infix",
9652
+ latexTrigger: ["\\veebar"],
9653
+ precedence: 232
9654
+ },
9655
+ // Possible alt: \oplus ⊕ U+2295
9656
+ {
9657
+ name: "Not",
9658
+ kind: "prefix",
9659
+ latexTrigger: ["\\lnot"],
9660
+ precedence: 880
9661
+ },
9662
+ {
9663
+ kind: "prefix",
9664
+ latexTrigger: ["\\neg"],
9665
+ parse: "Not",
9666
+ precedence: 880
9667
+ },
9668
+ {
9669
+ name: "Nand",
9670
+ kind: "infix",
9671
+ latexTrigger: ["\\barwedge"],
9672
+ precedence: 232
9673
+ // serialize: '\\mid',
9674
+ },
9675
+ {
9676
+ name: "Nor",
9677
+ kind: "infix",
9678
+ latexTrigger: ["\u22BD"],
9679
+ // bar vee
9680
+ precedence: 232
9681
+ // serialize: '\\downarrow',
9682
+ },
9683
+ // Functions
9684
+ {
9685
+ kind: "function",
9686
+ symbolTrigger: "and",
9687
+ parse: "And"
9688
+ },
9689
+ {
9690
+ kind: "function",
9691
+ symbolTrigger: "or",
9692
+ parse: "Or"
9693
+ },
9694
+ {
9695
+ kind: "function",
9696
+ symbolTrigger: "not",
9697
+ parse: "Not"
9698
+ },
9699
+ // Relations
9700
+ {
9701
+ name: "Implies",
9702
+ kind: "infix",
9703
+ precedence: 220,
9704
+ associativity: "right",
9705
+ latexTrigger: ["\\implies"],
9706
+ serialize: "\\implies"
9707
+ },
9708
+ {
9709
+ latexTrigger: ["\\Rightarrow"],
9710
+ kind: "infix",
9711
+ precedence: 220,
9712
+ associativity: "right",
9713
+ parse: "Implies"
9714
+ },
9715
+ {
9716
+ latexTrigger: ["\\rightarrow"],
9717
+ kind: "infix",
9718
+ precedence: 220,
9719
+ associativity: "right",
9720
+ parse: "Implies"
9721
+ },
9722
+ {
9723
+ latexTrigger: ["\\Longrightarrow"],
9724
+ kind: "infix",
9725
+ precedence: 220,
9726
+ associativity: "right",
9727
+ parse: "Implies"
9728
+ },
9729
+ {
9730
+ latexTrigger: ["\\longrightarrow"],
9731
+ kind: "infix",
9732
+ precedence: 220,
9733
+ associativity: "right",
9734
+ parse: "Implies"
9735
+ },
9736
+ {
9737
+ // Non-strict mode: => for implies
9738
+ latexTrigger: ["=", ">"],
9739
+ kind: "infix",
9740
+ precedence: 220,
9741
+ associativity: "right",
9742
+ parse: (parser, lhs, until) => {
9743
+ if (parser.options.strict !== false) return null;
9744
+ const rhs = parser.parseExpression({ ...until, minPrec: 220 });
9745
+ if (rhs === null) return null;
9746
+ return ["Implies", lhs, rhs];
9747
+ }
9748
+ },
9749
+ {
9750
+ name: "Equivalent",
9751
+ // MathML: identical to, Mathematica: Congruent
9752
+ latexTrigger: ["\\iff"],
9753
+ kind: "infix",
9754
+ associativity: "right",
9755
+ precedence: 219
9756
+ },
9757
+ {
9758
+ latexTrigger: ["\\Leftrightarrow"],
9759
+ kind: "infix",
9760
+ associativity: "right",
9761
+ precedence: 219,
9762
+ parse: "Equivalent"
9763
+ },
9764
+ {
9765
+ latexTrigger: ["\\leftrightarrow"],
9766
+ kind: "infix",
9767
+ associativity: "right",
9768
+ precedence: 219,
9769
+ parse: "Equivalent"
9770
+ },
9771
+ {
9772
+ latexTrigger: ["\\Longleftrightarrow"],
9773
+ kind: "infix",
9774
+ associativity: "right",
9775
+ precedence: 219,
9776
+ parse: "Equivalent"
9777
+ },
9778
+ {
9779
+ latexTrigger: ["\\longleftrightarrow"],
9780
+ kind: "infix",
9781
+ associativity: "right",
9782
+ precedence: 219,
9783
+ parse: "Equivalent"
9784
+ },
9785
+ {
9786
+ // Non-strict mode: <=> for equivalence
9787
+ latexTrigger: ["<", "=", ">"],
9788
+ kind: "infix",
9789
+ precedence: 219,
9790
+ associativity: "right",
9791
+ parse: (parser, lhs, until) => {
9792
+ if (parser.options.strict !== false) return null;
9793
+ const rhs = parser.parseExpression({ ...until, minPrec: 219 });
9794
+ if (rhs === null) return null;
9795
+ return ["Equivalent", lhs, rhs];
9796
+ }
9797
+ },
9798
+ {
9799
+ latexTrigger: ["\\equiv"],
9800
+ kind: "infix",
9801
+ associativity: "right",
9802
+ precedence: 219,
9803
+ parse: (parser, lhs, terminator) => {
9804
+ const rhs = parser.parseExpression({ ...terminator, minPrec: 219 });
9805
+ const index = parser.index;
9806
+ const modulus = parser.parseExpression({ ...terminator, minPrec: 219 });
9807
+ if (modulus !== null && operator(modulus) === "Mod")
9808
+ return ["Congruent", lhs, rhs, missingIfEmpty(operand(modulus, 1))];
9809
+ parser.index = index;
9810
+ return ["Equivalent", lhs, missingIfEmpty(rhs)];
9811
+ }
9812
+ },
9813
+ {
9814
+ name: "Proves",
9815
+ kind: "infix",
9816
+ latexTrigger: ["\\vdash"],
9817
+ precedence: 220,
9818
+ associativity: "right",
9819
+ serialize: "\\vdash"
9820
+ },
9821
+ {
9822
+ name: "Entails",
9823
+ kind: "infix",
9824
+ latexTrigger: ["\\vDash"],
9825
+ precedence: 220,
9826
+ associativity: "right",
9827
+ serialize: "\\vDash"
9828
+ },
9829
+ {
9830
+ name: "Satisfies",
9831
+ kind: "infix",
9832
+ latexTrigger: ["\\models"],
9833
+ precedence: 220,
9834
+ associativity: "right",
9835
+ serialize: "\\models"
9836
+ },
9837
+ // Quantifiers: for all, exists
9838
+ {
9839
+ name: "ForAll",
9840
+ kind: "prefix",
9841
+ latexTrigger: ["\\forall"],
9842
+ precedence: 200,
9843
+ // Has to be lower than COMPARISON_PRECEDENCE
9844
+ serialize: serializeQuantifier("\\forall"),
9845
+ parse: parseQuantifier("ForAll")
9846
+ },
9847
+ {
9848
+ name: "Exists",
9849
+ kind: "prefix",
9850
+ latexTrigger: ["\\exists"],
9851
+ precedence: 200,
9852
+ // Has to be lower than COMPARISON_PRECEDENCE,
9853
+ serialize: serializeQuantifier("\\exists"),
9854
+ parse: parseQuantifier("Exists")
9855
+ },
9856
+ {
9857
+ name: "ExistsUnique",
9858
+ kind: "prefix",
9859
+ latexTrigger: ["\\exists", "!"],
9860
+ precedence: 200,
9861
+ // Has to be lower than COMPARISON_PRECEDENCE,
9862
+ serialize: serializeQuantifier("\\exists!"),
9863
+ parse: parseQuantifier("ExistsUnique")
9864
+ },
9865
+ {
9866
+ name: "NotForAll",
9867
+ kind: "prefix",
9868
+ latexTrigger: ["\\lnot", "\\forall"],
9869
+ precedence: 200,
9870
+ // Has to be lower than COMPARISON_PRECEDENCE
9871
+ serialize: serializeQuantifier("\\lnot\\forall"),
9872
+ parse: parseQuantifier("NotForAll")
9873
+ },
9874
+ {
9875
+ name: "NotExists",
9876
+ kind: "prefix",
9877
+ latexTrigger: ["\\lnot", "\\exists"],
9878
+ precedence: 200,
9879
+ // Has to be lower than COMPARISON_PRECEDENCE,
9880
+ serialize: serializeQuantifier("\\lnot\\exists"),
9881
+ parse: parseQuantifier("NotExists")
9882
+ },
9883
+ {
9884
+ name: "KroneckerDelta",
9885
+ kind: "prefix",
9886
+ latexTrigger: ["\\delta", "_"],
9887
+ precedence: 200,
9888
+ serialize: (serializer, expr2) => {
9889
+ const args = operands(expr2);
9890
+ if (args.length === 0) return "\\delta";
9891
+ if (args.every((x) => symbol(x)))
9892
+ return `\\delta_{${args.map((arg) => serializer.serialize(arg)).join("")}}`;
9893
+ return `\\delta_{${args.map((arg) => serializer.serialize(arg)).join(", ")}}`;
9894
+ },
9895
+ parse: (parser) => {
9896
+ const group = parser.parseGroup();
9897
+ if (group === null) {
9898
+ const token = parser.parseToken();
9899
+ if (!token) return null;
9900
+ return ["KroneckerDelta", token];
9901
+ }
9902
+ const seq = getSequence(group);
9903
+ if (seq && seq.length <= 2) return ["KroneckerDelta", ...seq];
9904
+ if (operator(group) === "InvisibleOperator")
9905
+ return ["KroneckerDelta", ...operands(group)];
9906
+ if (group !== null) return ["KroneckerDelta", group];
9907
+ return null;
9908
+ }
9909
+ },
9910
+ // Iverson brackets. Also called the "indicator function"
9911
+ // Must have a single argument, a relational expression, i.e.
9912
+ // `[ a = b ]` or `[ x \leq 0 ]`
9913
+ // Otherwise, it gets rejected, it could be something else, like a list or
9914
+ // tuple.
9915
+ {
9916
+ name: "Boole",
9917
+ kind: "matchfix",
9918
+ openTrigger: "[",
9919
+ closeTrigger: "]",
9920
+ // serialize: (serializer: Serializer, expr: MathJsonExpression) => {
9921
+ // const args = ops(expr);
9922
+ // return `[${serializer.serialize(arg)}]`;
9923
+ // },
9924
+ parse: (_parser, body) => {
9925
+ const h = operator(body);
9926
+ if (!h) return null;
9927
+ if (!DEFINITIONS_INEQUALITIES.some((x) => x.name === h)) return null;
9928
+ return ["Boole", body];
9929
+ }
9930
+ },
9931
+ {
9932
+ kind: "matchfix",
9933
+ openTrigger: "\\llbracket",
9934
+ closeTrigger: "\\rrbracket",
9935
+ parse: (_parser, body) => {
9936
+ const h = operator(body);
9937
+ if (!h) return null;
9938
+ if (!DEFINITIONS_INEQUALITIES.some((x) => x.name === h)) return null;
9939
+ return ["Boole", body];
9940
+ }
9941
+ },
9942
+ // Predicate application in First-Order Logic.
9943
+ // ["Predicate", "P", "x", "y"] serializes to "P(x, y)"
9944
+ {
9945
+ name: "Predicate",
9946
+ serialize: (serializer, expr2) => {
9947
+ const args = operands(expr2);
9948
+ if (args.length === 0) return "";
9949
+ const pred = args[0];
9950
+ const predStr = typeof pred === "string" ? pred : serializer.serialize(pred);
9951
+ if (args.length === 1) return predStr;
9952
+ const argStrs = args.slice(1).map((arg) => serializer.serialize(arg));
9953
+ return `${predStr}(${argStrs.join(", ")})`;
9954
+ }
9955
+ }
9956
+ ];
9957
+ function serializeQuantifier(quantifierSymbol) {
9958
+ return (serializer, expr2) => {
9959
+ const args = operands(expr2);
9960
+ if (args.length === 0) return quantifierSymbol;
9961
+ if (args.length === 1)
9962
+ return `${quantifierSymbol} ${serializer.serialize(args[0])}`;
9963
+ const boundVar = serializer.serialize(args[0]);
9964
+ const body = serializer.serialize(args[1]);
9965
+ return `${quantifierSymbol} ${boundVar}, ${body}`;
9966
+ };
9967
+ }
9968
+ function tightBindingCondition(p, terminator) {
9969
+ 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);
9970
+ }
9971
+ function parseQuantifier(kind) {
9972
+ return (parser, terminator) => {
9973
+ const index = parser.index;
9974
+ const useTightBinding = parser.options.quantifierScope !== "loose";
9975
+ const symbol2 = parser.parseSymbol(terminator);
9976
+ if (symbol2) {
9977
+ parser.skipSpace();
9978
+ if (parser.match(",") || parser.match("\\mid") || parser.match(".") || parser.match(":") || parser.match("\\colon")) {
9979
+ const bodyTerminator = useTightBinding ? {
9980
+ ...terminator,
9981
+ condition: (p) => tightBindingCondition(p, terminator)
9982
+ } : terminator;
9983
+ parser.enterQuantifierScope();
9984
+ const body2 = parser.parseExpression(bodyTerminator);
9985
+ parser.exitQuantifierScope();
9986
+ return [kind, symbol2, missingIfEmpty(body2)];
9987
+ }
9988
+ parser.enterQuantifierScope();
9989
+ const body = parser.parseEnclosure();
9990
+ parser.exitQuantifierScope();
9991
+ if (body) return [kind, symbol2, missingIfEmpty(body)];
9992
+ }
9993
+ parser.index = index;
9994
+ const condTerminator = {
9995
+ ...terminator,
9996
+ condition: (p) => p.peek === ":" || p.peek === "\\colon" || (terminator.condition?.(p) ?? false)
9997
+ };
9998
+ const condition = parser.parseExpression(condTerminator);
9999
+ if (condition === null) return null;
10000
+ parser.skipSpace();
10001
+ if (parser.matchAny([",", "\\mid", ":", "\\colon"])) {
10002
+ const bodyTerminator = useTightBinding ? {
10003
+ ...terminator,
10004
+ condition: (p) => tightBindingCondition(p, terminator)
10005
+ } : terminator;
10006
+ parser.enterQuantifierScope();
10007
+ const body = parser.parseExpression(bodyTerminator);
10008
+ parser.exitQuantifierScope();
10009
+ return [kind, condition, missingIfEmpty(body)];
10010
+ }
10011
+ if (parser.match("(")) {
10012
+ parser.enterQuantifierScope();
10013
+ const body = parser.parseExpression(terminator);
10014
+ parser.exitQuantifierScope();
10015
+ if (!parser.match(")")) return null;
10016
+ return [kind, condition, missingIfEmpty(body)];
10017
+ }
10018
+ return null;
10019
+ };
10020
+ }
10021
+
9576
10022
  // src/compute-engine/latex-syntax/dictionary/definitions-core.ts
9577
10023
  function parseSequence(parser, terminator, lhs, prec, sep) {
9578
10024
  if (terminator && terminator.minPrec >= prec) return null;
@@ -10183,6 +10629,120 @@ var ComputeEngineCore = (() => {
10183
10629
  precedence: 21,
10184
10630
  parse: (parser, lhs, until) => parseWhereExpression(parser, lhs, until)
10185
10631
  },
10632
+ // \text{and} — logical conjunction infix
10633
+ {
10634
+ latexTrigger: ["\\text"],
10635
+ kind: "infix",
10636
+ associativity: "right",
10637
+ precedence: 235,
10638
+ // Same as \land
10639
+ parse: (parser, lhs, until) => {
10640
+ const start = parser.index;
10641
+ if (!matchTextKeyword(parser, "and")) {
10642
+ parser.index = start;
10643
+ return null;
10644
+ }
10645
+ const rhs = parser.parseExpression({ ...until, minPrec: 235 });
10646
+ return ["And", lhs, rhs ?? "Nothing"];
10647
+ }
10648
+ },
10649
+ // \text{or} — logical disjunction infix
10650
+ {
10651
+ latexTrigger: ["\\text"],
10652
+ kind: "infix",
10653
+ associativity: "right",
10654
+ precedence: 230,
10655
+ // Same as \lor
10656
+ parse: (parser, lhs, until) => {
10657
+ const start = parser.index;
10658
+ if (!matchTextKeyword(parser, "or")) {
10659
+ parser.index = start;
10660
+ return null;
10661
+ }
10662
+ const rhs = parser.parseExpression({ ...until, minPrec: 230 });
10663
+ return ["Or", lhs, rhs ?? "Nothing"];
10664
+ }
10665
+ },
10666
+ // \text{iff} — biconditional (if and only if)
10667
+ {
10668
+ latexTrigger: ["\\text"],
10669
+ kind: "infix",
10670
+ associativity: "right",
10671
+ precedence: 219,
10672
+ // Same as \iff
10673
+ parse: (parser, lhs, until) => {
10674
+ const start = parser.index;
10675
+ if (!matchTextKeyword(parser, "iff")) {
10676
+ parser.index = start;
10677
+ return null;
10678
+ }
10679
+ const rhs = parser.parseExpression({ ...until, minPrec: 219 });
10680
+ return ["Equivalent", lhs, rhs ?? "Nothing"];
10681
+ }
10682
+ },
10683
+ // \text{if and only if} — verbose biconditional
10684
+ {
10685
+ latexTrigger: ["\\text"],
10686
+ kind: "infix",
10687
+ associativity: "right",
10688
+ precedence: 219,
10689
+ parse: (parser, lhs, until) => {
10690
+ const start = parser.index;
10691
+ if (!matchTextKeyword(parser, "if and only if")) {
10692
+ parser.index = start;
10693
+ return null;
10694
+ }
10695
+ const rhs = parser.parseExpression({ ...until, minPrec: 219 });
10696
+ return ["Equivalent", lhs, rhs ?? "Nothing"];
10697
+ }
10698
+ },
10699
+ // \text{such that} — constraint separator (like : in set-builder notation)
10700
+ {
10701
+ latexTrigger: ["\\text"],
10702
+ kind: "infix",
10703
+ associativity: "right",
10704
+ precedence: 21,
10705
+ // Low precedence to capture full condition (same as 'where')
10706
+ parse: (parser, lhs, until) => {
10707
+ const start = parser.index;
10708
+ if (!matchTextKeyword(parser, "such that")) {
10709
+ parser.index = start;
10710
+ return null;
10711
+ }
10712
+ const rhs = parser.parseExpression({ ...until, minPrec: 21 });
10713
+ return ["Colon", lhs, rhs ?? "Nothing"];
10714
+ }
10715
+ },
10716
+ // \text{for all} — universal quantifier
10717
+ {
10718
+ latexTrigger: ["\\text"],
10719
+ kind: "prefix",
10720
+ precedence: 200,
10721
+ // Same as \forall
10722
+ parse: (parser, until) => {
10723
+ const start = parser.index;
10724
+ if (!matchTextKeyword(parser, "for all")) {
10725
+ parser.index = start;
10726
+ return null;
10727
+ }
10728
+ return parseQuantifier("ForAll")(parser, until);
10729
+ }
10730
+ },
10731
+ // \text{there exists} — existential quantifier
10732
+ {
10733
+ latexTrigger: ["\\text"],
10734
+ kind: "prefix",
10735
+ precedence: 200,
10736
+ // Same as \exists
10737
+ parse: (parser, until) => {
10738
+ const start = parser.index;
10739
+ if (!matchTextKeyword(parser, "there exists")) {
10740
+ parser.index = start;
10741
+ return null;
10742
+ }
10743
+ return parseQuantifier("Exists")(parser, until);
10744
+ }
10745
+ },
10186
10746
  // Block serializer — used by both `where` and semicolon blocks
10187
10747
  {
10188
10748
  name: "Block",
@@ -10298,6 +10858,39 @@ var ComputeEngineCore = (() => {
10298
10858
  parser.parseExpression(until) ?? "Nothing"
10299
10859
  ]
10300
10860
  },
10861
+ // Text serializer — reconstructs \text{...} with inline $...$ for math
10862
+ {
10863
+ name: "Text",
10864
+ serialize: (serializer, expr2) => {
10865
+ const args = operands(expr2);
10866
+ if (args.length === 0) return "";
10867
+ let firstStr = -1;
10868
+ let lastStr = -1;
10869
+ for (let i = 0; i < args.length; i++) {
10870
+ if (stringValue(args[i]) !== null) {
10871
+ if (firstStr < 0) firstStr = i;
10872
+ lastStr = i;
10873
+ }
10874
+ }
10875
+ if (firstStr < 0)
10876
+ return joinLatex(args.map((a) => serializer.serialize(a)));
10877
+ const parts = [];
10878
+ for (let i = 0; i < firstStr; i++)
10879
+ parts.push(serializer.serialize(args[i]));
10880
+ let textContent = "";
10881
+ for (let i = firstStr; i <= lastStr; i++) {
10882
+ const s = stringValue(args[i]);
10883
+ if (s !== null) textContent += sanitizeLatex(s);
10884
+ else if (operator(args[i]) === "Annotated" || operator(args[i]) === "Text")
10885
+ textContent += serializer.serialize(args[i]);
10886
+ else textContent += "$" + serializer.serialize(args[i]) + "$";
10887
+ }
10888
+ parts.push("\\text{" + textContent + "}");
10889
+ for (let i = lastStr + 1; i < args.length; i++)
10890
+ parts.push(serializer.serialize(args[i]));
10891
+ return joinLatex(parts);
10892
+ }
10893
+ },
10301
10894
  {
10302
10895
  name: "String",
10303
10896
  latexTrigger: ["\\text"],
@@ -10688,9 +11281,10 @@ var ComputeEngineCore = (() => {
10688
11281
  } else if (parser.match("\\textcolor")) {
10689
11282
  const pos = parser.index;
10690
11283
  const color = parser.parseStringGroup();
10691
- const body2 = parser.parseExpression();
10692
- if (color !== null && body2 !== null) {
10693
- runs.push(["Annotated", body2, { dict: { color } }]);
11284
+ if (color !== null) {
11285
+ flush();
11286
+ const body2 = parseTextRun(parser);
11287
+ runs.push(["Annotated", body2, dictionaryFromEntries({ color })]);
10694
11288
  } else {
10695
11289
  parser.index = pos;
10696
11290
  text += "\\textcolor";
@@ -10708,6 +11302,7 @@ var ComputeEngineCore = (() => {
10708
11302
  const expr2 = parser.parseExpression() ?? "Nothing";
10709
11303
  parser.skipSpace();
10710
11304
  if (parser.match("<$>")) {
11305
+ flush();
10711
11306
  runs.push(expr2);
10712
11307
  } else {
10713
11308
  text += "$";
@@ -10718,6 +11313,7 @@ var ComputeEngineCore = (() => {
10718
11313
  const expr2 = parser.parseExpression() ?? "Nothing";
10719
11314
  parser.skipSpace();
10720
11315
  if (parser.match("<$$>")) {
11316
+ flush();
10721
11317
  runs.push(expr2);
10722
11318
  } else {
10723
11319
  text += "$$";
@@ -11068,14 +11664,20 @@ var ComputeEngineCore = (() => {
11068
11664
  }
11069
11665
  while (parser.match("<space>")) {
11070
11666
  }
11071
- let text = "";
11072
- while (!parser.atEnd && parser.peek !== "<}>" && parser.peek !== "<space>") {
11073
- const tok = parser.peek;
11074
- if (/^[a-zA-Z]$/.test(tok)) {
11075
- text += tok;
11076
- parser.nextToken();
11667
+ for (let i = 0; i < keyword.length; i++) {
11668
+ if (keyword[i] === " ") {
11669
+ if (!parser.match("<space>")) {
11670
+ parser.index = start;
11671
+ return false;
11672
+ }
11673
+ while (parser.match("<space>")) {
11674
+ }
11077
11675
  } else {
11078
- break;
11676
+ if (parser.peek !== keyword[i]) {
11677
+ parser.index = start;
11678
+ return false;
11679
+ }
11680
+ parser.nextToken();
11079
11681
  }
11080
11682
  }
11081
11683
  while (parser.match("<space>")) {
@@ -11084,10 +11686,6 @@ var ComputeEngineCore = (() => {
11084
11686
  parser.index = start;
11085
11687
  return false;
11086
11688
  }
11087
- if (text !== keyword) {
11088
- parser.index = start;
11089
- return false;
11090
- }
11091
11689
  return true;
11092
11690
  }
11093
11691
  function matchKeyword(parser, keyword) {
@@ -11365,452 +11963,6 @@ var ComputeEngineCore = (() => {
11365
11963
  }
11366
11964
  ];
11367
11965
 
11368
- // src/compute-engine/latex-syntax/dictionary/definitions-logic.ts
11369
- var DEFINITIONS_LOGIC = [
11370
- // Constants
11371
- {
11372
- name: "True",
11373
- kind: "symbol",
11374
- latexTrigger: ["\\top"]
11375
- // ⊤ U+22A4
11376
- },
11377
- {
11378
- kind: "symbol",
11379
- latexTrigger: "\\mathrm{True}",
11380
- parse: "True"
11381
- },
11382
- {
11383
- kind: "symbol",
11384
- latexTrigger: "\\operatorname{True}",
11385
- parse: "True"
11386
- },
11387
- {
11388
- kind: "symbol",
11389
- latexTrigger: "\\mathsf{T}",
11390
- parse: "True"
11391
- },
11392
- {
11393
- name: "False",
11394
- kind: "symbol",
11395
- latexTrigger: ["\\bot"]
11396
- // ⊥ U+22A5
11397
- },
11398
- {
11399
- kind: "symbol",
11400
- latexTrigger: "\\operatorname{False}",
11401
- parse: "False"
11402
- },
11403
- {
11404
- kind: "symbol",
11405
- latexTrigger: "\\mathsf{F}",
11406
- parse: "False"
11407
- },
11408
- // Operators
11409
- // Logic operators have lower precedence than comparisons (245)
11410
- // so that `x = 1 \lor x = 2` parses as `(x = 1) \lor (x = 2)`
11411
- // See https://github.com/cortex-js/compute-engine/issues/243
11412
- {
11413
- name: "And",
11414
- kind: "infix",
11415
- latexTrigger: ["\\land"],
11416
- precedence: 235
11417
- // serialize: '\\land',
11418
- },
11419
- { kind: "infix", latexTrigger: ["\\wedge"], parse: "And", precedence: 235 },
11420
- { kind: "infix", latexTrigger: "\\&", parse: "And", precedence: 235 },
11421
- {
11422
- kind: "infix",
11423
- latexTrigger: "\\operatorname{and}",
11424
- parse: "And",
11425
- precedence: 235
11426
- },
11427
- {
11428
- name: "Or",
11429
- kind: "infix",
11430
- latexTrigger: ["\\lor"],
11431
- precedence: 230
11432
- },
11433
- { kind: "infix", latexTrigger: ["\\vee"], parse: "Or", precedence: 230 },
11434
- { kind: "infix", latexTrigger: "\\parallel", parse: "Or", precedence: 230 },
11435
- {
11436
- kind: "infix",
11437
- latexTrigger: "\\operatorname{or}",
11438
- parse: "Or",
11439
- precedence: 230
11440
- },
11441
- {
11442
- name: "Xor",
11443
- kind: "infix",
11444
- latexTrigger: ["\\veebar"],
11445
- precedence: 232
11446
- },
11447
- // Possible alt: \oplus ⊕ U+2295
11448
- {
11449
- name: "Not",
11450
- kind: "prefix",
11451
- latexTrigger: ["\\lnot"],
11452
- precedence: 880
11453
- },
11454
- {
11455
- kind: "prefix",
11456
- latexTrigger: ["\\neg"],
11457
- parse: "Not",
11458
- precedence: 880
11459
- },
11460
- {
11461
- name: "Nand",
11462
- kind: "infix",
11463
- latexTrigger: ["\\barwedge"],
11464
- precedence: 232
11465
- // serialize: '\\mid',
11466
- },
11467
- {
11468
- name: "Nor",
11469
- kind: "infix",
11470
- latexTrigger: ["\u22BD"],
11471
- // bar vee
11472
- precedence: 232
11473
- // serialize: '\\downarrow',
11474
- },
11475
- // Functions
11476
- {
11477
- kind: "function",
11478
- symbolTrigger: "and",
11479
- parse: "And"
11480
- },
11481
- {
11482
- kind: "function",
11483
- symbolTrigger: "or",
11484
- parse: "Or"
11485
- },
11486
- {
11487
- kind: "function",
11488
- symbolTrigger: "not",
11489
- parse: "Not"
11490
- },
11491
- // Relations
11492
- {
11493
- name: "Implies",
11494
- kind: "infix",
11495
- precedence: 220,
11496
- associativity: "right",
11497
- latexTrigger: ["\\implies"],
11498
- serialize: "\\implies"
11499
- },
11500
- {
11501
- latexTrigger: ["\\Rightarrow"],
11502
- kind: "infix",
11503
- precedence: 220,
11504
- associativity: "right",
11505
- parse: "Implies"
11506
- },
11507
- {
11508
- latexTrigger: ["\\rightarrow"],
11509
- kind: "infix",
11510
- precedence: 220,
11511
- associativity: "right",
11512
- parse: "Implies"
11513
- },
11514
- {
11515
- latexTrigger: ["\\Longrightarrow"],
11516
- kind: "infix",
11517
- precedence: 220,
11518
- associativity: "right",
11519
- parse: "Implies"
11520
- },
11521
- {
11522
- latexTrigger: ["\\longrightarrow"],
11523
- kind: "infix",
11524
- precedence: 220,
11525
- associativity: "right",
11526
- parse: "Implies"
11527
- },
11528
- {
11529
- // Non-strict mode: => for implies
11530
- latexTrigger: ["=", ">"],
11531
- kind: "infix",
11532
- precedence: 220,
11533
- associativity: "right",
11534
- parse: (parser, lhs, until) => {
11535
- if (parser.options.strict !== false) return null;
11536
- const rhs = parser.parseExpression({ ...until, minPrec: 220 });
11537
- if (rhs === null) return null;
11538
- return ["Implies", lhs, rhs];
11539
- }
11540
- },
11541
- {
11542
- name: "Equivalent",
11543
- // MathML: identical to, Mathematica: Congruent
11544
- latexTrigger: ["\\iff"],
11545
- kind: "infix",
11546
- associativity: "right",
11547
- precedence: 219
11548
- },
11549
- {
11550
- latexTrigger: ["\\Leftrightarrow"],
11551
- kind: "infix",
11552
- associativity: "right",
11553
- precedence: 219,
11554
- parse: "Equivalent"
11555
- },
11556
- {
11557
- latexTrigger: ["\\leftrightarrow"],
11558
- kind: "infix",
11559
- associativity: "right",
11560
- precedence: 219,
11561
- parse: "Equivalent"
11562
- },
11563
- {
11564
- latexTrigger: ["\\Longleftrightarrow"],
11565
- kind: "infix",
11566
- associativity: "right",
11567
- precedence: 219,
11568
- parse: "Equivalent"
11569
- },
11570
- {
11571
- latexTrigger: ["\\longleftrightarrow"],
11572
- kind: "infix",
11573
- associativity: "right",
11574
- precedence: 219,
11575
- parse: "Equivalent"
11576
- },
11577
- {
11578
- // Non-strict mode: <=> for equivalence
11579
- latexTrigger: ["<", "=", ">"],
11580
- kind: "infix",
11581
- precedence: 219,
11582
- associativity: "right",
11583
- parse: (parser, lhs, until) => {
11584
- if (parser.options.strict !== false) return null;
11585
- const rhs = parser.parseExpression({ ...until, minPrec: 219 });
11586
- if (rhs === null) return null;
11587
- return ["Equivalent", lhs, rhs];
11588
- }
11589
- },
11590
- {
11591
- latexTrigger: ["\\equiv"],
11592
- kind: "infix",
11593
- associativity: "right",
11594
- precedence: 219,
11595
- parse: (parser, lhs, terminator) => {
11596
- const rhs = parser.parseExpression({ ...terminator, minPrec: 219 });
11597
- const index = parser.index;
11598
- const modulus = parser.parseExpression({ ...terminator, minPrec: 219 });
11599
- if (modulus !== null && operator(modulus) === "Mod")
11600
- return ["Congruent", lhs, rhs, missingIfEmpty(operand(modulus, 1))];
11601
- parser.index = index;
11602
- return ["Equivalent", lhs, missingIfEmpty(rhs)];
11603
- }
11604
- },
11605
- {
11606
- name: "Proves",
11607
- kind: "infix",
11608
- latexTrigger: ["\\vdash"],
11609
- precedence: 220,
11610
- associativity: "right",
11611
- serialize: "\\vdash"
11612
- },
11613
- {
11614
- name: "Entails",
11615
- kind: "infix",
11616
- latexTrigger: ["\\vDash"],
11617
- precedence: 220,
11618
- associativity: "right",
11619
- serialize: "\\vDash"
11620
- },
11621
- {
11622
- name: "Satisfies",
11623
- kind: "infix",
11624
- latexTrigger: ["\\models"],
11625
- precedence: 220,
11626
- associativity: "right",
11627
- serialize: "\\models"
11628
- },
11629
- // Quantifiers: for all, exists
11630
- {
11631
- name: "ForAll",
11632
- kind: "prefix",
11633
- latexTrigger: ["\\forall"],
11634
- precedence: 200,
11635
- // Has to be lower than COMPARISON_PRECEDENCE
11636
- serialize: serializeQuantifier("\\forall"),
11637
- parse: parseQuantifier("ForAll")
11638
- },
11639
- {
11640
- name: "Exists",
11641
- kind: "prefix",
11642
- latexTrigger: ["\\exists"],
11643
- precedence: 200,
11644
- // Has to be lower than COMPARISON_PRECEDENCE,
11645
- serialize: serializeQuantifier("\\exists"),
11646
- parse: parseQuantifier("Exists")
11647
- },
11648
- {
11649
- name: "ExistsUnique",
11650
- kind: "prefix",
11651
- latexTrigger: ["\\exists", "!"],
11652
- precedence: 200,
11653
- // Has to be lower than COMPARISON_PRECEDENCE,
11654
- serialize: serializeQuantifier("\\exists!"),
11655
- parse: parseQuantifier("ExistsUnique")
11656
- },
11657
- {
11658
- name: "NotForAll",
11659
- kind: "prefix",
11660
- latexTrigger: ["\\lnot", "\\forall"],
11661
- precedence: 200,
11662
- // Has to be lower than COMPARISON_PRECEDENCE
11663
- serialize: serializeQuantifier("\\lnot\\forall"),
11664
- parse: parseQuantifier("NotForAll")
11665
- },
11666
- {
11667
- name: "NotExists",
11668
- kind: "prefix",
11669
- latexTrigger: ["\\lnot", "\\exists"],
11670
- precedence: 200,
11671
- // Has to be lower than COMPARISON_PRECEDENCE,
11672
- serialize: serializeQuantifier("\\lnot\\exists"),
11673
- parse: parseQuantifier("NotExists")
11674
- },
11675
- {
11676
- name: "KroneckerDelta",
11677
- kind: "prefix",
11678
- latexTrigger: ["\\delta", "_"],
11679
- precedence: 200,
11680
- serialize: (serializer, expr2) => {
11681
- const args = operands(expr2);
11682
- if (args.length === 0) return "\\delta";
11683
- if (args.every((x) => symbol(x)))
11684
- return `\\delta_{${args.map((arg) => serializer.serialize(arg)).join("")}}`;
11685
- return `\\delta_{${args.map((arg) => serializer.serialize(arg)).join(", ")}}`;
11686
- },
11687
- parse: (parser) => {
11688
- const group = parser.parseGroup();
11689
- if (group === null) {
11690
- const token = parser.parseToken();
11691
- if (!token) return null;
11692
- return ["KroneckerDelta", token];
11693
- }
11694
- const seq = getSequence(group);
11695
- if (seq && seq.length <= 2) return ["KroneckerDelta", ...seq];
11696
- if (operator(group) === "InvisibleOperator")
11697
- return ["KroneckerDelta", ...operands(group)];
11698
- if (group !== null) return ["KroneckerDelta", group];
11699
- return null;
11700
- }
11701
- },
11702
- // Iverson brackets. Also called the "indicator function"
11703
- // Must have a single argument, a relational expression, i.e.
11704
- // `[ a = b ]` or `[ x \leq 0 ]`
11705
- // Otherwise, it gets rejected, it could be something else, like a list or
11706
- // tuple.
11707
- {
11708
- name: "Boole",
11709
- kind: "matchfix",
11710
- openTrigger: "[",
11711
- closeTrigger: "]",
11712
- // serialize: (serializer: Serializer, expr: MathJsonExpression) => {
11713
- // const args = ops(expr);
11714
- // return `[${serializer.serialize(arg)}]`;
11715
- // },
11716
- parse: (_parser, body) => {
11717
- const h = operator(body);
11718
- if (!h) return null;
11719
- if (!DEFINITIONS_INEQUALITIES.some((x) => x.name === h)) return null;
11720
- return ["Boole", body];
11721
- }
11722
- },
11723
- {
11724
- kind: "matchfix",
11725
- openTrigger: "\\llbracket",
11726
- closeTrigger: "\\rrbracket",
11727
- parse: (_parser, body) => {
11728
- const h = operator(body);
11729
- if (!h) return null;
11730
- if (!DEFINITIONS_INEQUALITIES.some((x) => x.name === h)) return null;
11731
- return ["Boole", body];
11732
- }
11733
- },
11734
- // Predicate application in First-Order Logic.
11735
- // ["Predicate", "P", "x", "y"] serializes to "P(x, y)"
11736
- {
11737
- name: "Predicate",
11738
- serialize: (serializer, expr2) => {
11739
- const args = operands(expr2);
11740
- if (args.length === 0) return "";
11741
- const pred = args[0];
11742
- const predStr = typeof pred === "string" ? pred : serializer.serialize(pred);
11743
- if (args.length === 1) return predStr;
11744
- const argStrs = args.slice(1).map((arg) => serializer.serialize(arg));
11745
- return `${predStr}(${argStrs.join(", ")})`;
11746
- }
11747
- }
11748
- ];
11749
- function serializeQuantifier(quantifierSymbol) {
11750
- return (serializer, expr2) => {
11751
- const args = operands(expr2);
11752
- if (args.length === 0) return quantifierSymbol;
11753
- if (args.length === 1)
11754
- return `${quantifierSymbol} ${serializer.serialize(args[0])}`;
11755
- const boundVar = serializer.serialize(args[0]);
11756
- const body = serializer.serialize(args[1]);
11757
- return `${quantifierSymbol} ${boundVar}, ${body}`;
11758
- };
11759
- }
11760
- function tightBindingCondition(p, terminator) {
11761
- 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);
11762
- }
11763
- function parseQuantifier(kind) {
11764
- return (parser, terminator) => {
11765
- const index = parser.index;
11766
- const useTightBinding = parser.options.quantifierScope !== "loose";
11767
- const symbol2 = parser.parseSymbol(terminator);
11768
- if (symbol2) {
11769
- parser.skipSpace();
11770
- if (parser.match(",") || parser.match("\\mid") || parser.match(".") || parser.match(":") || parser.match("\\colon")) {
11771
- const bodyTerminator = useTightBinding ? {
11772
- ...terminator,
11773
- condition: (p) => tightBindingCondition(p, terminator)
11774
- } : terminator;
11775
- parser.enterQuantifierScope();
11776
- const body2 = parser.parseExpression(bodyTerminator);
11777
- parser.exitQuantifierScope();
11778
- return [kind, symbol2, missingIfEmpty(body2)];
11779
- }
11780
- parser.enterQuantifierScope();
11781
- const body = parser.parseEnclosure();
11782
- parser.exitQuantifierScope();
11783
- if (body) return [kind, symbol2, missingIfEmpty(body)];
11784
- }
11785
- parser.index = index;
11786
- const condTerminator = {
11787
- ...terminator,
11788
- condition: (p) => p.peek === ":" || p.peek === "\\colon" || (terminator.condition?.(p) ?? false)
11789
- };
11790
- const condition = parser.parseExpression(condTerminator);
11791
- if (condition === null) return null;
11792
- parser.skipSpace();
11793
- if (parser.matchAny([",", "\\mid", ":", "\\colon"])) {
11794
- const bodyTerminator = useTightBinding ? {
11795
- ...terminator,
11796
- condition: (p) => tightBindingCondition(p, terminator)
11797
- } : terminator;
11798
- parser.enterQuantifierScope();
11799
- const body = parser.parseExpression(bodyTerminator);
11800
- parser.exitQuantifierScope();
11801
- return [kind, condition, missingIfEmpty(body)];
11802
- }
11803
- if (parser.match("(")) {
11804
- parser.enterQuantifierScope();
11805
- const body = parser.parseExpression(terminator);
11806
- parser.exitQuantifierScope();
11807
- if (!parser.match(")")) return null;
11808
- return [kind, condition, missingIfEmpty(body)];
11809
- }
11810
- return null;
11811
- };
11812
- }
11813
-
11814
11966
  // src/compute-engine/latex-syntax/dictionary/definitions-sets.ts
11815
11967
  function parseIntervalBody(body, openLeft, openRight) {
11816
11968
  if (isEmptySequence(body)) return null;
@@ -16315,7 +16467,7 @@ var ComputeEngineCore = (() => {
16315
16467
  var FLAG_SEQUENCE = "\\p{RI}\\p{RI}";
16316
16468
  var TAG_MOD = `(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})`;
16317
16469
  var EMOJI_MOD = `(?:\\p{EMod}|${VS16}${KEYCAP}?|${TAG_MOD})`;
16318
- var EMOJI_NOT_SYMBOL = `(?:(?=\\P{XIDC})\\p{Emoji})`;
16470
+ var EMOJI_NOT_SYMBOL = `(?:(?=\\P{XIDC})(?=[^\\x23\\x2a\\x30-\\x39])\\p{Emoji})`;
16319
16471
  var ZWJ_ELEMENT = `(?:${EMOJI_NOT_SYMBOL}${EMOJI_MOD}*|\\p{Emoji}${EMOJI_MOD}+|${FLAG_SEQUENCE})`;
16320
16472
  var POSSIBLE_EMOJI = `(?:${ZWJ_ELEMENT})(${ZWJ2}${ZWJ_ELEMENT})*`;
16321
16473
  var SOME_EMOJI = new RegExp(`(?:${POSSIBLE_EMOJI})+`, "u");
@@ -17024,7 +17176,9 @@ var ComputeEngineCore = (() => {
17024
17176
  }
17025
17177
  return c;
17026
17178
  }
17027
- return parser.nextToken();
17179
+ const raw = parser.peek;
17180
+ if (raw && /^[\p{XIDC}\p{M}]/u.test(raw)) return parser.nextToken();
17181
+ return null;
17028
17182
  }
17029
17183
  function parseSymbolBody(parser) {
17030
17184
  let id = matchPrefixedSymbol(parser);
@@ -18314,6 +18468,29 @@ var ComputeEngineCore = (() => {
18314
18468
  this.index = start;
18315
18469
  return null;
18316
18470
  }
18471
+ /**
18472
+ * Speculatively check if any \text infix entry (e.g. "and", "or", "where")
18473
+ * would match the upcoming tokens. This is used to prevent InvisibleOperator
18474
+ * from consuming \text{keyword} as a text run when the keyword is actually
18475
+ * an infix operator that was skipped due to precedence constraints.
18476
+ *
18477
+ * Returns true if any entry's parse function would succeed (non-null result).
18478
+ * The parser index is always restored to its original position.
18479
+ */
18480
+ wouldMatchTextInfix(opDefs) {
18481
+ const start = this.index;
18482
+ for (const [def, n] of opDefs) {
18483
+ if (def.kind !== "infix") continue;
18484
+ this.index = start + n;
18485
+ const result = def.parse(this, "Nothing", { minPrec: 0 });
18486
+ if (result !== null) {
18487
+ this.index = start;
18488
+ return true;
18489
+ }
18490
+ }
18491
+ this.index = start;
18492
+ return false;
18493
+ }
18317
18494
  /**
18318
18495
  * This returns an array of arguments (as in a function application),
18319
18496
  * or null if there is no match.
@@ -18939,6 +19116,7 @@ var ComputeEngineCore = (() => {
18939
19116
  if (isDelimiterCommand(this))
18940
19117
  return this.error("unexpected-delimiter", start);
18941
19118
  if (command[0] !== "\\") {
19119
+ this.nextToken();
18942
19120
  return this.error(
18943
19121
  ["unexpected-token", { str: tokensToString(command) }],
18944
19122
  start
@@ -19067,25 +19245,28 @@ var ComputeEngineCore = (() => {
19067
19245
  if (result === null && until.minPrec <= INVISIBLE_OP_PRECEDENCE) {
19068
19246
  const opDefs = this.peekDefinitions("operator");
19069
19247
  if (opDefs.length === 0 || opDefs.every(([def]) => def.latexTrigger === "\\text")) {
19070
- const rhs = this.parseExpression({
19071
- ...until,
19072
- minPrec: INVISIBLE_OP_PRECEDENCE + 1
19073
- });
19074
- if (rhs !== null) {
19075
- if (operator(lhs) === "InvisibleOperator") {
19076
- if (operator(rhs) === "InvisibleOperator")
19077
- result = [
19078
- "InvisibleOperator",
19079
- ...operands(lhs),
19080
- ...operands(rhs)
19081
- ];
19082
- else result = ["InvisibleOperator", ...operands(lhs), rhs];
19083
- } else if (operator(rhs) === "InvisibleOperator") {
19084
- result = ["InvisibleOperator", lhs, ...operands(rhs)];
19085
- } else result = ["InvisibleOperator", lhs, rhs];
19248
+ if (opDefs.length > 0 && this.wouldMatchTextInfix(opDefs)) {
19086
19249
  } else {
19087
- if (result === null) {
19088
- result = this.options.parseUnexpectedToken?.(lhs, this) ?? null;
19250
+ const rhs = this.parseExpression({
19251
+ ...until,
19252
+ minPrec: INVISIBLE_OP_PRECEDENCE + 1
19253
+ });
19254
+ if (rhs !== null) {
19255
+ if (operator(lhs) === "InvisibleOperator") {
19256
+ if (operator(rhs) === "InvisibleOperator")
19257
+ result = [
19258
+ "InvisibleOperator",
19259
+ ...operands(lhs),
19260
+ ...operands(rhs)
19261
+ ];
19262
+ else result = ["InvisibleOperator", ...operands(lhs), rhs];
19263
+ } else if (operator(rhs) === "InvisibleOperator") {
19264
+ result = ["InvisibleOperator", lhs, ...operands(rhs)];
19265
+ } else result = ["InvisibleOperator", lhs, rhs];
19266
+ } else {
19267
+ if (result === null) {
19268
+ result = this.options.parseUnexpectedToken?.(lhs, this) ?? null;
19269
+ }
19089
19270
  }
19090
19271
  }
19091
19272
  }
@@ -37910,6 +38091,10 @@ ${e.message}
37910
38091
  scoped: true,
37911
38092
  lazy: true,
37912
38093
  signature: "(expression, variable:symbol, variables:symbol+) -> expression",
38094
+ type: ([body]) => {
38095
+ if (body && body.type.matches("number")) return body.type;
38096
+ return void 0;
38097
+ },
37913
38098
  canonical: (ops, { engine: ce, scope }) => {
37914
38099
  if (isSymbol2(ops[0]) && ops[0].canonical.operatorDefinition) {
37915
38100
  const vars = ops.slice(1);
@@ -42481,6 +42666,18 @@ ${e.message}
42481
42666
  }
42482
42667
  }
42483
42668
  ops = flattenInvisibleOperator(ops);
42669
+ if (ops.some((op) => isFunction2(op, "Text") || isString(op))) {
42670
+ const runs = [];
42671
+ for (const op of ops) {
42672
+ if (isFunction2(op, "Text")) {
42673
+ runs.push(...op.ops);
42674
+ } else if (op.operator !== "HorizontalSpacing") {
42675
+ runs.push(op.canonical);
42676
+ }
42677
+ }
42678
+ return ce._fn("Text", runs);
42679
+ }
42680
+ ops = combineFunctionApplications(ce, ops);
42484
42681
  {
42485
42682
  const significant = ops.filter((x) => x.operator !== "HorizontalSpacing");
42486
42683
  if (significant.length === 2) {
@@ -42495,7 +42692,7 @@ ${e.message}
42495
42692
  }
42496
42693
  ops = flatten(ops);
42497
42694
  if (ops.every(
42498
- (x) => x.isValid && (x.type.isUnknown || x.type.matches("number") || x.isIndexedCollection && !isString(x))
42695
+ (x) => x.isValid && (x.type.isUnknown || x.type.type === "any" || x.type.type === "expression" || x.type.matches("number") || x.isIndexedCollection && !isString(x))
42499
42696
  )) {
42500
42697
  return ce._fn("Multiply", ops);
42501
42698
  }
@@ -42510,6 +42707,40 @@ ${e.message}
42510
42707
  }
42511
42708
  return ys;
42512
42709
  }
42710
+ function combineFunctionApplications(ce, ops) {
42711
+ const result = [];
42712
+ let i = 0;
42713
+ while (i < ops.length) {
42714
+ const op = ops[i];
42715
+ if (i < ops.length - 1 && isSymbol2(op) && isFunction2(ops[i + 1], "Delimiter")) {
42716
+ const symName = op.symbol;
42717
+ const def = ce.lookupDefinition(symName);
42718
+ const delim = ops[i + 1];
42719
+ if (def && (isOperatorDef(def) || def.value?.type?.matches("function"))) {
42720
+ let args = delim.op1 ? isFunction2(delim.op1, "Sequence") ? delim.op1.ops : [delim.op1] : [];
42721
+ args = flatten(args);
42722
+ result.push(ce.function(symName, args));
42723
+ i += 2;
42724
+ continue;
42725
+ }
42726
+ if (delim.op1 && isFunction2(delim.op1, "Sequence")) {
42727
+ let args = delim.op1.ops;
42728
+ args = flatten(args);
42729
+ if (args.length > 1) {
42730
+ if (!def) ce.declare(symName, "function");
42731
+ else if (!isOperatorDef(def) && def.value?.type?.isUnknown)
42732
+ op.canonical.infer("function");
42733
+ result.push(ce.function(symName, args));
42734
+ i += 2;
42735
+ continue;
42736
+ }
42737
+ }
42738
+ }
42739
+ result.push(ops[i]);
42740
+ i++;
42741
+ }
42742
+ return result;
42743
+ }
42513
42744
  function asInteger(expr2) {
42514
42745
  if (isNumber(expr2)) {
42515
42746
  const n = expr2.re;
@@ -43513,7 +43744,21 @@ ${e.message}
43513
43744
  },
43514
43745
  Text: {
43515
43746
  description: "A sequence of strings, annotated expressions and other Text expressions",
43516
- signature: "(any*) -> expression"
43747
+ signature: "(any*) -> string",
43748
+ evaluate: (ops, { engine: ce }) => {
43749
+ if (ops.length === 0) return ce.string("");
43750
+ const parts = [];
43751
+ for (const op of ops) {
43752
+ const unwrapped = op.operator === "Annotated" ? op.op1 : op;
43753
+ if (isString(unwrapped)) parts.push(unwrapped.string);
43754
+ else {
43755
+ const evaluated = unwrapped.evaluate();
43756
+ if (isString(evaluated)) parts.push(evaluated.string);
43757
+ else parts.push(evaluated.toString());
43758
+ }
43759
+ }
43760
+ return ce.string(parts.join(""));
43761
+ }
43517
43762
  }
43518
43763
  },
43519
43764
  {
@@ -43608,7 +43853,16 @@ ${e.message}
43608
43853
  if (!isSymbol2(symbol2)) {
43609
43854
  symbol2 = checkType(ce, lhs, "symbol");
43610
43855
  }
43611
- return ce._fn("Assign", [symbol2, args[1].canonical]);
43856
+ const canonRhs = args[1].canonical;
43857
+ const result = ce._fn("Assign", [symbol2, canonRhs]);
43858
+ const symbolName2 = sym(symbol2);
43859
+ if (symbolName2 && isFunction2(canonRhs, "Function")) {
43860
+ if (!ce.lookupDefinition(symbolName2)) ce.symbol(symbolName2);
43861
+ const def = ce.lookupDefinition(symbolName2);
43862
+ if (def && isValueDef(def) && def.value.inferredType)
43863
+ def.value.type = ce.type("function");
43864
+ }
43865
+ return result;
43612
43866
  },
43613
43867
  evaluate: ([op1, op2], { engine: ce }) => {
43614
43868
  if (isFunction2(op1, "Subscript") && sym(op1.op1)) {
@@ -43805,6 +44059,7 @@ ${e.message}
43805
44059
  description: "Simplify an expression.",
43806
44060
  lazy: true,
43807
44061
  signature: "(any) -> expression",
44062
+ type: ([x]) => x?.type ?? void 0,
43808
44063
  canonical: (ops, { engine: ce }) => ce._fn("Simplify", checkArity(ce, ops, 1)),
43809
44064
  evaluate: ([x]) => x.simplify() ?? void 0
43810
44065
  },
@@ -67450,7 +67705,7 @@ ${workgroupAttr}fn main(${paramStr})${returnStr} {
67450
67705
  _setDefaultEngineFactory(() => new ComputeEngine());
67451
67706
 
67452
67707
  // src/core.ts
67453
- var version = "0.55.0";
67708
+ var version = "0.55.2";
67454
67709
  return __toCommonJS(core_exports);
67455
67710
  })();
67456
67711
  /*! Bundled license information: