@cortex-js/compute-engine 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compute-engine.esm.js +14942 -11619
- package/dist/compute-engine.min.esm.js +2 -2
- package/dist/compute-engine.min.js +2 -2
- package/dist/math-json.esm.js +62 -43
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +72 -57
- package/dist/types/compute-engine/boxed-expression/box.d.ts +2 -14
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +4 -4
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +36 -19
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +46 -38
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +6 -4
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +5 -5
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +13 -10
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +28 -14
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +25 -8
- package/dist/types/compute-engine/compute-engine.d.ts +72 -49
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -3
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +8 -7
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +3 -3
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +87 -62
- package/dist/types/compute-engine/latex-syntax/public.d.ts +65 -46
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +6 -4
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +11 -0
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +15 -0
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +19 -0
- package/dist/types/compute-engine/{dictionary → library}/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +2 -0
- package/dist/types/compute-engine/library/calculus.d.ts +2 -0
- package/dist/types/compute-engine/library/collections.d.ts +2 -0
- package/dist/types/compute-engine/library/core.d.ts +2 -0
- package/dist/types/compute-engine/library/domains.d.ts +15 -0
- package/dist/types/compute-engine/library/library.d.ts +17 -0
- package/dist/types/compute-engine/library/logic.d.ts +2 -0
- package/dist/types/compute-engine/library/polynomials.d.ts +2 -0
- package/dist/types/compute-engine/library/relational-operator.d.ts +2 -0
- package/dist/types/compute-engine/library/sets.d.ts +2 -0
- package/dist/types/compute-engine/library/trigonometry.d.ts +2 -0
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-decimal.d.ts +5 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +4 -2
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/public.d.ts +717 -504
- package/dist/types/compute-engine/rules.d.ts +1 -1
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/sum.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +27 -23
- package/dist/types/math-json/utils.d.ts +22 -16
- package/dist/types/math-json.d.ts +3 -3
- package/package.json +20 -20
- package/dist/types/compute-engine/dictionary/arithmetic-add.d.ts +0 -11
- package/dist/types/compute-engine/dictionary/arithmetic-divide.d.ts +0 -9
- package/dist/types/compute-engine/dictionary/arithmetic-multiply.d.ts +0 -17
- package/dist/types/compute-engine/dictionary/arithmetic.d.ts +0 -2
- package/dist/types/compute-engine/dictionary/collections.d.ts +0 -2
- package/dist/types/compute-engine/dictionary/core.d.ts +0 -2
- package/dist/types/compute-engine/dictionary/dictionary.d.ts +0 -26
- package/dist/types/compute-engine/dictionary/logic.d.ts +0 -2
- package/dist/types/compute-engine/dictionary/polynomials.d.ts +0 -2
- package/dist/types/compute-engine/dictionary/relational-operator.d.ts +0 -2
- package/dist/types/compute-engine/dictionary/sets.d.ts +0 -2
- package/dist/types/compute-engine/dictionary/trigonometry.d.ts +0 -2
package/dist/math-json.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** MathJSON 0.
|
|
1
|
+
/** MathJSON 0.8.0 */
|
|
2
2
|
/**
|
|
3
3
|
* These constants are the 'primitive' functions and constants that are used
|
|
4
4
|
* for some basic manipulations such as parsing, and transforming to canonical
|
|
@@ -32,7 +32,7 @@ function isAtomic(expr) {
|
|
|
32
32
|
* **U+0027 APOSTROPHE** : **`'`** or an object literal with a `str` key.
|
|
33
33
|
*/
|
|
34
34
|
function stringValue(expr) {
|
|
35
|
-
if (expr === null)
|
|
35
|
+
if (expr === null || expr === undefined)
|
|
36
36
|
return null;
|
|
37
37
|
if (typeof expr === 'object' && 'str' in expr)
|
|
38
38
|
return expr.str;
|
|
@@ -54,7 +54,7 @@ function stringValue(expr) {
|
|
|
54
54
|
* * `[["Prime", "f"], "x"]` -> `["Prime", "f"]`
|
|
55
55
|
*/
|
|
56
56
|
function head(expr) {
|
|
57
|
-
if (expr === null)
|
|
57
|
+
if (expr === null || expr === undefined)
|
|
58
58
|
return null;
|
|
59
59
|
if (Array.isArray(expr))
|
|
60
60
|
return expr[0];
|
|
@@ -68,7 +68,7 @@ function headName(expr) {
|
|
|
68
68
|
return typeof h === 'string' ? h : '';
|
|
69
69
|
}
|
|
70
70
|
function op(expr, n) {
|
|
71
|
-
if (expr === null)
|
|
71
|
+
if (expr === null || expr === undefined)
|
|
72
72
|
return null;
|
|
73
73
|
if (Array.isArray(expr))
|
|
74
74
|
return expr[n] ?? null;
|
|
@@ -76,43 +76,43 @@ function op(expr, n) {
|
|
|
76
76
|
return expr.fn[n] ?? null;
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Return all the elements but the first one, i.e. the arguments of a
|
|
81
|
+
* function.
|
|
82
|
+
*/
|
|
83
|
+
function ops(expr) {
|
|
84
|
+
if (expr === null || expr === undefined)
|
|
85
|
+
return null;
|
|
86
|
+
if (Array.isArray(expr))
|
|
87
|
+
return expr.slice(1);
|
|
88
|
+
if (isFunctionObject(expr))
|
|
89
|
+
return expr.fn.slice(1);
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
79
92
|
function nops(expr) {
|
|
80
|
-
if (
|
|
93
|
+
if (expr === null || expr === undefined)
|
|
94
|
+
return 0;
|
|
95
|
+
if (Array.isArray(expr))
|
|
81
96
|
return Math.max(0, expr.length - 1);
|
|
82
|
-
|
|
83
|
-
if (isFunctionObject(expr)) {
|
|
97
|
+
if (isFunctionObject(expr))
|
|
84
98
|
return Math.max(0, expr.fn.length - 1);
|
|
85
|
-
}
|
|
86
99
|
return 0;
|
|
87
100
|
}
|
|
88
101
|
function symbol(expr) {
|
|
89
|
-
if (expr === null)
|
|
102
|
+
if (expr === null || expr === undefined)
|
|
90
103
|
return null;
|
|
91
104
|
const s = isSymbolObject(expr) ? expr.sym : expr;
|
|
92
105
|
if (typeof s !== 'string')
|
|
93
106
|
return null;
|
|
94
|
-
|
|
95
|
-
|
|
107
|
+
// Is it a string literal?
|
|
108
|
+
if (s.length >= 2 && s[0] === "'" && s[s.length - 1] === "'")
|
|
96
109
|
return null;
|
|
97
|
-
}
|
|
98
110
|
return s;
|
|
99
111
|
}
|
|
100
|
-
function string(expr) {
|
|
101
|
-
if (expr === null)
|
|
102
|
-
return null;
|
|
103
|
-
const s = isSymbolObject(expr) ? expr.sym : expr;
|
|
104
|
-
if (typeof s !== 'string')
|
|
105
|
-
return null;
|
|
106
|
-
if (s.length < 2 || s[0] !== "'" || s[s.length - 1] !== "'") {
|
|
107
|
-
// It's a symbol
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
return s.slice(1, -1);
|
|
111
|
-
}
|
|
112
112
|
function keyValuePair(expr) {
|
|
113
113
|
const h = head(expr);
|
|
114
114
|
if (h === 'KeyValuePair' || h === 'Tuple' || h === 'Pair') {
|
|
115
|
-
const key =
|
|
115
|
+
const key = stringValue(op(expr, 1));
|
|
116
116
|
if (!key)
|
|
117
117
|
return null;
|
|
118
118
|
return [key, op(expr, 2) ?? 'Nothing'];
|
|
@@ -128,7 +128,7 @@ function dictionary(expr) {
|
|
|
128
128
|
if (kv)
|
|
129
129
|
return { [kv[0]]: kv[1] };
|
|
130
130
|
const h = head(expr);
|
|
131
|
-
if (h === '
|
|
131
|
+
if (h === 'Dictionary') {
|
|
132
132
|
const result = {};
|
|
133
133
|
for (let i = 1; i < nops(expr); i++) {
|
|
134
134
|
const kv = keyValuePair(op(expr, i));
|
|
@@ -139,23 +139,10 @@ function dictionary(expr) {
|
|
|
139
139
|
}
|
|
140
140
|
return null;
|
|
141
141
|
}
|
|
142
|
-
/**
|
|
143
|
-
* Return all the elements but the first one, i.e. the arguments of a
|
|
144
|
-
* function.
|
|
145
|
-
*/
|
|
146
|
-
function tail(expr) {
|
|
147
|
-
if (Array.isArray(expr)) {
|
|
148
|
-
return expr.slice(1);
|
|
149
|
-
}
|
|
150
|
-
if (isFunctionObject(expr)) {
|
|
151
|
-
return expr.fn.slice(1);
|
|
152
|
-
}
|
|
153
|
-
return [];
|
|
154
|
-
}
|
|
155
142
|
function applyRecursively(expr, fn) {
|
|
156
143
|
const h = head(expr);
|
|
157
144
|
if (h !== null) {
|
|
158
|
-
return [fn(h), ...
|
|
145
|
+
return [fn(h), ...(ops(expr) ?? []).map(fn)];
|
|
159
146
|
}
|
|
160
147
|
const dict = dictionary(expr);
|
|
161
148
|
if (dict !== null) {
|
|
@@ -207,9 +194,41 @@ function asValidJSONNumber(num) {
|
|
|
207
194
|
}
|
|
208
195
|
}
|
|
209
196
|
return num;
|
|
210
|
-
}
|
|
197
|
+
}
|
|
198
|
+
// function number(
|
|
199
|
+
// expr: Expression | null | undefined
|
|
200
|
+
// ): number | string | null {
|
|
201
|
+
// if (expr === null || expr === undefined) return null;
|
|
202
|
+
// if (typeof expr === 'number') return expr;
|
|
203
|
+
// if (isNumberObject(expr)) return expr.num;
|
|
204
|
+
// return null;
|
|
205
|
+
// }
|
|
206
|
+
// export function isEqual(lhs: Expression, rhs: Expression): boolean {
|
|
207
|
+
// const symbLhs = symbol(lhs);
|
|
208
|
+
// if (symbLhs) return symbLhs === symbol(rhs);
|
|
209
|
+
// const strLhs = string(lhs);
|
|
210
|
+
// if (strLhs) return strLhs === string(rhs);
|
|
211
|
+
// if (Array.isArray(lhs) || isFunctionObject(lhs)) {
|
|
212
|
+
// if (!(Array.isArray(rhs) || isFunctionObject(rhs))) return false;
|
|
213
|
+
// if (nops(lhs) !== nops(rhs)) return false;
|
|
214
|
+
// if (!isEqual(head(lhs)!, head(rhs)!)) return false;
|
|
215
|
+
// const lhsTail = tail(lhs);
|
|
216
|
+
// const rhsTail = tail(rhs);
|
|
217
|
+
// for (let i = 0; i <= nops(lhs); i += 1)
|
|
218
|
+
// if (!isEqual(lhsTail[i], rhsTail[i])) return false;
|
|
219
|
+
// return true;
|
|
220
|
+
// }
|
|
221
|
+
// if (typeof lhs === 'number' || isNumberObject(lhs)) {
|
|
222
|
+
// if (!(typeof rhs === 'number' || isNumberObject(rhs))) return false;
|
|
223
|
+
// const mLhs = number(lhs);
|
|
224
|
+
// const mRhs = number(rhs);
|
|
225
|
+
// if (mLhs !== null) return mLhs === mRhs;
|
|
226
|
+
// return false;
|
|
227
|
+
// }
|
|
228
|
+
// return false;
|
|
229
|
+
// }
|
|
211
230
|
|
|
212
231
|
// This is the root of the `math-json` package (i.e. `math-json.js` and
|
|
213
|
-
const version = '0.
|
|
232
|
+
const version = '0.8.0';
|
|
214
233
|
|
|
215
|
-
export { applyRecursively, asValidJSONNumber, dictionary as getDictionary, stringValue as getStringValue, head, headName, isAtomic, isDictionaryObject, isFunctionObject, isStringObject, isSymbolObject, mapArgs, nops, op, symbol,
|
|
234
|
+
export { applyRecursively, asValidJSONNumber, dictionary as getDictionary, stringValue as getStringValue, head, headName, isAtomic, isDictionaryObject, isFunctionObject, isStringObject, isSymbolObject, mapArgs, nops, op, symbol, version };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** MathJSON 0.
|
|
2
|
-
function n(n){return null!==n&&"object"==typeof n&&"sym"in n}function t(n){return null!==n&&"object"==typeof n&&"str"in n}function r(n){return null!==n&&"object"==typeof n&&"fn"in n}function u(n){return null!==n&&"object"==typeof n&&"dict"in n}function l(n){return null===n||!Array.isArray(n)&&("object"!=typeof n||!("fn"in n||"dic"in n))}function e(n){return null
|
|
1
|
+
/** MathJSON 0.8.0 */
|
|
2
|
+
function n(n){return null!==n&&"object"==typeof n&&"sym"in n}function t(n){return null!==n&&"object"==typeof n&&"str"in n}function r(n){return null!==n&&"object"==typeof n&&"fn"in n}function u(n){return null!==n&&"object"==typeof n&&"dict"in n}function l(n){return null===n||!Array.isArray(n)&&("object"!=typeof n||!("fn"in n||"dic"in n))}function e(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 i(n){return null==n?null:Array.isArray(n)?n[0]:r(n)?n.fn[0]:null}function o(n){const t=i(n);return"string"==typeof t?t:""}function f(n,t){return null==n?null:Array.isArray(n)?n[t]??null:r(n)?n.fn[t]??null:null}function c(n){return null==n?null:Array.isArray(n)?n.slice(1):r(n)?n.fn.slice(1):null}function s(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 y(t){if(null==t)return null;const r=n(t)?t.sym:t;return"string"!=typeof r||r.length>=2&&"'"===r[0]&&"'"===r[r.length-1]?null:r}function a(n){const t=i(n);if("KeyValuePair"===t||"Tuple"===t||"Pair"===t){const t=e(f(n,1));return t?[t,f(n,2)??"Nothing"]:null}return null}function g(n){if(null===n)return null;if("object"==typeof n&&"dict"in n)return n.dict;const t=a(n);if(t)return{[t[0]]:t[1]};if("Dictionary"===i(n)){const t={};for(let r=1;r<s(n);r++){const u=a(f(n,r));u&&(t[u[0]]=u[1])}return t}return null}function p(n,t){const r=i(n);if(null!==r)return[t(r),...(c(n)??[]).map(t)];const u=g(n);if(null!==u){const n=Object.keys(u),r={};for(const l of n)r[l]=t(u[l]);return{dict:r}}return t(n)}function h(n,t){let u=null;if(Array.isArray(n)&&(u=n),r(n)&&(u=n.fn),null===u)return[];let l=1;const e=[];for(;l<u.length;)e.push(t(u[l])),l+=1;return e}function A(n){if("string"==typeof n){const t=Number(n);if("+"===n[0]&&(n=n.slice(1)),t.toString()===n)return isNaN(t)||!isFinite(t)?t.toString():t}return n}const b="0.8.0";export{p as applyRecursively,A as asValidJSONNumber,g as getDictionary,e as getStringValue,i as head,o as headName,l as isAtomic,u as isDictionaryObject,r as isFunctionObject,t as isStringObject,n as isSymbolObject,h as mapArgs,s as nops,f as op,y as symbol,b as version};
|
package/dist/math-json.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** MathJSON 0.
|
|
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 e(n){return null
|
|
1
|
+
/** MathJSON 0.8.0 */
|
|
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 i(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 u(n){return null==n?null:Array.isArray(n)?n.slice(1):r(n)?n.fn.slice(1):null}function o(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 f(n){var t;const r=e(n);if("KeyValuePair"===r||"Tuple"===r||"Pair"===r){const r=l(i(n,1));return r?[r,null!==(t=i(n,2))&&void 0!==t?t:"Nothing"]:null}return null}function c(n){if(null===n)return null;if("object"==typeof n&&"dict"in n)return n.dict;const t=f(n);if(t)return{[t[0]]:t[1]};if("Dictionary"===e(n)){const t={};for(let r=1;r<o(n);r++){const l=f(i(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 i=c(n);if(null!==i){const n=Object.keys(i),r={};for(const l of n)r[l]=t(i[l]);return{dict:r}}return t(n)},n.asValidJSONNumber=function(n){if("string"==typeof n){const t=Number(n);if("+"===n[0]&&(n=n.slice(1)),t.toString()===n)return isNaN(t)||!isFinite(t)?t.toString():t}return n},n.getDictionary=c,n.getStringValue=l,n.head=e,n.headName=function(n){const t=e(n);return"string"==typeof t?t:""},n.isAtomic=function(n){return null===n||!Array.isArray(n)&&("object"!=typeof n||!("fn"in n||"dic"in n))},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 i=[];for(;e<l.length;)i.push(t(l[e])),e+=1;return i},n.nops=o,n.op=i,n.symbol=function(n){if(null==n)return null;const r=t(n)?n.sym:n;return"string"!=typeof r||r.length>=2&&"'"===r[0]&&"'"===r[r.length-1]?null:r},n.version="0.8.0",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,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.8.0 */
|
|
2
2
|
export declare 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 declare type SignalMessage = SignalCode | [SignalCode, ...any[]];
|
|
4
4
|
export declare type SignalOrigin = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.8.0 */
|
|
2
2
|
/**
|
|
3
3
|
* Add an assumption, in the form of a predicate, for example:
|
|
4
4
|
*
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
* current context).
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
-
export declare function assume(
|
|
21
|
+
export declare function assume(proposition: BoxedExpression): AssumeResult;
|
|
@@ -1,56 +1,74 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.8.0 */
|
|
2
2
|
import type { Complex } from 'complex.js';
|
|
3
3
|
import { Expression } from '../../math-json/math-json-format';
|
|
4
|
-
import { BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSymbolDefinition,
|
|
4
|
+
import { BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSymbolDefinition, BoxedDomain, EvaluateOptions, IComputeEngine, LatexString, Metadata, NOptions, PatternMatchOption, SemiBoxedExpression, SimplifyOptions, Substitution, RuntimeScope, DomainCompatibility, DomainLiteral, BoxedBaseDefinition } from '../public';
|
|
5
5
|
/**
|
|
6
6
|
* AbstractBoxedExpression
|
|
7
7
|
*/
|
|
8
8
|
export declare abstract class AbstractBoxedExpression implements BoxedExpression {
|
|
9
|
-
abstract
|
|
10
|
-
abstract
|
|
11
|
-
abstract
|
|
12
|
-
abstract isEqual(rhs: BoxedExpression): boolean;
|
|
9
|
+
abstract readonly hash: number;
|
|
10
|
+
abstract readonly json: Expression;
|
|
11
|
+
abstract readonly head: BoxedExpression | string;
|
|
13
12
|
abstract get isCanonical(): boolean;
|
|
14
13
|
abstract set isCanonical(_val: boolean);
|
|
15
|
-
abstract
|
|
14
|
+
abstract isSame(rhs: BoxedExpression): boolean;
|
|
15
|
+
abstract isEqual(rhs: BoxedExpression): boolean;
|
|
16
16
|
abstract match(rhs: BoxedExpression, options?: PatternMatchOption): Substitution | null;
|
|
17
17
|
readonly engine: IComputeEngine;
|
|
18
|
-
/**
|
|
19
|
-
* synthetically
|
|
18
|
+
/** Verbatim LaTeX, obtained from a source, i.e. from parsing, not generated
|
|
19
|
+
* synthetically
|
|
20
|
+
*/
|
|
20
21
|
protected _latex?: string;
|
|
21
|
-
protected _wikidata
|
|
22
|
+
protected _wikidata: string | undefined;
|
|
22
23
|
constructor(ce: IComputeEngine, metadata?: Metadata);
|
|
23
|
-
/** Object.
|
|
24
|
-
|
|
24
|
+
/** `Object.valueOf()`: return a primitive value for the object
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
valueOf(): number | string | boolean;
|
|
25
28
|
/** Object.toString() */
|
|
26
29
|
toString(): string;
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
[Symbol.toPrimitive](hint: 'number' | 'string' | 'default'): number | string | null;
|
|
31
|
+
/** Called by `JSON.stringify()` when serializing to json */
|
|
32
|
+
toJSON(): Expression;
|
|
29
33
|
/** Object.is() */
|
|
30
34
|
is(rhs: any): boolean;
|
|
31
|
-
has(_v: string | string[]): boolean;
|
|
32
|
-
get description(): string[];
|
|
33
|
-
get url(): string;
|
|
34
|
-
_purge(): undefined;
|
|
35
|
-
get isPure(): boolean;
|
|
36
|
-
get isLiteral(): boolean;
|
|
37
35
|
get latex(): LatexString;
|
|
38
36
|
set latex(val: LatexString);
|
|
39
|
-
get
|
|
40
|
-
|
|
41
|
-
get
|
|
37
|
+
get symbol(): string | null;
|
|
38
|
+
get isNothing(): boolean;
|
|
39
|
+
get string(): string | null;
|
|
40
|
+
getSubexpressions(head: string): BoxedExpression[];
|
|
41
|
+
get subexpressions(): BoxedExpression[];
|
|
42
|
+
get symbols(): BoxedExpression[];
|
|
43
|
+
get errors(): BoxedExpression[];
|
|
42
44
|
get ops(): null | BoxedExpression[];
|
|
43
45
|
get nops(): number;
|
|
44
46
|
get op1(): BoxedExpression;
|
|
45
47
|
get op2(): BoxedExpression;
|
|
46
48
|
get op3(): BoxedExpression;
|
|
47
|
-
get
|
|
48
|
-
get
|
|
49
|
-
|
|
50
|
-
get
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
get isValid(): boolean;
|
|
50
|
+
get isPure(): boolean;
|
|
51
|
+
/** For a symbol, true if the symbol is a free variable (no value) */
|
|
52
|
+
get isFree(): boolean;
|
|
53
|
+
/** For a symbol, true if the symbol is a constant (unchangeable value) */
|
|
54
|
+
get isConstant(): boolean;
|
|
55
|
+
get canonical(): BoxedExpression;
|
|
56
|
+
apply(_fn: (x: BoxedExpression) => SemiBoxedExpression, _head?: string): BoxedExpression;
|
|
57
|
+
subs(_sub: Substitution): BoxedExpression;
|
|
58
|
+
solve(_vars: Iterable<string>): null | BoxedExpression[];
|
|
59
|
+
replace(_rules: BoxedRuleSet): null | BoxedExpression;
|
|
60
|
+
has(_v: string | string[]): boolean;
|
|
61
|
+
get isNaN(): boolean | undefined;
|
|
62
|
+
get isZero(): boolean | undefined;
|
|
63
|
+
get isNotZero(): boolean | undefined;
|
|
64
|
+
get isOne(): boolean | undefined;
|
|
65
|
+
get isNegativeOne(): boolean | undefined;
|
|
66
|
+
get isInfinity(): boolean | undefined;
|
|
67
|
+
get isFinite(): boolean | undefined;
|
|
68
|
+
get isEven(): boolean | undefined;
|
|
69
|
+
get isOdd(): boolean | undefined;
|
|
70
|
+
get isPrime(): boolean | undefined;
|
|
71
|
+
get isComposite(): boolean | undefined;
|
|
54
72
|
get machineValue(): number | null;
|
|
55
73
|
get rationalValue(): [numer: number, denom: number] | [null, null];
|
|
56
74
|
get decimalValue(): Decimal | null;
|
|
@@ -59,29 +77,37 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
|
|
|
59
77
|
get asSmallInteger(): number | null;
|
|
60
78
|
get asRational(): [number, number] | [null, null];
|
|
61
79
|
get sgn(): -1 | 0 | 1 | undefined | null;
|
|
62
|
-
get symbol(): string | null;
|
|
63
|
-
get isMissing(): boolean;
|
|
64
|
-
get value(): BoxedExpression | undefined;
|
|
65
|
-
set value(_value: BoxedExpression | number | undefined);
|
|
66
|
-
get numericValue(): BoxedExpression | undefined;
|
|
67
|
-
isSubdomainOf(_d: BoxedExpression | string): undefined | boolean;
|
|
68
|
-
get domain(): Domain;
|
|
69
|
-
set domain(_domain: Domain);
|
|
70
|
-
get valueDomain(): Domain;
|
|
71
|
-
get string(): string | null;
|
|
72
80
|
isLess(_rhs: BoxedExpression): boolean | undefined;
|
|
73
81
|
isLessEqual(_rhs: BoxedExpression): boolean | undefined;
|
|
74
82
|
isGreater(_rhs: BoxedExpression): boolean | undefined;
|
|
75
83
|
isGreaterEqual(_rhs: BoxedExpression): boolean | undefined;
|
|
76
|
-
get isZero(): boolean | undefined;
|
|
77
|
-
get isNotZero(): boolean | undefined;
|
|
78
84
|
get isPositive(): boolean | undefined;
|
|
79
85
|
get isNonNegative(): boolean | undefined;
|
|
80
86
|
get isNegative(): boolean | undefined;
|
|
81
87
|
get isNonPositive(): boolean | undefined;
|
|
82
|
-
|
|
83
|
-
get
|
|
84
|
-
get
|
|
88
|
+
isCompatible(_dom: BoxedDomain | DomainLiteral, _kind?: DomainCompatibility): boolean;
|
|
89
|
+
get description(): string[] | undefined;
|
|
90
|
+
get url(): string | undefined;
|
|
91
|
+
get isLiteral(): boolean;
|
|
92
|
+
get wikidata(): string | undefined;
|
|
93
|
+
set wikidata(val: string | undefined);
|
|
94
|
+
get complexity(): number | undefined;
|
|
95
|
+
get basedDefinition(): BoxedBaseDefinition | undefined;
|
|
96
|
+
get symbolDefinition(): BoxedSymbolDefinition | undefined;
|
|
97
|
+
get functionDefinition(): BoxedFunctionDefinition | undefined;
|
|
98
|
+
bind(_scope: RuntimeScope | null): void;
|
|
99
|
+
unbind(): void;
|
|
100
|
+
get keys(): IterableIterator<string> | null;
|
|
101
|
+
get keysCount(): number;
|
|
102
|
+
getKey(_key: string): BoxedExpression | undefined;
|
|
103
|
+
hasKey(_key: string): boolean;
|
|
104
|
+
get value(): BoxedExpression | undefined;
|
|
105
|
+
set value(_value: BoxedExpression | number | undefined);
|
|
106
|
+
get numericValue(): BoxedExpression | undefined;
|
|
107
|
+
isSubdomainOf(_d: BoxedExpression | string): undefined | boolean;
|
|
108
|
+
get domain(): BoxedDomain;
|
|
109
|
+
set domain(_domain: BoxedDomain);
|
|
110
|
+
get explicitDomain(): BoxedDomain | undefined;
|
|
85
111
|
get isNumber(): boolean | undefined;
|
|
86
112
|
get isInteger(): boolean | undefined;
|
|
87
113
|
get isRational(): boolean | undefined;
|
|
@@ -91,18 +117,7 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
|
|
|
91
117
|
get isComplex(): boolean | undefined;
|
|
92
118
|
get isImaginary(): boolean | undefined;
|
|
93
119
|
get isExtendedComplex(): boolean | undefined;
|
|
94
|
-
get isOne(): boolean | undefined;
|
|
95
|
-
get isNegativeOne(): boolean | undefined;
|
|
96
|
-
get isEven(): boolean | undefined;
|
|
97
|
-
get isOdd(): boolean | undefined;
|
|
98
|
-
get isPrime(): boolean | undefined;
|
|
99
|
-
get isComposite(): boolean | undefined;
|
|
100
|
-
get canonical(): BoxedExpression;
|
|
101
|
-
apply(_fn: (x: BoxedExpression) => SemiBoxedExpression, _head?: string): BoxedExpression;
|
|
102
|
-
evaluate(options?: EvaluateOptions): BoxedExpression;
|
|
103
120
|
simplify(_options?: SimplifyOptions): BoxedExpression;
|
|
121
|
+
evaluate(options?: EvaluateOptions): BoxedExpression;
|
|
104
122
|
N(_options?: NOptions): BoxedExpression;
|
|
105
|
-
replace(_rules: BoxedRuleSet): null | BoxedExpression;
|
|
106
|
-
subs(_sub: Substitution): BoxedExpression;
|
|
107
|
-
solve(_vars: Iterable<string>): null | BoxedExpression[];
|
|
108
123
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.8.0 */
|
|
2
2
|
import { Decimal } from 'decimal.js';
|
|
3
3
|
import { IComputeEngine, SemiBoxedExpression, BoxedExpression, Metadata } from '../public';
|
|
4
|
-
import {
|
|
4
|
+
import { MathJsonNumber } from '../../math-json/math-json-format';
|
|
5
5
|
/**
|
|
6
6
|
* Notes about the boxed form:
|
|
7
7
|
*
|
|
@@ -40,15 +40,3 @@ export declare function box(ce: IComputeEngine, expr: Decimal | Complex | [num:
|
|
|
40
40
|
* The result may not be canonical
|
|
41
41
|
*/
|
|
42
42
|
export declare function boxNumber(ce: IComputeEngine, num: MathJsonNumber | BoxedExpression | number | Complex | Decimal | [numer: number, denom: number], metadata?: Metadata): BoxedExpression | null;
|
|
43
|
-
/**
|
|
44
|
-
* Given a head (either as a string or a lambda expression)
|
|
45
|
-
* and a set of arguments, return a boxed function expression.
|
|
46
|
-
*
|
|
47
|
-
* If available, preserve LaTeX and wikidata metadata in the boxed expression.
|
|
48
|
-
*
|
|
49
|
-
* The result is *not* a canonical expression.
|
|
50
|
-
*
|
|
51
|
-
* Note that `boxFunction()` should only be called from `ComputeEngine` or
|
|
52
|
-
* `box()`
|
|
53
|
-
*/
|
|
54
|
-
export declare function boxFunction(ce: IComputeEngine, head: string, ops: Expression[], metadata?: Metadata): BoxedExpression;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata, PatternMatchOption,
|
|
1
|
+
/* 0.8.0 */
|
|
2
|
+
import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata, PatternMatchOption, BoxedDomain } from '../public';
|
|
3
3
|
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
4
4
|
/**
|
|
5
5
|
* BoxedDictionary
|
|
@@ -10,7 +10,7 @@ export declare class BoxedDictionary extends AbstractBoxedExpression {
|
|
|
10
10
|
constructor(ce: IComputeEngine, dict: {
|
|
11
11
|
[key: string]: SemiBoxedExpression;
|
|
12
12
|
}, metadata?: Metadata);
|
|
13
|
-
|
|
13
|
+
unbind(): undefined;
|
|
14
14
|
get hash(): number;
|
|
15
15
|
get complexity(): number;
|
|
16
16
|
get head(): 'Dictionary';
|
|
@@ -20,7 +20,7 @@ export declare class BoxedDictionary extends AbstractBoxedExpression {
|
|
|
20
20
|
get keys(): IterableIterator<string>;
|
|
21
21
|
get keysCount(): number;
|
|
22
22
|
has(x: string | string[]): boolean;
|
|
23
|
-
get domain():
|
|
23
|
+
get domain(): BoxedDomain;
|
|
24
24
|
get json(): Expression;
|
|
25
25
|
/** Structural equality */
|
|
26
26
|
isSame(rhs: BoxedExpression): boolean;
|
|
@@ -1,34 +1,51 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import { BoxedExpression,
|
|
1
|
+
/* 0.8.0 */
|
|
2
|
+
import { BoxedDomain, BoxedExpression, DomainCompatibility, DomainConstructor, DomainExpression, DomainLiteral, IComputeEngine, Metadata, PatternMatchOption, Substitution } from '../public';
|
|
3
3
|
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* A `_BoxedDomain` is a wrapper around a boxed, canonical, domain expression.
|
|
6
|
+
*
|
|
7
|
+
* If could also be an error, in which case, `isValid` is `false`.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export declare class _BoxedDomain extends AbstractBoxedExpression implements BoxedDomain {
|
|
11
|
+
/** The value of a boxed domain is either a string if a domain literal, or a
|
|
12
|
+
* domain constructor function.
|
|
13
|
+
* Since the domains are alway canonicalized when boxed, their value can
|
|
14
|
+
* be represented by a simple array, without the need for extra boxing.
|
|
15
|
+
*/
|
|
16
|
+
_value: DomainExpression<BoxedExpression>;
|
|
6
17
|
private _hash;
|
|
7
18
|
constructor(ce: IComputeEngine, dom: DomainExpression, metadata?: Metadata);
|
|
8
|
-
get domainExpression(): DomainExpression;
|
|
9
|
-
get hash(): number;
|
|
10
19
|
get isCanonical(): boolean;
|
|
20
|
+
/** Boxed domains are always canonical. */
|
|
21
|
+
get canonical(): _BoxedDomain;
|
|
22
|
+
get isValid(): boolean;
|
|
23
|
+
get json(): Expression;
|
|
24
|
+
get literal(): string | null;
|
|
25
|
+
get ctor(): DomainConstructor | null;
|
|
26
|
+
get domainArgs(): (string | BoxedExpression | DomainExpression<BoxedExpression>)[] | null;
|
|
27
|
+
get domainArg1(): string | BoxedExpression | DomainExpression<BoxedExpression> | null;
|
|
28
|
+
get codomain(): BoxedDomain | null;
|
|
29
|
+
get hash(): number;
|
|
11
30
|
isEqual(rhs: BoxedExpression): boolean;
|
|
12
31
|
isSame(rhs: BoxedExpression): boolean;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
get json(): Expression;
|
|
32
|
+
is(rhs: any): boolean;
|
|
33
|
+
isCompatible(dom: BoxedDomain | DomainLiteral, compatibility?: DomainCompatibility): boolean;
|
|
16
34
|
match(rhs: BoxedExpression, _options?: PatternMatchOption): Substitution | null;
|
|
17
35
|
get head(): string;
|
|
18
|
-
get domain():
|
|
19
|
-
get codomain(): Domain | null;
|
|
20
|
-
is(rhs: BoxedExpression): boolean;
|
|
36
|
+
get domain(): BoxedDomain;
|
|
21
37
|
get isNothing(): boolean;
|
|
22
38
|
get isFunction(): boolean;
|
|
23
|
-
get isPredicate(): boolean;
|
|
24
|
-
get isNumericFunction(): boolean;
|
|
25
|
-
get isBoolean(): boolean;
|
|
26
|
-
get isRealFunction(): boolean;
|
|
27
39
|
get isNumeric(): boolean;
|
|
28
|
-
get isLogicOperator(): boolean;
|
|
29
40
|
get isRelationalOperator(): boolean;
|
|
30
41
|
}
|
|
31
42
|
/**
|
|
32
|
-
* Note that `boxDomain()` should only be called from `ComputeEngine
|
|
43
|
+
* Note that `boxDomain()` should only be called from `ComputeEngine`.
|
|
44
|
+
* This gives a chance for `ComputeEngine` to substitute cached objects.
|
|
33
45
|
*/
|
|
34
|
-
export declare function boxDomain(ce: IComputeEngine, dom:
|
|
46
|
+
export declare function boxDomain(ce: IComputeEngine, dom: BoxedDomain | DomainExpression, metadata?: Metadata): BoxedDomain;
|
|
47
|
+
/** Validate that `expr` is a Domain */
|
|
48
|
+
export declare function isDomain(expr: Expression | BoxedExpression | BoxedDomain | DomainExpression): expr is BoxedDomain | DomainExpression;
|
|
49
|
+
export declare function isSubdomainOf(lhs: DomainExpression<BoxedExpression>, rhs: DomainExpression<BoxedExpression>): boolean;
|
|
50
|
+
/** Return the ancestor domain that is shared by both `a` and `b` */
|
|
51
|
+
export declare function sharedAncestorDomain(a: BoxedDomain, b: BoxedDomain): BoxedDomain;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.8.0 */
|
|
2
2
|
export declare function makeFunctionDefinition(engine: IComputeEngine, def: FunctionDefinition): BoxedFunctionDefinition;
|