@cortex-js/compute-engine 0.5.0 → 0.6.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.
Files changed (77) hide show
  1. package/dist/compute-engine.esm.js +4312 -3783
  2. package/dist/compute-engine.min.esm.js +2 -2
  3. package/dist/compute-engine.min.js +2 -2
  4. package/dist/math-json.esm.js +48 -13
  5. package/dist/math-json.min.esm.js +2 -2
  6. package/dist/math-json.min.js +2 -2
  7. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  8. package/dist/types/common/signals.d.ts +1 -1
  9. package/dist/types/compute-engine/assume.d.ts +1 -1
  10. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +6 -5
  11. package/dist/types/compute-engine/boxed-expression/box.d.ts +3 -5
  12. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +3 -3
  13. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +32 -6
  14. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
  15. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +5 -3
  16. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +3 -3
  17. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +3 -3
  18. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -3
  19. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +5 -5
  20. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +4 -4
  21. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  22. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  23. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  24. package/dist/types/compute-engine/boxed-expression/utils.d.ts +3 -3
  25. package/dist/types/compute-engine/compute-engine.d.ts +10 -8
  26. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  27. package/dist/types/compute-engine/dictionary/arithmetic-add.d.ts +2 -2
  28. package/dist/types/compute-engine/dictionary/arithmetic-divide.d.ts +1 -1
  29. package/dist/types/compute-engine/dictionary/arithmetic-multiply.d.ts +1 -1
  30. package/dist/types/compute-engine/dictionary/arithmetic-power.d.ts +1 -1
  31. package/dist/types/compute-engine/dictionary/arithmetic.d.ts +1 -1
  32. package/dist/types/compute-engine/dictionary/collections.d.ts +1 -1
  33. package/dist/types/compute-engine/dictionary/core.d.ts +1 -1
  34. package/dist/types/compute-engine/dictionary/dictionary.d.ts +1 -1
  35. package/dist/types/compute-engine/dictionary/logic.d.ts +1 -1
  36. package/dist/types/compute-engine/dictionary/polynomials.d.ts +1 -1
  37. package/dist/types/compute-engine/dictionary/relational-operator.d.ts +1 -1
  38. package/dist/types/compute-engine/dictionary/sets.d.ts +1 -1
  39. package/dist/types/compute-engine/dictionary/trigonometry.d.ts +1 -1
  40. package/dist/types/compute-engine/domain-utils.d.ts +1 -1
  41. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  42. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  43. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  44. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  45. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
  46. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  47. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  48. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  49. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  50. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  51. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -2
  52. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +2 -2
  53. package/dist/types/compute-engine/latex-syntax/parse.d.ts +10 -9
  54. package/dist/types/compute-engine/latex-syntax/public.d.ts +23 -24
  55. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  56. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  57. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  58. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  59. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  60. package/dist/types/compute-engine/numerics/numeric-decimal.d.ts +1 -1
  61. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  62. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  63. package/dist/types/compute-engine/public.d.ts +72 -76
  64. package/dist/types/compute-engine/rules.d.ts +1 -1
  65. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  66. package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
  67. package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
  68. package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
  69. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  70. package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
  71. package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
  72. package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
  73. package/dist/types/compute-engine.d.ts +3 -2
  74. package/dist/types/math-json/math-json-format.d.ts +1 -1
  75. package/dist/types/math-json/utils.d.ts +3 -4
  76. package/dist/types/math-json.d.ts +2 -2
  77. package/package.json +6 -7
