eyemind 0.4.0 → 0.5.1

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/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.4.0
5
+ Version: eyemind 0.5.1
6
6
  ```
7
7
 
8
8
  This document specifies the syntax and meaning of eyemind programs and data
@@ -66,20 +66,20 @@ proof.
66
66
  - [10.4 Search certificates](#104-search-certificates)
67
67
  - [10.5 Call-fidelity certificates](#105-call-fidelity-certificates)
68
68
  - [11. Proof Checking](#11-proof-checking)
69
- - [11.1 Reading the document](#111-reading-the-document)
70
- - [11.2 C1 Resolution](#112-c1-resolution)
71
- - [11.3 C2 Well-foundedness](#113-c2-well-foundedness)
72
- - [11.4 C3 Justification](#114-c3-justification)
73
- - [11.5 C4 Coverage](#115-c4-coverage)
74
- - [11.6 C5 Re-decision](#116-c5-re-decision)
75
- - [11.7 C6 Boundary consistency](#117-c6-boundary-consistency)
76
- - [11.8 C7 Relevance](#118-c7-relevance)
77
- - [11.9 C8 Witness integrity](#119-c8-witness-integrity)
78
- - [11.10 C9 Search closure](#1110-c9-search-closure)
79
- - [11.11 Counts and validity](#1111-counts-and-validity)
80
- - [11.12 Scope of a valid proof](#1112-scope-of-a-valid-proof)
81
- - [11.13 Operational query fidelity](#1113-operational-query-fidelity)
82
- - [11.14 C10 Call fidelity](#1114-c10-call-fidelity)
69
+ - [11.1 Scope of a valid proof](#111-scope-of-a-valid-proof)
70
+ - [11.2 Operational query fidelity](#112-operational-query-fidelity)
71
+ - [11.3 Reading the document](#113-reading-the-document)
72
+ - [11.4 C1 Resolution](#114-c1-resolution)
73
+ - [11.5 C2 Well-foundedness](#115-c2-well-foundedness)
74
+ - [11.6 C3 Justification](#116-c3-justification)
75
+ - [11.7 C4 Coverage](#117-c4-coverage)
76
+ - [11.8 C5 Re-decision](#118-c5-re-decision)
77
+ - [11.9 C6 Boundary consistency](#119-c6-boundary-consistency)
78
+ - [11.10 C7 Relevance](#1110-c7-relevance)
79
+ - [11.11 C8 Witness integrity](#1111-c8-witness-integrity)
80
+ - [11.12 C9 Search closure](#1112-c9-search-closure)
81
+ - [11.13 C10 Call fidelity](#1113-c10-call-fidelity)
82
+ - [11.14 Counts and validity](#1114-counts-and-validity)
83
83
  - [12. Check Reports](#12-check-reports)
84
84
  - [12.1 JSON form](#121-json-form)
85
85
  - [13. Command-Line Interface](#13-command-line-interface)
@@ -203,7 +203,7 @@ Proofs:
203
203
  by a clause, a primitive, a control, an absence or a collection; its
204
204
  **uses** are the goals that justify it ([Section 10.3](#103-steps)).
205
205
  - **Boundary**: a negation or collection that a proof justifies by an
206
- `'absent'` or `'collected'` step ([Section 11.7](#117-c6-boundary-consistency)).
206
+ `'absent'` or `'collected'` step ([Section 11.9](#119-c6-boundary-consistency)).
207
207
  - **Search certificate**: the tables and listings that record the searches
208
208
  behind a proof's boundaries ([Section 10.4](#104-search-certificates)).
209
209
  - **Table**: `searched(Call, Answers)`, every answer of one call, in order
@@ -215,17 +215,17 @@ Proofs:
215
215
  certificate and checked by C10 ([Section 10.5](#105-call-fidelity-certificates)).
216
216
  - **Original question**: each external goal; without external goals, the
217
217
  body of each query; without queries, each ordinary forward head. C10
218
- checks the claims answering them ([Section 11.14](#1114-c10-call-fidelity)).
218
+ checks the claims answering them ([Section 11.13](#1113-c10-call-fidelity)).
219
219
  - **Settled**: established by its search certificate, as a boundary is when
220
- C9 accepts that certificate ([Section 11.10](#1110-c9-search-closure)).
220
+ C9 accepts that certificate ([Section 11.12](#1112-c9-search-closure)).
221
221
  - **Trusted boundary**: a boundary that is not settled. A valid proof
222
222
  assumes it, and its check report lists it as an **obligation**, as it
223
- lists each claim whose call fidelity remains unproved (Sections [11.7](#117-c6-boundary-consistency),
224
- [11.14](#1114-c10-call-fidelity) and [12](#12-check-reports)).
223
+ lists each claim whose call fidelity remains unproved (Sections [11.9](#119-c6-boundary-consistency),
224
+ [11.13](#1113-c10-call-fidelity) and [12](#12-check-reports)).
225
225
  - **Check report**: what a checker writes: the claims, the outcome of each
226
226
  of C1–C10, failures, obligations, counts and a verdict ([Section 12](#12-check-reports)).
227
227
  - **Valid**: of a proof, failing no condition; a valid proof with
228
- obligations is valid conditional on them ([Section 11.11](#1111-counts-and-validity)).
228
+ obligations is valid conditional on them ([Section 11.14](#1114-counts-and-validity)).
229
229
 
230
230
  ## 2. Terms
231
231
 
@@ -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`. |
@@ -817,7 +820,7 @@ at every use. Unrelated unbound variables keep [Section 8.2](#82-forward-evaluat
817
820
  When inspection variables remain free in a conclusion or its captured
818
821
  template context, that firing MUST NOT introduce head-only existential
819
822
  witnesses: it MUST fail with an error requiring the inspection variables to
820
- be bound first. [Section 11.9](#119-c8-witness-integrity) rejects certificates that bypass this boundary.
823
+ be bound first. [Section 11.11](#1111-c8-witness-integrity) rejects certificates that bypass this boundary.
821
824
 
822
825
  Inspection uses a fixed source catalogue, so its own results do not depend on
823
826
  forward rounds. Other goals using derived patterns still participate in
@@ -919,7 +922,7 @@ infinite closure. A finite model does not ensure search termination:
919
922
  recurs indefinitely. Exceeding a resource bound raises an error ([Section
920
923
  8.3](#83-resource-bounds)). Contradictions halt without completing the closure ([Section 8.5](#85-contradictions)).
921
924
  A valid proof establishes only its claims subject to its trusted boundaries
922
- ([Section 11.12](#1112-scope-of-a-valid-proof)), not completeness of the model or the answers. Its search
925
+ ([Section 11.1](#111-scope-of-a-valid-proof)), not completeness of the model or the answers. Its search
923
926
  certificate settles the negations and collections it can ([Section 10.4](#104-search-certificates)).
924
927
 
925
928
  ## 8. Evaluation and Conclusions
@@ -972,7 +975,7 @@ and `p(2)` publishes `a(1)`, `b(1)`, `a(2)`, `b(2)`. For each head:
972
975
  free, in order of first occurrence in the heads. A rule that keeps meeting new firings does
973
976
  not terminate ([Section 8.3](#83-resource-bounds)). Derived facts other than scoped inspection
974
977
  patterns ([Section 6.3](#63-source-rule-inspection)) are therefore ground. A
975
- checker verifies the Skolem terms of a proof (C8, [Section 11.9](#119-c8-witness-integrity));
978
+ checker verifies the Skolem terms of a proof (C8, [Section 11.11](#1111-c8-witness-integrity));
976
979
  - a head `'true'` reports the instance of the rule's body, as a conjunction,
977
980
  once per distinct instance (by identity of canonical text);
978
981
  - a head `'false'` records the conclusion `'false'` and stops all reasoning
@@ -1061,12 +1064,15 @@ When a proof is requested, each solution records how each of its goals was
1061
1064
  justified: by a fact or rule of the program, by a derived fact (whose own
1062
1065
  record is kept), by a primitive, by a control, by an absence (a negation) or
1063
1066
  by a collection (`findall`). For each conclusion the first derivation found is
1064
- recorded. Each original question gets call-fidelity evidence (Sections [10.5](#105-call-fidelity-certificates) and [11.14](#1114-c10-call-fidelity)),
1067
+ recorded. Each original question gets call-fidelity evidence (Sections [10.5](#105-call-fidelity-certificates) and [11.13](#1113-c10-call-fidelity)),
1065
1068
  when supported. Each negation and collection of a proof gets the search certificate
1066
- 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
1069
+ that settles it (Sections [10.4](#104-search-certificates) and [11.12](#1112-c9-search-closure)) whenever [Section 11.12](#1112-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. A
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
@@ -1318,7 +1324,7 @@ proof's negations and collections:
1318
1324
 
1319
1325
  A table exists for each call to a relation that a backward rule defines or
1320
1326
  forward rules conclude, made by those searches or by the closure checks of
1321
- [Section 11.10](#1110-c9-search-closure); a call to a relation defined by facts alone needs none. A
1327
+ [Section 11.12](#1112-c9-search-closure); a call to a relation defined by facts alone needs none. A
1322
1328
  listing exists for each relation forward rules conclude that a table or a
1323
1329
  closure check consults. A reasoner writes only the tables and listings of
1324
1330
  the boundaries it settles: listings first, in the order first consulted,
@@ -1333,7 +1339,7 @@ searched(nonpacifist('ada'), [])
1333
1339
 
1334
1340
  `called(Call, Answers)` is a **call table**. Its shape and answer ordering
1335
1341
  are those of `searched/2` ([Section 10.4](#104-search-certificates)), but it records a call made while
1336
- answering an original question, for C10 ([Section 11.14](#1114-c10-call-fidelity)). External goals
1342
+ answering an original question, for C10 ([Section 11.13](#1113-c10-call-fidelity)). External goals
1337
1343
  remain inputs to the checker: a call table cannot supply or specialize the
1338
1344
  question a claim must answer.
1339
1345
 
@@ -1360,41 +1366,178 @@ They share any applicable `derived/2` listings, whose facts require steps.
1360
1366
 
1361
1367
  ## 11. Proof Checking
1362
1368
 
1363
- A checker is given a program, a proof document and, when the proof answers
1364
- goals asked from outside the program, those goals. It MUST NOT call a
1365
- reasoner to supply a missing step; it MAY recompute primitives, and it MAY
1366
- expand a call one level against the program with every inner call answered
1367
- by the search certificate ([Section 11.10](#1110-c9-search-closure)). It
1368
- checks C1–C10 and records each failure with its condition, a
1369
- detail and, where there is one, the term concerned.
1370
-
1371
- ### 11.1 Reading the document
1372
-
1373
- The document MUST read ([Section 9.1](#91-accepted-document-syntax)); otherwise C3 fails and the document has
1374
- no claims and no steps. Each `clause(N, Display)` MUST name a clause of the
1375
- program whose display ([Section 10.2](#102-clause-displays)) is identical to `Display`, variable
1376
- names included, so a display that merely renames the clause's variables
1377
- differs; otherwise C1 fails. Each `step` MUST have bindings that read as a list of `'='/2` pairs,
1378
- as an object literal does, and a list of uses, and no two steps may have
1379
- identical goals; otherwise C3 fails and the step is set aside. A `searched`
1380
- statement MUST have a callable `Call` and an array of answers, and a
1381
- `derived` statement a callable `Pattern` and an array of facts; no two tables
1382
- may have calls identical up to renaming of their variables, and no two
1383
- listings may name the same relation; otherwise C3 fails and the statement is
1384
- set aside. Every other statement is a claim ([Section 10.1](#101-structure)).
1385
-
1386
- ### 11.2 C1 Resolution
1387
-
1388
- For a `clause(N)` step, `N` MUST be a clause of the program; an `N` that is
1389
- not such a clause number, such as `'x'` or `1.0`, fails C1. The clause,
1390
- renamed apart, MUST satisfy: each binding names a distinct variable of the
1391
- clause and unifies it with its value; and for one of the clause's heads
1392
- (each conjunct of a forward rule's head), the head unifies with `Goal` and
1393
- the body, of the same length as `Uses`, unifies with `Uses` pairwise, such
1394
- that afterwards the head is identical to `Goal` and each body goal to its
1395
- use. A step's own terms MUST NOT need further instantiation to match: a
1396
- source clause `same(X, X)` cannot justify `same('a', 'b')`. Identity keeps
1397
- the sign of zero, so a fact `z(0.0)` cannot justify the goal `z(-0.0)`.
1369
+ A checker establishes whether the proof's claimed answers follow from the
1370
+ source program, with any assumptions reported as obligations. Its inputs
1371
+ are the program, the proof document and, when the proof answers goals asked
1372
+ from outside the program, those original goals. The source program is the
1373
+ authority for clauses and questions; the proof supplies evidence to check.
1374
+
1375
+ There are three parts to that evidence:
1376
+
1377
+ | Evidence in the proof | What the checker establishes |
1378
+ | --- | --- |
1379
+ | `step(Goal, By, Bindings, Uses)` | Each recorded inference follows from its cited source clause, primitive or control, with justified premises and correct witnesses. |
1380
+ | `searched(Call, Answers)` and `derived(Pattern, Facts)` | A negation's search has no solution, or a collection contains all its search results (C9). |
1381
+ | `called(Call, Answers)`, sharing applicable `derived/2` listings | A claimed answer can result from the original question with its actual call-time bindings and control choices (C10). |
1382
+
1383
+ The tables and listings are statements **inside the proof document**, after
1384
+ its steps ([Section 10.1](#101-structure)). They are checked claims about
1385
+ search, not authority to invent answers. The `called/2` table used by C10
1386
+ is distinct from the `called(Called)` justification of a state-test step
1387
+ ([Section 10.3](#103-steps)).
1388
+
1389
+ The checker MUST NOT call a reasoner to supply missing evidence. It MAY
1390
+ recompute primitives and expand a call one level against the source
1391
+ program, answering inner relation calls from the certificate. Each
1392
+ consulted table is itself checked by this expansion; tables cannot justify
1393
+ themselves through a cycle. Sections [11.12](#1112-c9-search-closure) and
1394
+ [11.13](#1113-c10-call-fidelity) specify these checks.
1395
+
1396
+ The ten conditions answer different questions:
1397
+
1398
+ | Condition | Question |
1399
+ | --- | --- |
1400
+ | [C1 Resolution](#114-c1-resolution) | Is this step an instance of the source clause it cites? |
1401
+ | [C2 Well-foundedness](#115-c2-well-foundedness) | Are the steps free of circular justification through their uses? |
1402
+ | [C3 Justification](#116-c3-justification) | Is each statement and justification well formed? |
1403
+ | [C4 Coverage](#117-c4-coverage) | Does every claim and premise have evidence? |
1404
+ | [C5 Re-decision](#118-c5-re-decision) | Do primitives hold, and do control steps compose from their uses? |
1405
+ | [C6 Boundary consistency](#119-c6-boundary-consistency) | Does available evidence contradict an unsettled negation or collection? |
1406
+ | [C7 Relevance](#1110-c7-relevance) | Does the evidence serve the claimed answers to the program's questions? |
1407
+ | [C8 Witness integrity](#1111-c8-witness-integrity) | Does each existential witness identify the correct rule firing? |
1408
+ | [C9 Search closure](#1112-c9-search-closure) | Does the certificate establish the recorded negation or collection? |
1409
+ | [C10 Call fidelity](#1113-c10-call-fidelity) | Can the original question return this answer? |
1410
+
1411
+ C9 checks the search behind a recorded step; C10 checks the original call
1412
+ before the proof's final bindings. This distinction matters for negation,
1413
+ collection, `once` and tests of variable state. A specialized goal can
1414
+ succeed even when the original open question would not return it
1415
+ ([Section 11.2](#112-operational-query-fidelity)). Every proof check
1416
+ includes C10.
1417
+
1418
+ The checker records each failure with its condition, a detail and, where
1419
+ there is one, the term concerned. Missing or unsupported search evidence
1420
+ can instead leave an obligation. The verdict distinguishes these outcomes:
1421
+
1422
+ | Verdict | Meaning |
1423
+ | --- | --- |
1424
+ | `checked` | No condition failed and no obligation remains. |
1425
+ | `checked_with_obligations` | No condition failed, but the claims depend on the reported obligations. |
1426
+ | `failed(N)` | The checker recorded `N` failures. |
1427
+
1428
+ Strict checking forbids unresolved obligations. Even `checked` establishes
1429
+ only the claimed answers, not that the proof contains every answer or that
1430
+ the whole program terminates ([Section 11.1](#111-scope-of-a-valid-proof)).
1431
+
1432
+ ### 11.1 Scope of a valid proof
1433
+
1434
+ A valid proof establishes that each claim follows from the source program
1435
+ by the recorded steps, conditional on any reported obligations. A settled
1436
+ boundary is established by its search certificate. An unconditional
1437
+ `checked` verdict also establishes operational query fidelity
1438
+ ([Section 11.2](#112-operational-query-fidelity)).
1439
+
1440
+ It does not establish:
1441
+
1442
+ - that the proof contains all conclusions of the program;
1443
+ - that the program derives no `'false'`;
1444
+ - that execution of the whole program terminates or reaches every question;
1445
+ - that the supplied program expresses the author's intended model.
1446
+
1447
+ A proof MAY omit conclusions. A run's own proof contains exactly that
1448
+ run's conclusions. An empty proof establishes no answers, including no
1449
+ claim that a question has no answers.
1450
+
1451
+ ### 11.2 Operational query fidelity
1452
+
1453
+ **Operational query fidelity** means that the original question can return
1454
+ the claimed answer under [Section 8](#8-evaluation-and-conclusions), with
1455
+ the bindings, control choices and forward state applicable at its calls.
1456
+ C10 checks this property. It concerns each claimed answer's reachability
1457
+ in that question's ordered search, not whether the proof includes every
1458
+ answer or whether execution reaches the question at all.
1459
+
1460
+ Proof steps show goals after the whole solution's bindings have been
1461
+ applied ([Section 10.3](#103-steps)). Those final instances can hide a
1462
+ different result at the original call. For example:
1463
+
1464
+ ```js
1465
+ fact(value('a'), value('b'))
1466
+ implied_by(p(X), value(X))
1467
+ implied_by(q(X), once(p(X)))
1468
+ ```
1469
+
1470
+ For the external question `q(X)`, `once(p(X))` selects `'a'`, so the only
1471
+ answer is `q('a')`. But if the checker starts from the final instance
1472
+ `q('b')`, the specialized call `once(p('b'))` succeeds. A derivation of
1473
+ that specialized call can pass C1–C9 without showing that the original
1474
+ question could return it.
1475
+
1476
+ Negation has the same problem with call-time bindings. Consider a separate
1477
+ program:
1478
+
1479
+ ```js
1480
+ fact(p('a'))
1481
+ implied_by(q(X), [not(p(X)), unify(X, 'b')])
1482
+ ```
1483
+
1484
+ The external question `q(X)` raises an error: `X` is still a named unbound
1485
+ variable when `not(p(X))` runs. The specialized call `q('b')` succeeds,
1486
+ but the later `unify` cannot retroactively bind the original negation.
1487
+ Tests of variable state and collection likewise depend on their actual
1488
+ calls ([Section 7.5](#75-sets-and-operational-behavior)).
1489
+
1490
+ A checker MUST NOT treat C7's instance test or C5's composition of a
1491
+ `once` step as establishing the original call's result. To establish
1492
+ operational query fidelity, it MUST validate the original call state,
1493
+ propagation of bindings between ordered premises, freshening and scope,
1494
+ and any first-solution choice or required search closure. These must follow
1495
+ from the original question, source clauses and checked evidence. Generator
1496
+ captures MUST remain independent of later caller bindings. The checker
1497
+ MUST NOT invoke the reasoner to fill gaps.
1498
+
1499
+ C10 supplies this certificate check in [Section 11.13](#1113-c10-call-fidelity).
1500
+ A C1–C9 verdict alone MUST NOT be presented as establishing operational
1501
+ query fidelity. Fidelity does not establish completeness, avoidance of an
1502
+ earlier contradiction, or termination of preceding questions.
1503
+
1504
+ ### 11.3 Reading the document
1505
+
1506
+ The document MUST be read as data using [Section 9.1](#91-accepted-document-syntax),
1507
+ without executing it. If it cannot be read, C3 fails and the document has no
1508
+ claims and no steps. The reader classifies its statements as follows:
1509
+
1510
+ | Statement | Requirement | Failure |
1511
+ | --- | --- | --- |
1512
+ | `clause(N, Display)` | `N` names a source clause whose display is identical to `Display`, including variable names ([Section 10.2](#102-clause-displays)). | C1 |
1513
+ | `step(Goal, By, Bindings, Uses)` | Bindings read as a list of `'='/2` pairs, as an object literal does; uses form a list; no other step has an identical goal. | C3; set the step aside |
1514
+ | `searched(Call, Answers)` | `Call` is callable and `Answers` is an array; no other search table has the same call up to variable renaming. | C3; set the statement aside |
1515
+ | `derived(Pattern, Facts)` | `Pattern` is callable and `Facts` is an array; no other listing names the same relation. | C3; set the statement aside |
1516
+ | `called(Call, Answers)` | The call-table requirements of [Section 10.5](#105-call-fidelity-certificates) hold, including preservation of anonymous-variable status when detecting duplicates. | C3; set the statement aside |
1517
+
1518
+ Every other statement is a claim, wherever it occurs in the document
1519
+ ([Section 10.1](#101-structure)). Renaming variables in a clause display
1520
+ does not make it identical to the source display.
1521
+
1522
+ ### 11.4 C1 Resolution
1523
+
1524
+ C1 checks that the displayed inference is an instance of the source
1525
+ clause. For a `clause(N)` step:
1526
+
1527
+ 1. `N` MUST identify a clause of the program. A value such as `'x'` or
1528
+ `1.0` that is not a clause number fails C1.
1529
+ 2. Rename the source clause apart. Each binding MUST name a distinct
1530
+ variable of that clause and unify it with its displayed value.
1531
+ 3. One head of the clause MUST unify with `Goal`. For a forward rule,
1532
+ consider each conjunct of its head separately. The body MUST have the
1533
+ same length as `Uses` and unify with it pairwise, in order.
1534
+ 4. After these unifications, the head MUST be identical to `Goal`, and
1535
+ each body goal to its corresponding use. The step's own terms MUST NOT
1536
+ require further instantiation.
1537
+
1538
+ For example, a source clause `same(X, X)` cannot justify `same('a', 'b')`.
1539
+ Identity also keeps the sign of zero: a fact `z(0.0)` cannot justify
1540
+ `z(-0.0)`.
1398
1541
 
1399
1542
  For a derived clause step, each enclosing generator MUST belong to the
1400
1543
  program. Its bindings may name variables of those generators' scope
@@ -1409,45 +1552,69 @@ sharing as well as the rule's direction and structure. The source rule is
1409
1552
  read as data; its body is not derived by the checker. These steps count as
1410
1553
  verified C1 steps and cite the usual source clause display.
1411
1554
 
1412
- ### 11.3 C2 Well-foundedness
1413
-
1414
- No step MAY depend on itself through the uses of steps. A checker finds
1415
- the dependencies by a depth-first search that starts from each step not yet
1416
- visited, in document order, and follows each step's uses in order, each
1417
- conjunct of a conjunctive use separately, to the steps whose goals they are.
1418
- Each use that leads back to a step on the current search path is one C2
1419
- failure, whose conclusion is the goal of that step.
1420
-
1421
- ### 11.4 C3 Justification
1422
-
1423
- `By` MUST be one of the forms of [Section 10.3](#103-steps). A `'builtin'` step MUST have
1424
- no bindings and no uses and a goal that is a primitive; a `called` step MUST
1425
- have no bindings and no uses and a goal that is a state test; an `'absent'` or
1426
- `'collected'` step MUST have no bindings and no uses and a goal that is a
1427
- negation or a `findall`, respectively. A step that fails C3 is not a trusted
1428
- boundary: it counts in neither `trusted`, C6 nor C9.
1429
-
1430
- ### 11.5 C4 Coverage
1431
-
1432
- Each conjunct of each claim MUST have a step. Each use, and each conjunct of
1433
- a use, MUST have a step or be identical to an instance of a fact of the
1434
- program. The conclusion of a failure for a use without a step is the goal of
1435
- the step that uses it. A document without claims is valid and certifies
1436
- nothing.
1437
-
1438
- ### 11.6 C5 Re-decision
1439
-
1440
- A `'builtin'` step's goal, solved as a primitive with no prior bindings, MUST
1441
- succeed without binding anything. For a `called(Called)` step, `Called`
1442
- MUST have the goal's name and arity; `Called`, renamed apart and solved as a
1443
- primitive with no prior bindings, MUST succeed without binding anything; and
1444
- the goal MUST be an instance of `Called`, so only the variables `Called`
1445
- leaves unbound may differ. C5 does not establish that the test ran in that
1446
- state: like the choice of a `once` step, the call state is operational
1447
- ([Section 11.13](#1113-operational-query-fidelity)), and C10 checks the original questions. A `'control'` step MUST have no bindings,
1448
- and its uses MUST be identical, in order, to the conjuncts of the argument of
1449
- `call` or `once`, or of one side of a disjunction. When trusted boundaries are
1450
- forbidden ("strict"), each `'absent'` or `'collected'` step fails C5.
1555
+ ### 11.5 C2 Well-foundedness
1556
+
1557
+ No step MAY depend on itself through the uses of steps. Even individually
1558
+ valid clause instances cannot justify each other in a circle.
1559
+
1560
+ To find these dependencies, perform a depth-first walk starting from each
1561
+ step not yet visited, in document order. Follow its uses in order to the
1562
+ steps with those goals, following each conjunct of a conjunctive use
1563
+ separately. Each use that leads back to a step on the current path is one
1564
+ C2 failure, whose conclusion is the goal of that step. Circular search
1565
+ tables are checked separately by C9 and C10.
1566
+
1567
+ ### 11.6 C3 Justification
1568
+
1569
+ `By` MUST be one of the forms of [Section 10.3](#103-steps). The following
1570
+ forms MUST have no bindings and no uses:
1571
+
1572
+ | `By` | Required goal |
1573
+ | --- | --- |
1574
+ | `'builtin'` | A primitive |
1575
+ | `called(Called)` | A state test |
1576
+ | `'absent'` | A negation `not(G)` |
1577
+ | `'collected'` | A collection `findall(T, G, L)` |
1578
+
1579
+ A well-formed negation or collection step is called a **boundary**. A step
1580
+ that fails C3 is not a trusted boundary: it counts in neither `trusted`, C6
1581
+ nor C9. The checks for clause and source justifications are in C1; control
1582
+ composition is checked by C5.
1583
+
1584
+ ### 11.7 C4 Coverage
1585
+
1586
+ C4 checks that the proof has no missing premises:
1587
+
1588
+ - Each conjunct of each claim MUST have a step.
1589
+ - Each use, and each conjunct of a use, MUST have a step or be identical to
1590
+ an instance of a source fact. Source facts can therefore serve directly
1591
+ as premises, but claims still require steps.
1592
+
1593
+ For a missing use, the failure's conclusion is the goal of the step that
1594
+ uses it. A document without claims certifies nothing; it is valid if no
1595
+ condition fails.
1596
+
1597
+ ### 11.8 C5 Re-decision
1598
+
1599
+ C5 recomputes primitives and checks how control steps use their premises:
1600
+
1601
+ - **Primitive.** A `'builtin'` step's goal, solved as a primitive with no
1602
+ prior bindings, MUST succeed without binding anything.
1603
+ - **State test.** For `called(Called)`, `Called` MUST have the goal's name
1604
+ and arity. Rename `Called` apart and solve it as a primitive with no
1605
+ prior bindings; it MUST succeed without binding anything. The displayed
1606
+ goal MUST be an instance of `Called`, so only variables the test leaves
1607
+ unbound may differ.
1608
+ - **Control.** A `'control'` step MUST have no bindings. Its uses MUST be
1609
+ identical, in order, to the conjuncts of the argument of `call` or
1610
+ `once`, or of one side of a disjunction.
1611
+ - **Strict checking.** When trusted boundaries are forbidden, each
1612
+ `'absent'` or `'collected'` step that C9 did not settle fails C5.
1613
+
1614
+ C5 checks the displayed primitive or chosen control branch. Whether a
1615
+ state test actually ran with the claimed bindings, or `once` selected that
1616
+ answer from the original open call, is checked by C10
1617
+ ([Section 11.13](#1113-c10-call-fidelity)).
1451
1618
 
1452
1619
  Host math is the one exception to identical re-decision. A `'builtin'` step
1453
1620
  `is(V, E)`, where `V` is a float and `E` applies `exp`, `log`, `log2`,
@@ -1461,20 +1628,20 @@ implementation even when its primitive steps pass C5. Every other recomputed res
1461
1628
  that grows beyond this bound, for example through cancellation, MAY make a
1462
1629
  proof fail on an implementation other than the one that made it.
1463
1630
 
1464
- ### 11.7 C6 Boundary consistency
1631
+ ### 11.9 C6 Boundary consistency
1465
1632
 
1466
- A negation or collection is a **boundary**. A boundary that its search
1467
- certificate settles or refutes is checked by C9 ([Section 11.10](#1110-c9-search-closure)); C6
1468
- confronts every other well-formed boundary step with the evidence at hand.
1633
+ C6 can refute an unsettled boundary using evidence already at hand. It
1634
+ cannot establish that a search is complete. C9 checks boundaries whose
1635
+ certificates settle or refute them; C6 checks the other well-formed
1636
+ boundary steps ([Section 11.12](#1112-c9-search-closure)).
1469
1637
 
1470
- A boundary that is not settled cannot be proved, but the evidence at
1471
- hand can refute it. The evidence for a goal is: when the goal is a ground
1472
- primitive, the goal itself if it holds, and otherwise the recomputed fact
1473
- that it fails; when it is a control, none, and the boundary is left
1474
- undecided; otherwise the program's facts and the goals of the document's
1475
- steps with the same name and arity. A goal of the last kind **has evidence**
1476
- only when there is at least one such fact or step goal; with none, nothing
1477
- could refute the boundary, and it is left undecided.
1638
+ For a ground primitive, recompute whether it holds: the evidence is the
1639
+ goal itself when it holds, and otherwise the fact that it fails. Controls
1640
+ provide no evidence for this check and leave the boundary undecided. For
1641
+ other goals, use the source facts and the document's step goals with the
1642
+ same name and arity. Such a goal **has evidence** only if at least one
1643
+ such fact or step exists. No evidence leaves the boundary undecided;
1644
+ it does not establish absence.
1478
1645
 
1479
1646
  - An absence `not(G)` is decided when `G` is a single goal, or a ground
1480
1647
  conjunction, whose every goal has evidence. It fails C6 when every goal of
@@ -1484,27 +1651,46 @@ could refute the boundary, and it is left undecided.
1484
1651
  decided when `G` is a single goal with evidence. It fails C6 when an
1485
1652
  instance of `T` for some evidence of `G` unifies with no element of `L`.
1486
1653
 
1487
- A trusted boundary that is not refuted remains an obligation ([Section 12](#12-check-reports)).
1654
+ For example, evidence of `p('a')` refutes `not(p('a'))` and refutes
1655
+ `findall(X, p(X), [])`. Merely failing to find evidence of `p('b')` does
1656
+ not prove `not(p('b'))` by C6.
1657
+
1658
+ A trusted boundary that is not refuted remains an obligation. Even a
1659
+ boundary that C6 has decided without finding a contradiction remains
1660
+ conditional until C9 settles it ([Section 12](#12-check-reports)).
1488
1661
 
1489
- ### 11.8 C7 Relevance
1662
+ ### 11.10 C7 Relevance
1490
1663
 
1491
- When goals were given and no claim is `'false'`, the questions are the goals.
1492
- Otherwise the questions are, for each forward rule, each ordinary head other
1493
- than `'true'`, and the rule's body as a conjunction when one of its heads is
1494
- `'true'` and no claim is `'false'`. Each claim MUST be an instance of a
1495
- question. Each step MUST be reachable from a conjunct of a claim through the
1496
- conjuncts of uses and, from a settled boundary, through the facts of the
1497
- listings it rests on. Each table and listing MUST be consulted by the search
1498
- or closure check of some boundary.
1664
+ C7 checks that claims answer relevant questions and that evidence serves
1665
+ those claims. When external goals were given and no claim is `'false'`,
1666
+ the questions are those goals. Otherwise take, for each forward rule:
1499
1667
 
1500
- ### 11.9 C8 Witness integrity
1668
+ - each ordinary head other than `'true'`;
1669
+ - its body as a conjunction when one head is `'true'` and no claim is
1670
+ `'false'`.
1501
1671
 
1502
- A forward rule's head MAY contain variables its body does not contain; each
1503
- says that something exists, and a reasoner concludes it with a Skolem term
1504
- ([Section 8.2](#82-forward-evaluation-and-witnesses)). C1 alone would accept any value for such a variable, since any
1505
- value gives an instance of the rule, so for a `clause(N)` step citing a
1506
- forward rule, under the substitution of C1, each such variable `V` MUST be
1507
- bound to `skolem(N, Name, Args)`, where:
1672
+ Each claim MUST be an instance of a question. This instance test alone
1673
+ does not establish that an original question returns the claim; C10 checks
1674
+ that separately.
1675
+
1676
+ Each step MUST be reachable from a conjunct of a claim through the
1677
+ conjuncts of uses or, from a settled boundary, through facts in the listings
1678
+ it rests on. Each table and listing MUST be consulted by a boundary's
1679
+ search or closure check, or by the C10 check of a claim. Facts in listings
1680
+ consulted by C10 are reachable through that evidence
1681
+ ([Section 11.13](#1113-c10-call-fidelity)).
1682
+
1683
+ ### 11.11 C8 Witness integrity
1684
+
1685
+ A forward rule's head MAY contain variables its body does not contain.
1686
+ Each such variable asserts existence and receives a Skolem term identifying
1687
+ the firing ([Section 8.2](#82-forward-evaluation-and-witnesses)). C1 alone
1688
+ would accept an arbitrary value for it. C8 checks that the value is the
1689
+ specified witness and that its arguments come from the firing's evidence.
1690
+
1691
+ **Witness shape.** For a `clause(N)` step citing a forward rule, under the
1692
+ substitution of C1, each head-only variable `V` MUST be bound to
1693
+ `skolem(N, Name, Args)`, where:
1508
1694
 
1509
1695
  - `Name` is the name of `V` as the program writes it ([Section 8.2](#82-forward-evaluation-and-witnesses));
1510
1696
  - `Args` is the same for every such variable of the step, and is the list of
@@ -1513,7 +1699,8 @@ bound to `skolem(N, Name, Args)`, where:
1513
1699
  firing, as established below. The spelling of a Skolem term alone MUST
1514
1700
  NOT establish that it is fresh.
1515
1701
 
1516
- A value containing `skolem(N, _, Args)` is a **candidate** for omission.
1702
+ **Which values belong in `Args`.** A value containing
1703
+ `skolem(N, _, Args)` is a **candidate** for omission.
1517
1704
  Values of variables occurring only in the head hold the witnesses checked
1518
1705
  above. If any other head variable's value is omitted, the checker MUST
1519
1706
  establish its **parametric provenance**:
@@ -1541,7 +1728,7 @@ establish its **parametric provenance**:
1541
1728
  change. A backward caller cannot make an earlier firing's data fresh.
1542
1729
  4. An unchanged boundary may use its original evidence or obligation. A
1543
1730
  changed boundary MUST already be settled in its original form, and its
1544
- abstracted form MUST also be settled by [Section 11.10](#1110-c9-search-closure), consulting only
1731
+ abstracted form MUST also be settled by [Section 11.12](#1112-c9-search-closure), consulting only
1545
1732
  tables and listings the original boundary rests on. A missing or
1546
1733
  incomplete certificate fails provenance; an obligation for a specific
1547
1734
  boundary MUST NOT silently become an obligation for a stronger one.
@@ -1550,14 +1737,16 @@ Failure of this provenance check is C8, not C1: the original step may be a
1550
1737
  valid clause instance while proposing the wrong witness context. Provenance
1551
1738
  rechecks do not add steps or change the C1, C5 or C9 counts. They establish
1552
1739
  that the displayed firing's evidence permits fresh parameters, not that the
1553
- firing is the one an original open call would select ([Section 11.13](#1113-operational-query-fidelity)).
1740
+ firing is the one an original open call would select ([Section 11.2](#112-operational-query-fidelity)).
1554
1741
 
1555
- When a forward clause has any such variables, its full head under the step's
1556
- substitution MUST be ground; a step that leaves such a variable unbound, or
1557
- bound to anything but its Skolem term, fails C8 rather than C1. A generic inspection pattern cannot share one
1558
- existential witness across all its instances ([Section 6.3](#63-source-rule-inspection)).
1742
+ **Groundness.** When a forward clause has head-only variables, its full
1743
+ head under the step's substitution MUST be ground. A step that leaves such
1744
+ a variable unbound, or bound to anything but its Skolem term, fails C8
1745
+ rather than C1. A generic inspection pattern cannot share one existential
1746
+ witness across all its instances ([Section 6.3](#63-source-rule-inspection)).
1559
1747
 
1560
- For a generator, use its scope projection ([Section 6.2](#62-inline-rule-templates)) as the head for this
1748
+ **Generators and captures.** For a generator, use its scope projection
1749
+ ([Section 6.2](#62-inline-rule-templates)) as the head for this
1561
1750
  check. For every derived clause step, including a backward clause step, the
1562
1751
  checker MUST also perform C8 for each enclosing generator under the same
1563
1752
  substitution. A forged outer witness cannot be authorized by using it in a
@@ -1569,165 +1758,162 @@ instantiated under the step's substitution, as one element of `Args`, as
1569
1758
  required by [Section 8.2](#82-forward-evaluation-and-witnesses). The checker MUST compute this from the source
1570
1759
  template's capture list and the substitution, not from the witness term.
1571
1760
 
1572
- A variable of the head that also occurs in the body is not checked by C8,
1573
- even when the body leaves it unbound; its value comes from the uses, which
1574
- other conditions check. Its effect on a head-only variable's witness context
1575
- is nevertheless subject to the provenance check above. A step with no
1576
- witnesses in its own forward head or enclosing generators is not covered
1577
- by C8.
1578
-
1579
- ### 11.10 C9 Search closure
1580
-
1581
- A checker tries to **settle** each well-formed boundary step (Sections [11.4](#114-c3-justification)
1582
- and [11.7](#117-c6-boundary-consistency)) with the search certificate, by searching its goal `G` as [Section
1583
- 8.1](#81-goal-search) does, except that:
1584
-
1585
- - a call to a relation that a backward rule defines or forward rules
1586
- conclude is answered by the table whose call is identical to it up to
1587
- renaming, each answer renamed apart in turn, and a call to a relation
1588
- defined by facts alone by those facts, in clause order;
1589
- - a negation inside the search treats its unbound variables as anonymous.
1590
-
1591
- The **expansion** of a call is the search of [Section 8.1](#81-goal-search) taken one level:
1592
- the facts in the listing of its relation, in order, then the program's facts
1593
- and backward rules of that name and arity, in clause order, each rule's body
1594
- searched in its place, inner calls answered as above. The boundary's search
1595
- **rests on** each table and listing it consults, and on those its tables and
1596
- the closure checks of its listings consult, transitively. The boundary is
1597
- settled when:
1598
-
1599
- 1. each table it rests on equals its expansion: the same number of answers,
1600
- each identical up to renaming of variables to the answer in the same
1601
- position;
1602
- 2. each listing it rests on has a step for each fact, every fact of the
1603
- listed name and arity and ground, and is **closed**: for each forward
1604
- rule with a head of that relation, each solution of the rule's body under
1605
- the certificate, with the rule's witnesses bound to their Skolem terms
1606
- ([Section 8.2](#82-forward-evaluation-and-witnesses)), gives head instances of that relation that are listed or
1607
- are ground facts of the program;
1608
- 3. no table it rests on depends on itself through the tables its expansion
1609
- consults;
1610
- 4. its outcome agrees: for a negation, `G` has no solution; for a collection
1611
- `findall(T, G, L)`, `L` is an instance of the list of the instances of
1612
- `T`, one per solution of `G`, in order, each renamed apart;
1613
- 5. no collection or `once` within its search, a table it rests on or a
1614
- closure check uses a table whose answers rest on a listing, since the
1615
- order of derived facts cannot be checked this way; and its search reaches
1616
- no source inspection and no clause appended by a template, and it
1617
- consults no listing whose relation a forward rule with a template head
1618
- or captures concludes ([Section 6.2](#62-inline-rule-templates)).
1619
-
1620
- For example, the absence `not(nonpacifist('ada'))` rests on the table
1621
- `searched(nonpacifist('ada'), [])` and the listing `derived(nonpacifist(A),
1622
- [nonpacifist('nixon')])`. The table equals its expansion: the listed fact
1623
- does not match the call, and no backward rule defines `nonpacifist/1`. The
1624
- listing is closed: the only rule concluding `nonpacifist/1` derives
1625
- `nonpacifist('nixon')`, which is listed, and that fact has its own step.
1626
-
1627
- A boundary fails C9 when its certificate is wrong: a table differs from its
1628
- expansion, a listed fact has no step or another name or arity, a listing is
1629
- not closed, tables depend on themselves, a search leads to an error, or a
1630
- negation's goal has a solution. Each wrong table or listing is reported once,
1631
- for the first boundary resting on it. A boundary whose certificate is
1632
- missing, incomplete or not applicable under item 5, or a collection whose
1633
- list does not agree, is not settled. A listing's facts are examined in
1634
- order, and the first that is not ground, such as a pattern a source
1635
- inspection derived, leaves the boundary not settled rather than failing it. A boundary that is not settled is
1636
- trusted, including one that fails C9; C6 confronts each boundary C9 neither
1637
- settled nor refuted with the evidence ([Section 11.7](#117-c6-boundary-consistency)).
1638
-
1639
- ### 11.11 Counts and validity
1761
+ **Coverage.** A variable of the head that also occurs in the body is not
1762
+ checked by C8, even when the body leaves it unbound; its value comes from
1763
+ the uses, which other conditions check. Its effect on a head-only
1764
+ variable's witness context is nevertheless subject to the provenance check
1765
+ above. A step with no witnesses in its own forward head or enclosing
1766
+ generators is not covered by C8.
1640
1767
 
1641
- | Condition | Covered |
1768
+ ### 11.12 C9 Search closure
1769
+
1770
+ C9 establishes that a recorded negation or collection has the stated search
1771
+ result. A step's uses alone cannot show that nothing matches, or that no
1772
+ result was omitted. The **search certificate** supplies complete answer
1773
+ tables and forward-fact listings for the checker to validate
1774
+ ([Section 10.4](#104-search-certificates)):
1775
+
1776
+ | Statement in the proof | Claim to check |
1642
1777
  | --- | --- |
1643
- | C1 resolution | `clause` and `source` steps that passed C1 |
1644
- | C2 well_founded | steps |
1645
- | C3 justification | steps |
1646
- | C4 coverage | claims plus uses |
1647
- | C5 re_decision | `'builtin'` and `'control'` steps that passed C5 |
1648
- | C6 boundary_consistency | boundaries not settled that the evidence decided |
1649
- | C7 relevance | claims plus steps |
1650
- | C8 witness_integrity | `clause` steps with witnesses in their forward head or enclosing generators that passed C8 |
1651
- | C9 search_closure | boundaries their search certificate settled or refuted |
1652
- | C10 call_fidelity | claims whose call fidelity is established or refuted |
1778
+ | `searched(Call, Answers)` | These are all answers to this call, in search order, repetitions included. |
1779
+ | `derived(Pattern, Facts)` | These are the forward-derived facts for this relation; each has evidence, and none required by closure is omitted. |
1780
+
1781
+ A boundary is **settled** only when the certificate is supported, complete
1782
+ for its search, applicable under the restrictions below, and agrees with
1783
+ the boundary's result. C9 checks the goal as displayed in the step. C10
1784
+ separately checks the bindings with which the original question called it.
1785
+
1786
+ **Answering calls from the certificate.** Search the boundary's inner goal
1787
+ `G` according to [Section 8.1](#81-goal-search), with these changes:
1788
+
1789
+ - Answer a relation defined by backward rules or concluded by forward
1790
+ rules from the `searched/2` table whose call is identical up to variable
1791
+ renaming. Rename each answer apart before using it.
1792
+ - Answer a relation defined by source facts alone from those facts, in
1793
+ clause order; it needs no table.
1794
+ - Inside this search, negation treats unbound variables as anonymous.
1795
+ This does not establish that a named variable was bound at the original
1796
+ call; that is a C10 requirement.
1797
+
1798
+ **Expanding and checking tables.** The **expansion** of a call is one level
1799
+ of the search of [Section 8.1](#81-goal-search): try its relation's listed
1800
+ forward facts in listing order, then source facts and backward rules in
1801
+ clause order. Search each rule's body in its place, answering inner calls
1802
+ as above. Each table MUST equal its expansion: the same number of answers,
1803
+ each identical up to variable renaming to the answer in the same position.
1804
+
1805
+ The boundary **rests on** every table and listing its search consults,
1806
+ including those consulted transitively by table expansions and listing
1807
+ closure checks. No table it rests on may depend on itself through the
1808
+ tables consulted by its expansion.
1809
+
1810
+ **Supporting and closing listings.** Every listed fact MUST have a step,
1811
+ have the listing's name and arity, and be ground. Its step is subject to the
1812
+ other proof conditions. A listing is **closed** when, for every forward
1813
+ rule with a head of its relation, each solution of the body under the
1814
+ certificate gives head instances that are listed or are ground source
1815
+ facts. Bind the rule's witnesses to their specified Skolem terms when
1816
+ checking this closure ([Section 8.2](#82-forward-evaluation-and-witnesses)).
1817
+
1818
+ Support rules out invented facts; closure rules out omitted facts. For
1819
+ example, an empty answer table is insufficient if a forward rule could
1820
+ derive a matching fact left out of the listing.
1821
+
1822
+ **Comparing the result.** With all relied-on evidence checked, settlement
1823
+ requires:
1824
+
1825
+ - For `not(G)`, `G` has no solution.
1826
+ - For `findall(T, G, L)`, `L` is an instance of the list of instances of
1827
+ `T`, one per solution of `G`, in order, each renamed apart. Repeated
1828
+ solutions remain repeated list elements. The instance test allows later
1829
+ goals to have bound variables in the copied results.
1830
+
1831
+ **Certificate limits.** Settlement also requires all of the following:
1832
+
1833
+ - No collection or `once` in the boundary's search, a relied-on table or a
1834
+ closure check uses a table whose answers rest on a forward listing.
1835
+ This format checks support and closure of derived facts, but cannot
1836
+ establish their publication order for order-sensitive operations.
1837
+ - The search reaches neither source inspection nor a clause appended by
1838
+ a template.
1839
+ - No consulted listing's relation is concluded by a forward rule with a
1840
+ template head or captures ([Section 6.2](#62-inline-rule-templates)).
1841
+
1842
+ For example, the saved
1843
+ [Nixon diamond proof](https://eyereasoner.github.io/eyemind/examples/proof/nixon-diamond.js)
1844
+ contains this step and certificate:
1653
1845
 
1654
- A check also counts the **steps** it read, the **claims**, the `clause` steps
1655
- **verified** by C1, the `source` inspection steps also **verified** by C1,
1656
- the `'builtin'` and `called` steps **recomputed** by C5, the
1657
- `'control'` steps **composed** by C5, and the `'absent'` and `'collected'`
1658
- steps **trusted**, those C9 did not settle, plus each claim whose call
1659
- fidelity remains unproved by C10.
1660
-
1661
- A proof is **valid** when no condition failed. A valid proof with obligations is valid *conditional on* them.
1662
-
1663
- ### 11.12 Scope of a valid proof
1664
-
1665
- A valid proof establishes that each of its claims follows from the program
1666
- by the recorded steps, given its obligations; a settled boundary is
1667
- established by its search certificate, and an unconditional verdict also
1668
- establishes operational query fidelity ([Section 11.13](#1113-operational-query-fidelity)). It does not establish
1669
- that the claims are all the conclusions of the program, that the program
1670
- derives no `'false'`, or that the program is the one intended: a proof MAY
1671
- leave conclusions out, and a run's own proof holds exactly its conclusions.
1672
-
1673
- ### 11.13 Operational query fidelity
1674
-
1675
- **Operational query fidelity** means that a claimed answer can be reported
1676
- for an original question under [Section 8](#8-evaluation-and-conclusions), retaining its original call-time
1677
- bindings, control choices and applicable forward state. Each claimed answer
1678
- must be reachable in that question's ordered search. This is distinct from
1679
- completeness: a proof may omit other reachable answers without falsifying
1680
- the answers it does give. Fidelity concerns the question's search; it does
1681
- not certify that execution of the whole program reaches that question,
1682
- avoids a prior contradiction, or terminates preceding questions.
1683
-
1684
- C1–C9 check the recorded instances and their evidence. They do not establish
1685
- operational query fidelity for binding-sensitive or order-sensitive goals.
1686
- In particular, a checker MUST NOT treat C7's instance test, or C5's
1687
- composition of a `once` step, as proof that the original open call selected
1688
- that instance. For example:
1846
+ ```js
1847
+ step(not(nonpacifist('ada')), 'absent', {}, [])
1848
+
1849
+ derived(nonpacifist(A), [nonpacifist('nixon')])
1850
+ searched(nonpacifist('ada'), [])
1851
+ ```
1852
+
1853
+ The table expands to no answers: the listed fact does not match Ada and no
1854
+ backward rule defines `nonpacifist/1`. The only forward rule for that
1855
+ relation derives Nixon's fact, which is listed and has a step elsewhere in
1856
+ the proof. Thus the listing is supported and closed, and the negation is
1857
+ settled. Replacing the listing with `[]` would fail closure.
1858
+
1859
+ For a backward-defined relation `p/1` whose ordered answers are `p('a')`
1860
+ and `p('b')`, a collection can instead have these entries:
1689
1861
 
1690
1862
  ```js
1691
- fact(p('a'), p('b'))
1692
- implied_by(q(X), once(p(X)))
1863
+ step(findall(A, p(A), ['a', 'b']), 'collected', {}, [])
1864
+
1865
+ searched(p(B), [p('a'), p('b')])
1693
1866
  ```
1694
1867
 
1695
- The question `q(X)` answers only `q('a')`. Nevertheless, a C1–C9 proof may
1696
- justify `q('b')` with `once(p('b'))` and `p('b')`, since the specialized
1697
- call `q('b')` succeeds. A final substitution does not show that the original
1698
- call was `once(p(X))` with `X` unbound, or that its first answer was `'a'`.
1699
- Tests of current variable state have the same distinction ([Section 7.5](#75-sets-and-operational-behavior)).
1700
-
1701
- A checker claiming the additional property MUST validate evidence of the
1702
- original call state, propagation of bindings between ordered premises,
1703
- freshening and scope, and any first-solution choice or required search
1704
- closure. A claimed call state or substitution is not authority: it must
1705
- follow from the original question, source clauses and checked evidence.
1706
- It MUST preserve generator captures independently of later caller bindings
1707
- and MUST NOT invoke the reasoner to fill gaps. C10 provides the certificate
1708
- check of [Section 11.14](#1114-c10-call-fidelity). A C1–C9 verdict alone MUST NOT be presented as
1709
- establishing it.
1710
-
1711
- ### 11.14 C10 Call fidelity
1712
-
1713
- Every proof check includes C10. A false original-call certificate or an
1714
- answer excluded by a complete certificate fails C10. Missing, incomplete or
1715
- unsupported evidence leaves an explicit
1716
- `obligation('call_fidelity', 'original_call', Claim)`. Such a claim MUST NOT
1717
- receive an unconditional `checked` verdict. When trusted obligations are
1718
- forbidden, each such obligation also fails C10.
1719
-
1720
- The **original questions** are the external goals, if any. Otherwise, when
1721
- the program has a forward head `'true'`, they are those rules' bodies as
1722
- conjunctions; otherwise they are its ordinary forward heads, excluding
1723
- `'false'`. The questions are not instantiated with a proof's final bindings.
1724
- Only questions of which a claim is an instance need a certificate. Empty
1725
- proofs certify no answers and do not establish that a question has none.
1726
- When the claims contain `'false'`, C10 is inapplicable: it covers no answers
1727
- and adds no call-fidelity obligations for that halted proof.
1728
-
1729
- For each such question a checker searches its answers by [Section 11.10](#1110-c9-search-closure)'s
1730
- one-level expansion and closure checks, with the following differences:
1868
+ The checker expands `p(B)` against its source definition to validate the
1869
+ table, then copies the template once per answer and compares the resulting
1870
+ `['a', 'b']` with the step's list.
1871
+
1872
+ **Failures and obligations.** The checker distinguishes a false certificate
1873
+ from evidence that cannot settle the boundary:
1874
+
1875
+ | Finding | Result |
1876
+ | --- | --- |
1877
+ | A table differs from its expansion; a listed fact lacks a step or has the wrong name or arity; a listing is not closed; tables are circular; the certificate's search raises an error; or the checked search finds a solution to a negated goal. | C9 fails. |
1878
+ | A needed table or listing is missing, evidence is incomplete, or a certificate limit above applies. | The boundary is not settled. |
1879
+ | A collection's list disagrees with the certificate's search results. | The boundary is not settled; C6 may refute it from available evidence. |
1880
+ | A listing contains a nonground fact. | At the first such fact in listing order, leave the boundary unsettled rather than fail it. |
1881
+
1882
+ An incorrect table or listing is reported once, for the first boundary
1883
+ resting on it. Any boundary C9 did not settle counts as trusted, including
1884
+ one that failed C9; this count does not cancel the failure. C6 confronts
1885
+ boundaries C9 neither settled nor refuted. An unresolved boundary remains
1886
+ an obligation, and strict checking rejects it.
1887
+
1888
+ A collection mismatch alone is left unsettled because a step shows the
1889
+ goal after the whole solution's substitution; later bindings may have
1890
+ specialized the goal that was actually searched. C10 checks collection
1891
+ against the original call and cannot use that final substitution to
1892
+ specialize the question.
1893
+
1894
+ ### 11.13 C10 Call fidelity
1895
+
1896
+ C10 checks that the original question can return each claimed answer. It
1897
+ uses `called(Call, Answers)` tables in the proof, distinct from C9's
1898
+ `searched/2` tables. Both checks share applicable `derived/2` listings.
1899
+ Every proof check includes C10; unresolved evidence leaves a call-fidelity
1900
+ obligation rather than an unconditional `checked` verdict.
1901
+
1902
+ **Selecting the original questions.** Use the external goals, if any.
1903
+ Otherwise, if any forward rule has a head `'true'`, use those rules' bodies
1904
+ as conjunctions. Otherwise use the ordinary forward heads, excluding
1905
+ `'false'`. Do not instantiate these questions with the proof's final
1906
+ bindings. Only questions of which a claim is an instance need a
1907
+ certificate.
1908
+
1909
+ When the claims contain `'false'`, C10 is inapplicable: it covers no
1910
+ answers and adds no call-fidelity obligations for that halted proof.
1911
+ Empty proofs certify no answers and do not establish that a question has
1912
+ none.
1913
+
1914
+ **Checking calls.** For each relevant original question, use the one-level
1915
+ expansion and closure checks of [Section 11.12](#1112-c9-search-closure),
1916
+ with these differences:
1731
1917
 
1732
1918
  1. Inner relation calls use `called/2` rather than `searched/2`. Call and
1733
1919
  answer comparison preserves anonymous-variable status ([Section 10.5](#105-call-fidelity-certificates)).
@@ -1738,7 +1924,7 @@ one-level expansion and closure checks, with the following differences:
1738
1924
  call. C9's treatment of an unbound named variable as anonymous MUST NOT
1739
1925
  be used. A source search that raises an error fails its certificate.
1740
1926
  3. `once` and `findall` keep their [Section 4.2](#42-controls) meanings, so the first answer
1741
- or collected answers come from the actual inner call. [Section 11.10](#1110-c9-search-closure)'s
1927
+ or collected answers come from the actual inner call. [Section 11.12](#1112-c9-search-closure)'s
1742
1928
  restriction on order-sensitive uses of derived listings still applies.
1743
1929
  The order of unrelated answers of an ordinary question need not be
1744
1930
  established to check membership of a claim.
@@ -1749,55 +1935,120 @@ one-level expansion and closure checks, with the following differences:
1749
1935
  positive fragment described below. A final listing alone MUST NOT certify
1750
1936
  binding-sensitive or order-sensitive forward firings outside that fragment.
1751
1937
 
1752
- For this check, a forward listing's **ground positive dependency closure**
1753
- contains its relation and each ordinary body relation of every source fact,
1754
- backward rule or forward rule defining any relation in that closure. All
1755
- source facts in the closure MUST be ground. Rule bodies MUST contain only
1756
- ordinary calls, `'true'`, conjunction and disjunction; templates, captures
1757
- and source inspection are excluded. A body call to an ordinary relation
1758
- grounds its variables. Conjunction accumulates the grounded variables of its
1759
- parts; disjunction grounds only those grounded by both alternatives. Every
1760
- backward head variable MUST be grounded by its body. Every forward head
1761
- variable MUST either be grounded by its body or be a head-only witness
1762
- checked by C8. Supported facts plus a closed listing then establish the
1763
- least ground positive closure. More general forward execution requires
1764
- publication evidence not supplied by this format, and leaves call fidelity
1765
- unproved.
1766
-
1767
- Every relevant call certificate MUST be valid. Each claim MUST be identical,
1768
- up to renaming, to an answer of at least one corresponding original question;
1769
- merely being an instance of a more general answer does not suffice. For
1770
- example, `q('b')` fails C10 for the question in [Section 11.13](#1113-operational-query-fidelity) even though
1771
- its ground logical derivation passes C1–C9. A proof of `p('a')` likewise
1772
- cannot replace an original call's actual universal answer `p(A)`.
1773
-
1774
- A claim fails C10 once when a corresponding question has a false
1775
- certificate or complete certificates for every matching question exclude its
1776
- answer. An unresolved alternative question leaves an obligation unless
1777
- another question certifies the answer. With no applicable complete
1778
- certificate, its call fidelity likewise remains an obligation. C10 does not discharge earlier C6/C9 obligations.
1779
-
1780
- The current format requires complete tables, including for a relation
1781
- called under `once`. A later error or recursion may prevent that table
1782
- from closing even when `once` itself terminates. C10 then cannot be
1783
- established; a search-prefix certificate is not defined here. A reasoner
1784
- MUST attempt call-fidelity certification for every proof it generates
1785
- ([Section 8.7](#87-proof-generation)); unresolved evidence remains an obligation. A reasoner MAY bound this auxiliary production; exceeding its
1786
- bound leaves call fidelity unproved, and it MUST NOT change the run's
1787
- answers. The bounds are not part of conformance, so two conforming reasoners
1788
- may differ in which claims of a generated proof carry call-fidelity
1789
- obligations. (eyemind bounds it per question by the smaller of
1938
+ For the `once` example in [Section 11.2](#112-operational-query-fidelity),
1939
+ the call certificate contains:
1940
+
1941
+ ```js
1942
+ called(q(A), [q('a')])
1943
+ called(p(B), [p('a'), p('b')])
1944
+ ```
1945
+
1946
+ The checker validates the first table by expanding the original question
1947
+ `q(X)` using the source rule. Its inner call is `p(X)` with `X` unbound.
1948
+ The second table, checked against `p`'s source definition, supplies `'a'`
1949
+ first, and `once` selects it. Thus `q('a')` is an answer and `q('b')` is
1950
+ excluded. Substituting `called(p('b'), [p('b')])` cannot establish the
1951
+ different call `p(X)`.
1952
+
1953
+ **Supported forward listings.** A forward listing's **ground positive
1954
+ dependency closure** contains its relation and each ordinary body relation
1955
+ of every source fact, backward rule or forward rule defining any relation
1956
+ in that closure. To use a listing for C10:
1957
+
1958
+ - All source facts in the closure MUST be ground.
1959
+ - Rule bodies MUST contain only ordinary calls, `'true'`, conjunction and
1960
+ disjunction. Templates, captures and source inspection are excluded.
1961
+ - A body call to an ordinary relation grounds its variables. Conjunction
1962
+ accumulates the grounded variables of its parts; disjunction grounds only
1963
+ those grounded by both alternatives.
1964
+ - Every backward head variable MUST be grounded by its body.
1965
+ - Every forward head variable MUST either be grounded by its body or be a
1966
+ head-only witness checked by C8.
1967
+
1968
+ Supported facts and closed listings then establish the least ground
1969
+ positive closure. More general forward execution requires publication
1970
+ evidence this format does not supply, leaving call fidelity unproved.
1971
+
1972
+ **Deciding claims.** Every relevant call certificate MUST be valid. Each
1973
+ claim MUST be identical, up to variable renaming, to an answer of at least
1974
+ one corresponding original question. Being an instance of a more general
1975
+ answer is insufficient: a claim `p('a')` cannot replace an original call's
1976
+ actual universal answer `p(A)`.
1977
+
1978
+ For each claim, apply these outcomes:
1979
+
1980
+ | Evidence for matching original questions | C10 result |
1981
+ | --- | --- |
1982
+ | Any corresponding question has a false certificate. | Fail the claim once. |
1983
+ | No corresponding certificate is false, and at least one complete certificate returns the claim up to renaming. | Establish call fidelity for the claim. |
1984
+ | Every matching question has a complete certificate, and all exclude the claim. | Fail the claim once. |
1985
+ | No certificate establishes the claim, and an applicable certificate is missing, incomplete or unsupported. | Leave `obligation('call_fidelity', 'original_call', Claim)`. |
1986
+
1987
+ An unresolved alternative question leaves an obligation unless another
1988
+ question certifies the answer. With no applicable complete certificate,
1989
+ call fidelity also remains an obligation. When trusted obligations are
1990
+ forbidden, each such obligation fails C10. C10 does not discharge C6/C9
1991
+ obligations: both the recorded boundary and the original call need their
1992
+ respective evidence.
1993
+
1994
+ **Limits and production of certificates.** The current format requires
1995
+ complete tables, even for a relation called under `once`. Later recursion
1996
+ or an error may prevent a table from closing although `once` itself
1997
+ terminates. A certificate for just the searched prefix is not defined, so
1998
+ call fidelity then remains unproved.
1999
+
2000
+ A reasoner MUST attempt call-fidelity certification for every proof it
2001
+ generates ([Section 8.7](#87-proof-generation)). It MAY bound this auxiliary
2002
+ production. Exceeding that bound leaves an obligation and MUST NOT change
2003
+ the run's answers. The bounds are outside conformance, so conforming
2004
+ reasoners may differ in which generated claims carry call-fidelity
2005
+ obligations. eyemind bounds this work per question by the smaller of
1790
2006
  `max_inferences` and 50,000 calls plus answers, and by 8,388,608 UTF-16 code
1791
- units of answer text.)
2007
+ units of answer text.
2008
+
2009
+ **Relevance and counts.** Call tables and their supporting listings serve
2010
+ the claims for C7; their listed facts are reachable through that evidence.
2011
+ C10 does not change C1–C9 covered counts. Its own covered count includes
2012
+ claims whose call fidelity is established or refuted, excluding unresolved
2013
+ claims. Report failures in claim order, after checking boundaries and
2014
+ before C7 and C2 ([Section 12](#12-check-reports)).
2015
+
2016
+ These checks establish membership of claimed answers in an original
2017
+ question's results. They do not establish that all answers were claimed
2018
+ or that preceding distinct questions terminated.
2019
+
2020
+ ### 11.14 Counts and validity
2021
+
2022
+ The report distinguishes how many items a condition covered from how many
2023
+ failures it found. A zero failure count does not by itself establish a
2024
+ negation, collection or original call that remains an obligation.
2025
+
2026
+ | Condition | Covered |
2027
+ | --- | --- |
2028
+ | C1 resolution | `clause` and `source` steps that passed C1 |
2029
+ | C2 well_founded | steps |
2030
+ | C3 justification | steps |
2031
+ | C4 coverage | claims plus uses |
2032
+ | C5 re_decision | `'builtin'`, `called(Called)` and `'control'` steps that passed C5 |
2033
+ | C6 boundary_consistency | boundaries not settled that the evidence decided |
2034
+ | C7 relevance | claims plus steps |
2035
+ | C8 witness_integrity | `clause` steps with witnesses in their forward head or enclosing generators that passed C8 |
2036
+ | C9 search_closure | boundaries their search certificate settled or refuted |
2037
+ | C10 call_fidelity | claims whose call fidelity is established or refuted |
2038
+
2039
+ A check also records these totals:
2040
+
2041
+ - **steps**: the steps it read;
2042
+ - **claims**: the claims it read;
2043
+ - **verified**: the `clause` and `source` inspection steps verified by C1;
2044
+ - **recomputed**: the `'builtin'` and `called(Called)` steps that passed C5;
2045
+ - **composed**: the `'control'` steps that passed C5;
2046
+ - **trusted**: the `'absent'` and `'collected'` steps C9 did not settle,
2047
+ plus each claim whose call fidelity remains unproved by C10.
1792
2048
 
1793
- Call tables and their supporting listings consulted for C10 serve the claims
1794
- for C7, and their listed facts are reachable through that evidence. C10's
1795
- auxiliary search does not change C1–C9 covered counts. Its own covered count
1796
- counts claims whose call fidelity is established or refuted, excluding
1797
- unresolved claims. Failures are reported in
1798
- claim order after checking boundaries and before C7 and C2 ([Section 12](#12-check-reports)).
1799
- The answer checks are per original question; they do not establish that all
1800
- answers were claimed or that preceding distinct questions terminated.
2049
+ A proof is **valid** when no condition failed. It is valid *conditional on*
2050
+ any obligations that remain. Section [12](#12-check-reports) specifies the
2051
+ report format and verdict; strict checking forbids those obligations.
1801
2052
 
1802
2053
  ## 12. Check Reports
1803
2054
 
@@ -1814,7 +2065,7 @@ the following report facts, one per line:
1814
2065
  `obligation('call_fidelity', 'original_call', Claim)` per unresolved claim,
1815
2066
  in claim order;
1816
2067
  4. `steps(N)`, `verified(N)`, `recomputed(N)`, `composed(N)`, `trusted(N)`,
1817
- `claims(N)`, the counts of [Section 11.11](#1111-counts-and-validity);
2068
+ `claims(N)`, the counts of [Section 11.14](#1114-counts-and-validity);
1818
2069
  5. `verdict(V)`, where `V` is `failed(N)` when `N` failures were recorded,
1819
2070
  otherwise `'checked_with_obligations'` when there are obligations,
1820
2071
  otherwise `'checked'`.
@@ -1829,7 +2080,7 @@ and that the verdict does not establish completeness. Comments are informative
1829
2080
  and MAY be worded differently. They are ignored when the document is read.
1830
2081
 
1831
2082
  Failures are listed in the order they are found: those of reading the
1832
- document ([Section 11.1](#111-reading-the-document)), in document order; C4 for each claim, in claim
2083
+ document ([Section 11.3](#113-reading-the-document)), in document order; C4 for each claim, in claim
1833
2084
  order; then for each step, in document order, C4 for its uses and the C1, C3,
1834
2085
  C5 or C8 failure of its justification; for each boundary, in step order, the
1835
2086
  C9 failures of its search certificate in the order found, or else its C6
@@ -1936,7 +2187,7 @@ are required as specified. Comment wording and failure `Detail` text are
1936
2187
  informative. Fresh variable names are unspecified where [Section 2.4](#24-standard-order) says
1937
2188
  so. Float results of `exp`, logarithms, trigonometric and hyperbolic
1938
2189
  functions, and `pow` with floats MAY differ by one unit in the last place,
1939
- and C5 accepts a result of such a function within 4 units ([Section 11.6](#116-c5-re-decision)).
2190
+ and C5 accepts a result of such a function within 4 units ([Section 11.8](#118-c5-re-decision)).
1940
2191
 
1941
2192
  The conformance cases and saved example documents exercise these
1942
2193
  requirements. They do not replace the definitions in this specification.
@@ -2010,7 +2261,7 @@ bound their size, nesting depth, processing time and memory, in addition to
2010
2261
  the reasoning bounds of [Section 8.3](#83-resource-bounds). A regular expression can take time exponential in
2011
2262
  the length of the text it searches ([Section 4.3](#43-primitives)), and no reasoning bound counts
2012
2263
  that time, so a deployment running untrusted programs SHOULD also bound it. A valid proof establishes only the
2013
- claims and assumptions described in [Section 11.12](#1112-scope-of-a-valid-proof).
2264
+ claims and assumptions described in [Section 11.1](#111-scope-of-a-valid-proof).
2014
2265
 
2015
2266
  ## Appendix A. Document Grammar
2016
2267