@cortex-js/compute-engine 0.12.3 → 0.12.5

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 (89) hide show
  1. package/dist/compute-engine.esm.js +24382 -28195
  2. package/dist/compute-engine.js +24557 -0
  3. package/dist/compute-engine.min.esm.js +24540 -2
  4. package/dist/compute-engine.min.js +24553 -2
  5. package/dist/math-json.esm.js +256 -185
  6. package/dist/math-json.js +283 -0
  7. package/dist/math-json.min.esm.js +258 -2
  8. package/dist/math-json.min.js +283 -2
  9. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  10. package/dist/types/common/signals.d.ts +1 -1
  11. package/dist/types/common/utils.d.ts +1 -1
  12. package/dist/types/compute-engine/assume.d.ts +1 -1
  13. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +3 -1
  14. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  15. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  16. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +3 -2
  17. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
  18. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +4 -3
  19. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +2 -2
  20. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  21. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  22. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
  23. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  24. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  25. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  26. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  27. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  28. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  29. package/dist/types/compute-engine/compute-engine.d.ts +4 -3
  30. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  31. package/dist/types/compute-engine/domain-utils.d.ts +1 -1
  32. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  33. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  34. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  35. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  36. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
  37. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  38. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  39. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  40. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +2 -1
  41. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  42. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +25 -16
  43. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  44. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +15 -0
  45. package/dist/types/compute-engine/latex-syntax/parse.d.ts +31 -34
  46. package/dist/types/compute-engine/latex-syntax/public.d.ts +63 -66
  47. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  48. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  49. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +10 -6
  50. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +2 -1
  51. package/dist/types/compute-engine/library/arithmetic-add.d.ts +3 -2
  52. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
  53. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +2 -2
  54. package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
  55. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  56. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  57. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  58. package/dist/types/compute-engine/library/core.d.ts +1 -1
  59. package/dist/types/compute-engine/library/domains.d.ts +1 -1
  60. package/dist/types/compute-engine/library/library.d.ts +1 -1
  61. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  62. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  63. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  64. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  65. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  66. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  67. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  68. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  69. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  70. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  71. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  72. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  73. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  74. package/dist/types/compute-engine/public.d.ts +17 -8
  75. package/dist/types/compute-engine/rules.d.ts +1 -1
  76. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  77. package/dist/types/compute-engine/solve.d.ts +1 -1
  78. package/dist/types/compute-engine/symbolic/expand.d.ts +18 -10
  79. package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
  80. package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
  81. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  82. package/dist/types/compute-engine/symbolic/product.d.ts +4 -1
  83. package/dist/types/compute-engine/symbolic/sum.d.ts +2 -1
  84. package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
  85. package/dist/types/compute-engine.d.ts +2 -2
  86. package/dist/types/math-json/math-json-format.d.ts +1 -1
  87. package/dist/types/math-json/utils.d.ts +4 -1
  88. package/dist/types/math-json.d.ts +2 -2
  89. package/package.json +5 -14
@@ -1,2 +1,283 @@
1
- /** MathJSON 0.12.3 */
2
- var global,factory;global=this,factory=function(n){function t(n){return null!==n&&"object"==typeof n&&"sym"in n}function r(n){return null!==n&&"object"==typeof n&&"fn"in n}function l(n){return null==n?null:"object"==typeof n&&"str"in n?n.str:"string"!=typeof n||n.length<2||"'"!==n[0]||"'"!==n[n.length-1]?null:n.substring(1,n.length-1)}function e(n){return null==n?null:Array.isArray(n)?n[0]:r(n)?n.fn[0]:null}function u(n){return null==n?null:Array.isArray(n)?n.slice(1):r(n)?n.fn.slice(1):null}function o(n,t){var l,e;return null==n?null:Array.isArray(n)?null!==(l=n[t])&&void 0!==l?l:null:r(n)&&null!==(e=n.fn[t])&&void 0!==e?e:null}function i(n){return o(n,2)}function f(n){return null==n?0:Array.isArray(n)?Math.max(0,n.length-1):r(n)?Math.max(0,n.fn.length-1):0}function c(n){var t;const r=e(n);if("KeyValuePair"===r||"Tuple"===r||"Pair"===r){const r=l(function(n){return o(n,1)}(n));return r?[r,null!==(t=i(n))&&void 0!==t?t:"Nothing"]:null}return null}function s(n){if(null===n)return null;if("object"==typeof n&&"dict"in n)return n.dict;const t=c(n);if(t)return{[t[0]]:t[1]};if("Dictionary"===e(n)){const t={};for(let r=1;r<f(n);r++){const l=c(o(n,r));l&&(t[l[0]]=l[1])}return t}return null}n.applyRecursively=function(n,t){var r;const l=e(n);if(null!==l)return[t(l),...(null!==(r=u(n))&&void 0!==r?r:[]).map(t)];const o=s(n);if(null!==o){const n=Object.keys(o),r={};for(const l of n)r[l]=t(o[l]);return{dict:r}}return t(n)},n.getDictionary=s,n.getStringValue=l,n.head=e,n.headName=function(n){const t=e(n);return"string"==typeof t?t:""},n.isDictionaryObject=function(n){return null!==n&&"object"==typeof n&&"dict"in n},n.isFunctionObject=r,n.isStringObject=function(n){return null!==n&&"object"==typeof n&&"str"in n},n.isSymbolObject=t,n.mapArgs=function(n,t){let l=null;if(Array.isArray(n)&&(l=n),r(n)&&(l=n.fn),null===l)return[];let e=1;const u=[];for(;e<l.length;)u.push(t(l[e])),e+=1;return u},n.nops=f,n.op=o,n.symbol=function(n){if(null==n)return null;if("string"==typeof n){if(/^[+\-\.0-9]/.test(n))return null;if(n.length>=2&&"'"===n[0]&&"'"===n[n.length-1])return null}const r=t(n)?n.sym:n;return"string"!=typeof r?null:r},n.version="0.12.3",Object.defineProperty(n,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory((global="undefined"!=typeof globalThis?globalThis:global||self).MathJson={});
1
+ /** CortexJS MathJSON 0.12.5 */
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.MathJson = {}));})(this, (function (exports) { 'use strict';
3
+ var MathJson = (() => {
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/math-json.ts
23
+ var math_json_exports = {};
24
+ __export(math_json_exports, {
25
+ applyRecursively: () => applyRecursively,
26
+ getDictionary: () => dictionary,
27
+ getStringValue: () => stringValue,
28
+ head: () => head,
29
+ headName: () => headName,
30
+ isDictionaryObject: () => isDictionaryObject,
31
+ isFunctionObject: () => isFunctionObject,
32
+ isStringObject: () => isStringObject,
33
+ isSymbolObject: () => isSymbolObject,
34
+ mapArgs: () => mapArgs,
35
+ nops: () => nops,
36
+ op: () => op,
37
+ symbol: () => symbol,
38
+ version: () => version
39
+ });
40
+
41
+ // src/math-json/utils.ts
42
+ function isSymbolObject(expr) {
43
+ return expr !== null && typeof expr === "object" && "sym" in expr;
44
+ }
45
+ function isStringObject(expr) {
46
+ return expr !== null && typeof expr === "object" && "str" in expr;
47
+ }
48
+ function isFunctionObject(expr) {
49
+ return expr !== null && typeof expr === "object" && "fn" in expr;
50
+ }
51
+ function isDictionaryObject(expr) {
52
+ return expr !== null && typeof expr === "object" && "dict" in expr;
53
+ }
54
+ var recommendedScriptsRegex;
55
+ function isRecommendedScripts(text) {
56
+ if (!recommendedScriptsRegex) {
57
+ const recommendedScripts = [
58
+ "Zyyy",
59
+ "Zinh",
60
+ "Arab",
61
+ "Armn",
62
+ "Beng",
63
+ "Bopo",
64
+ "Cyrl",
65
+ "Deva",
66
+ "Ethi",
67
+ "Geor",
68
+ "Grek",
69
+ "Gujr",
70
+ "Guru",
71
+ "Hang",
72
+ "Hani",
73
+ "Hebr",
74
+ "Hira",
75
+ "Kana",
76
+ "Knda",
77
+ "Khmr",
78
+ "Laoo",
79
+ "Latn",
80
+ "Mlym",
81
+ "Mymr",
82
+ "Orya",
83
+ "Sinh",
84
+ "Taml",
85
+ "Telu",
86
+ "Thaa",
87
+ "Thai",
88
+ "Tibt"
89
+ ];
90
+ const regexPattern = `^[${recommendedScripts.map((x) => `\\p{Script=${x}}`).join("")}]*$`;
91
+ recommendedScriptsRegex = new RegExp(regexPattern, "u");
92
+ }
93
+ return recommendedScriptsRegex.test(text);
94
+ }
95
+ function isValidIdentifier(s) {
96
+ if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))
97
+ return true;
98
+ if (ONLY_EMOJIS.test(s))
99
+ return true;
100
+ if (!isRecommendedScripts(s))
101
+ return false;
102
+ return /^[\p{XIDS}_]\p{XIDC}*$/u.test(s);
103
+ }
104
+ var VS16 = "\\u{FE0F}";
105
+ var KEYCAP = "\\u{20E3}";
106
+ var ZWJ = "\\u{200D}";
107
+ var FLAG_SEQUENCE = "\\p{RI}\\p{RI}";
108
+ var TAG_MOD = `(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})`;
109
+ var EMOJI_MOD = `(?:\\p{EMod}|${VS16}${KEYCAP}?|${TAG_MOD})`;
110
+ var EMOJI_NOT_IDENTIFIER = `(?:(?=\\P{XIDC})\\p{Emoji})`;
111
+ var ZWJ_ELEMENT = `(?:${EMOJI_NOT_IDENTIFIER}${EMOJI_MOD}*|\\p{Emoji}${EMOJI_MOD}+|${FLAG_SEQUENCE})`;
112
+ var POSSIBLE_EMOJI = `(?:${ZWJ_ELEMENT})(${ZWJ}${ZWJ_ELEMENT})*`;
113
+ var SOME_EMOJI = new RegExp(`(?:${POSSIBLE_EMOJI})+`, "u");
114
+ var ONLY_EMOJIS = new RegExp(`^(?:${POSSIBLE_EMOJI})+$`, "u");
115
+ function validateIdentifier(s) {
116
+ if (typeof s !== "string")
117
+ return "not-a-string";
118
+ if (s === "")
119
+ return "empty-string";
120
+ if (s.normalize() !== s)
121
+ return "expected-nfc";
122
+ if (/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(s))
123
+ return "unexpected-bidi-marker";
124
+ if (ONLY_EMOJIS.test(s))
125
+ return "valid";
126
+ if (/\p{XIDC}/u.test(s) && SOME_EMOJI.test(s))
127
+ return "unexpected-mixed-emoji";
128
+ if (!isRecommendedScripts(s))
129
+ return "unexpected-script";
130
+ if (!isValidIdentifier(s)) {
131
+ if (!isValidIdentifier(s[0]))
132
+ return "invalid-first-char";
133
+ return "invalid-char";
134
+ }
135
+ return "valid";
136
+ }
137
+ function stringValue(expr) {
138
+ if (expr === null || expr === void 0)
139
+ return null;
140
+ if (typeof expr === "object" && "str" in expr)
141
+ return expr.str;
142
+ if (typeof expr !== "string")
143
+ return null;
144
+ if (expr.length < 2)
145
+ return null;
146
+ if (expr[0] !== "'" || expr[expr.length - 1] !== "'")
147
+ return null;
148
+ return expr.substring(1, expr.length - 1);
149
+ }
150
+ function head(expr) {
151
+ if (expr === null || expr === void 0)
152
+ return null;
153
+ if (Array.isArray(expr)) {
154
+ if (typeof expr[0] === "string" && !isValidIdentifier(expr[0])) {
155
+ console.error(
156
+ `Invalid identifier "${expr[0]}": ${validateIdentifier(expr[0])}`
157
+ );
158
+ return null;
159
+ }
160
+ return expr[0];
161
+ }
162
+ if (isFunctionObject(expr))
163
+ return expr.fn[0];
164
+ return null;
165
+ }
166
+ function headName(expr) {
167
+ const h = head(expr);
168
+ return typeof h === "string" ? h : "";
169
+ }
170
+ function ops(expr) {
171
+ if (expr === null || expr === void 0)
172
+ return null;
173
+ if (Array.isArray(expr))
174
+ return expr.slice(1);
175
+ if (isFunctionObject(expr))
176
+ return expr.fn.slice(1);
177
+ return null;
178
+ }
179
+ function op(expr, n) {
180
+ if (expr === null || expr === void 0)
181
+ return null;
182
+ if (Array.isArray(expr))
183
+ return expr[n] ?? null;
184
+ if (isFunctionObject(expr))
185
+ return expr.fn[n] ?? null;
186
+ return null;
187
+ }
188
+ function op1(expr) {
189
+ return op(expr, 1);
190
+ }
191
+ function op2(expr) {
192
+ return op(expr, 2);
193
+ }
194
+ function nops(expr) {
195
+ if (expr === null || expr === void 0)
196
+ return 0;
197
+ if (Array.isArray(expr))
198
+ return Math.max(0, expr.length - 1);
199
+ if (isFunctionObject(expr))
200
+ return Math.max(0, expr.fn.length - 1);
201
+ return 0;
202
+ }
203
+ function symbol(expr) {
204
+ if (expr === null || expr === void 0)
205
+ return null;
206
+ if (typeof expr === "string") {
207
+ if (/^[+\-\.0-9]/.test(expr))
208
+ return null;
209
+ if (expr.length >= 2 && expr[0] === "'" && expr[expr.length - 1] === "'")
210
+ return null;
211
+ }
212
+ const s = isSymbolObject(expr) ? expr.sym : expr;
213
+ if (typeof s !== "string")
214
+ return null;
215
+ return s;
216
+ }
217
+ function keyValuePair(expr) {
218
+ const h = head(expr);
219
+ if (h === "KeyValuePair" || h === "Tuple" || h === "Pair") {
220
+ const key = stringValue(op1(expr));
221
+ if (!key)
222
+ return null;
223
+ return [key, op2(expr) ?? "Nothing"];
224
+ }
225
+ return null;
226
+ }
227
+ function dictionary(expr) {
228
+ if (expr === null)
229
+ return null;
230
+ if (typeof expr === "object" && "dict" in expr)
231
+ return expr.dict;
232
+ const kv = keyValuePair(expr);
233
+ if (kv)
234
+ return { [kv[0]]: kv[1] };
235
+ const h = head(expr);
236
+ if (h === "Dictionary") {
237
+ const result = {};
238
+ for (let i = 1; i < nops(expr); i++) {
239
+ const kv2 = keyValuePair(op(expr, i));
240
+ if (kv2)
241
+ result[kv2[0]] = kv2[1];
242
+ }
243
+ return result;
244
+ }
245
+ return null;
246
+ }
247
+ function applyRecursively(expr, fn) {
248
+ const h = head(expr);
249
+ if (h !== null) {
250
+ return [fn(h), ...(ops(expr) ?? []).map(fn)];
251
+ }
252
+ const dict = dictionary(expr);
253
+ if (dict !== null) {
254
+ const keys = Object.keys(dict);
255
+ const result = {};
256
+ for (const key of keys)
257
+ result[key] = fn(dict[key]);
258
+ return { dict: result };
259
+ }
260
+ return fn(expr);
261
+ }
262
+ function mapArgs(expr, fn) {
263
+ let args = null;
264
+ if (Array.isArray(expr))
265
+ args = expr;
266
+ if (isFunctionObject(expr))
267
+ args = expr.fn;
268
+ if (args === null)
269
+ return [];
270
+ let i = 1;
271
+ const result = [];
272
+ while (i < args.length) {
273
+ result.push(fn(args[i]));
274
+ i += 1;
275
+ }
276
+ return result;
277
+ }
278
+
279
+ // src/math-json.ts
280
+ var version = "0.12.5";
281
+ return __toCommonJS(math_json_exports);
282
+ })();
283
+ Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  /**
3
3
  * Return a string or an array of graphemes.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export type SignalCode = RuntimeSignalCode | ('invalid-name' | 'expected-predicate' | 'expected-symbol' | 'operator-requires-one-operand' | 'postfix-operator-requires-one-operand' | 'prefix-operator-requires-one-operand' | 'unbalanced-symbols' | 'expected-argument' | 'unexpected-command' | 'cyclic-definition' | 'invalid-supersets' | 'expected-supersets' | 'unknown-domain' | 'duplicate-wikidata' | 'invalid-dictionary-entry' | 'syntax-error');
3
3
  export type SignalMessage = SignalCode | [SignalCode, ...any[]];
4
4
  export type SignalOrigin = {
@@ -1 +1 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  /**
3
3
  * Add an assumption, in the form of a predicate, for example:
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  import { Complex } from 'complex.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
4
  import { BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSymbolDefinition, BoxedDomain, EvaluateOptions, IComputeEngine, LatexString, Metadata, NOptions, PatternMatchOptions, SemiBoxedExpression, SimplifyOptions, Substitution, RuntimeScope, DomainCompatibility, DomainLiteral, BoxedBaseDefinition, Rational, BoxedSubstitution } from '../public';
@@ -30,6 +30,8 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
30
30
  [Symbol.toPrimitive](hint: 'number' | 'string' | 'default'): number | string | null;
31
31
  /** Called by `JSON.stringify()` when serializing to json */
32
32
  toJSON(): Expression;
33
+ /** @internal */
34
+ get rawJson(): Expression;
33
35
  get scope(): RuntimeScope | null;
34
36
  /** Object.is() */
35
37
  is(rhs: any): boolean;
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { IComputeEngine, SemiBoxedExpression, BoxedExpression, Metadata, Rational } from '../public';
4
4
  import { MathJsonNumber } from '../../math-json/math-json-format';
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata, PatternMatchOptions, BoxedDomain, BoxedSubstitution } from '../public';
3
3
  import { AbstractBoxedExpression } from './abstract-boxed-expression';
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  import { BoxedDomain, BoxedExpression, BoxedSubstitution, DomainCompatibility, DomainConstructor, DomainExpression, DomainLiteral, IComputeEngine, Metadata, PatternMatchOptions } from '../public';
3
3
  import { AbstractBoxedExpression } from './abstract-boxed-expression';
