@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
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.55.0 */
1
+ /** Compute Engine 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.ComputeEngine = {}));})(this, (function (exports) { 'use strict';
3
3
  var ComputeEngine = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -9601,6 +9601,452 @@ var ComputeEngine = (() => {
9601
9601
  return expr2;
9602
9602
  }
9603
9603
 
9604
+ // src/compute-engine/latex-syntax/dictionary/definitions-logic.ts
9605
+ var DEFINITIONS_LOGIC = [
9606
+ // Constants
9607
+ {
9608
+ name: "True",
9609
+ kind: "symbol",
9610
+ latexTrigger: ["\\top"]
9611
+ // ⊤ U+22A4
9612
+ },
9613
+ {
9614
+ kind: "symbol",
9615
+ latexTrigger: "\\mathrm{True}",
9616
+ parse: "True"
9617
+ },
9618
+ {
9619
+ kind: "symbol",
9620
+ latexTrigger: "\\operatorname{True}",
9621
+ parse: "True"
9622
+ },
9623
+ {
9624
+ kind: "symbol",
9625
+ latexTrigger: "\\mathsf{T}",
9626
+ parse: "True"
9627
+ },
9628
+ {
9629
+ name: "False",
9630
+ kind: "symbol",
9631
+ latexTrigger: ["\\bot"]
9632
+ // ⊥ U+22A5
9633
+ },
9634
+ {
9635
+ kind: "symbol",
9636
+ latexTrigger: "\\operatorname{False}",
9637
+ parse: "False"
9638
+ },
9639
+ {
9640
+ kind: "symbol",
9641
+ latexTrigger: "\\mathsf{F}",
9642
+ parse: "False"
9643
+ },
9644
+ // Operators
9645
+ // Logic operators have lower precedence than comparisons (245)
9646
+ // so that `x = 1 \lor x = 2` parses as `(x = 1) \lor (x = 2)`
9647
+ // See https://github.com/cortex-js/compute-engine/issues/243
9648
+ {
9649
+ name: "And",
9650
+ kind: "infix",
9651
+ latexTrigger: ["\\land"],
9652
+ precedence: 235
9653
+ // serialize: '\\land',
9654
+ },
9655
+ { kind: "infix", latexTrigger: ["\\wedge"], parse: "And", precedence: 235 },
9656
+ { kind: "infix", latexTrigger: "\\&", parse: "And", precedence: 235 },
9657
+ {
9658
+ kind: "infix",
9659
+ latexTrigger: "\\operatorname{and}",
9660
+ parse: "And",
9661
+ precedence: 235
9662
+ },
9663
+ {
9664
+ name: "Or",
9665
+ kind: "infix",
9666
+ latexTrigger: ["\\lor"],
9667
+ precedence: 230
9668
+ },
9669
+ { kind: "infix", latexTrigger: ["\\vee"], parse: "Or", precedence: 230 },
9670
+ { kind: "infix", latexTrigger: "\\parallel", parse: "Or", precedence: 230 },
9671
+ {
9672
+ kind: "infix",
9673
+ latexTrigger: "\\operatorname{or}",
9674
+ parse: "Or",
9675
+ precedence: 230
9676
+ },
9677
+ {
9678
+ name: "Xor",
9679
+ kind: "infix",
9680
+ latexTrigger: ["\\veebar"],
9681
+ precedence: 232
9682
+ },
9683
+ // Possible alt: \oplus ⊕ U+2295
9684
+ {
9685
+ name: "Not",
9686
+ kind: "prefix",
9687
+ latexTrigger: ["\\lnot"],
9688
+ precedence: 880
9689
+ },
9690
+ {
9691
+ kind: "prefix",
9692
+ latexTrigger: ["\\neg"],
9693
+ parse: "Not",
9694
+ precedence: 880
9695
+ },
9696
+ {
9697
+ name: "Nand",
9698
+ kind: "infix",
9699
+ latexTrigger: ["\\barwedge"],
9700
+ precedence: 232
9701
+ // serialize: '\\mid',
9702
+ },
9703
+ {
9704
+ name: "Nor",
9705
+ kind: "infix",
9706
+ latexTrigger: ["\u22BD"],
9707
+ // bar vee
9708
+ precedence: 232
9709
+ // serialize: '\\downarrow',
9710
+ },
9711
+ // Functions
9712
+ {
9713
+ kind: "function",
9714
+ symbolTrigger: "and",
9715
+ parse: "And"
9716
+ },
9717
+ {
9718
+ kind: "function",
9719
+ symbolTrigger: "or",
9720
+ parse: "Or"
9721
+ },
9722
+ {
9723
+ kind: "function",
9724
+ symbolTrigger: "not",
9725
+ parse: "Not"
9726
+ },
9727
+ // Relations
9728
+ {
9729
+ name: "Implies",
9730
+ kind: "infix",
9731
+ precedence: 220,
9732
+ associativity: "right",
9733
+ latexTrigger: ["\\implies"],
9734
+ serialize: "\\implies"
9735
+ },
9736
+ {
9737
+ latexTrigger: ["\\Rightarrow"],
9738
+ kind: "infix",
9739
+ precedence: 220,
9740
+ associativity: "right",
9741
+ parse: "Implies"
9742
+ },
9743
+ {
9744
+ latexTrigger: ["\\rightarrow"],
9745
+ kind: "infix",
9746
+ precedence: 220,
9747
+ associativity: "right",
9748
+ parse: "Implies"
9749
+ },
9750
+ {
9751
+ latexTrigger: ["\\Longrightarrow"],
9752
+ kind: "infix",
9753
+ precedence: 220,
9754
+ associativity: "right",
9755
+ parse: "Implies"
9756
+ },
9757
+ {
9758
+ latexTrigger: ["\\longrightarrow"],
9759
+ kind: "infix",
9760
+ precedence: 220,
9761
+ associativity: "right",
9762
+ parse: "Implies"
9763
+ },
9764
+ {
9765
+ // Non-strict mode: => for implies
9766
+ latexTrigger: ["=", ">"],
9767
+ kind: "infix",
9768
+ precedence: 220,
9769
+ associativity: "right",
9770
+ parse: (parser, lhs, until) => {
9771
+ if (parser.options.strict !== false) return null;
9772
+ const rhs = parser.parseExpression({ ...until, minPrec: 220 });
9773
+ if (rhs === null) return null;
9774
+ return ["Implies", lhs, rhs];
9775
+ }
9776
+ },
9777
+ {
9778
+ name: "Equivalent",
9779
+ // MathML: identical to, Mathematica: Congruent
9780
+ latexTrigger: ["\\iff"],
9781
+ kind: "infix",
9782
+ associativity: "right",
9783
+ precedence: 219
9784
+ },
9785
+ {
9786
+ latexTrigger: ["\\Leftrightarrow"],
9787
+ kind: "infix",
9788
+ associativity: "right",
9789
+ precedence: 219,
9790
+ parse: "Equivalent"
9791
+ },
9792
+ {
9793
+ latexTrigger: ["\\leftrightarrow"],
9794
+ kind: "infix",
9795
+ associativity: "right",
9796
+ precedence: 219,
9797
+ parse: "Equivalent"
9798
+ },
9799
+ {
9800
+ latexTrigger: ["\\Longleftrightarrow"],
9801
+ kind: "infix",
9802
+ associativity: "right",
9803
+ precedence: 219,
9804
+ parse: "Equivalent"
9805
+ },
9806
+ {
9807
+ latexTrigger: ["\\longleftrightarrow"],
9808
+ kind: "infix",
9809
+ associativity: "right",
9810
+ precedence: 219,
9811
+ parse: "Equivalent"
9812
+ },
9813
+ {
9814
+ // Non-strict mode: <=> for equivalence
9815
+ latexTrigger: ["<", "=", ">"],
9816
+ kind: "infix",
9817
+ precedence: 219,
9818
+ associativity: "right",
9819
+ parse: (parser, lhs, until) => {
9820
+ if (parser.options.strict !== false) return null;
9821
+ const rhs = parser.parseExpression({ ...until, minPrec: 219 });
9822
+ if (rhs === null) return null;
9823
+ return ["Equivalent", lhs, rhs];
9824
+ }
9825
+ },
9826
+ {
9827
+ latexTrigger: ["\\equiv"],
9828
+ kind: "infix",
9829
+ associativity: "right",
9830
+ precedence: 219,
9831
+ parse: (parser, lhs, terminator) => {
9832
+ const rhs = parser.parseExpression({ ...terminator, minPrec: 219 });
9833
+ const index = parser.index;
9834
+ const modulus = parser.parseExpression({ ...terminator, minPrec: 219 });
9835
+ if (modulus !== null && operator(modulus) === "Mod")
9836
+ return ["Congruent", lhs, rhs, missingIfEmpty(operand(modulus, 1))];
9837
+ parser.index = index;
9838
+ return ["Equivalent", lhs, missingIfEmpty(rhs)];
9839
+ }
9840
+ },
9841
+ {
9842
+ name: "Proves",
9843
+ kind: "infix",
9844
+ latexTrigger: ["\\vdash"],
9845
+ precedence: 220,
9846
+ associativity: "right",
9847
+ serialize: "\\vdash"
9848
+ },
9849
+ {
9850
+ name: "Entails",
9851
+ kind: "infix",
9852
+ latexTrigger: ["\\vDash"],
9853
+ precedence: 220,
9854
+ associativity: "right",
9855
+ serialize: "\\vDash"
9856
+ },
9857
+ {
9858
+ name: "Satisfies",
9859
+ kind: "infix",
9860
+ latexTrigger: ["\\models"],
9861
+ precedence: 220,
9862
+ associativity: "right",
9863
+ serialize: "\\models"
9864
+ },
9865
+ // Quantifiers: for all, exists
9866
+ {
9867
+ name: "ForAll",
9868
+ kind: "prefix",
9869
+ latexTrigger: ["\\forall"],
9870
+ precedence: 200,
9871
+ // Has to be lower than COMPARISON_PRECEDENCE
9872
+ serialize: serializeQuantifier("\\forall"),
9873
+ parse: parseQuantifier("ForAll")
9874
+ },
9875
+ {
9876
+ name: "Exists",
9877
+ kind: "prefix",
9878
+ latexTrigger: ["\\exists"],
9879
+ precedence: 200,
9880
+ // Has to be lower than COMPARISON_PRECEDENCE,
9881
+ serialize: serializeQuantifier("\\exists"),
9882
+ parse: parseQuantifier("Exists")
9883
+ },
9884
+ {
9885
+ name: "ExistsUnique",
9886
+ kind: "prefix",
9887
+ latexTrigger: ["\\exists", "!"],
9888
+ precedence: 200,
9889
+ // Has to be lower than COMPARISON_PRECEDENCE,
9890
+ serialize: serializeQuantifier("\\exists!"),
9891
+ parse: parseQuantifier("ExistsUnique")
9892
+ },
9893
+ {
9894
+ name: "NotForAll",
9895
+ kind: "prefix",
9896
+ latexTrigger: ["\\lnot", "\\forall"],
9897
+ precedence: 200,
9898
+ // Has to be lower than COMPARISON_PRECEDENCE
9899
+ serialize: serializeQuantifier("\\lnot\\forall"),
9900
+ parse: parseQuantifier("NotForAll")
9901
+ },
9902
+ {
9903
+ name: "NotExists",
9904
+ kind: "prefix",
9905
+ latexTrigger: ["\\lnot", "\\exists"],
9906
+ precedence: 200,
9907
+ // Has to be lower than COMPARISON_PRECEDENCE,
9908
+ serialize: serializeQuantifier("\\lnot\\exists"),
9909
+ parse: parseQuantifier("NotExists")
9910
+ },
9911
+ {
9912
+ name: "KroneckerDelta",
9913
+ kind: "prefix",
9914
+ latexTrigger: ["\\delta", "_"],
9915
+ precedence: 200,
9916
+ serialize: (serializer, expr2) => {
9917
+ const args = operands(expr2);
9918
+ if (args.length === 0) return "\\delta";
9919
+ if (args.every((x) => symbol(x)))
9920
+ return `\\delta_{${args.map((arg) => serializer.serialize(arg)).join("")}}`;
9921
+ return `\\delta_{${args.map((arg) => serializer.serialize(arg)).join(", ")}}`;
9922
+ },
9923
+ parse: (parser) => {
9924
+ const group = parser.parseGroup();
9925
+ if (group === null) {
9926
+ const token = parser.parseToken();
9927
+ if (!token) return null;
9928
+ return ["KroneckerDelta", token];
9929
+ }
9930
+ const seq = getSequence(group);
9931
+ if (seq && seq.length <= 2) return ["KroneckerDelta", ...seq];
9932
+ if (operator(group) === "InvisibleOperator")
9933
+ return ["KroneckerDelta", ...operands(group)];
9934
+ if (group !== null) return ["KroneckerDelta", group];
9935
+ return null;
9936
+ }
9937
+ },
9938
+ // Iverson brackets. Also called the "indicator function"
9939
+ // Must have a single argument, a relational expression, i.e.
9940
+ // `[ a = b ]` or `[ x \leq 0 ]`
9941
+ // Otherwise, it gets rejected, it could be something else, like a list or
9942
+ // tuple.
9943
+ {
9944
+ name: "Boole",
9945
+ kind: "matchfix",
9946
+ openTrigger: "[",
9947
+ closeTrigger: "]",
9948
+ // serialize: (serializer: Serializer, expr: MathJsonExpression) => {
9949
+ // const args = ops(expr);
9950
+ // return `[${serializer.serialize(arg)}]`;
9951
+ // },
9952
+ parse: (_parser, body) => {
9953
+ const h = operator(body);
9954
+ if (!h) return null;
9955
+ if (!DEFINITIONS_INEQUALITIES.some((x) => x.name === h)) return null;
9956
+ return ["Boole", body];
9957
+ }
9958
+ },
9959
+ {
9960
+ kind: "matchfix",
9961
+ openTrigger: "\\llbracket",
9962
+ closeTrigger: "\\rrbracket",
9963
+ parse: (_parser, body) => {
9964
+ const h = operator(body);
9965
+ if (!h) return null;
9966
+ if (!DEFINITIONS_INEQUALITIES.some((x) => x.name === h)) return null;
9967
+ return ["Boole", body];
9968
+ }
9969
+ },
9970
+ // Predicate application in First-Order Logic.
9971
+ // ["Predicate", "P", "x", "y"] serializes to "P(x, y)"
9972
+ {
9973
+ name: "Predicate",
9974
+ serialize: (serializer, expr2) => {
9975
+ const args = operands(expr2);
9976
+ if (args.length === 0) return "";
9977
+ const pred = args[0];
9978
+ const predStr = typeof pred === "string" ? pred : serializer.serialize(pred);
9979
+ if (args.length === 1) return predStr;
9980
+ const argStrs = args.slice(1).map((arg) => serializer.serialize(arg));
9981
+ return `${predStr}(${argStrs.join(", ")})`;
9982
+ }
9983
+ }
9984
+ ];
9985
+ function serializeQuantifier(quantifierSymbol) {
9986
+ return (serializer, expr2) => {
9987
+ const args = operands(expr2);
9988
+ if (args.length === 0) return quantifierSymbol;
9989
+ if (args.length === 1)
9990
+ return `${quantifierSymbol} ${serializer.serialize(args[0])}`;
9991
+ const boundVar = serializer.serialize(args[0]);
9992
+ const body = serializer.serialize(args[1]);
9993
+ return `${quantifierSymbol} ${boundVar}, ${body}`;
9994
+ };
9995
+ }
9996
+ function tightBindingCondition(p, terminator) {
9997
+ 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);
9998
+ }
9999
+ function parseQuantifier(kind) {
10000
+ return (parser, terminator) => {
10001
+ const index = parser.index;
10002
+ const useTightBinding = parser.options.quantifierScope !== "loose";
10003
+ const symbol2 = parser.parseSymbol(terminator);
10004
+ if (symbol2) {
10005
+ parser.skipSpace();
10006
+ if (parser.match(",") || parser.match("\\mid") || parser.match(".") || parser.match(":") || parser.match("\\colon")) {
10007
+ const bodyTerminator = useTightBinding ? {
10008
+ ...terminator,
10009
+ condition: (p) => tightBindingCondition(p, terminator)
10010
+ } : terminator;
10011
+ parser.enterQuantifierScope();
10012
+ const body2 = parser.parseExpression(bodyTerminator);
10013
+ parser.exitQuantifierScope();
10014
+ return [kind, symbol2, missingIfEmpty(body2)];
10015
+ }
10016
+ parser.enterQuantifierScope();
10017
+ const body = parser.parseEnclosure();
10018
+ parser.exitQuantifierScope();
10019
+ if (body) return [kind, symbol2, missingIfEmpty(body)];
10020
+ }
10021
+ parser.index = index;
10022
+ const condTerminator = {
10023
+ ...terminator,
10024
+ condition: (p) => p.peek === ":" || p.peek === "\\colon" || (terminator.condition?.(p) ?? false)
10025
+ };
10026
+ const condition = parser.parseExpression(condTerminator);
10027
+ if (condition === null) return null;
10028
+ parser.skipSpace();
10029
+ if (parser.matchAny([",", "\\mid", ":", "\\colon"])) {
10030
+ const bodyTerminator = useTightBinding ? {
10031
+ ...terminator,
10032
+ condition: (p) => tightBindingCondition(p, terminator)
10033
+ } : terminator;
10034
+ parser.enterQuantifierScope();
10035
+ const body = parser.parseExpression(bodyTerminator);
10036
+ parser.exitQuantifierScope();
10037
+ return [kind, condition, missingIfEmpty(body)];
10038
+ }
10039
+ if (parser.match("(")) {
10040
+ parser.enterQuantifierScope();
10041
+ const body = parser.parseExpression(terminator);
10042
+ parser.exitQuantifierScope();
10043
+ if (!parser.match(")")) return null;
10044
+ return [kind, condition, missingIfEmpty(body)];
10045
+ }
10046
+ return null;
10047
+ };
10048
+ }
10049
+
9604
10050
  // src/compute-engine/latex-syntax/dictionary/definitions-core.ts
9605
10051
  function parseSequence(parser, terminator, lhs, prec, sep) {
9606
10052
  if (terminator && terminator.minPrec >= prec) return null;
@@ -10211,6 +10657,120 @@ var ComputeEngine = (() => {
10211
10657
  precedence: 21,
10212
10658
  parse: (parser, lhs, until) => parseWhereExpression(parser, lhs, until)
10213
10659
  },
10660
+ // \text{and} — logical conjunction infix
10661
+ {
10662
+ latexTrigger: ["\\text"],
10663
+ kind: "infix",
10664
+ associativity: "right",
10665
+ precedence: 235,
10666
+ // Same as \land
10667
+ parse: (parser, lhs, until) => {
10668
+ const start = parser.index;
10669
+ if (!matchTextKeyword(parser, "and")) {
10670
+ parser.index = start;
10671
+ return null;
10672
+ }
10673
+ const rhs = parser.parseExpression({ ...until, minPrec: 235 });
10674
+ return ["And", lhs, rhs ?? "Nothing"];
10675
+ }
10676
+ },
10677
+ // \text{or} — logical disjunction infix
10678
+ {
10679
+ latexTrigger: ["\\text"],
10680
+ kind: "infix",
10681
+ associativity: "right",
10682
+ precedence: 230,
10683
+ // Same as \lor
10684
+ parse: (parser, lhs, until) => {
10685
+ const start = parser.index;
10686
+ if (!matchTextKeyword(parser, "or")) {
10687
+ parser.index = start;
10688
+ return null;
10689
+ }
10690
+ const rhs = parser.parseExpression({ ...until, minPrec: 230 });
10691
+ return ["Or", lhs, rhs ?? "Nothing"];
10692
+ }
10693
+ },
10694
+ // \text{iff} — biconditional (if and only if)
10695
+ {
10696
+ latexTrigger: ["\\text"],
10697
+ kind: "infix",
10698
+ associativity: "right",
10699
+ precedence: 219,
10700
+ // Same as \iff
10701
+ parse: (parser, lhs, until) => {
10702
+ const start = parser.index;
10703
+ if (!matchTextKeyword(parser, "iff")) {
10704
+ parser.index = start;
10705
+ return null;
10706
+ }
10707
+ const rhs = parser.parseExpression({ ...until, minPrec: 219 });
10708
+ return ["Equivalent", lhs, rhs ?? "Nothing"];
10709
+ }
10710
+ },
10711
+ // \text{if and only if} — verbose biconditional
10712
+ {
10713
+ latexTrigger: ["\\text"],
10714
+ kind: "infix",
10715
+ associativity: "right",
10716
+ precedence: 219,
10717
+ parse: (parser, lhs, until) => {
10718
+ const start = parser.index;
10719
+ if (!matchTextKeyword(parser, "if and only if")) {
10720
+ parser.index = start;
10721
+ return null;
10722
+ }
10723
+ const rhs = parser.parseExpression({ ...until, minPrec: 219 });
10724
+ return ["Equivalent", lhs, rhs ?? "Nothing"];
10725
+ }
10726
+ },
10727
+ // \text{such that} — constraint separator (like : in set-builder notation)
10728
+ {
10729
+ latexTrigger: ["\\text"],
10730
+ kind: "infix",
10731
+ associativity: "right",
10732
+ precedence: 21,
10733
+ // Low precedence to capture full condition (same as 'where')
10734
+ parse: (parser, lhs, until) => {
10735
+ const start = parser.index;
10736
+ if (!matchTextKeyword(parser, "such that")) {
10737
+ parser.index = start;
10738
+ return null;
10739
+ }
10740
+ const rhs = parser.parseExpression({ ...until, minPrec: 21 });
10741
+ return ["Colon", lhs, rhs ?? "Nothing"];
10742
+ }
10743
+ },
10744
+ // \text{for all} — universal quantifier
10745
+ {
10746
+ latexTrigger: ["\\text"],
10747
+ kind: "prefix",
10748
+ precedence: 200,
10749
+ // Same as \forall
10750
+ parse: (parser, until) => {
10751
+ const start = parser.index;
10752
+ if (!matchTextKeyword(parser, "for all")) {
10753
+ parser.index = start;
10754
+ return null;
10755
+ }
10756
+ return parseQuantifier("ForAll")(parser, until);
10757
+ }
10758
+ },
10759
+ // \text{there exists} — existential quantifier
10760
+ {
10761
+ latexTrigger: ["\\text"],
10762
+ kind: "prefix",
10763
+ precedence: 200,
10764
+ // Same as \exists
10765
+ parse: (parser, until) => {
10766
+ const start = parser.index;
10767
+ if (!matchTextKeyword(parser, "there exists")) {
10768
+ parser.index = start;
10769
+ return null;
10770
+ }
10771
+ return parseQuantifier("Exists")(parser, until);
10772
+ }
10773
+ },
10214
10774
  // Block serializer — used by both `where` and semicolon blocks
10215
10775
  {
10216
10776
  name: "Block",
@@ -10326,6 +10886,39 @@ var ComputeEngine = (() => {
10326
10886
  parser.parseExpression(until) ?? "Nothing"
10327
10887
  ]
10328
10888
  },
10889
+ // Text serializer — reconstructs \text{...} with inline $...$ for math
10890
+ {
10891
+ name: "Text",
10892
+ serialize: (serializer, expr2) => {
10893
+ const args = operands(expr2);
10894
+ if (args.length === 0) return "";
10895
+ let firstStr = -1;
10896
+ let lastStr = -1;
10897
+ for (let i = 0; i < args.length; i++) {
10898
+ if (stringValue(args[i]) !== null) {
10899
+ if (firstStr < 0) firstStr = i;
10900
+ lastStr = i;
10901
+ }
10902
+ }
10903
+ if (firstStr < 0)
10904
+ return joinLatex(args.map((a) => serializer.serialize(a)));
10905
+ const parts = [];
10906
+ for (let i = 0; i < firstStr; i++)
10907
+ parts.push(serializer.serialize(args[i]));
10908
+ let textContent = "";
10909
+ for (let i = firstStr; i <= lastStr; i++) {
10910
+ const s = stringValue(args[i]);
10911
+ if (s !== null) textContent += sanitizeLatex(s);
10912
+ else if (operator(args[i]) === "Annotated" || operator(args[i]) === "Text")
10913
+ textContent += serializer.serialize(args[i]);
10914
+ else textContent += "$" + serializer.serialize(args[i]) + "$";
10915
+ }
10916
+ parts.push("\\text{" + textContent + "}");
10917
+ for (let i = lastStr + 1; i < args.length; i++)
10918
+ parts.push(serializer.serialize(args[i]));
10919
+ return joinLatex(parts);
10920
+ }
10921
+ },
10329
10922
  {
10330
10923
  name: "String",
10331
10924
  latexTrigger: ["\\text"],
@@ -10716,9 +11309,10 @@ var ComputeEngine = (() => {
10716
11309
  } else if (parser.match("\\textcolor")) {
10717
11310
  const pos = parser.index;
10718
11311
  const color = parser.parseStringGroup();
10719
- const body2 = parser.parseExpression();
10720
- if (color !== null && body2 !== null) {
10721
- runs.push(["Annotated", body2, { dict: { color } }]);
11312
+ if (color !== null) {
11313
+ flush();
11314
+ const body2 = parseTextRun(parser);
11315
+ runs.push(["Annotated", body2, dictionaryFromEntries({ color })]);
10722
11316
  } else {
10723
11317
  parser.index = pos;
10724
11318
  text += "\\textcolor";
@@ -10736,6 +11330,7 @@ var ComputeEngine = (() => {
10736
11330
  const expr2 = parser.parseExpression() ?? "Nothing";
10737
11331
  parser.skipSpace();
10738
11332
  if (parser.match("<$>")) {
11333
+ flush();
10739
11334
  runs.push(expr2);
10740
11335
  } else {
10741
11336
  text += "$";
@@ -10746,6 +11341,7 @@ var ComputeEngine = (() => {
10746
11341
  const expr2 = parser.parseExpression() ?? "Nothing";
10747
11342
  parser.skipSpace();
10748
11343
  if (parser.match("<$$>")) {
11344
+ flush();
10749
11345
  runs.push(expr2);
10750
11346
  } else {
10751
11347
  text += "$$";
@@ -11096,14 +11692,20 @@ var ComputeEngine = (() => {
11096
11692
  }
11097
11693
  while (parser.match("<space>")) {
11098
11694
  }
11099
- let text = "";
11100
- while (!parser.atEnd && parser.peek !== "<}>" && parser.peek !== "<space>") {
11101
- const tok = parser.peek;
11102
- if (/^[a-zA-Z]$/.test(tok)) {
11103
- text += tok;
11104
- parser.nextToken();
11695
+ for (let i = 0; i < keyword.length; i++) {
11696
+ if (keyword[i] === " ") {
11697
+ if (!parser.match("<space>")) {
11698
+ parser.index = start;
11699
+ return false;
11700
+ }
11701
+ while (parser.match("<space>")) {
11702
+ }
11105
11703
  } else {
11106
- break;
11704
+ if (parser.peek !== keyword[i]) {
11705
+ parser.index = start;
11706
+ return false;
11707
+ }
11708
+ parser.nextToken();
11107
11709
  }
11108
11710
  }
11109
11711
  while (parser.match("<space>")) {
@@ -11112,10 +11714,6 @@ var ComputeEngine = (() => {
11112
11714
  parser.index = start;
11113
11715
  return false;
11114
11716
  }
11115
- if (text !== keyword) {
11116
- parser.index = start;
11117
- return false;
11118
- }
11119
11717
  return true;
11120
11718
  }
11121
11719
  function matchKeyword(parser, keyword) {
@@ -11393,452 +11991,6 @@ var ComputeEngine = (() => {
11393
11991
  }
11394
11992
  ];
11395
11993
 
11396
- // src/compute-engine/latex-syntax/dictionary/definitions-logic.ts
11397
- var DEFINITIONS_LOGIC = [
11398
- // Constants
11399
- {
11400
- name: "True",
11401
- kind: "symbol",
11402
- latexTrigger: ["\\top"]
11403
- // ⊤ U+22A4
11404
- },
11405
- {
11406
- kind: "symbol",
11407
- latexTrigger: "\\mathrm{True}",
11408
- parse: "True"
11409
- },
11410
- {
11411
- kind: "symbol",
11412
- latexTrigger: "\\operatorname{True}",
11413
- parse: "True"
11414
- },
11415
- {
11416
- kind: "symbol",
11417
- latexTrigger: "\\mathsf{T}",
11418
- parse: "True"
11419
- },
11420
- {
11421
- name: "False",
11422
- kind: "symbol",
11423
- latexTrigger: ["\\bot"]
11424
- // ⊥ U+22A5
11425
- },
11426
- {
11427
- kind: "symbol",
11428
- latexTrigger: "\\operatorname{False}",
11429
- parse: "False"
11430
- },
11431
- {
11432
- kind: "symbol",
11433
- latexTrigger: "\\mathsf{F}",
11434
- parse: "False"
11435
- },
11436
- // Operators
11437
- // Logic operators have lower precedence than comparisons (245)
11438
- // so that `x = 1 \lor x = 2` parses as `(x = 1) \lor (x = 2)`
11439
- // See https://github.com/cortex-js/compute-engine/issues/243
11440
- {
11441
- name: "And",
11442
- kind: "infix",
11443
- latexTrigger: ["\\land"],
11444
- precedence: 235
11445
- // serialize: '\\land',
11446
- },
11447
- { kind: "infix", latexTrigger: ["\\wedge"], parse: "And", precedence: 235 },
11448
- { kind: "infix", latexTrigger: "\\&", parse: "And", precedence: 235 },
11449
- {
11450
- kind: "infix",
11451
- latexTrigger: "\\operatorname{and}",
11452
- parse: "And",
11453
- precedence: 235
11454
- },
11455
- {
11456
- name: "Or",
11457
- kind: "infix",
11458
- latexTrigger: ["\\lor"],
11459
- precedence: 230
11460
- },
11461
- { kind: "infix", latexTrigger: ["\\vee"], parse: "Or", precedence: 230 },
11462
- { kind: "infix", latexTrigger: "\\parallel", parse: "Or", precedence: 230 },
11463
- {
11464
- kind: "infix",
11465
- latexTrigger: "\\operatorname{or}",
11466
- parse: "Or",
11467
- precedence: 230
11468
- },
11469
- {
11470
- name: "Xor",
11471
- kind: "infix",
11472
- latexTrigger: ["\\veebar"],
11473
- precedence: 232
11474
- },
11475
- // Possible alt: \oplus ⊕ U+2295
11476
- {
11477
- name: "Not",
11478
- kind: "prefix",
11479
- latexTrigger: ["\\lnot"],
11480
- precedence: 880
11481
- },
11482
- {
11483
- kind: "prefix",
11484
- latexTrigger: ["\\neg"],
11485
- parse: "Not",
11486
- precedence: 880
11487
- },
11488
- {
11489
- name: "Nand",
11490
- kind: "infix",
11491
- latexTrigger: ["\\barwedge"],
11492
- precedence: 232
11493
- // serialize: '\\mid',
11494
- },
11495
- {
11496
- name: "Nor",
11497
- kind: "infix",
11498
- latexTrigger: ["\u22BD"],
11499
- // bar vee
11500
- precedence: 232
11501
- // serialize: '\\downarrow',
11502
- },
11503
- // Functions
11504
- {
11505
- kind: "function",
11506
- symbolTrigger: "and",
11507
- parse: "And"
11508
- },
11509
- {
11510
- kind: "function",
11511
- symbolTrigger: "or",
11512
- parse: "Or"
11513
- },
11514
- {
11515
- kind: "function",
11516
- symbolTrigger: "not",
11517
- parse: "Not"
11518
- },
11519
- // Relations
11520
- {
11521
- name: "Implies",
11522
- kind: "infix",
11523
- precedence: 220,
11524
- associativity: "right",
11525
- latexTrigger: ["\\implies"],
11526
- serialize: "\\implies"
11527
- },
11528
- {
11529
- latexTrigger: ["\\Rightarrow"],
11530
- kind: "infix",
11531
- precedence: 220,
11532
- associativity: "right",
11533
- parse: "Implies"
11534
- },
11535
- {
11536
- latexTrigger: ["\\rightarrow"],
11537
- kind: "infix",
11538
- precedence: 220,
11539
- associativity: "right",
11540
- parse: "Implies"
11541
- },
11542
- {
11543
- latexTrigger: ["\\Longrightarrow"],
11544
- kind: "infix",
11545
- precedence: 220,
11546
- associativity: "right",
11547
- parse: "Implies"
11548
- },
11549
- {
11550
- latexTrigger: ["\\longrightarrow"],
11551
- kind: "infix",
11552
- precedence: 220,
11553
- associativity: "right",
11554
- parse: "Implies"
11555
- },
11556
- {
11557
- // Non-strict mode: => for implies
11558
- latexTrigger: ["=", ">"],
11559
- kind: "infix",
11560
- precedence: 220,
11561
- associativity: "right",
11562
- parse: (parser, lhs, until) => {
11563
- if (parser.options.strict !== false) return null;
11564
- const rhs = parser.parseExpression({ ...until, minPrec: 220 });
11565
- if (rhs === null) return null;
11566
- return ["Implies", lhs, rhs];
11567
- }
11568
- },
11569
- {
11570
- name: "Equivalent",
11571
- // MathML: identical to, Mathematica: Congruent
11572
- latexTrigger: ["\\iff"],
11573
- kind: "infix",
11574
- associativity: "right",
11575
- precedence: 219
11576
- },
11577
- {
11578
- latexTrigger: ["\\Leftrightarrow"],
11579
- kind: "infix",
11580
- associativity: "right",
11581
- precedence: 219,
11582
- parse: "Equivalent"
11583
- },
11584
- {
11585
- latexTrigger: ["\\leftrightarrow"],
11586
- kind: "infix",
11587
- associativity: "right",
11588
- precedence: 219,
11589
- parse: "Equivalent"
11590
- },
11591
- {
11592
- latexTrigger: ["\\Longleftrightarrow"],
11593
- kind: "infix",
11594
- associativity: "right",
11595
- precedence: 219,
11596
- parse: "Equivalent"
11597
- },
11598
- {
11599
- latexTrigger: ["\\longleftrightarrow"],
11600
- kind: "infix",
11601
- associativity: "right",
11602
- precedence: 219,
11603
- parse: "Equivalent"
11604
- },
11605
- {
11606
- // Non-strict mode: <=> for equivalence
11607
- latexTrigger: ["<", "=", ">"],
11608
- kind: "infix",
11609
- precedence: 219,
11610
- associativity: "right",
11611
- parse: (parser, lhs, until) => {
11612
- if (parser.options.strict !== false) return null;
11613
- const rhs = parser.parseExpression({ ...until, minPrec: 219 });
11614
- if (rhs === null) return null;
11615
- return ["Equivalent", lhs, rhs];
11616
- }
11617
- },
11618
- {
11619
- latexTrigger: ["\\equiv"],
11620
- kind: "infix",
11621
- associativity: "right",
11622
- precedence: 219,
11623
- parse: (parser, lhs, terminator) => {
11624
- const rhs = parser.parseExpression({ ...terminator, minPrec: 219 });
11625
- const index = parser.index;
11626
- const modulus = parser.parseExpression({ ...terminator, minPrec: 219 });
11627
- if (modulus !== null && operator(modulus) === "Mod")
11628
- return ["Congruent", lhs, rhs, missingIfEmpty(operand(modulus, 1))];
11629
- parser.index = index;
11630
- return ["Equivalent", lhs, missingIfEmpty(rhs)];
11631
- }
11632
- },
11633
- {
11634
- name: "Proves",
11635
- kind: "infix",
11636
- latexTrigger: ["\\vdash"],
11637
- precedence: 220,
11638
- associativity: "right",
11639
- serialize: "\\vdash"
11640
- },
11641
- {
11642
- name: "Entails",
11643
- kind: "infix",
11644
- latexTrigger: ["\\vDash"],
11645
- precedence: 220,
11646
- associativity: "right",
11647
- serialize: "\\vDash"
11648
- },
11649
- {
11650
- name: "Satisfies",
11651
- kind: "infix",
11652
- latexTrigger: ["\\models"],
11653
- precedence: 220,
11654
- associativity: "right",
11655
- serialize: "\\models"
11656
- },
11657
- // Quantifiers: for all, exists
11658
- {
11659
- name: "ForAll",
11660
- kind: "prefix",
11661
- latexTrigger: ["\\forall"],
11662
- precedence: 200,
11663
- // Has to be lower than COMPARISON_PRECEDENCE
11664
- serialize: serializeQuantifier("\\forall"),
11665
- parse: parseQuantifier("ForAll")
11666
- },
11667
- {
11668
- name: "Exists",
11669
- kind: "prefix",
11670
- latexTrigger: ["\\exists"],
11671
- precedence: 200,
11672
- // Has to be lower than COMPARISON_PRECEDENCE,
11673
- serialize: serializeQuantifier("\\exists"),
11674
- parse: parseQuantifier("Exists")
11675
- },
11676
- {
11677
- name: "ExistsUnique",
11678
- kind: "prefix",
11679
- latexTrigger: ["\\exists", "!"],
11680
- precedence: 200,
11681
- // Has to be lower than COMPARISON_PRECEDENCE,
11682
- serialize: serializeQuantifier("\\exists!"),
11683
- parse: parseQuantifier("ExistsUnique")
11684
- },
11685
- {
11686
- name: "NotForAll",
11687
- kind: "prefix",
11688
- latexTrigger: ["\\lnot", "\\forall"],
11689
- precedence: 200,
11690
- // Has to be lower than COMPARISON_PRECEDENCE
11691
- serialize: serializeQuantifier("\\lnot\\forall"),
11692
- parse: parseQuantifier("NotForAll")
11693
- },
11694
- {
11695
- name: "NotExists",
11696
- kind: "prefix",
11697
- latexTrigger: ["\\lnot", "\\exists"],
11698
- precedence: 200,
11699
- // Has to be lower than COMPARISON_PRECEDENCE,
11700
- serialize: serializeQuantifier("\\lnot\\exists"),
11701
- parse: parseQuantifier("NotExists")
11702
- },
11703
- {
11704
- name: "KroneckerDelta",
11705
- kind: "prefix",
11706
- latexTrigger: ["\\delta", "_"],
11707
- precedence: 200,
11708
- serialize: (serializer, expr2) => {
11709
- const args = operands(expr2);
11710
- if (args.length === 0) return "\\delta";
11711
- if (args.every((x) => symbol(x)))
11712
- return `\\delta_{${args.map((arg) => serializer.serialize(arg)).join("")}}`;
11713
- return `\\delta_{${args.map((arg) => serializer.serialize(arg)).join(", ")}}`;
11714
- },
11715
- parse: (parser) => {
11716
- const group = parser.parseGroup();
11717
- if (group === null) {
11718
- const token = parser.parseToken();
11719
- if (!token) return null;
11720
- return ["KroneckerDelta", token];
11721
- }
11722
- const seq = getSequence(group);
11723
- if (seq && seq.length <= 2) return ["KroneckerDelta", ...seq];
11724
- if (operator(group) === "InvisibleOperator")
11725
- return ["KroneckerDelta", ...operands(group)];
11726
- if (group !== null) return ["KroneckerDelta", group];
11727
- return null;
11728
- }
11729
- },
11730
- // Iverson brackets. Also called the "indicator function"
11731
- // Must have a single argument, a relational expression, i.e.
11732
- // `[ a = b ]` or `[ x \leq 0 ]`
11733
- // Otherwise, it gets rejected, it could be something else, like a list or
11734
- // tuple.
11735
- {
11736
- name: "Boole",
11737
- kind: "matchfix",
11738
- openTrigger: "[",
11739
- closeTrigger: "]",
11740
- // serialize: (serializer: Serializer, expr: MathJsonExpression) => {
11741
- // const args = ops(expr);
11742
- // return `[${serializer.serialize(arg)}]`;
11743
- // },
11744
- parse: (_parser, body) => {
11745
- const h = operator(body);
11746
- if (!h) return null;
11747
- if (!DEFINITIONS_INEQUALITIES.some((x) => x.name === h)) return null;
11748
- return ["Boole", body];
11749
- }
11750
- },
11751
- {
11752
- kind: "matchfix",
11753
- openTrigger: "\\llbracket",
11754
- closeTrigger: "\\rrbracket",
11755
- parse: (_parser, body) => {
11756
- const h = operator(body);
11757
- if (!h) return null;
11758
- if (!DEFINITIONS_INEQUALITIES.some((x) => x.name === h)) return null;
11759
- return ["Boole", body];
11760
- }
11761
- },
11762
- // Predicate application in First-Order Logic.
11763
- // ["Predicate", "P", "x", "y"] serializes to "P(x, y)"
11764
- {
11765
- name: "Predicate",
11766
- serialize: (serializer, expr2) => {
11767
- const args = operands(expr2);
11768
- if (args.length === 0) return "";
11769
- const pred = args[0];
11770
- const predStr = typeof pred === "string" ? pred : serializer.serialize(pred);
11771
- if (args.length === 1) return predStr;
11772
- const argStrs = args.slice(1).map((arg) => serializer.serialize(arg));
11773
- return `${predStr}(${argStrs.join(", ")})`;
11774
- }
11775
- }
11776
- ];
11777
- function serializeQuantifier(quantifierSymbol) {
11778
- return (serializer, expr2) => {
11779
- const args = operands(expr2);
11780
- if (args.length === 0) return quantifierSymbol;
11781
- if (args.length === 1)
11782
- return `${quantifierSymbol} ${serializer.serialize(args[0])}`;
11783
- const boundVar = serializer.serialize(args[0]);
11784
- const body = serializer.serialize(args[1]);
11785
- return `${quantifierSymbol} ${boundVar}, ${body}`;
11786
- };
11787
- }
11788
- function tightBindingCondition(p, terminator) {
11789
- 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);
11790
- }
11791
- function parseQuantifier(kind) {
11792
- return (parser, terminator) => {
11793
- const index = parser.index;
11794
- const useTightBinding = parser.options.quantifierScope !== "loose";
11795
- const symbol2 = parser.parseSymbol(terminator);
11796
- if (symbol2) {
11797
- parser.skipSpace();
11798
- if (parser.match(",") || parser.match("\\mid") || parser.match(".") || parser.match(":") || parser.match("\\colon")) {
11799
- const bodyTerminator = useTightBinding ? {
11800
- ...terminator,
11801
- condition: (p) => tightBindingCondition(p, terminator)
11802
- } : terminator;
11803
- parser.enterQuantifierScope();
11804
- const body2 = parser.parseExpression(bodyTerminator);
11805
- parser.exitQuantifierScope();
11806
- return [kind, symbol2, missingIfEmpty(body2)];
11807
- }
11808
- parser.enterQuantifierScope();
11809
- const body = parser.parseEnclosure();
11810
- parser.exitQuantifierScope();
11811
- if (body) return [kind, symbol2, missingIfEmpty(body)];
11812
- }
11813
- parser.index = index;
11814
- const condTerminator = {
11815
- ...terminator,
11816
- condition: (p) => p.peek === ":" || p.peek === "\\colon" || (terminator.condition?.(p) ?? false)
11817
- };
11818
- const condition = parser.parseExpression(condTerminator);
11819
- if (condition === null) return null;
11820
- parser.skipSpace();
11821
- if (parser.matchAny([",", "\\mid", ":", "\\colon"])) {
11822
- const bodyTerminator = useTightBinding ? {
11823
- ...terminator,
11824
- condition: (p) => tightBindingCondition(p, terminator)
11825
- } : terminator;
11826
- parser.enterQuantifierScope();
11827
- const body = parser.parseExpression(bodyTerminator);
11828
- parser.exitQuantifierScope();
11829
- return [kind, condition, missingIfEmpty(body)];
11830
- }
11831
- if (parser.match("(")) {
11832
- parser.enterQuantifierScope();
11833
- const body = parser.parseExpression(terminator);
11834
- parser.exitQuantifierScope();
11835
- if (!parser.match(")")) return null;
11836
- return [kind, condition, missingIfEmpty(body)];
11837
- }
11838
- return null;
11839
- };
11840
- }
11841
-
11842
11994
  // src/compute-engine/latex-syntax/dictionary/definitions-sets.ts
11843
11995
  function parseIntervalBody(body, openLeft, openRight) {
11844
11996
  if (isEmptySequence(body)) return null;
@@ -16343,7 +16495,7 @@ var ComputeEngine = (() => {
16343
16495
  var FLAG_SEQUENCE = "\\p{RI}\\p{RI}";
16344
16496
  var TAG_MOD = `(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})`;
16345
16497
  var EMOJI_MOD = `(?:\\p{EMod}|${VS16}${KEYCAP}?|${TAG_MOD})`;
16346
- var EMOJI_NOT_SYMBOL = `(?:(?=\\P{XIDC})\\p{Emoji})`;
16498
+ var EMOJI_NOT_SYMBOL = `(?:(?=\\P{XIDC})(?=[^\\x23\\x2a\\x30-\\x39])\\p{Emoji})`;
16347
16499
  var ZWJ_ELEMENT = `(?:${EMOJI_NOT_SYMBOL}${EMOJI_MOD}*|\\p{Emoji}${EMOJI_MOD}+|${FLAG_SEQUENCE})`;
16348
16500
  var POSSIBLE_EMOJI = `(?:${ZWJ_ELEMENT})(${ZWJ2}${ZWJ_ELEMENT})*`;
16349
16501
  var SOME_EMOJI = new RegExp(`(?:${POSSIBLE_EMOJI})+`, "u");
@@ -17052,7 +17204,9 @@ var ComputeEngine = (() => {
17052
17204
  }
17053
17205
  return c;
17054
17206
  }
17055
- return parser.nextToken();
17207
+ const raw = parser.peek;
17208
+ if (raw && /^[\p{XIDC}\p{M}]/u.test(raw)) return parser.nextToken();
17209
+ return null;
17056
17210
  }
17057
17211
  function parseSymbolBody(parser) {
17058
17212
  let id = matchPrefixedSymbol(parser);
@@ -18342,6 +18496,29 @@ var ComputeEngine = (() => {
18342
18496
  this.index = start;
18343
18497
  return null;
18344
18498
  }
18499
+ /**
18500
+ * Speculatively check if any \text infix entry (e.g. "and", "or", "where")
18501
+ * would match the upcoming tokens. This is used to prevent InvisibleOperator
18502
+ * from consuming \text{keyword} as a text run when the keyword is actually
18503
+ * an infix operator that was skipped due to precedence constraints.
18504
+ *
18505
+ * Returns true if any entry's parse function would succeed (non-null result).
18506
+ * The parser index is always restored to its original position.
18507
+ */
18508
+ wouldMatchTextInfix(opDefs) {
18509
+ const start = this.index;
18510
+ for (const [def, n] of opDefs) {
18511
+ if (def.kind !== "infix") continue;
18512
+ this.index = start + n;
18513
+ const result = def.parse(this, "Nothing", { minPrec: 0 });
18514
+ if (result !== null) {
18515
+ this.index = start;
18516
+ return true;
18517
+ }
18518
+ }
18519
+ this.index = start;
18520
+ return false;
18521
+ }
18345
18522
  /**
18346
18523
  * This returns an array of arguments (as in a function application),
18347
18524
  * or null if there is no match.
@@ -18967,6 +19144,7 @@ var ComputeEngine = (() => {
18967
19144
  if (isDelimiterCommand(this))
18968
19145
  return this.error("unexpected-delimiter", start);
18969
19146
  if (command[0] !== "\\") {
19147
+ this.nextToken();
18970
19148
  return this.error(
18971
19149
  ["unexpected-token", { str: tokensToString(command) }],
18972
19150
  start
@@ -19095,25 +19273,28 @@ var ComputeEngine = (() => {
19095
19273
  if (result === null && until.minPrec <= INVISIBLE_OP_PRECEDENCE) {
19096
19274
  const opDefs = this.peekDefinitions("operator");
19097
19275
  if (opDefs.length === 0 || opDefs.every(([def]) => def.latexTrigger === "\\text")) {
19098
- const rhs = this.parseExpression({
19099
- ...until,
19100
- minPrec: INVISIBLE_OP_PRECEDENCE + 1
19101
- });
19102
- if (rhs !== null) {
19103
- if (operator(lhs) === "InvisibleOperator") {
19104
- if (operator(rhs) === "InvisibleOperator")
19105
- result = [
19106
- "InvisibleOperator",
19107
- ...operands(lhs),
19108
- ...operands(rhs)
19109
- ];
19110
- else result = ["InvisibleOperator", ...operands(lhs), rhs];
19111
- } else if (operator(rhs) === "InvisibleOperator") {
19112
- result = ["InvisibleOperator", lhs, ...operands(rhs)];
19113
- } else result = ["InvisibleOperator", lhs, rhs];
19276
+ if (opDefs.length > 0 && this.wouldMatchTextInfix(opDefs)) {
19114
19277
  } else {
19115
- if (result === null) {
19116
- result = this.options.parseUnexpectedToken?.(lhs, this) ?? null;
19278
+ const rhs = this.parseExpression({
19279
+ ...until,
19280
+ minPrec: INVISIBLE_OP_PRECEDENCE + 1
19281
+ });
19282
+ if (rhs !== null) {
19283
+ if (operator(lhs) === "InvisibleOperator") {
19284
+ if (operator(rhs) === "InvisibleOperator")
19285
+ result = [
19286
+ "InvisibleOperator",
19287
+ ...operands(lhs),
19288
+ ...operands(rhs)
19289
+ ];
19290
+ else result = ["InvisibleOperator", ...operands(lhs), rhs];
19291
+ } else if (operator(rhs) === "InvisibleOperator") {
19292
+ result = ["InvisibleOperator", lhs, ...operands(rhs)];
19293
+ } else result = ["InvisibleOperator", lhs, rhs];
19294
+ } else {
19295
+ if (result === null) {
19296
+ result = this.options.parseUnexpectedToken?.(lhs, this) ?? null;
19297
+ }
19117
19298
  }
19118
19299
  }
19119
19300
  }
@@ -37938,6 +38119,10 @@ ${e.message}
37938
38119
  scoped: true,
37939
38120
  lazy: true,
37940
38121
  signature: "(expression, variable:symbol, variables:symbol+) -> expression",
38122
+ type: ([body]) => {
38123
+ if (body && body.type.matches("number")) return body.type;
38124
+ return void 0;
38125
+ },
37941
38126
  canonical: (ops, { engine: ce, scope }) => {
37942
38127
  if (isSymbol2(ops[0]) && ops[0].canonical.operatorDefinition) {
37943
38128
  const vars = ops.slice(1);
@@ -42509,6 +42694,18 @@ ${e.message}
42509
42694
  }
42510
42695
  }
42511
42696
  ops = flattenInvisibleOperator(ops);
42697
+ if (ops.some((op) => isFunction2(op, "Text") || isString(op))) {
42698
+ const runs = [];
42699
+ for (const op of ops) {
42700
+ if (isFunction2(op, "Text")) {
42701
+ runs.push(...op.ops);
42702
+ } else if (op.operator !== "HorizontalSpacing") {
42703
+ runs.push(op.canonical);
42704
+ }
42705
+ }
42706
+ return ce._fn("Text", runs);
42707
+ }
42708
+ ops = combineFunctionApplications(ce, ops);
42512
42709
  {
42513
42710
  const significant = ops.filter((x) => x.operator !== "HorizontalSpacing");
42514
42711
  if (significant.length === 2) {
@@ -42523,7 +42720,7 @@ ${e.message}
42523
42720
  }
42524
42721
  ops = flatten(ops);
42525
42722
  if (ops.every(
42526
- (x) => x.isValid && (x.type.isUnknown || x.type.matches("number") || x.isIndexedCollection && !isString(x))
42723
+ (x) => x.isValid && (x.type.isUnknown || x.type.type === "any" || x.type.type === "expression" || x.type.matches("number") || x.isIndexedCollection && !isString(x))
42527
42724
  )) {
42528
42725
  return ce._fn("Multiply", ops);
42529
42726
  }
@@ -42538,6 +42735,40 @@ ${e.message}
42538
42735
  }
42539
42736
  return ys;
42540
42737
  }
42738
+ function combineFunctionApplications(ce, ops) {
42739
+ const result = [];
42740
+ let i = 0;
42741
+ while (i < ops.length) {
42742
+ const op = ops[i];
42743
+ if (i < ops.length - 1 && isSymbol2(op) && isFunction2(ops[i + 1], "Delimiter")) {
42744
+ const symName = op.symbol;
42745
+ const def = ce.lookupDefinition(symName);
42746
+ const delim = ops[i + 1];
42747
+ if (def && (isOperatorDef(def) || def.value?.type?.matches("function"))) {
42748
+ let args = delim.op1 ? isFunction2(delim.op1, "Sequence") ? delim.op1.ops : [delim.op1] : [];
42749
+ args = flatten(args);
42750
+ result.push(ce.function(symName, args));
42751
+ i += 2;
42752
+ continue;
42753
+ }
42754
+ if (delim.op1 && isFunction2(delim.op1, "Sequence")) {
42755
+ let args = delim.op1.ops;
42756
+ args = flatten(args);
42757
+ if (args.length > 1) {
42758
+ if (!def) ce.declare(symName, "function");
42759
+ else if (!isOperatorDef(def) && def.value?.type?.isUnknown)
42760
+ op.canonical.infer("function");
42761
+ result.push(ce.function(symName, args));
42762
+ i += 2;
42763
+ continue;
42764
+ }
42765
+ }
42766
+ }
42767
+ result.push(ops[i]);
42768
+ i++;
42769
+ }
42770
+ return result;
42771
+ }
42541
42772
  function asInteger(expr2) {
42542
42773
  if (isNumber(expr2)) {
42543
42774
  const n = expr2.re;
@@ -43541,7 +43772,21 @@ ${e.message}
43541
43772
  },
43542
43773
  Text: {
43543
43774
  description: "A sequence of strings, annotated expressions and other Text expressions",
43544
- signature: "(any*) -> expression"
43775
+ signature: "(any*) -> string",
43776
+ evaluate: (ops, { engine: ce }) => {
43777
+ if (ops.length === 0) return ce.string("");
43778
+ const parts = [];
43779
+ for (const op of ops) {
43780
+ const unwrapped = op.operator === "Annotated" ? op.op1 : op;
43781
+ if (isString(unwrapped)) parts.push(unwrapped.string);
43782
+ else {
43783
+ const evaluated = unwrapped.evaluate();
43784
+ if (isString(evaluated)) parts.push(evaluated.string);
43785
+ else parts.push(evaluated.toString());
43786
+ }
43787
+ }
43788
+ return ce.string(parts.join(""));
43789
+ }
43545
43790
  }
43546
43791
  },
43547
43792
  {
@@ -43636,7 +43881,16 @@ ${e.message}
43636
43881
  if (!isSymbol2(symbol2)) {
43637
43882
  symbol2 = checkType(ce, lhs, "symbol");
43638
43883
  }
43639
- return ce._fn("Assign", [symbol2, args[1].canonical]);
43884
+ const canonRhs = args[1].canonical;
43885
+ const result = ce._fn("Assign", [symbol2, canonRhs]);
43886
+ const symbolName2 = sym(symbol2);
43887
+ if (symbolName2 && isFunction2(canonRhs, "Function")) {
43888
+ if (!ce.lookupDefinition(symbolName2)) ce.symbol(symbolName2);
43889
+ const def = ce.lookupDefinition(symbolName2);
43890
+ if (def && isValueDef(def) && def.value.inferredType)
43891
+ def.value.type = ce.type("function");
43892
+ }
43893
+ return result;
43640
43894
  },
43641
43895
  evaluate: ([op1, op2], { engine: ce }) => {
43642
43896
  if (isFunction2(op1, "Subscript") && sym(op1.op1)) {
@@ -43833,6 +44087,7 @@ ${e.message}
43833
44087
  description: "Simplify an expression.",
43834
44088
  lazy: true,
43835
44089
  signature: "(any) -> expression",
44090
+ type: ([x]) => x?.type ?? void 0,
43836
44091
  canonical: (ops, { engine: ce }) => ce._fn("Simplify", checkArity(ce, ops, 1)),
43837
44092
  evaluate: ([x]) => x.simplify() ?? void 0
43838
44093
  },
@@ -67908,14 +68163,14 @@ ${code}`;
67908
68163
  _setDefaultEngineFactory(() => new ComputeEngine());
67909
68164
 
67910
68165
  // src/compute-engine.ts
67911
- var version = "0.55.0";
68166
+ var version = "0.55.2";
67912
68167
  ComputeEngine._latexSyntaxFactory = () => new LatexSyntax();
67913
68168
  _setDefaultEngineFactory(
67914
68169
  () => new ComputeEngine({ latexSyntax: new LatexSyntax() })
67915
68170
  );
67916
68171
  globalThis[/* @__PURE__ */ Symbol.for("io.cortexjs.compute-engine")] = {
67917
68172
  ComputeEngine: ComputeEngine.prototype.constructor,
67918
- version: "0.55.0"
68173
+ version: "0.55.2"
67919
68174
  };
67920
68175
  return __toCommonJS(compute_engine_exports);
67921
68176
  })();