@@ -1,4 +1,4 @@
1
- /** MathJSON 0.5.0 */
1
+ /** MathJSON 0.6.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
@@ -88,15 +88,55 @@ function nops(expr) {
88
88
  function symbol(expr) {
89
89
  if (expr === null)
90
90
  return null;
91
- if (typeof expr === 'string') {
92
- if (expr.length >= 2 && expr[0] === "'" && expr[expr.length - 1] === "'") {
93
- // It's a string literal, not a symbol
91
+ const s = isSymbolObject(expr) ? expr.sym : expr;
92
+ if (typeof s !== 'string')
93
+ return null;
94
+ if (s.length >= 2 && s[0] === "'" && s[s.length - 1] === "'") {
95
+ // It's a string literal, not a symbol
96
+ return null;
97
+ }
98
+ return s;
99
+ }
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
+ function keyValuePair(expr) {
113
+ const h = head(expr);
114
+ if (h === 'KeyValuePair' || h === 'Tuple' || h === 'Pair') {
115
+ const key = string(op(expr, 1));
116
+ if (!key)
94
117
  return null;
118
+ return [key, op(expr, 2) ?? 'Nothing'];
119
+ }
120
+ return null;
121
+ }
122
+ function dictionary(expr) {
123
+ if (expr === null)
124
+ return null;
125
+ if (typeof expr === 'object' && 'dict' in expr)
126
+ return expr.dict;
127
+ const kv = keyValuePair(expr);
128
+ if (kv)
129
+ return { [kv[0]]: kv[1] };
130
+ const h = head(expr);
131
+ if (h === 'List' || h === 'Dictionary') {
132
+ const result = {};
133
+ for (let i = 1; i < nops(expr); i++) {
134
+ const kv = keyValuePair(op(expr, i));
135
+ if (kv)
136
+ result[kv[0]] = kv[1];
95
137
  }
96
- return expr;
138
+ return result;
97
139
  }
98
- if (isSymbolObject(expr))
99
- return expr.sym;
100
140
  return null;
101
141
  }
102
142
  /**
@@ -146,11 +186,6 @@ function mapArgs(expr, fn) {
146
186
  }
147
187
  return result;
148
188
  }
149
- function dictionary(expr) {
150
- if (typeof expr === 'object' && 'dict' in expr)
151
- return expr.dict;
152
- return null;
153
- }
154
189
  /**
155
190
  * Return num as a number if it's a valid JSON number (that is
156
191
  * a valid JavaScript number but not NaN or +/-Infinity) or
@@ -175,6 +210,6 @@ function asValidJSONNumber(num) {
175
210
  }
176
211
 
177
212
  // This is the root of the `math-json` package (i.e. `math-json.js` and
178
- const version = '0.5.0';
213
+ const version = '0.6.0';
179
214
 
180
215
  export { applyRecursively, asValidJSONNumber, dictionary as getDictionary, stringValue as getStringValue, head, headName, isAtomic, isDictionaryObject, isFunctionObject, isStringObject, isSymbolObject, mapArgs, nops, op, symbol, tail, version };
@@ -1,2 +1,2 @@
1
- /** MathJSON 0.5.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 Array.isArray(n)?Math.max(0,n.length-1):r(n)?Math.max(0,n.fn.length-1):0}function s(t){return null===t?null:"string"==typeof t?t.length>=2&&"'"===t[0]&&"'"===t[t.length-1]?null:t:n(t)?t.sym:null}function y(n){return Array.isArray(n)?n.slice(1):r(n)?n.fn.slice(1):[]}function a(n,t){const r=i(n);if(null!==r)return[t(r),...y(n).map(t)];const u=p(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 g(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 p(n){return"object"==typeof n&&"dict"in n?n.dict:null}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 h="0.5.0";export{a as applyRecursively,A as asValidJSONNumber,p 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,g as mapArgs,c as nops,f as op,s as symbol,y as tail,h as version};
1
+ /** MathJSON 0.6.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 c(n,t){return null===n?null:Array.isArray(n)?n[t]??null:r(n)?n.fn[t]??null:null}function f(n){return Array.isArray(n)?Math.max(0,n.length-1):r(n)?Math.max(0,n.fn.length-1):0}function s(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 y(t){const r=i(t);if("KeyValuePair"===r||"Tuple"===r||"Pair"===r){const r=function(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.slice(1,-1)}(c(t,1));return r?[r,c(t,2)??"Nothing"]:null}return null}function a(n){if(null===n)return null;if("object"==typeof n&&"dict"in n)return n.dict;const t=y(n);if(t)return{[t[0]]:t[1]};const r=i(n);if("List"===r||"Dictionary"===r){const t={};for(let r=1;r<f(n);r++){const u=y(c(n,r));u&&(t[u[0]]=u[1])}return t}return null}function g(n){return Array.isArray(n)?n.slice(1):r(n)?n.fn.slice(1):[]}function p(n,t){const r=i(n);if(null!==r)return[t(r),...g(n).map(t)];const u=a(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.6.0";export{p as applyRecursively,A as asValidJSONNumber,a 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,f as nops,c as op,s as symbol,g as tail,b as version};
@@ -1,2 +1,2 @@
1
- /** MathJSON 0.5.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===n?null:Array.isArray(n)?n[0]:r(n)?n.fn[0]:null}function l(n){return Array.isArray(n)?n.slice(1):r(n)?n.fn.slice(1):[]}function i(n){return"object"==typeof n&&"dict"in n?n.dict:null}n.applyRecursively=function(n,t){const r=e(n);if(null!==r)return[t(r),...l(n).map(t)];const o=i(n);if(null!==o){const n=Object.keys(o),r={};for(const e of n)r[e]=t(o[e]);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=i,n.getStringValue=function(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)},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 e=null;if(Array.isArray(n)&&(e=n),r(n)&&(e=n.fn),null===e)return[];let l=1;const i=[];for(;l<e.length;)i.push(t(e[l])),l+=1;return i},n.nops=function(n){return Array.isArray(n)?Math.max(0,n.length-1):r(n)?Math.max(0,n.fn.length-1):0},n.op=function(n,t){var e,l;return null===n?null:Array.isArray(n)?null!==(e=n[t])&&void 0!==e?e:null:r(n)&&null!==(l=n.fn[t])&&void 0!==l?l:null},n.symbol=function(n){return null===n?null:"string"==typeof n?n.length>=2&&"'"===n[0]&&"'"===n[n.length-1]?null:n:t(n)?n.sym:null},n.tail=l,n.version="0.5.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
+ /** MathJSON 0.6.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===n?null:Array.isArray(n)?n[0]:r(n)?n.fn[0]:null}function l(n,t){var e,l;return null===n?null:Array.isArray(n)?null!==(e=n[t])&&void 0!==e?e:null:r(n)&&null!==(l=n.fn[t])&&void 0!==l?l:null}function i(n){return Array.isArray(n)?Math.max(0,n.length-1):r(n)?Math.max(0,n.fn.length-1):0}function o(n){var r;const i=e(n);if("KeyValuePair"===i||"Tuple"===i||"Pair"===i){const e=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.slice(1,-1)}(l(n,1));return e?[e,null!==(r=l(n,2))&&void 0!==r?r:"Nothing"]:null}return null}function u(n){if(null===n)return null;if("object"==typeof n&&"dict"in n)return n.dict;const t=o(n);if(t)return{[t[0]]:t[1]};const r=e(n);if("List"===r||"Dictionary"===r){const t={};for(let r=1;r<i(n);r++){const e=o(l(n,r));e&&(t[e[0]]=e[1])}return t}return null}function f(n){return Array.isArray(n)?n.slice(1):r(n)?n.fn.slice(1):[]}n.applyRecursively=function(n,t){const r=e(n);if(null!==r)return[t(r),...f(n).map(t)];const l=u(n);if(null!==l){const n=Object.keys(l),r={};for(const e of n)r[e]=t(l[e]);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=u,n.getStringValue=function(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)},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 e=null;if(Array.isArray(n)&&(e=n),r(n)&&(e=n.fn),null===e)return[];let l=1;const i=[];for(;l<e.length;)i.push(t(e[l])),l+=1;return i},n.nops=i,n.op=l,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.tail=f,n.version="0.6.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.5.0 */
1
+ /* 0.6.0 */
2
2
  /**
3
3
  * Return a string or an array of graphemes.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.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.5.0 */