4
4
  /**
@@ -43,8 +43,9 @@ export declare class _BoxedDomain extends AbstractBoxedExpression implements Box
43
43
  * Note that `boxDomain()` should only be called from `ComputeEngine`.
44
44
  * This gives a chance for `ComputeEngine` to substitute cached objects.
45
45
  */
46
- export declare function boxDomain(ce: IComputeEngine, dom: BoxedDomain | DomainExpression, metadata?: Metadata): BoxedDomain;
46
+ export declare function boxDomain(ce: IComputeEngine, dom: BoxedExpression | DomainExpression, metadata?: Metadata): BoxedDomain;
47
47
  /** Validate that `expr` is a Domain */
48
48
  export declare function isDomain(expr: Expression | BoxedExpression | BoxedDomain | DomainExpression): expr is BoxedDomain | DomainExpression;
49
+ export declare function isValidDomain(expr: any): expr is BoxedDomain | DomainExpression;
49
50
  /** Return the ancestor domain that is shared by both `a` and `b` */
50
51
  export declare function sharedAncestorDomain(a: BoxedDomain, b: BoxedDomain): BoxedDomain;
@@ -1,2 +1,2 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export declare function makeFunctionDefinition(engine: IComputeEngine, name: string, def: FunctionDefinition | BoxedFunctionDefinition): BoxedFunctionDefinition;
@@ -1,6 +1,6 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  import { Expression } from '../../math-json/math-json-format';
3
- import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedSubstitution } from '../public';
3
+ import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedSubstitution, EvaluateOptions } from '../public';
4
4
  /**
5
5
  * BoxedFunction
6
6
  */
