eyemind 0.4.0 → 0.5.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/README.md +16 -3
- package/SPEC.md +8 -2
- package/package.json +1 -1
- package/src/builtins.js +26 -1
- package/src/digest.js +162 -0
- package/src/engine.js +3 -1
- package/src/version.js +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ eyemind is a **JavaScript rule language** with forward and backward reasoning an
|
|
|
7
7
|
|
|
8
8
|
[Playground](https://eyereasoner.github.io/eyemind/playground/) · [Specification](https://eyereasoner.github.io/eyemind/SPEC) · [Conformance](https://eyereasoner.github.io/eyemind/conformance/) · [Examples](https://eyereasoner.github.io/eyemind/examples/)
|
|
9
9
|
|
|
10
|
-
The playground runs programs in your browser; the specification defines the language, its canonical text, the proof format and the C1–C10 checks. The examples are 94 runnable programs, each with a card deck and saved conclusions, proofs and check reports. The conformance suite has
|
|
10
|
+
The playground runs programs in your browser; the specification defines the language, its canonical text, the proof format and the C1–C10 checks. The examples are 94 runnable programs, each with a card deck and saved conclusions, proofs and check reports. The conformance suite has 1353 cases that test any implementation of the specification through its command line; run it [in your browser](https://eyereasoner.github.io/eyemind/playground/conformance).
|
|
11
11
|
|
|
12
12
|
## Contents
|
|
13
13
|
|
|
@@ -19,6 +19,7 @@ The playground runs programs in your browser; the specification defines the lang
|
|
|
19
19
|
- [Deriving rules](#deriving-rules)
|
|
20
20
|
- [Inspecting rules](#inspecting-rules)
|
|
21
21
|
- [RDF 1.2](#rdf-12)
|
|
22
|
+
- [Notation3](#notation3)
|
|
22
23
|
- [How eyemind reasons](#how-eyemind-reasons)
|
|
23
24
|
- [Proofs, and what checking one means](#proofs-and-what-checking-one-means)
|
|
24
25
|
- [Why negation and collection are safe](#why-negation-and-collection-are-safe)
|
|
@@ -58,7 +59,7 @@ Prolog, Datalog, N3 and SRL already exist, and eyemind adds no new logic: rules
|
|
|
58
59
|
When eyemind is not the right tool:
|
|
59
60
|
|
|
60
61
|
- If you do not need proofs, use the mature tools: SWI-Prolog and XSB have tabling, and Soufflé is fast at scale.
|
|
61
|
-
- N3 and SRL are designed around RDF and Web data. eyemind does not compete there: RDF comes in as data (see [RDF 1.2](#rdf-12)).
|
|
62
|
+
- N3 and SRL are designed around RDF and Web data. eyemind does not compete there: RDF comes in as data (see [RDF 1.2](#rdf-12)), and N3 programs compile to eyemind (see [Notation3](#notation3)).
|
|
62
63
|
- eyemind is for cases where someone else has to be able to check why a conclusion holds: audits, compliance, and decisions between parties that do not trust each other.
|
|
63
64
|
|
|
64
65
|
## Install and run
|
|
@@ -123,7 +124,7 @@ Now add `fact(parent('carol', 'dave'))`, or remove a rule, and watch which answe
|
|
|
123
124
|
|
|
124
125
|
**An array is a conjunction:** `implies([p(X), q(X)], [r(X), s(X)])`. Disjunction is `or(A, B)`, negation is `not(G)`, and collection is `findall(T, G, L)`, alongside `call` and `once`.
|
|
125
126
|
|
|
126
|
-
**Text is atoms:** `atom_chars`, `atom_concat` and `atom_length` take them apart, and `regex_match(P, T)`, `regex_find(P, T, Groups)` and `regex_replace(P, T, R, U)` search them with ECMAScript regular expressions.
|
|
127
|
+
**Text is atoms:** `atom_chars`, `atom_concat` and `atom_length` take them apart, `atom_lower` and `atom_upper` change their case, `regex_match(P, T)`, `regex_find(P, T, Groups)` and `regex_replace(P, T, R, U)` search them with ECMAScript regular expressions, `digest('sha256', A, Hex)` hashes them, and `term_text(T, A)` writes a ground term as its canonical text.
|
|
127
128
|
|
|
128
129
|
### Terms and names
|
|
129
130
|
|
|
@@ -185,6 +186,18 @@ eyemind has no built-in RDF; RDF arrives as data through [rdf-interchange](https
|
|
|
185
186
|
|
|
186
187
|
A Skolem term becomes a blank node, the same one for the same rule firing. The `rdf12-*` examples show triple terms, annotations, directional strings, typed numbers and named graphs.
|
|
187
188
|
|
|
189
|
+
### Notation3
|
|
190
|
+
|
|
191
|
+
N3 programs run on eyemind through [n3-interchange](https://github.com/eyereasoner/n3-interchange). `n3-to-eyemind` compiles N3 facts and rules into an eyemind program, with the N3 built-ins it uses written as eyemind rules, and `eyemind-to-n3` writes the conclusions back as N3; `eyemind-n3` does both around a run:
|
|
192
|
+
|
|
193
|
+
```sh
|
|
194
|
+
npm install -g n3-interchange
|
|
195
|
+
eyemind-n3 socrates.n3 # the derived triples, as N3
|
|
196
|
+
n3-to-eyemind socrates.n3 -o socrates.js # or the program, to run, prove and check
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Triples are `rdf(Subject, Predicate, Object)`, with IRIs, blank nodes and literals written as in the RDF table above and N3 numbers as eyemind numbers. `=>` becomes `implies`, `<=` becomes `implied_by`, and scoped negation and collection become `not` and `findall`, so an N3 run has a proof that eyemind checks like any other. Built-ins that need what eyemind leaves out, such as hashing or file access, stop the compiler with a message naming them; the n3-interchange README lists them and how much of the N3 test suite passes.
|
|
200
|
+
|
|
188
201
|
## How eyemind reasons
|
|
189
202
|
|
|
190
203
|
The statement chooses the direction:
|
package/SPEC.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
```text
|
|
4
4
|
Title: The eyemind Rule Language and Proof Format
|
|
5
|
-
Version: eyemind 0.
|
|
5
|
+
Version: eyemind 0.5.0
|
|
6
6
|
```
|
|
7
7
|
|
|
8
8
|
This document specifies the syntax and meaning of eyemind programs and data
|
|
@@ -575,6 +575,9 @@ primitive called outside its patterns raises an error.
|
|
|
575
575
|
| `atom_length` | `atom_length(+A, ?N)` | `N` is the number of characters of `A`. |
|
|
576
576
|
| `number_chars` | `number_chars(?N, +L)`, `number_chars(+N, -L)` | A bound `L` is read as a number: an optional sign and decimal digits give an integer, and with a fraction or an exponent a float, as in `'007'`, `'-21.5'`, `'.5'`, `'1.'` and `'2E-2'`; other text fails, as does text whose value is too large for a finite float, such as `'1e400'`. Otherwise `L` spells `N` in its canonical text ([Section 9.2](#92-canonical-atoms-numbers-variables-and-lists)). |
|
|
577
577
|
| `atom_concat` | `atom_concat(+A, +B, ?AB)`, `atom_concat(?A, ?B, +AB)` | `AB` is `A` followed by `B`; with `AB` given, every split, shortest `A` first. |
|
|
578
|
+
| `atom_lower`, `atom_upper` | `atom_lower(+A, ?L)`, `atom_upper(+A, ?U)` | `L` is `A` in lower case, `U` in upper case, by Unicode default case conversion: the full mappings, independent of locale, with the final sigma of a word lowered to `'ς'`, so `atom_upper('straße', 'STRASSE')` holds. |
|
|
579
|
+
| `digest` | `digest(+H, +A, ?D)` | `D` is the digest of the UTF-8 encoding of the atom `A` by the hash function `H`, one of `'md5'`, `'sha1'`, `'sha256'` and `'sha512'`, as lowercase hexadecimal. A lone surrogate is encoded as U+FFFD. Another `H` raises an error. |
|
|
580
|
+
| `term_text` | `term_text(+T, ?A)` | `A` is the canonical text of `T` ([Section 9.2](#92-canonical-atoms-numbers-variables-and-lists)), which MUST be ground: `term_text(f('a', [1, 2.0]), "f('a', [1, 2.0])")` holds. |
|
|
578
581
|
| `regex_match` | `regex_match(+P, +T)` | Some part of the atom `T` matches the regular expression `P`. |
|
|
579
582
|
| `regex_find` | `regex_find(+P, +T, ?G)` | One solution per match of `P` in `T`, from left to right: `G` is the list of the matched text followed by each capture group's text, `''` for a group that took no part in the match. |
|
|
580
583
|
| `regex_replace` | `regex_replace(+P, +T, +R, ?U)` | `U` is `T` with every match of `P` replaced by `R`. |
|
|
@@ -1066,7 +1069,10 @@ when supported. Each negation and collection of a proof gets the search certific
|
|
|
1066
1069
|
that settles it (Sections [10.4](#104-search-certificates) and [11.10](#1110-c9-search-closure)) whenever [Section 11.10](#1110-c9-search-closure) allows one. A
|
|
1067
1070
|
table holds every answer of its call, so it can search beyond where the run
|
|
1068
1071
|
stopped, as under `once`; a boundary whose tables would meet an error, or
|
|
1069
|
-
exceed `max_inferences` calls and answers ([Section 8.3](#83-resource-bounds)), stays trusted.
|
|
1072
|
+
exceed `max_inferences` calls and answers ([Section 8.3](#83-resource-bounds)), stays trusted. So does a
|
|
1073
|
+
boundary of a halted run ([Section 8.5](#85-contradictions)) whose listings a rule of a later stratum
|
|
1074
|
+
would extend: the run stopped before its fixpoint, so its derived facts need
|
|
1075
|
+
not be closed under the rules. A
|
|
1070
1076
|
reasoner MUST check every proof it generates ([Section 11](#11-proof-checking)) before returning it,
|
|
1071
1077
|
and MUST fail with an error rather than return a proof that does not pass. A
|
|
1072
1078
|
run without conclusions has a proof without claims, which is valid and
|
package/package.json
CHANGED
package/src/builtins.js
CHANGED
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
EyemindError, Struct, Var, codePoints, compareTerms, copyResolved, deref, identical, isGround, key,
|
|
16
16
|
listFromItems, properListItems, unify,
|
|
17
17
|
} from './terms.js';
|
|
18
|
-
import {
|
|
18
|
+
import { DIGESTS, utf8 } from './digest.js';
|
|
19
|
+
import { floatText, write } from './writer.js';
|
|
19
20
|
|
|
20
21
|
function comparison(holds) {
|
|
21
22
|
return (args, resolved, env) => holds(arith.compare(args[0], args[1], env));
|
|
@@ -191,6 +192,26 @@ function regexReplace(args, resolved, env, bind) {
|
|
|
191
192
|
return bind(args[3], source.replace(compiled, replacement));
|
|
192
193
|
}
|
|
193
194
|
|
|
195
|
+
// atom_lower(+A, ?L), atom_upper(+A, ?U): Unicode default case conversion,
|
|
196
|
+
// with its full mappings, so 'ß' becomes 'SS', and no locale.
|
|
197
|
+
function caseConversion(name, convert) {
|
|
198
|
+
return (args, resolved, env, bind) => bind(args[1], convert(text(name, resolved[0], 'atom')));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// digest(+Algorithm, +A, ?Hex): the lowercase hexadecimal digest of A's UTF-8
|
|
202
|
+
// bytes, by md5, sha1, sha256 or sha512.
|
|
203
|
+
function digest(args, resolved, env, bind) {
|
|
204
|
+
const algorithm = DIGESTS.get(resolved[0]);
|
|
205
|
+
if (algorithm === undefined) throw new EyemindError(`digest/3 needs md5, sha1, sha256 or sha512, not ${write(resolved[0])}`);
|
|
206
|
+
return bind(args[2], algorithm(utf8(text('digest/3', resolved[1], 'atom'))));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// term_text(+T, ?A): A is the canonical text of the ground term T.
|
|
210
|
+
function termText(args, resolved, env, bind) {
|
|
211
|
+
if (!isGround(args[0], env)) throw new EyemindError('term_text/2 needs a ground term');
|
|
212
|
+
return bind(args[1], write(copyResolved(args[0], env)));
|
|
213
|
+
}
|
|
214
|
+
|
|
194
215
|
const isNumberValue = (term) => typeof term === 'bigint' || typeof term === 'number';
|
|
195
216
|
|
|
196
217
|
export const TESTS = new Map([
|
|
@@ -224,6 +245,10 @@ export const TESTS = new Map([
|
|
|
224
245
|
['atom_length/2', atomLength],
|
|
225
246
|
['number_chars/2', numberChars],
|
|
226
247
|
['compare/3', compare],
|
|
248
|
+
['atom_lower/2', caseConversion('atom_lower/2', (a) => a.toLowerCase())],
|
|
249
|
+
['atom_upper/2', caseConversion('atom_upper/2', (a) => a.toUpperCase())],
|
|
250
|
+
['digest/3', digest],
|
|
251
|
+
['term_text/2', termText],
|
|
227
252
|
['regex_match/2', regexMatch],
|
|
228
253
|
['regex_replace/4', regexReplace],
|
|
229
254
|
]);
|
package/src/digest.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// Message digests for digest/3: MD5, SHA-1, SHA-256 and SHA-512 of a text's
|
|
2
|
+
// UTF-8 bytes, as lowercase hexadecimal. Written out here, synchronous and
|
|
3
|
+
// without Node, so every host gives the same digest.
|
|
4
|
+
|
|
5
|
+
const encoder = new TextEncoder();
|
|
6
|
+
|
|
7
|
+
// A lone surrogate has no UTF-8 encoding; TextEncoder writes U+FFFD for it.
|
|
8
|
+
export function utf8(text) {
|
|
9
|
+
return encoder.encode(text);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const hex32 = (words, littleEndian = false) => words.map((w) => {
|
|
13
|
+
const value = littleEndian
|
|
14
|
+
? ((w & 0xff) << 24) | (((w >>> 8) & 0xff) << 16) | (((w >>> 16) & 0xff) << 8) | (w >>> 24)
|
|
15
|
+
: w;
|
|
16
|
+
return (value >>> 0).toString(16).padStart(8, '0');
|
|
17
|
+
}).join('');
|
|
18
|
+
|
|
19
|
+
// The message padded to a multiple of the block size, with its bit length
|
|
20
|
+
// at the end in lengthBytes bytes, big- or little-endian.
|
|
21
|
+
function pad(bytes, block, lengthBytes, littleEndian) {
|
|
22
|
+
const total = Math.ceil((bytes.length + 1 + lengthBytes) / block) * block;
|
|
23
|
+
const out = new Uint8Array(total);
|
|
24
|
+
out.set(bytes);
|
|
25
|
+
out[bytes.length] = 0x80;
|
|
26
|
+
let bits = BigInt(bytes.length) * 8n;
|
|
27
|
+
for (let i = 0; i < lengthBytes; i++) {
|
|
28
|
+
const position = littleEndian ? total - lengthBytes + i : total - 1 - i;
|
|
29
|
+
out[position] = Number(bits & 0xffn);
|
|
30
|
+
bits >>= 8n;
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const rotl = (x, n) => (x << n) | (x >>> (32 - n));
|
|
36
|
+
const rotr = (x, n) => (x >>> n) | (x << (32 - n));
|
|
37
|
+
|
|
38
|
+
function md5(bytes) {
|
|
39
|
+
const s = [7, 12, 17, 22, 5, 9, 14, 20, 4, 11, 16, 23, 6, 10, 15, 21];
|
|
40
|
+
const k = Array.from({ length: 64 }, (_, i) => Math.floor(Math.abs(Math.sin(i + 1)) * 2 ** 32) | 0);
|
|
41
|
+
const m = pad(bytes, 64, 8, true);
|
|
42
|
+
let [a0, b0, c0, d0] = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476];
|
|
43
|
+
for (let offset = 0; offset < m.length; offset += 64) {
|
|
44
|
+
const w = Array.from({ length: 16 }, (_, i) => m[offset + 4 * i] | (m[offset + 4 * i + 1] << 8) |
|
|
45
|
+
(m[offset + 4 * i + 2] << 16) | (m[offset + 4 * i + 3] << 24));
|
|
46
|
+
let [a, b, c, d] = [a0, b0, c0, d0];
|
|
47
|
+
for (let i = 0; i < 64; i++) {
|
|
48
|
+
let f;
|
|
49
|
+
let g;
|
|
50
|
+
if (i < 16) [f, g] = [(b & c) | (~b & d), i];
|
|
51
|
+
else if (i < 32) [f, g] = [(d & b) | (~d & c), (5 * i + 1) % 16];
|
|
52
|
+
else if (i < 48) [f, g] = [b ^ c ^ d, (3 * i + 5) % 16];
|
|
53
|
+
else [f, g] = [c ^ (b | ~d), (7 * i) % 16];
|
|
54
|
+
const next = d;
|
|
55
|
+
d = c;
|
|
56
|
+
c = b;
|
|
57
|
+
b = (b + rotl((a + f + k[i] + w[g]) | 0, s[(i >> 4) * 4 + (i % 4)])) | 0;
|
|
58
|
+
a = next;
|
|
59
|
+
}
|
|
60
|
+
[a0, b0, c0, d0] = [(a0 + a) | 0, (b0 + b) | 0, (c0 + c) | 0, (d0 + d) | 0];
|
|
61
|
+
}
|
|
62
|
+
return hex32([a0, b0, c0, d0], true);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Big-endian 32-bit words of a padded 64-byte block.
|
|
66
|
+
const words = (m, offset, count) => Array.from({ length: count }, (_, i) => (m[offset + 4 * i] << 24) |
|
|
67
|
+
(m[offset + 4 * i + 1] << 16) | (m[offset + 4 * i + 2] << 8) | m[offset + 4 * i + 3]);
|
|
68
|
+
|
|
69
|
+
function sha1(bytes) {
|
|
70
|
+
const m = pad(bytes, 64, 8, false);
|
|
71
|
+
let h = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
|
|
72
|
+
for (let offset = 0; offset < m.length; offset += 64) {
|
|
73
|
+
const w = words(m, offset, 16);
|
|
74
|
+
for (let i = 16; i < 80; i++) w[i] = rotl(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
|
|
75
|
+
let [a, b, c, d, e] = h;
|
|
76
|
+
for (let i = 0; i < 80; i++) {
|
|
77
|
+
const [f, k] = i < 20 ? [(b & c) | (~b & d), 0x5a827999] : i < 40 ? [b ^ c ^ d, 0x6ed9eba1]
|
|
78
|
+
: i < 60 ? [(b & c) | (b & d) | (c & d), 0x8f1bbcdc] : [b ^ c ^ d, 0xca62c1d6];
|
|
79
|
+
const t = (rotl(a, 5) + f + e + k + w[i]) | 0;
|
|
80
|
+
[e, d, c, b, a] = [d, c, rotl(b, 30), a, t];
|
|
81
|
+
}
|
|
82
|
+
h = h.map((x, i) => (x + [a, b, c, d, e][i]) | 0);
|
|
83
|
+
}
|
|
84
|
+
return hex32(h);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const K256 = [
|
|
88
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
89
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
90
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
91
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
92
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
93
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
94
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
95
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
function sha256(bytes) {
|
|
99
|
+
const m = pad(bytes, 64, 8, false);
|
|
100
|
+
let h = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];
|
|
101
|
+
for (let offset = 0; offset < m.length; offset += 64) {
|
|
102
|
+
const w = words(m, offset, 16);
|
|
103
|
+
for (let i = 16; i < 64; i++) {
|
|
104
|
+
const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ (w[i - 15] >>> 3);
|
|
105
|
+
const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ (w[i - 2] >>> 10);
|
|
106
|
+
w[i] = (w[i - 16] + s0 + w[i - 7] + s1) | 0;
|
|
107
|
+
}
|
|
108
|
+
let [a, b, c, d, e, f, g, k] = h;
|
|
109
|
+
for (let i = 0; i < 64; i++) {
|
|
110
|
+
const t1 = (k + (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) + ((e & f) ^ (~e & g)) + K256[i] + w[i]) | 0;
|
|
111
|
+
const t2 = ((rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + ((a & b) ^ (a & c) ^ (b & c))) | 0;
|
|
112
|
+
[k, g, f, e, d, c, b, a] = [g, f, e, (d + t1) | 0, c, b, a, (t1 + t2) | 0];
|
|
113
|
+
}
|
|
114
|
+
h = h.map((x, i) => (x + [a, b, c, d, e, f, g, k][i]) | 0);
|
|
115
|
+
}
|
|
116
|
+
return hex32(h);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// SHA-512 works on 64-bit words, kept as BigInts.
|
|
120
|
+
const MASK64 = (1n << 64n) - 1n;
|
|
121
|
+
const K512 = `428a2f98d728ae22 7137449123ef65cd b5c0fbcfec4d3b2f e9b5dba58189dbbc 3956c25bf348b538 59f111f1b605d019
|
|
122
|
+
923f82a4af194f9b ab1c5ed5da6d8118 d807aa98a3030242 12835b0145706fbe 243185be4ee4b28c 550c7dc3d5ffb4e2 72be5d74f27b896f
|
|
123
|
+
80deb1fe3b1696b1 9bdc06a725c71235 c19bf174cf692694 e49b69c19ef14ad2 efbe4786384f25e3 0fc19dc68b8cd5b5 240ca1cc77ac9c65
|
|
124
|
+
2de92c6f592b0275 4a7484aa6ea6e483 5cb0a9dcbd41fbd4 76f988da831153b5 983e5152ee66dfab a831c66d2db43210 b00327c898fb213f
|
|
125
|
+
bf597fc7beef0ee4 c6e00bf33da88fc2 d5a79147930aa725 06ca6351e003826f 142929670a0e6e70 27b70a8546d22ffc 2e1b21385c26c926
|
|
126
|
+
4d2c6dfc5ac42aed 53380d139d95b3df 650a73548baf63de 766a0abb3c77b2a8 81c2c92e47edaee6 92722c851482353b a2bfe8a14cf10364
|
|
127
|
+
a81a664bbc423001 c24b8b70d0f89791 c76c51a30654be30 d192e819d6ef5218 d69906245565a910 f40e35855771202a 106aa07032bbd1b8
|
|
128
|
+
19a4c116b8d2d0c8 1e376c085141ab53 2748774cdf8eeb99 34b0bcb5e19b48a8 391c0cb3c5c95a63 4ed8aa4ae3418acb 5b9cca4f7763e373
|
|
129
|
+
682e6ff3d6b2b8a3 748f82ee5defb2fc 78a5636f43172f60 84c87814a1f0ab72 8cc702081a6439ec 90befffa23631e28 a4506cebde82bde9
|
|
130
|
+
bef9a3f7b2c67915 c67178f2e372532b ca273eceea26619c d186b8c721c0c207 eada7dd6cde0eb1e f57d4f7fee6ed178 06f067aa72176fba
|
|
131
|
+
0a637dc5a2c898a6 113f9804bef90dae 1b710b35131c471b 28db77f523047d84 32caab7b40c72493 3c9ebe0a15c9bebc 431d67c49c100d4c
|
|
132
|
+
4cc5d4becb3e42b6 597f299cfc657e2a 5fcb6fab3ad6faec 6c44198c4a475817`.split(/\s+/).map((x) => BigInt(`0x${x}`));
|
|
133
|
+
const rotr64 = (x, n) => ((x >> n) | (x << (64n - n))) & MASK64;
|
|
134
|
+
|
|
135
|
+
function sha512(bytes) {
|
|
136
|
+
const m = pad(bytes, 128, 16, false);
|
|
137
|
+
let h = `6a09e667f3bcc908 bb67ae8584caa73b 3c6ef372fe94f82b a54ff53a5f1d36f1 510e527fade682d1 9b05688c2b3e6c1f
|
|
138
|
+
1f83d9abfb41bd6b 5be0cd19137e2179`.split(/\s+/).map((x) => BigInt(`0x${x}`));
|
|
139
|
+
for (let offset = 0; offset < m.length; offset += 128) {
|
|
140
|
+
const w = [];
|
|
141
|
+
for (let i = 0; i < 16; i++) {
|
|
142
|
+
let x = 0n;
|
|
143
|
+
for (let j = 0; j < 8; j++) x = (x << 8n) | BigInt(m[offset + 8 * i + j]);
|
|
144
|
+
w.push(x);
|
|
145
|
+
}
|
|
146
|
+
for (let i = 16; i < 80; i++) {
|
|
147
|
+
const s0 = rotr64(w[i - 15], 1n) ^ rotr64(w[i - 15], 8n) ^ (w[i - 15] >> 7n);
|
|
148
|
+
const s1 = rotr64(w[i - 2], 19n) ^ rotr64(w[i - 2], 61n) ^ (w[i - 2] >> 6n);
|
|
149
|
+
w[i] = (w[i - 16] + s0 + w[i - 7] + s1) & MASK64;
|
|
150
|
+
}
|
|
151
|
+
let [a, b, c, d, e, f, g, k] = h;
|
|
152
|
+
for (let i = 0; i < 80; i++) {
|
|
153
|
+
const t1 = (k + (rotr64(e, 14n) ^ rotr64(e, 18n) ^ rotr64(e, 41n)) + ((e & f) ^ (~e & MASK64 & g)) + K512[i] + w[i]) & MASK64;
|
|
154
|
+
const t2 = ((rotr64(a, 28n) ^ rotr64(a, 34n) ^ rotr64(a, 39n)) + ((a & b) ^ (a & c) ^ (b & c))) & MASK64;
|
|
155
|
+
[k, g, f, e, d, c, b, a] = [g, f, e, (d + t1) & MASK64, c, b, a, (t1 + t2) & MASK64];
|
|
156
|
+
}
|
|
157
|
+
h = h.map((x, i) => (x + [a, b, c, d, e, f, g, k][i]) & MASK64);
|
|
158
|
+
}
|
|
159
|
+
return h.map((x) => x.toString(16).padStart(16, '0')).join('');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export const DIGESTS = new Map([['md5', md5], ['sha1', sha1], ['sha256', sha256], ['sha512', sha512]]);
|
package/src/engine.js
CHANGED
|
@@ -1031,9 +1031,11 @@ function certify(solver, boundaries, operational = false) {
|
|
|
1031
1031
|
if (outcome.status === 'settled' && (!operational || positiveListings(program, outcome.listings))) {
|
|
1032
1032
|
for (const item of outcome.tables) tables.add(item);
|
|
1033
1033
|
for (const item of outcome.listings) listings.add(item);
|
|
1034
|
-
} else if (outcome.status === 'failed') {
|
|
1034
|
+
} else if (outcome.status === 'failed' && solver.haltCode === null) {
|
|
1035
1035
|
throw new EyemindError(`cannot certify this result: ${outcome.failures[0]?.[0] ?? 'its search certificate fails'}`);
|
|
1036
1036
|
}
|
|
1037
|
+
// A halted run stopped before its fixpoint, so its derived facts need not
|
|
1038
|
+
// be closed under the rules; a boundary they cannot settle stays trusted.
|
|
1037
1039
|
}
|
|
1038
1040
|
return {
|
|
1039
1041
|
// Tables in the order their calls were first met.
|
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// The release this checkout is; ./release keeps it in step with package.json.
|
|
2
|
-
export const VERSION = '0.
|
|
2
|
+
export const VERSION = '0.5.0';
|