1
+ /* 0.6.0 */
2
2
  /**
3
3
  * Add an assumption, in the form of a predicate, for example:
4
4
  *
@@ -1,7 +1,7 @@
1
- /* 0.5.0 */
1
+ /* 0.6.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, EvaluateOptions, IComputeEngine, LatexString, Metadata, NOptions, PatternMatchOption, SemiBoxedExpression, SimplifyOptions, Substitution } from '../public';
4
+ import { BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSymbolDefinition, Domain, EvaluateOptions, IComputeEngine, LatexString, Metadata, NOptions, PatternMatchOption, SemiBoxedExpression, SimplifyOptions, Substitution } from '../public';
5
5
  /**
6
6
  * AbstractBoxedExpression
7
7
  */
@@ -64,9 +64,10 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
64
64
  get value(): BoxedExpression | undefined;
65
65
  set value(_value: BoxedExpression | number | undefined);
66
66
  get numericValue(): BoxedExpression | undefined;
67
- isSubsetOf(_d: BoxedExpression | string): undefined | boolean;
68
- get domain(): BoxedExpression;
69
- set domain(_domain: BoxedExpression);
67
+ isSubdomainOf(_d: BoxedExpression | string): undefined | boolean;
68
+ get domain(): Domain;
69
+ set domain(_domain: Domain);
70
+ get valueDomain(): Domain;
70
71
  get string(): string | null;
71
72
  isLess(_rhs: BoxedExpression): boolean | undefined;
72
73
  isLessEqual(_rhs: BoxedExpression): boolean | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { IComputeEngine, SemiBoxedExpression, BoxedExpression, Metadata } from '../public';
4
4
  import { Expression, MathJsonNumber } from '../../math-json/math-json-format';
@@ -36,12 +36,10 @@ export declare function box(ce: IComputeEngine, expr: Decimal | Complex | [num:
36
36
  *
37
37
  *
38
38
  * Note that `boxNumber()` should only be called from `ComputeEngine`
39
+ *
40
+ * The result may not be canonical
39
41
  */
40
42
  export declare function boxNumber(ce: IComputeEngine, num: MathJsonNumber | BoxedExpression | number | Complex | Decimal | [numer: number, denom: number], metadata?: Metadata): BoxedExpression | null;
41
- /**
42
- * Note that `boxDomain()` should only be called from `ComputeEngine`
43
- */
44
- export declare function boxDomain(ce: IComputeEngine, dom: string | BoxedExpression, metadata?: Metadata): BoxedExpression;
45
43
  /**
46
44
  * Given a head (either as a string or a lambda expression)
47
45
  * and a set of arguments, return a boxed function expression.
@@ -1,5 +1,5 @@
1
- /* 0.5.0 */
2
- import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata, PatternMatchOption } from '../public';
1
+ /* 0.6.0 */
2
+ import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata, PatternMatchOption, Domain } from '../public';
3
3
  import { AbstractBoxedExpression } from './abstract-boxed-expression';
4
4
  /**
5
5
  * BoxedDictionary
@@ -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(): BoxedExpression;
23
+ get domain(): Domain;
24
24
  get json(): Expression;
25
25
  /** Structural equality */
26
26
  isSame(rhs: BoxedExpression): boolean;