@@ -29,6 +29,7 @@ export declare class BoxedFunction extends AbstractBoxedExpression {
29
29
  set isCanonical(val: boolean);
30
30
  get isPure(): boolean;
31
31
  get json(): Expression;
32
+ get rawJson(): Expression;
32
33
  get scope(): RuntimeScope | null;
33
34
  get head(): string | BoxedExpression;
34
35
  get ops(): BoxedExpression[];
@@ -86,7 +87,7 @@ export declare class BoxedFunction extends AbstractBoxedExpression {
86
87
  }
87
88
  export declare function makeCanonicalFunction(ce: IComputeEngine, head: string | BoxedExpression, ops: SemiBoxedExpression[], metadata?: Metadata): BoxedExpression;
88
89
  /** Apply arguments to an expression. If the expression is a lambda expression
89
- * it's wildcard arguments are substituted before being evaluated. Otherwise
90
+ * its wildcard arguments are substituted before being evaluated. Otherwise
90
91
  * the expression is just evaluated.
91
92
  */
92
93
  export declare function apply(fn: BoxedExpression, args: BoxedExpression[]): BoxedExpression;
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  import { Complex } from 'complex.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
4
  import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, NOptions, PatternMatchOptions, Rational, SimplifyOptions, BoxedSubstitution } from '../public';
