eyeling 1.34.5 → 1.34.6

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 (307) hide show
  1. package/README.md +3 -90
  2. package/bin/eyeling.cjs +4 -56
  3. package/dist/browser/eyeling.browser.js +0 -1
  4. package/examples/context-schema-audit.n3 +1 -1
  5. package/eyeling.js +0 -1
  6. package/index.d.ts +3 -37
  7. package/index.js +1 -90
  8. package/lib/cli.js +0 -1
  9. package/package.json +3 -12
  10. package/test/packlist.test.js +0 -2
  11. package/test/run.js +0 -2
  12. package/docs/eyelang-guide.md +0 -535
  13. package/docs/eyelang-language-reference.md +0 -697
  14. package/examples/eyelang/access-control-policy.pl +0 -52
  15. package/examples/eyelang/ackermann.pl +0 -46
  16. package/examples/eyelang/age.pl +0 -28
  17. package/examples/eyelang/aliases-and-namespaces.pl +0 -22
  18. package/examples/eyelang/alignment-demo.pl +0 -44
  19. package/examples/eyelang/allen-interval-calculus.pl +0 -64
  20. package/examples/eyelang/ancestor.pl +0 -21
  21. package/examples/eyelang/animal.pl +0 -21
  22. package/examples/eyelang/annotation.pl +0 -34
  23. package/examples/eyelang/auroracare.pl +0 -309
  24. package/examples/eyelang/backward.pl +0 -12
  25. package/examples/eyelang/basic-monadic.pl +0 -10032
  26. package/examples/eyelang/bayes-diagnosis.pl +0 -108
  27. package/examples/eyelang/bayes-therapy.pl +0 -182
  28. package/examples/eyelang/beam-deflection.pl +0 -50
  29. package/examples/eyelang/blocks-world-planning.pl +0 -75
  30. package/examples/eyelang/bmi.pl +0 -232
  31. package/examples/eyelang/braking-safety-worlds.pl +0 -69
  32. package/examples/eyelang/buck-converter-design.pl +0 -78
  33. package/examples/eyelang/cache-performance.pl +0 -54
  34. package/examples/eyelang/canary-release.pl +0 -49
  35. package/examples/eyelang/cat-koko.pl +0 -24
  36. package/examples/eyelang/clinical-trial-screening.pl +0 -92
  37. package/examples/eyelang/combinatorics-findall-sort.pl +0 -37
  38. package/examples/eyelang/competitive-enzyme-kinetics.pl +0 -78
  39. package/examples/eyelang/complex.pl +0 -121
  40. package/examples/eyelang/composition-of-injective-functions-is-injective.pl +0 -50
  41. package/examples/eyelang/context-association.pl +0 -53
  42. package/examples/eyelang/context-schema-audit.pl +0 -46
  43. package/examples/eyelang/control-system.pl +0 -72
  44. package/examples/eyelang/cyclic-path.pl +0 -16
  45. package/examples/eyelang/d3-group.pl +0 -100
  46. package/examples/eyelang/dairy-energy-balance.pl +0 -65
  47. package/examples/eyelang/data-negotiation.pl +0 -39
  48. package/examples/eyelang/deep-taxonomy-10.pl +0 -115
  49. package/examples/eyelang/deep-taxonomy-100.pl +0 -385
  50. package/examples/eyelang/deep-taxonomy-1000.pl +0 -3085
  51. package/examples/eyelang/deep-taxonomy-10000.pl +0 -30094
  52. package/examples/eyelang/deep-taxonomy-100000.pl +0 -300184
  53. package/examples/eyelang/delfour.pl +0 -281
  54. package/examples/eyelang/deontic-logic.pl +0 -52
  55. package/examples/eyelang/derived-backward-rule.pl +0 -30
  56. package/examples/eyelang/derived-rule.pl +0 -27
  57. package/examples/eyelang/diamond-property.pl +0 -38
  58. package/examples/eyelang/dijkstra-findall-sort.pl +0 -44
  59. package/examples/eyelang/dijkstra-risk-path.pl +0 -86
  60. package/examples/eyelang/dijkstra.pl +0 -46
  61. package/examples/eyelang/dining-philosophers.pl +0 -140
  62. package/examples/eyelang/dog.pl +0 -25
  63. package/examples/eyelang/dpv-odrl-purpose-mapping.pl +0 -46
  64. package/examples/eyelang/drone-corridor-planner.pl +0 -51
  65. package/examples/eyelang/easter-computus.pl +0 -89
  66. package/examples/eyelang/electrical-rc-filter.pl +0 -36
  67. package/examples/eyelang/epidemic-policy.pl +0 -67
  68. package/examples/eyelang/equivalence-classes-overlap-implies-same-class.pl +0 -27
  69. package/examples/eyelang/eulerian-path.pl +0 -85
  70. package/examples/eyelang/ev-range-worlds.pl +0 -82
  71. package/examples/eyelang/existential-rule.pl +0 -18
  72. package/examples/eyelang/exoplanet-validation-worlds.pl +0 -88
  73. package/examples/eyelang/expression-eval.pl +0 -43
  74. package/examples/eyelang/family-cousins.pl +0 -65
  75. package/examples/eyelang/fastpow.pl +0 -53
  76. package/examples/eyelang/fft8-numeric.pl +0 -83
  77. package/examples/eyelang/fibonacci.pl +0 -53
  78. package/examples/eyelang/field-nitrogen-balance.pl +0 -70
  79. package/examples/eyelang/flandor.pl +0 -296
  80. package/examples/eyelang/floating-point.pl +0 -23
  81. package/examples/eyelang/four-color-map.pl +0 -127
  82. package/examples/eyelang/fundamental-theorem-arithmetic.pl +0 -113
  83. package/examples/eyelang/gd-step-certified.pl +0 -158
  84. package/examples/eyelang/gdpr-compliance.pl +0 -69
  85. package/examples/eyelang/good-cobbler.pl +0 -14
  86. package/examples/eyelang/gps.pl +0 -152
  87. package/examples/eyelang/graph-reachability.pl +0 -36
  88. package/examples/eyelang/gray-code-counter.pl +0 -48
  89. package/examples/eyelang/greatest-lower-bound-uniqueness.pl +0 -28
  90. package/examples/eyelang/group-inverse-uniqueness.pl +0 -34
  91. package/examples/eyelang/hamiltonian-path.pl +0 -49
  92. package/examples/eyelang/hamming-code.pl +0 -105
  93. package/examples/eyelang/hanoi.pl +0 -20
  94. package/examples/eyelang/heat-loss.pl +0 -51
  95. package/examples/eyelang/heron-theorem.pl +0 -36
  96. package/examples/eyelang/ideal-gas-law.pl +0 -37
  97. package/examples/eyelang/illegitimate-reasoning.pl +0 -88
  98. package/examples/eyelang/knowledge-engineering-alignment-flow.pl +0 -40
  99. package/examples/eyelang/law-of-cosines.pl +0 -31
  100. package/examples/eyelang/least-squares-regression.pl +0 -81
  101. package/examples/eyelang/list-collection.pl +0 -33
  102. package/examples/eyelang/lldm.pl +0 -78
  103. package/examples/eyelang/manufacturing-quality-control.pl +0 -73
  104. package/examples/eyelang/microgrid-dispatch.pl +0 -85
  105. package/examples/eyelang/monkey-bananas.pl +0 -45
  106. package/examples/eyelang/network-sla.pl +0 -48
  107. package/examples/eyelang/newton-raphson.pl +0 -49
  108. package/examples/eyelang/nixon-diamond.pl +0 -37
  109. package/examples/eyelang/observability-log-correlation.pl +0 -34
  110. package/examples/eyelang/odrl-dpv-fpv-trust-flow.pl +0 -43
  111. package/examples/eyelang/odrl-dpv-healthcare-risk-ranked.pl +0 -266
  112. package/examples/eyelang/odrl-dpv-risk-ranked.pl +0 -320
  113. package/examples/eyelang/orbital-transfer-design.pl +0 -113
  114. package/examples/eyelang/output/access-control-policy.pl +0 -2
  115. package/examples/eyelang/output/ackermann.pl +0 -12
  116. package/examples/eyelang/output/age.pl +0 -2
  117. package/examples/eyelang/output/aliases-and-namespaces.pl +0 -5
  118. package/examples/eyelang/output/alignment-demo.pl +0 -32
  119. package/examples/eyelang/output/allen-interval-calculus.pl +0 -154
  120. package/examples/eyelang/output/ancestor.pl +0 -6
  121. package/examples/eyelang/output/animal.pl +0 -4
  122. package/examples/eyelang/output/annotation.pl +0 -4
  123. package/examples/eyelang/output/auroracare.pl +0 -117
  124. package/examples/eyelang/output/backward.pl +0 -1
  125. package/examples/eyelang/output/basic-monadic.pl +0 -1518
  126. package/examples/eyelang/output/bayes-diagnosis.pl +0 -13
  127. package/examples/eyelang/output/bayes-therapy.pl +0 -23
  128. package/examples/eyelang/output/beam-deflection.pl +0 -5
  129. package/examples/eyelang/output/blocks-world-planning.pl +0 -4
  130. package/examples/eyelang/output/bmi.pl +0 -32
  131. package/examples/eyelang/output/braking-safety-worlds.pl +0 -18
  132. package/examples/eyelang/output/buck-converter-design.pl +0 -6
  133. package/examples/eyelang/output/cache-performance.pl +0 -4
  134. package/examples/eyelang/output/canary-release.pl +0 -5
  135. package/examples/eyelang/output/cat-koko.pl +0 -3
  136. package/examples/eyelang/output/clinical-trial-screening.pl +0 -9
  137. package/examples/eyelang/output/combinatorics-findall-sort.pl +0 -2
  138. package/examples/eyelang/output/competitive-enzyme-kinetics.pl +0 -6
  139. package/examples/eyelang/output/complex.pl +0 -1
  140. package/examples/eyelang/output/composition-of-injective-functions-is-injective.pl +0 -2
  141. package/examples/eyelang/output/context-association.pl +0 -3
  142. package/examples/eyelang/output/context-schema-audit.pl +0 -12
  143. package/examples/eyelang/output/control-system.pl +0 -6
  144. package/examples/eyelang/output/cyclic-path.pl +0 -16
  145. package/examples/eyelang/output/d3-group.pl +0 -2
  146. package/examples/eyelang/output/dairy-energy-balance.pl +0 -13
  147. package/examples/eyelang/output/data-negotiation.pl +0 -1
  148. package/examples/eyelang/output/deep-taxonomy-10.pl +0 -16
  149. package/examples/eyelang/output/deep-taxonomy-100.pl +0 -16
  150. package/examples/eyelang/output/deep-taxonomy-1000.pl +0 -16
  151. package/examples/eyelang/output/deep-taxonomy-10000.pl +0 -16
  152. package/examples/eyelang/output/deep-taxonomy-100000.pl +0 -16
  153. package/examples/eyelang/output/delfour.pl +0 -31
  154. package/examples/eyelang/output/deontic-logic.pl +0 -4
  155. package/examples/eyelang/output/derived-backward-rule.pl +0 -3
  156. package/examples/eyelang/output/derived-rule.pl +0 -2
  157. package/examples/eyelang/output/diamond-property.pl +0 -4
  158. package/examples/eyelang/output/dijkstra-findall-sort.pl +0 -2
  159. package/examples/eyelang/output/dijkstra-risk-path.pl +0 -29
  160. package/examples/eyelang/output/dijkstra.pl +0 -16
  161. package/examples/eyelang/output/dining-philosophers.pl +0 -350
  162. package/examples/eyelang/output/dog.pl +0 -1
  163. package/examples/eyelang/output/dpv-odrl-purpose-mapping.pl +0 -18
  164. package/examples/eyelang/output/drone-corridor-planner.pl +0 -17
  165. package/examples/eyelang/output/easter-computus.pl +0 -30
  166. package/examples/eyelang/output/electrical-rc-filter.pl +0 -3
  167. package/examples/eyelang/output/epidemic-policy.pl +0 -14
  168. package/examples/eyelang/output/equivalence-classes-overlap-implies-same-class.pl +0 -18
  169. package/examples/eyelang/output/eulerian-path.pl +0 -3
  170. package/examples/eyelang/output/ev-range-worlds.pl +0 -19
  171. package/examples/eyelang/output/existential-rule.pl +0 -2
  172. package/examples/eyelang/output/exoplanet-validation-worlds.pl +0 -22
  173. package/examples/eyelang/output/expression-eval.pl +0 -1
  174. package/examples/eyelang/output/family-cousins.pl +0 -28
  175. package/examples/eyelang/output/fastpow.pl +0 -6
  176. package/examples/eyelang/output/fft8-numeric.pl +0 -4
  177. package/examples/eyelang/output/fibonacci.pl +0 -6
  178. package/examples/eyelang/output/field-nitrogen-balance.pl +0 -21
  179. package/examples/eyelang/output/flandor.pl +0 -43
  180. package/examples/eyelang/output/floating-point.pl +0 -9
  181. package/examples/eyelang/output/four-color-map.pl +0 -3
  182. package/examples/eyelang/output/fundamental-theorem-arithmetic.pl +0 -9
  183. package/examples/eyelang/output/gd-step-certified.pl +0 -79
  184. package/examples/eyelang/output/gdpr-compliance.pl +0 -6
  185. package/examples/eyelang/output/good-cobbler.pl +0 -1
  186. package/examples/eyelang/output/gps.pl +0 -21
  187. package/examples/eyelang/output/graph-reachability.pl +0 -3
  188. package/examples/eyelang/output/gray-code-counter.pl +0 -1
  189. package/examples/eyelang/output/greatest-lower-bound-uniqueness.pl +0 -2
  190. package/examples/eyelang/output/group-inverse-uniqueness.pl +0 -2
  191. package/examples/eyelang/output/hamiltonian-path.pl +0 -121
  192. package/examples/eyelang/output/hamming-code.pl +0 -6
  193. package/examples/eyelang/output/hanoi.pl +0 -1
  194. package/examples/eyelang/output/heat-loss.pl +0 -5
  195. package/examples/eyelang/output/heron-theorem.pl +0 -4
  196. package/examples/eyelang/output/ideal-gas-law.pl +0 -3
  197. package/examples/eyelang/output/illegitimate-reasoning.pl +0 -15
  198. package/examples/eyelang/output/knowledge-engineering-alignment-flow.pl +0 -17
  199. package/examples/eyelang/output/law-of-cosines.pl +0 -3
  200. package/examples/eyelang/output/least-squares-regression.pl +0 -5
  201. package/examples/eyelang/output/list-collection.pl +0 -3
  202. package/examples/eyelang/output/lldm.pl +0 -6
  203. package/examples/eyelang/output/manufacturing-quality-control.pl +0 -6
  204. package/examples/eyelang/output/microgrid-dispatch.pl +0 -6
  205. package/examples/eyelang/output/monkey-bananas.pl +0 -5
  206. package/examples/eyelang/output/network-sla.pl +0 -4
  207. package/examples/eyelang/output/newton-raphson.pl +0 -3
  208. package/examples/eyelang/output/nixon-diamond.pl +0 -5
  209. package/examples/eyelang/output/observability-log-correlation.pl +0 -28
  210. package/examples/eyelang/output/odrl-dpv-fpv-trust-flow.pl +0 -9
  211. package/examples/eyelang/output/odrl-dpv-healthcare-risk-ranked.pl +0 -42
  212. package/examples/eyelang/output/odrl-dpv-risk-ranked.pl +0 -120
  213. package/examples/eyelang/output/orbital-transfer-design.pl +0 -7
  214. package/examples/eyelang/output/path-discovery.pl +0 -3
  215. package/examples/eyelang/output/peano-arithmetic.pl +0 -3
  216. package/examples/eyelang/output/peasant.pl +0 -10
  217. package/examples/eyelang/output/pendulum-period.pl +0 -4
  218. package/examples/eyelang/output/polynomial.pl +0 -14
  219. package/examples/eyelang/output/proof-contrapositive.pl +0 -3
  220. package/examples/eyelang/output/quadratic-formula.pl +0 -6
  221. package/examples/eyelang/output/radioactive-decay.pl +0 -5
  222. package/examples/eyelang/output/reusable-builtins.pl +0 -5
  223. package/examples/eyelang/output/riemann-hypothesis.pl +0 -12
  224. package/examples/eyelang/output/security-incident-correlation.pl +0 -3
  225. package/examples/eyelang/output/service-impact.pl +0 -11
  226. package/examples/eyelang/output/sieve.pl +0 -1
  227. package/examples/eyelang/output/skolem-functions.pl +0 -16
  228. package/examples/eyelang/output/socket-age.pl +0 -1
  229. package/examples/eyelang/output/socket-family.pl +0 -3
  230. package/examples/eyelang/output/socrates.pl +0 -2
  231. package/examples/eyelang/output/statistics-summary.pl +0 -4
  232. package/examples/eyelang/output/superdense-coding.pl +0 -6
  233. package/examples/eyelang/output/term-tools.pl +0 -6
  234. package/examples/eyelang/output/trust-flow-provenance-threshold.pl +0 -6
  235. package/examples/eyelang/output/turing.pl +0 -12
  236. package/examples/eyelang/output/vector-similarity.pl +0 -4
  237. package/examples/eyelang/output/vulnerability-impact.pl +0 -20
  238. package/examples/eyelang/output/witch.pl +0 -7
  239. package/examples/eyelang/output/wolf-goat-cabbage.pl +0 -3
  240. package/examples/eyelang/output/zebra.pl +0 -3
  241. package/examples/eyelang/path-discovery.pl +0 -45013
  242. package/examples/eyelang/peano-arithmetic.pl +0 -31
  243. package/examples/eyelang/peasant.pl +0 -30
  244. package/examples/eyelang/pendulum-period.pl +0 -50
  245. package/examples/eyelang/polynomial.pl +0 -124
  246. package/examples/eyelang/proof/age.pl +0 -71
  247. package/examples/eyelang/proof/aliases-and-namespaces.pl +0 -78
  248. package/examples/eyelang/proof/ancestor.pl +0 -140
  249. package/examples/eyelang/proof/animal.pl +0 -68
  250. package/examples/eyelang/proof/annotation.pl +0 -80
  251. package/examples/eyelang/proof/backward.pl +0 -22
  252. package/examples/eyelang/proof/cat-koko.pl +0 -86
  253. package/examples/eyelang/proof/data-negotiation.pl +0 -76
  254. package/examples/eyelang/proof/derived-rule.pl +0 -43
  255. package/examples/eyelang/proof/dog.pl +0 -31
  256. package/examples/eyelang/proof/electrical-rc-filter.pl +0 -105
  257. package/examples/eyelang/proof/existential-rule.pl +0 -40
  258. package/examples/eyelang/proof/floating-point.pl +0 -160
  259. package/examples/eyelang/proof/good-cobbler.pl +0 -16
  260. package/examples/eyelang/proof/group-inverse-uniqueness.pl +0 -84
  261. package/examples/eyelang/proof/list-collection.pl +0 -52
  262. package/examples/eyelang/proof/proof-contrapositive.pl +0 -78
  263. package/examples/eyelang/proof/socket-age.pl +0 -32
  264. package/examples/eyelang/proof/socket-family.pl +0 -59
  265. package/examples/eyelang/proof/socrates.pl +0 -38
  266. package/examples/eyelang/proof-contrapositive.pl +0 -27
  267. package/examples/eyelang/quadratic-formula.pl +0 -54
  268. package/examples/eyelang/radioactive-decay.pl +0 -56
  269. package/examples/eyelang/reusable-builtins.pl +0 -32
  270. package/examples/eyelang/riemann-hypothesis.pl +0 -110
  271. package/examples/eyelang/security-incident-correlation.pl +0 -69
  272. package/examples/eyelang/service-impact.pl +0 -41
  273. package/examples/eyelang/sieve.pl +0 -20
  274. package/examples/eyelang/skolem-functions.pl +0 -52
  275. package/examples/eyelang/socket-age.pl +0 -39
  276. package/examples/eyelang/socket-family.pl +0 -28
  277. package/examples/eyelang/socrates.pl +0 -19
  278. package/examples/eyelang/statistics-summary.pl +0 -54
  279. package/examples/eyelang/superdense-coding.pl +0 -84
  280. package/examples/eyelang/term-tools.pl +0 -23
  281. package/examples/eyelang/trust-flow-provenance-threshold.pl +0 -40
  282. package/examples/eyelang/turing.pl +0 -67
  283. package/examples/eyelang/vector-similarity.pl +0 -56
  284. package/examples/eyelang/vulnerability-impact.pl +0 -70
  285. package/examples/eyelang/witch.pl +0 -38
  286. package/examples/eyelang/wolf-goat-cabbage.pl +0 -56
  287. package/examples/eyelang/zebra.pl +0 -44
  288. package/eyelang.d.ts +0 -80
  289. package/lib/eyelang/bin.js +0 -7
  290. package/lib/eyelang/builtins/aggregation.js +0 -81
  291. package/lib/eyelang/builtins/arithmetic.js +0 -208
  292. package/lib/eyelang/builtins/context.js +0 -42
  293. package/lib/eyelang/builtins/control.js +0 -34
  294. package/lib/eyelang/builtins/core.js +0 -78
  295. package/lib/eyelang/builtins/lists.js +0 -283
  296. package/lib/eyelang/builtins/registry.js +0 -48
  297. package/lib/eyelang/builtins/strings.js +0 -234
  298. package/lib/eyelang/builtins/terms.js +0 -66
  299. package/lib/eyelang/cli.js +0 -180
  300. package/lib/eyelang/explain.js +0 -324
  301. package/lib/eyelang/hash.js +0 -294
  302. package/lib/eyelang/index.js +0 -47
  303. package/lib/eyelang/package.json +0 -3
  304. package/lib/eyelang/parser.js +0 -428
  305. package/lib/eyelang/program.js +0 -237
  306. package/lib/eyelang/solver.js +0 -237
  307. package/lib/eyelang/term.js +0 -328