@@ -1,8 +1,34 @@
1
- /* 0.5.0 */
2
- import { BoxedExpression, IComputeEngine, Metadata } from '../public';
3
- export declare class Domain extends BoxedSymbol {
4
- constructor(ce: IComputeEngine, dom: string, metadata?: Metadata);
1
+ /* 0.6.0 */
2
+ import { BoxedExpression, Domain, DomainExpression, IComputeEngine, Metadata, PatternMatchOption, Substitution } from '../public';
3
+ import { AbstractBoxedExpression } from './abstract-boxed-expression';
4
+ export declare class _Domain extends AbstractBoxedExpression implements Domain {
5
+ _value: DomainExpression;
6
+ private _hash;
7
+ constructor(ce: IComputeEngine, dom: DomainExpression, metadata?: Metadata);
8
+ get domainExpression(): DomainExpression;
9
+ get hash(): number;
10
+ get isCanonical(): boolean;
11
+ isEqual(rhs: BoxedExpression): boolean;
12
+ isSame(rhs: BoxedExpression): boolean;
13
+ isSubdomainOf(rhs: _Domain | string): boolean;
14
+ isMemberOf(expr: BoxedExpression): boolean;
15
+ get json(): Expression;
16
+ match(rhs: BoxedExpression, _options?: PatternMatchOption): Substitution | null;
5
17
  get head(): string;
6
- get domain(): BoxedExpression;
7
- isSubsetOf(dom: BoxedExpression | string): boolean;
18
+ get domain(): Domain;
19
+ get codomain(): Domain | null;
20
+ is(rhs: BoxedExpression): boolean;
21
+ get isNothing(): boolean;
22
+ get isFunction(): boolean;
23
+ get isPredicate(): boolean;
24
+ get isNumericFunction(): boolean;
25
+ get isBoolean(): boolean;
26
+ get isRealFunction(): boolean;
27
+ get isNumeric(): boolean;
28
+ get isLogicOperator(): boolean;
29
+ get isRelationalOperator(): boolean;
8
30
  }
31
+ /**
32
+ * Note that `boxDomain()` should only be called from `ComputeEngine`
33
+ */
34
+ export declare function boxDomain(ce: IComputeEngine, dom: Domain | DomainExpression, metadata?: Metadata): Domain;
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare function makeFunctionDefinition(engine: IComputeEngine, def: FunctionDefinition): BoxedFunctionDefinition;
@@ -1,6 +1,6 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { Expression } from '../../math-json/math-json-format';
3
- import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOption } from '../public';
3
+ import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOption, Domain } from '../public';
4
4
  /**
5
5
  * BoxedFunction
6
6
  */