@@ -35,7 +35,7 @@ export declare class BoxedNumber extends AbstractBoxedExpression {
35
35
  set isCanonical(val: boolean);
36
36
  get complexity(): number;
37
37
  get value(): BoxedExpression;
38
- get numericValue(): number | Decimal | Complex | Rational | null;
38
+ get numericValue(): number | Decimal | Complex | Rational;
39
39
  get domain(): BoxedDomain;
40
40
  get json(): Expression;
41
41
  get sgn(): -1 | 0 | 1 | undefined | null;
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  import { AbstractBoxedExpression } from './abstract-boxed-expression';
3
3
  import { BoxedExpression, BoxedSubstitution, BoxedDomain, IComputeEngine, LatexString, Metadata, Pattern, PatternMatchOptions, SemiBoxedExpression, Substitution } from '../public';
4
4
  export declare class BoxedPattern extends AbstractBoxedExpression implements Pattern {
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  import { AbstractBoxedExpression } from './abstract-boxed-expression';
3
3
  import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, PatternMatchOptions, BoxedSubstitution } from '../public';
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  /**
3
3
  * THEORY OF OPERATIONS
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  import { AbstractBoxedExpression } from './abstract-boxed-expression';
3
3
  import { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, EvaluateOptions, NOptions, ReplaceOptions, SimplifyOptions, Substitution, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedFunctionDefinition, BoxedBaseDefinition, DomainExpression, BoxedSubstitution } from '../public';
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export declare class ExpressionMap<U> implements ExpressionMapInterface<U> {
3
3
  readonly _items: Map<BoxedExpression, U>;
4
4
  constructor(source?: ExpressionMapInterface<U> | readonly (readonly [BoxedExpression, U])[]);
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export type Order = 'lex' | 'dexlex' | 'grevlex' | 'elim';
3
3
  export declare const DEFAULT_COMPLEXITY = 100000;
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  import Decimal from 'decimal.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
4
  import { BoxedExpression, IComputeEngine, Metadata, Rational } from '../public';
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  import { Expression } from '../../math-json/math-json-format';
3
3
  import { BoxedExpression, IComputeEngine } from '../public';
4
4
  export declare function isLatexString(s: unknown): s is string;
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export declare function validateArgumentCount(ce: IComputeEngine, ops: BoxedExpression[], count: number): BoxedExpression[];
3
3
  /**
4
4
  * Validation of arguments is normally done by checking the signature of the
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  import { Complex } from 'complex.js';
3
3
  import { Expression, MathJsonNumber } from '../math-json/math-json-format';
4
4
  import type { LibraryCategory, LatexDictionary, LatexDictionaryEntry, LatexString, NumberFormattingOptions, ParseLatexOptions, SerializeLatexOptions } from './latex-syntax/public';
@@ -279,10 +279,11 @@ export declare class ComputeEngine implements IComputeEngine {
279
279
  canonical?: boolean;
280
280
  }): BoxedExpression;
281
281
  canonical(xs: SemiBoxedExpression[]): BoxedExpression[];
282
- fn(head: string, ops: BoxedExpression[], metadata?: Metadata): BoxedExpression;
282
+ fn(head: string, ops: BoxedExpression[], options?: {
283
+ canonical: boolean;
284
+ }): BoxedExpression;
283
285
  /** @internal */
284
286
  _fn(head: string | BoxedExpression, ops: BoxedExpression[], metadata?: Metadata): BoxedExpression;
285
- error(message: ['invalid-domain', ...SemiBoxedExpression[]], where?: SemiBoxedExpression): BoxedDomain;
286
287
  error(message: string | [string, ...SemiBoxedExpression[]], where?: SemiBoxedExpression): BoxedExpression;
287
288
  hold(expr: SemiBoxedExpression): BoxedExpression;
288
289
  add(ops: BoxedExpression[], metadata?: Metadata): BoxedExpression;
@@ -1,3 +1,3 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export declare function costFunction(expr: BoxedExpression): number;
3
3
  export declare const DEFAULT_COST_FUNCTION: typeof costFunction;
@@ -1,4 +1,4 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { BoxedExpression, Rational } from './public';
4
4
  /** Quickly determine the numeric domain of a number or constant
@@ -1,2 +1,2 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export declare const DEFINITIONS_ALGEBRA: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export declare const DEFINITIONS_ARITHMETIC: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export declare const DEFINITIONS_CALCULUS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export declare const DEFINITIONS_CORE: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export declare const DEFINITIONS_INEQUALITIES: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export declare const DEFINITIONS_LOGIC: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export declare const DEFINITIONS_OTHERS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export declare const DEFINITIONS_SETS: LatexDictionary;
@@ -1,2 +1,3 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
+ export declare const SYMBOLS: [string, string, number][];
2
3
  export declare const DEFINITIONS_SYMBOLS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  export declare const DEFINITIONS_TRIGONOMETRY: LatexDictionary;
@@ -1,36 +1,45 @@
1
- /* 0.12.3 */
1
+ /* 0.12.5 */
2
2
  import { WarningSignal } from '../../../common/signals';
3
3
  export type CommonEntry = {
4
4
  name?: string;
5
5
  serialize: SerializeHandler | LatexString;
6
6
  };
7
- export type SymbolEntry = CommonEntry & {
8
- kind: 'symbol';
7
+ export type IndexedIdentifierEntry = CommonEntry & {
8
+ kind: 'identifier';
9
9
  precedence: number;
10
- parse: SymbolParseHandler;
10
+ parse: IdentifierParseHandler;
11
11
  };
12
- export type FunctionEntry = CommonEntry & {
12
+ /**
13
+ * A function has the following form:
14
+ * - a prefix such as `\mathrm` or `\operatorname`
15
+ * - a trigger string, such as `gcd`
16
+ * - some postfix operators such as `\prime`
17
+ * - an optional list of arguments in an enclosure (parentheses)
18
+ *
19
+ * Functions of this type are indexed in the dictionary by their trigger string.
20
+ */
21
+ export type IndexedFunctionEntry = CommonEntry & {
13
22
  kind: 'function';
14
23
  parse: FunctionParseHandler;
15
24
  };
16
- export type MatchfixEntry = CommonEntry & {
25
+ export type IndexedMatchfixEntry = CommonEntry & {
17
26
  kind: 'matchfix';
18
27
  openDelimiter: Delimiter | LatexToken[];
19
28
  closeDelimiter: Delimiter | LatexToken[];
20
29
  parse: MatchfixParseHandler;
21
30
  };
22
- export type InfixEntry = CommonEntry & {
31
+ export type IndexedInfixEntry = CommonEntry & {
23
32
  kind: 'infix';
24
33
  associativity: 'right' | 'left' | 'non' | 'both';
25
34
  precedence: number;
26
35
  parse: InfixParseHandler;
27
36
  };
28
- export type PrefixEntry = CommonEntry & {
37
+ export type IndexedPrefixEntry = CommonEntry & {
29
38
  kind: 'prefix';
30
39
  precedence: number;
31
40
  parse: PrefixParseHandler;
32
41
  };
33
- export type PostfixEntry = CommonEntry & {
42
+ export type IndexedPostfixEntry = CommonEntry & {
34
43
  kind: 'postfix';
35
44
  precedence: number;
36
45
  parse: PostfixParseHandler;
@@ -39,16 +48,16 @@ export type EnvironmentEntry = CommonEntry & {
39
48
  kind: 'environment';
40
49
  parse: EnvironmentParseHandler;
41
50
  };
42
- export type IndexedLatexDictionaryEntry = FunctionEntry | SymbolEntry | MatchfixEntry | InfixEntry | PrefixEntry | PostfixEntry | EnvironmentEntry;
51
+ export type IndexedLatexDictionaryEntry = IndexedFunctionEntry | IndexedIdentifierEntry | IndexedMatchfixEntry | IndexedInfixEntry | IndexedPrefixEntry | IndexedPostfixEntry | EnvironmentEntry;
43
52
  export type IndexedLatexDictionary = {
44
53
  lookahead: number;
45
54
  name: Map<string, IndexedLatexDictionaryEntry>;
46
- function: Map<string, FunctionEntry[]>;
47
- symbol: (Map<LatexString, SymbolEntry[]> | null)[];
48
- prefix: (Map<LatexString, PrefixEntry[]> | null)[];
49
- infix: (Map<LatexString, InfixEntry[]> | null)[];
50
- postfix: (Map<LatexString, PostfixEntry[]> | null)[];
51
- matchfix: MatchfixEntry[];
55
+ function: Map<string, IndexedFunctionEntry[]>;
56
+ identifier: (Map<LatexString, IndexedIdentifierEntry[]> | null)[];
57
+ prefix: (Map<LatexString, IndexedPrefixEntry[]> | null)[];
58
+ infix: (Map<LatexString, IndexedInfixEntry[]> | null)[];
59
+ postfix: (Map<LatexString, IndexedPostfixEntry[]> | null)[];
60
+ matchfix: IndexedMatchfixEntry[];
52
61
  environment: Map<string, EnvironmentEntry>;
53
62
  };
54
63
  export declare function indexLatexDictionary(dic: readonly LatexDictionaryEntry[], onError: (sig: WarningSignal) => void): IndexedLatexDictionary;