eyeling 1.14.2 → 1.14.3
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/HANDBOOK.md +1 -9
- package/examples/ackermann.n3 +2 -2
- package/eyeling-builtins.ttl +0 -3
- package/eyeling.js +3 -7
- package/lib/builtins.js +3 -7
- package/package.json +1 -1
package/HANDBOOK.md
CHANGED
|
@@ -979,15 +979,7 @@ If the types don’t fit any supported case, the builtin fails.
|
|
|
979
979
|
|
|
980
980
|
This is a pragmatic inversion, not a full algebra system.
|
|
981
981
|
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
**Shape:** `( $base $exp ) math:bigExponentiation $result`
|
|
985
|
-
|
|
986
|
-
- Exact integer exponentiation only.
|
|
987
|
-
- Requires integer `$base` and non-negative integer `$exp`.
|
|
988
|
-
- Fails if the estimated output size exceeds Eyeling’s built-in safety cap.
|
|
989
|
-
|
|
990
|
-
This builtin exists to avoid rule-level “repeat multiply” derivations that can explode memory for large exponents (e.g., the Ackermann example).
|
|
982
|
+
The **BigInt exact-integer mode** exists specifically to avoid rule-level “repeat multiply” derivations that can explode memory for large exponents (e.g., the Ackermann example).
|
|
991
983
|
|
|
992
984
|
#### Unary “math relations” (often invertible)
|
|
993
985
|
|
package/examples/ackermann.n3
CHANGED
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
(?Y ?Z) math:product ?A.
|
|
40
40
|
}.
|
|
41
41
|
|
|
42
|
-
# exponentiation (x=3) — use BigInt exponentiation
|
|
42
|
+
# exponentiation (x=3) — use BigInt-capable math:exponentiation to avoid blow-up
|
|
43
43
|
{
|
|
44
44
|
(3 ?Y ?Z) :ackermann ?A.
|
|
45
45
|
} <= {
|
|
46
|
-
(?Z ?Y) math:
|
|
46
|
+
(?Z ?Y) math:exponentiation ?A.
|
|
47
47
|
}.
|
|
48
48
|
|
|
49
49
|
# exponentiation (x=3), tetration (x=4), pentation (x=5), hexation (x=6), etc
|
package/eyeling-builtins.ttl
CHANGED
|
@@ -101,9 +101,6 @@ math:rounded a ex:Builtin ; ex:kind ex:Function ;
|
|
|
101
101
|
math:exponentiation a ex:Builtin ; ex:kind ex:Function ;
|
|
102
102
|
rdfs:comment "Exponentiation. Forward: (base exponent) -> result. If both arguments are integer literals and exponent is non-negative, Eyeling uses exact BigInt exponentiation (with a safety cap on result size). Otherwise it falls back to Number exponentiation. Limited inverse: if base is numeric and exponent is a variable, may solve exponent via logs for positive base != 1 and positive result (Number mode only)." .
|
|
103
103
|
|
|
104
|
-
math:bigExponentiation a ex:Builtin ; ex:kind ex:Function ;
|
|
105
|
-
rdfs:comment "Exact integer exponentiation (BigInt-only). Shape: (base exponent) math:bigExponentiation result. Requires integer base and non-negative integer exponent; fails if the estimated result size exceeds Eyeling's safety cap." .
|
|
106
|
-
|
|
107
104
|
math:absoluteValue a ex:Builtin ; ex:kind ex:Function ;
|
|
108
105
|
rdfs:comment "Absolute value. Computes |s| and unifies/binds object; output datatype follows common numeric datatype selection." .
|
|
109
106
|
|
package/eyeling.js
CHANGED
|
@@ -1792,10 +1792,9 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen, maxResults) {
|
|
|
1792
1792
|
}
|
|
1793
1793
|
|
|
1794
1794
|
// math:exponentiation
|
|
1795
|
-
//
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1795
|
+
// Schema: ( $base $exp ) math:exponentiation $result
|
|
1796
|
+
// Supports exact integer exponentiation via BigInt when both inputs are integers and exp >= 0.
|
|
1797
|
+
if (pv === MATH_NS + 'exponentiation') {
|
|
1799
1798
|
if (!(g.s instanceof ListTerm) || g.s.elems.length !== 2) return [];
|
|
1800
1799
|
const baseTerm = g.s.elems[0];
|
|
1801
1800
|
const expTerm = g.s.elems[1];
|
|
@@ -1832,9 +1831,6 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen, maxResults) {
|
|
|
1832
1831
|
return s2 !== null ? [s2] : [];
|
|
1833
1832
|
}
|
|
1834
1833
|
|
|
1835
|
-
// bigExponentiation is intentionally strict.
|
|
1836
|
-
if (onlyBigInt) return [];
|
|
1837
|
-
|
|
1838
1834
|
// 2) Numeric mode (Number): forward + limited inverse
|
|
1839
1835
|
const a = parseNum(baseTerm);
|
|
1840
1836
|
const b = a !== null ? parseNum(expTerm) : null;
|
package/lib/builtins.js
CHANGED
|
@@ -1780,10 +1780,9 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen, maxResults) {
|
|
|
1780
1780
|
}
|
|
1781
1781
|
|
|
1782
1782
|
// math:exponentiation
|
|
1783
|
-
//
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1783
|
+
// Schema: ( $base $exp ) math:exponentiation $result
|
|
1784
|
+
// Supports exact integer exponentiation via BigInt when both inputs are integers and exp >= 0.
|
|
1785
|
+
if (pv === MATH_NS + 'exponentiation') {
|
|
1787
1786
|
if (!(g.s instanceof ListTerm) || g.s.elems.length !== 2) return [];
|
|
1788
1787
|
const baseTerm = g.s.elems[0];
|
|
1789
1788
|
const expTerm = g.s.elems[1];
|
|
@@ -1820,9 +1819,6 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen, maxResults) {
|
|
|
1820
1819
|
return s2 !== null ? [s2] : [];
|
|
1821
1820
|
}
|
|
1822
1821
|
|
|
1823
|
-
// bigExponentiation is intentionally strict.
|
|
1824
|
-
if (onlyBigInt) return [];
|
|
1825
|
-
|
|
1826
1822
|
// 2) Numeric mode (Number): forward + limited inverse
|
|
1827
1823
|
const a = parseNum(baseTerm);
|
|
1828
1824
|
const b = a !== null ? parseNum(expTerm) : null;
|