@@ -35,8 +35,10 @@ export declare class BoxedFunction extends AbstractBoxedExpression {
35
35
  get op3(): BoxedExpression;
36
36
  get functionDefinition(): BoxedFunctionDefinition | undefined;
37
37
  _repairDefinition(): void;
38
+ /** Signature of the function */
39
+ get domain(): Domain;
38
40
  /** Domain of the value of the function */
39
- get domain(): BoxedExpression;
41
+ get valueDomain(): Domain;
40
42
  isLess(rhs: BoxedExpression): boolean | undefined;
41
43
  isLessEqual(rhs: BoxedExpression): boolean | undefined;
42
44
  isGreater(rhs: BoxedExpression): boolean | undefined;
@@ -1,7 +1,7 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { Complex } from 'complex.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
- import { BoxedExpression, IComputeEngine, Metadata, NOptions, PatternMatchOption, SimplifyOptions, Substitution } from '../public';
4
+ import { BoxedExpression, Domain, IComputeEngine, Metadata, NOptions, PatternMatchOption, SimplifyOptions, Substitution } from '../public';
5
5
  import { AbstractBoxedExpression } from './abstract-boxed-expression';
6
6
  /**
7
7
  * BoxedNumber
@@ -34,7 +34,7 @@ export declare class BoxedNumber extends AbstractBoxedExpression {
34
34
  get asFloat(): number | null;
35
35
  get asSmallInteger(): number | null;
36
36
  get asRational(): [number, number] | [null, null];
37
- get domain(): BoxedExpression;
37
+ get domain(): Domain;
38
38
  get json(): Expression;
39
39
  get sgn(): -1 | 0 | 1 | undefined | null;
40
40
  isSame(rhs: BoxedExpression): boolean;
@@ -1,6 +1,6 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { AbstractBoxedExpression } from './abstract-boxed-expression';
3
- import { BoxedExpression, IComputeEngine, LatexString, Metadata, Pattern, PatternMatchOption, SemiBoxedExpression, Substitution } from '../public';
3
+ import { BoxedExpression, Domain, IComputeEngine, LatexString, Metadata, Pattern, PatternMatchOption, SemiBoxedExpression, Substitution } from '../public';
4
4
  export declare class BoxedPattern extends AbstractBoxedExpression implements Pattern {
5
5
  _pattern: BoxedExpression;
6
6
  _canonicalPattern: BoxedExpression | undefined;
@@ -9,7 +9,7 @@ export declare class BoxedPattern extends AbstractBoxedExpression implements Pat
9
9
  _purge(): undefined;
10
10
  get json(): Expression;
11
11
  get head(): string | BoxedExpression;
12
- get domain(): BoxedExpression;
12
+ get valueDomain(): Domain;
13
13
  get isCanonical(): boolean;
14
14
  set isCanonical(_val: boolean);
15
15
  isSame(rhs: BoxedExpression): boolean;
@@ -1,6 +1,6 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { AbstractBoxedExpression } from './abstract-boxed-expression';
3
- import { BoxedExpression, IComputeEngine, Metadata, PatternMatchOption, Substitution } from '../public';
3
+ import { BoxedExpression, Domain, IComputeEngine, Metadata, PatternMatchOption, Substitution } from '../public';
4
4
  /**
5
5
  * BoxedString
6
6
  */
@@ -14,7 +14,7 @@ export declare class BoxedString extends AbstractBoxedExpression {
14
14
  get isLiteral(): boolean;
15
15
  get isCanonical(): boolean;
16
16
  set isCanonical(_va: boolean);
17
- get domain(): BoxedExpression;
17
+ get domain(): Domain;
18
18
  get complexity(): number;
19
19
  get string(): string;
20
20
  isEqual(rhs: BoxedExpression): boolean;
@@ -1,5 +1,5 @@
1
- /* 0.5.0 */
2
- export declare function domainToFlags(dom: BoxedExpression | undefined | null): Partial<SymbolFlags>;
1
+ /* 0.6.0 */
2
+ export declare function domainToFlags(dom: Domain | undefined | null): Partial<SymbolFlags>;
3
3
  export declare class BoxedSymbolDefinitionImpl implements BoxedSymbolDefinition {
4
4
  private _engine;
5
5
  private _value;
@@ -38,13 +38,13 @@ export declare class BoxedSymbolDefinitionImpl implements BoxedSymbolDefinition
38
38
  readonly hold: boolean;
39
39
  private _def;
40
40
  prototype?: BoxedFunctionDefinition;
41
- self?: any;
41
+ self?: unknown;
42
42
  constructor(ce: IComputeEngine, def: SymbolDefinition);
43
43
  _purge(): undefined;
44
44
  get value(): BoxedExpression | undefined;
45
45
  set value(val: BoxedExpression | number | undefined);
46
- get domain(): BoxedExpression | undefined;
47
- set domain(domain: BoxedExpression | undefined | string);
46
+ get domain(): Domain | undefined;
47
+ set domain(domain: Domain | undefined | string);
48
48
  updateFlags(flags: Partial<SymbolFlags>): void;
49
49
  setProps(props: Omit<Partial<BoxedSymbolDefinition>, 'domain' | 'value'>): void;
50
50
  get number(): boolean | undefined;
@@ -1,6 +1,6 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { AbstractBoxedExpression } from './abstract-boxed-expression';
3
- import { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, EvaluateOptions, NOptions, ReplaceOptions, SimplifyOptions, Substitution, Metadata, PatternMatchOption } from '../public';
3
+ import { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, EvaluateOptions, NOptions, ReplaceOptions, SimplifyOptions, Substitution, Metadata, PatternMatchOption, Domain } from '../public';
4
4
  /**
5
5
  * BoxedSymbol
6
6
  *
@@ -31,8 +31,8 @@ export declare class BoxedSymbol extends AbstractBoxedExpression {
31
31
  get value(): BoxedExpression | undefined;
32
32
  set value(value: BoxedExpression | number | undefined);
33
33
  get numericValue(): BoxedExpression | undefined;
34
- get domain(): BoxedExpression;
35
- set domain(d: BoxedExpression);
34
+ get domain(): Domain;
35
+ set domain(d: Domain);
36
36
  get json(): Expression;
37
37
  get sgn(): -1 | 0 | 1 | undefined | null;
38
38
  has(x: string | string[]): boolean;
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
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.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare type Order = 'lex' | 'dexlex' | 'grevlex' | 'elim';
3
3
  export declare const DEFAULT_COMPLEXITY = 100000;
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import Decimal from 'decimal.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
4
  import { BoxedExpression, IComputeEngine, Metadata } from '../public';
@@ -1,6 +1,6 @@
1
- /* 0.5.0 */
2
- export declare function isLatexString(s: any): s is string;
3
- export declare function latexString(s: any): string | null;
1
+ /* 0.6.0 */
2
+ export declare function isLatexString(s: unknown): s is string;
3
+ export declare function latexString(s: unknown): string | null;
4
4
  /**
5
5
  * Return a multiple of the imaginary unit, e.g.
6
6
  * - 'ImaginaryUnit'
@@ -1,9 +1,9 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { Complex } from 'complex.js';
3
3
  import { Expression, MathJsonNumber } from '../math-json/math-json-format';
4
4
  import { SignalMessage, WarningSignal } from '../common/signals';
5
- import type { DictionaryCategory, LatexDictionaryEntry, LatexString, NumberFormattingOptions, ParseLatexOptions, SerializeLatexOptions } from './latex-syntax/public';
6
- import { AssumeResult, BoxedExpression, BoxedFunctionDefinition, BoxedSymbolDefinition, IComputeEngine, Dictionary, ExpressionMapInterface, NumericMode as NumericMode, Pattern, RuntimeScope, Scope, SemiBoxedExpression, Substitution, SymbolDefinition, BoxedRuleSet, Rule, JsonSerializationOptions, ComputeEngineStats, Metadata } from './public';
5
+ import type { DictionaryCategory, LatexDictionary, LatexDictionaryEntry, LatexString, NumberFormattingOptions, ParseLatexOptions, SerializeLatexOptions } from './latex-syntax/public';
6
+ import { AssumeResult, BoxedExpression, BoxedFunctionDefinition, BoxedSymbolDefinition, IComputeEngine, Dictionary, ExpressionMapInterface, NumericMode as NumericMode, Pattern, RuntimeScope, Scope, SemiBoxedExpression, Substitution, SymbolDefinition, BoxedRuleSet, Rule, JsonSerializationOptions, ComputeEngineStats, Metadata, Domain, DomainExpression } from './public';
7
7
  /**
8
8
  *
9
9
  * To use the CortexJS Compute Engine, create a `ComputeEngine` instance.
@@ -180,8 +180,8 @@ export declare class ComputeEngine implements IComputeEngine {
180
180
  *
181
181
  * **Default:** `"ExtendedRealNumber"`
182
182
  */
183
- get defaultDomain(): BoxedExpression | null;
184
- set defaultDomain(domain: BoxedExpression | string | null);
183
+ get defaultDomain(): Domain | null;
184
+ set defaultDomain(domain: Domain | string | null);
185
185
  /**
186
186
  * Values smaller than the tolerance are considered to be zero for the
187
187
  * purpose of comparison, i.e. if `|b - a| <= tolerance`, `b` is considered
@@ -197,6 +197,7 @@ export declare class ComputeEngine implements IComputeEngine {
197
197
  chop(n: Decimal): Decimal | 0;
198
198
  chop(n: Complex): Complex | 0;
199
199
  private get latexSyntax();
200
+ static getLatexDictionary(domain?: DictionaryCategory | 'all'): Readonly<LatexDictionary>;
200
201
  set costFunction(fn: ((expr: BoxedExpression) => number) | undefined);
201
202
  get costFunction(): (expr: BoxedExpression) => number;
202
203
  /**
@@ -205,11 +206,12 @@ export declare class ComputeEngine implements IComputeEngine {
205
206
  */
206
207
  getSymbolDefinition(symbol: string, wikidata?: string): undefined | BoxedSymbolDefinition;
207
208
  /**
208
- * Return the definition for a function matching this head.
209
+ * Return the definition for a function matching this head and
210
+ * these arguments.
209
211
  *
210
212
  * Start looking in the current scope, than up the scope chain.
211
213
  */
212
- getFunctionDefinition(head: string): undefined | BoxedFunctionDefinition;
214
+ getFunctionDefinition(head: string, args?: BoxedExpression[]): undefined | BoxedFunctionDefinition;
213
215
  /**
214
216
  * Add (or replace) a definition for a symbol in the current scope.
215
217
  */
@@ -273,7 +275,7 @@ export declare class ComputeEngine implements IComputeEngine {
273
275
  tuple(elements: BoxedExpression[], metadata?: Metadata): BoxedExpression;
274
276
  string(s: string, metadata?: Metadata): BoxedExpression;
275
277
  symbol(sym: string, metadata?: Metadata): BoxedExpression;
276
- domain(domain: BoxedExpression | string, metadata?: Metadata): BoxedExpression;
278
+ domain(domain: BoxedExpression | DomainExpression | Domain, metadata?: Metadata): Domain;
277
279
  number(value: number | MathJsonNumber | Decimal | Complex | [num: number, denom: number], metadata?: Metadata): BoxedExpression;
278
280
  rules(rules: Rule[]): BoxedRuleSet;
279
281
  pattern(expr: LatexString | SemiBoxedExpression): Pattern;
@@ -1,3 +1,3 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
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.5.0 */
1
+ /* 0.6.0 */
2
2
  /** The canonical form of `Add`:
3
3
  * - removes `0`
4
4
  * - adds up small integers and rational numbers
@@ -6,6 +6,6 @@
6
6
  * - groups repeated terms (a + a -> 2a)
7
7
  * */
8
8
  export declare function canonicalAdd(ce: IComputeEngine, ops: BoxedExpression[]): BoxedExpression;
9
- export declare function domainAdd(ce: IComputeEngine, args: BoxedExpression[]): BoxedExpression | string;
9
+ export declare function domainAdd(_ce: IComputeEngine, args: BoxedExpression[]): Domain | string | null;
10
10
  export declare function numEvalAdd(ce: IComputeEngine, args: BoxedExpression[]): BoxedExpression;
11
11
  export declare function processAdd(ce: IComputeEngine, args: BoxedExpression[], _mode: 'simplify' | 'evaluate'): BoxedExpression | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  /**
3
3
  * Canonical form of 'Divide' (and 'Rational')
4
4
  * - remove denominator of 1
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  /** The canonical form of `Multiply`:
3
3
  * - remove `1`
4
4
  * - combine literal small integers and rationals
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  /**
3
3
  *
4
4
  * Return `null` if there is no canonicalization necessary and the result is
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const ARITHMETIC_DICTIONARY: Dictionary[];
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const COLLECTIONS_DICTIONARY: Dictionary;
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const CORE_DICTIONARY: Dictionary[];
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { IComputeEngine, Dictionary } from '../public';
3
3
  export declare function getDefaultDictionaries(categories?: DictionaryCategory[] | 'all'): Readonly<Dictionary>[];
4
4
  export declare const DICTIONARIES: {
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const LOGIC_DICTIONARY: Dictionary;
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const POLYNOMIALS_DICTIONARY: Dictionary[];
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const RELOP_DICTIONARY: Dictionary;
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const SETS_DICTIONARY: Dictionary;
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const TRIGONOMETRY_DICTIONARY: Dictionary[];
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { BoxedExpression } from './public';
4
4
  /** Quickly determine the numeric domain of a number or constant
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const DEFINITIONS_ALGEBRA: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const DEFINITIONS_ARITHMETIC: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const DEFINITIONS_CALCULUS: LatexDictionary;
@@ -1,4 +1,4 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  import { LatexDictionary, Serializer } from '../public';
3
3
  export declare function serializeLatex(serializer: Serializer, expr: Expression | null): string;
4
4
  export declare const DEFINITIONS_CORE: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const DEFINITIONS_INEQUALITIES: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const DEFINITIONS_LOGIC: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const DEFINITIONS_OTHERS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const DEFINITIONS_SETS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.5.0 */
1
+ /* 0.6.0 */
2
2
  export declare const DEFINITIONS_SYMBOLS: LatexDictionary;