@@ -1,294 +0,0 @@
1
- // Small dependency-free hashing helpers shared by Node and browser builds.
2
- // They intentionally avoid node:crypto so src/index.js remains importable by
3
- // browser builds that register hashing builtins.
4
-
5
- const textEncoder = new TextEncoder();
6
-
7
- export function hashHex(algorithm, text) {
8
- const name = String(algorithm).toLowerCase().replace(/[^a-z0-9]/g, '');
9
- const bytes = textEncoder.encode(String(text));
10
- if (name === 'md5') return md5Hex(bytes);
11
- if (name === 'sha' || name === 'sha1') return sha1Hex(bytes);
12
- if (name === 'sha256') return sha256Hex(bytes);
13
- if (name === 'sha512') return sha512Hex(bytes);
14
- throw new Error(`Unsupported hash algorithm: ${algorithm}`);
15
- }
16
-
17
- function hex32(x) {
18
- return (x >>> 0).toString(16).padStart(8, '0');
19
- }
20
-
21
- function rotr32(x, n) {
22
- return (x >>> n) | (x << (32 - n));
23
- }
24
-
25
- function rotl32(x, n) {
26
- return (x << n) | (x >>> (32 - n));
27
- }
28
-
29
- function bytesToHex(bytes) {
30
- let out = '';
31
- for (const b of bytes) out += b.toString(16).padStart(2, '0');
32
- return out;
33
- }
34
-
35
- function paddedBytes(bytes, blockBytes, lengthBytes, littleLength = false) {
36
- const bitLength = BigInt(bytes.length) * 8n;
37
- const withOne = bytes.length + 1;
38
- const zeroCount = (blockBytes - ((withOne + lengthBytes) % blockBytes)) % blockBytes;
39
- const out = new Uint8Array(withOne + zeroCount + lengthBytes);
40
- out.set(bytes, 0);
41
- out[bytes.length] = 0x80;
42
- for (let i = 0; i < lengthBytes; i++) {
43
- const shift = BigInt(littleLength ? i * 8 : (lengthBytes - 1 - i) * 8);
44
- out[out.length - lengthBytes + i] = Number((bitLength >> shift) & 0xffn);
45
- }
46
- return out;
47
- }
48
-
49
- function sha1Hex(bytes) {
50
- const msg = paddedBytes(bytes, 64, 8);
51
- let h0 = 0x67452301;
52
- let h1 = 0xefcdab89;
53
- let h2 = 0x98badcfe;
54
- let h3 = 0x10325476;
55
- let h4 = 0xc3d2e1f0;
56
- const w = new Array(80);
57
-
58
- for (let offset = 0; offset < msg.length; offset += 64) {
59
- for (let i = 0; i < 16; i++) {
60
- const j = offset + i * 4;
61
- w[i] = ((msg[j] << 24) | (msg[j + 1] << 16) | (msg[j + 2] << 8) | msg[j + 3]) >>> 0;
62
- }
63
- for (let i = 16; i < 80; i++) w[i] = rotl32(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1) >>> 0;
64
-
65
- let a = h0, b = h1, c = h2, d = h3, e = h4;
66
- for (let i = 0; i < 80; i++) {
67
- let f, k;
68
- if (i < 20) { f = (b & c) | (~b & d); k = 0x5a827999; }
69
- else if (i < 40) { f = b ^ c ^ d; k = 0x6ed9eba1; }
70
- else if (i < 60) { f = (b & c) | (b & d) | (c & d); k = 0x8f1bbcdc; }
71
- else { f = b ^ c ^ d; k = 0xca62c1d6; }
72
- const temp = (rotl32(a, 5) + f + e + k + w[i]) >>> 0;
73
- e = d;
74
- d = c;
75
- c = rotl32(b, 30) >>> 0;
76
- b = a;
77
- a = temp;
78
- }
79
- h0 = (h0 + a) >>> 0;
80
- h1 = (h1 + b) >>> 0;
81
- h2 = (h2 + c) >>> 0;
82
- h3 = (h3 + d) >>> 0;
83
- h4 = (h4 + e) >>> 0;
84
- }
85
-
86
- return [h0, h1, h2, h3, h4].map(hex32).join('');
87
- }
88
-
89
- const SHA256_K = [
90
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
91
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
92
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
93
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
94
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
95
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
96
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
97
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
98
- ];
99
-
100
- function sha256Hex(bytes) {
101
- const msg = paddedBytes(bytes, 64, 8);
102
- let h0 = 0x6a09e667;
103
- let h1 = 0xbb67ae85;
104
- let h2 = 0x3c6ef372;
105
- let h3 = 0xa54ff53a;
106
- let h4 = 0x510e527f;
107
- let h5 = 0x9b05688c;
108
- let h6 = 0x1f83d9ab;
109
- let h7 = 0x5be0cd19;
110
- const w = new Array(64);
111
-
112
- for (let offset = 0; offset < msg.length; offset += 64) {
113
- for (let i = 0; i < 16; i++) {
114
- const j = offset + i * 4;
115
- w[i] = ((msg[j] << 24) | (msg[j + 1] << 16) | (msg[j + 2] << 8) | msg[j + 3]) >>> 0;
116
- }
117
- for (let i = 16; i < 64; i++) {
118
- const s0 = (rotr32(w[i - 15], 7) ^ rotr32(w[i - 15], 18) ^ (w[i - 15] >>> 3)) >>> 0;
119
- const s1 = (rotr32(w[i - 2], 17) ^ rotr32(w[i - 2], 19) ^ (w[i - 2] >>> 10)) >>> 0;
120
- w[i] = (w[i - 16] + s0 + w[i - 7] + s1) >>> 0;
121
- }
122
-
123
- let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7;
124
- for (let i = 0; i < 64; i++) {
125
- const S1 = (rotr32(e, 6) ^ rotr32(e, 11) ^ rotr32(e, 25)) >>> 0;
126
- const ch = ((e & f) ^ (~e & g)) >>> 0;
127
- const temp1 = (h + S1 + ch + SHA256_K[i] + w[i]) >>> 0;
128
- const S0 = (rotr32(a, 2) ^ rotr32(a, 13) ^ rotr32(a, 22)) >>> 0;
129
- const maj = ((a & b) ^ (a & c) ^ (b & c)) >>> 0;
130
- const temp2 = (S0 + maj) >>> 0;
131
- h = g;
132
- g = f;
133
- f = e;
134
- e = (d + temp1) >>> 0;
135
- d = c;
136
- c = b;
137
- b = a;
138
- a = (temp1 + temp2) >>> 0;
139
- }
140
-
141
- h0 = (h0 + a) >>> 0;
142
- h1 = (h1 + b) >>> 0;
143
- h2 = (h2 + c) >>> 0;
144
- h3 = (h3 + d) >>> 0;
145
- h4 = (h4 + e) >>> 0;
146
- h5 = (h5 + f) >>> 0;
147
- h6 = (h6 + g) >>> 0;
148
- h7 = (h7 + h) >>> 0;
149
- }
150
-
151
- return [h0, h1, h2, h3, h4, h5, h6, h7].map(hex32).join('');
152
- }
153
-
154
- const MD5_S = [
155
- 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
156
- 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
157
- 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
158
- 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21,
159
- ];
160
- const MD5_K = Array.from({ length: 64 }, (_, i) => Math.floor(Math.abs(Math.sin(i + 1)) * 2 ** 32) >>> 0);
161
-
162
- function md5Hex(bytes) {
163
- const msg = paddedBytes(bytes, 64, 8, true);
164
- let a0 = 0x67452301;
165
- let b0 = 0xefcdab89;
166
- let c0 = 0x98badcfe;
167
- let d0 = 0x10325476;
168
- const m = new Array(16);
169
-
170
- for (let offset = 0; offset < msg.length; offset += 64) {
171
- for (let i = 0; i < 16; i++) {
172
- const j = offset + i * 4;
173
- m[i] = (msg[j] | (msg[j + 1] << 8) | (msg[j + 2] << 16) | (msg[j + 3] << 24)) >>> 0;
174
- }
175
- let a = a0, b = b0, c = c0, d = d0;
176
-
177
- for (let i = 0; i < 64; i++) {
178
- let f, g;
179
- if (i < 16) { f = (b & c) | (~b & d); g = i; }
180
- else if (i < 32) { f = (d & b) | (~d & c); g = (5 * i + 1) % 16; }
181
- else if (i < 48) { f = b ^ c ^ d; g = (3 * i + 5) % 16; }
182
- else { f = c ^ (b | ~d); g = (7 * i) % 16; }
183
- f = (f + a + MD5_K[i] + m[g]) >>> 0;
184
- a = d;
185
- d = c;
186
- c = b;
187
- b = (b + rotl32(f, MD5_S[i])) >>> 0;
188
- }
189
-
190
- a0 = (a0 + a) >>> 0;
191
- b0 = (b0 + b) >>> 0;
192
- c0 = (c0 + c) >>> 0;
193
- d0 = (d0 + d) >>> 0;
194
- }
195
-
196
- const out = new Uint8Array(16);
197
- for (const [i, word] of [a0, b0, c0, d0].entries()) {
198
- out[i * 4] = word & 0xff;
199
- out[i * 4 + 1] = (word >>> 8) & 0xff;
200
- out[i * 4 + 2] = (word >>> 16) & 0xff;
201
- out[i * 4 + 3] = (word >>> 24) & 0xff;
202
- }
203
- return bytesToHex(out);
204
- }
205
-
206
- const MASK64 = (1n << 64n) - 1n;
207
- const SHA512_H0 = [
208
- 0x6a09e667f3bcc908n, 0xbb67ae8584caa73bn, 0x3c6ef372fe94f82bn, 0xa54ff53a5f1d36f1n,
209
- 0x510e527fade682d1n, 0x9b05688c2b3e6c1fn, 0x1f83d9abfb41bd6bn, 0x5be0cd19137e2179n,
210
- ];
211
- const SHA512_K = [
212
- 0x428a2f98d728ae22n, 0x7137449123ef65cdn, 0xb5c0fbcfec4d3b2fn, 0xe9b5dba58189dbbcn,
213
- 0x3956c25bf348b538n, 0x59f111f1b605d019n, 0x923f82a4af194f9bn, 0xab1c5ed5da6d8118n,
214
- 0xd807aa98a3030242n, 0x12835b0145706fben, 0x243185be4ee4b28cn, 0x550c7dc3d5ffb4e2n,
215
- 0x72be5d74f27b896fn, 0x80deb1fe3b1696b1n, 0x9bdc06a725c71235n, 0xc19bf174cf692694n,
216
- 0xe49b69c19ef14ad2n, 0xefbe4786384f25e3n, 0x0fc19dc68b8cd5b5n, 0x240ca1cc77ac9c65n,
217
- 0x2de92c6f592b0275n, 0x4a7484aa6ea6e483n, 0x5cb0a9dcbd41fbd4n, 0x76f988da831153b5n,
218
- 0x983e5152ee66dfabn, 0xa831c66d2db43210n, 0xb00327c898fb213fn, 0xbf597fc7beef0ee4n,
219
- 0xc6e00bf33da88fc2n, 0xd5a79147930aa725n, 0x06ca6351e003826fn, 0x142929670a0e6e70n,
220
- 0x27b70a8546d22ffcn, 0x2e1b21385c26c926n, 0x4d2c6dfc5ac42aedn, 0x53380d139d95b3dfn,
221
- 0x650a73548baf63den, 0x766a0abb3c77b2a8n, 0x81c2c92e47edaee6n, 0x92722c851482353bn,
222
- 0xa2bfe8a14cf10364n, 0xa81a664bbc423001n, 0xc24b8b70d0f89791n, 0xc76c51a30654be30n,
223
- 0xd192e819d6ef5218n, 0xd69906245565a910n, 0xf40e35855771202an, 0x106aa07032bbd1b8n,
224
- 0x19a4c116b8d2d0c8n, 0x1e376c085141ab53n, 0x2748774cdf8eeb99n, 0x34b0bcb5e19b48a8n,
225
- 0x391c0cb3c5c95a63n, 0x4ed8aa4ae3418acbn, 0x5b9cca4f7763e373n, 0x682e6ff3d6b2b8a3n,
226
- 0x748f82ee5defb2fcn, 0x78a5636f43172f60n, 0x84c87814a1f0ab72n, 0x8cc702081a6439ecn,
227
- 0x90befffa23631e28n, 0xa4506cebde82bde9n, 0xbef9a3f7b2c67915n, 0xc67178f2e372532bn,
228
- 0xca273eceea26619cn, 0xd186b8c721c0c207n, 0xeada7dd6cde0eb1en, 0xf57d4f7fee6ed178n,
229
- 0x06f067aa72176fban, 0x0a637dc5a2c898a6n, 0x113f9804bef90daen, 0x1b710b35131c471bn,
230
- 0x28db77f523047d84n, 0x32caab7b40c72493n, 0x3c9ebe0a15c9bebcn, 0x431d67c49c100d4cn,
231
- 0x4cc5d4becb3e42b6n, 0x597f299cfc657e2an, 0x5fcb6fab3ad6faecn, 0x6c44198c4a475817n,
232
- ];
233
-
234
- function rotr64(x, n) {
235
- return ((x >> BigInt(n)) | (x << BigInt(64 - n))) & MASK64;
236
- }
237
-
238
- function shr64(x, n) {
239
- return x >> BigInt(n);
240
- }
241
-
242
- function add64(...xs) {
243
- let out = 0n;
244
- for (const x of xs) out = (out + x) & MASK64;
245
- return out;
246
- }
247
-
248
- function sha512Hex(bytes) {
249
- const msg = paddedBytes(bytes, 128, 16);
250
- const h = [...SHA512_H0];
251
- const w = new Array(80).fill(0n);
252
-
253
- for (let offset = 0; offset < msg.length; offset += 128) {
254
- for (let i = 0; i < 16; i++) {
255
- let word = 0n;
256
- for (let j = 0; j < 8; j++) word = (word << 8n) | BigInt(msg[offset + i * 8 + j]);
257
- w[i] = word;
258
- }
259
- for (let i = 16; i < 80; i++) {
260
- const s0 = rotr64(w[i - 15], 1) ^ rotr64(w[i - 15], 8) ^ shr64(w[i - 15], 7);
261
- const s1 = rotr64(w[i - 2], 19) ^ rotr64(w[i - 2], 61) ^ shr64(w[i - 2], 6);
262
- w[i] = add64(w[i - 16], s0, w[i - 7], s1);
263
- }
264
-
265
- let [a, b, c, d, e, f, g, hh] = h;
266
- for (let i = 0; i < 80; i++) {
267
- const S1 = rotr64(e, 14) ^ rotr64(e, 18) ^ rotr64(e, 41);
268
- const ch = (e & f) ^ (~e & g);
269
- const temp1 = add64(hh, S1, ch, SHA512_K[i], w[i]);
270
- const S0 = rotr64(a, 28) ^ rotr64(a, 34) ^ rotr64(a, 39);
271
- const maj = (a & b) ^ (a & c) ^ (b & c);
272
- const temp2 = add64(S0, maj);
273
- hh = g;
274
- g = f;
275
- f = e;
276
- e = add64(d, temp1);
277
- d = c;
278
- c = b;
279
- b = a;
280
- a = add64(temp1, temp2);
281
- }
282
-
283
- h[0] = add64(h[0], a);
284
- h[1] = add64(h[1], b);
285
- h[2] = add64(h[2], c);
286
- h[3] = add64(h[3], d);
287
- h[4] = add64(h[4], e);
288
- h[5] = add64(h[5], f);
289
- h[6] = add64(h[6], g);
290
- h[7] = add64(h[7], hh);
291
- }
292
-
293
- return h.map((x) => x.toString(16).padStart(16, '0')).join('');
294
- }
@@ -1,47 +0,0 @@
1
- // Public JavaScript API surface for embedders and the browser playground.
2
- // The CLI imports the same parser, program, solver, and term primitives from here.
3
- export { Program, makeProgram } from './program.js';
4
- export { parseClauses, parseProgramText } from './parser.js';
5
- export { Solver } from './solver.js';
6
- export * from './term.js';
7
- export { BuiltinRegistry, createDefaultRegistry, getDefaultRegistry } from './builtins/registry.js';
8
-
9
- import { Env, copyResolved, termIsGround, termToString } from './term.js';
10
- import { Program } from './program.js';
11
- import { Solver } from './solver.js';
12
- import { whyNoProof, whyProof } from './explain.js';
13
- import { getDefaultRegistry } from './builtins/registry.js';
14
-
15
- export function run(source, options = {}) {
16
- const includeWhy = options.proof === true || options.why === true || options.explain === true;
17
- const parseOptions = { ...options, sourceMetadata: includeWhy, markRecursive: includeWhy };
18
- const program = source instanceof Program ? source : Program.parse(source, parseOptions);
19
- const runOptions = options.registry ? options : { ...options, registry: getDefaultRegistry() };
20
- const solver = new Solver(program, runOptions);
21
- const output = [];
22
- const goals = program.materializationGoals();
23
- const materializedKeys = new Set(goals.map((goal) => `${goal.name}/${goal.arity}`));
24
- const facts = program.sourceFactLines(materializedKeys);
25
- const seen = new Set();
26
- for (const goal of goals) {
27
- solver.solutionsSeen = 0;
28
- for (const env of solver.solve([goal], new Env(), 0)) {
29
- const resolved = copyResolved(goal, env);
30
- if (!termIsGround(resolved)) continue;
31
- const line = `${termToString(resolved, new Env(), true)}.\n`;
32
- if (facts.has(line) || seen.has(line)) continue;
33
- seen.add(line);
34
- output.push(line);
35
- if (includeWhy) appendExplanation(output, program, resolved, runOptions.registry);
36
- }
37
- }
38
- return { stdout: output.join(''), stats: solver.stats };
39
- }
40
-
41
- function appendExplanation(output, program, resolved, registry) {
42
- const proof = whyProof(program, resolved, { registry });
43
- output.push(proof.text);
44
- if (!proof.ok) output.push(whyNoProof(resolved));
45
- }
46
-
47
- export * from './explain.js';
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }