eyemind 0.5.21 → 0.5.22

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 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 135 runnable programs, each with a card deck and saved conclusions, proofs and check reports. The conformance suite has 1376 cases that test any implementation of the specification through its command line; run it [in your browser](https://eyereasoner.github.io/eyemind/playground/conformance).
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 135 runnable programs, each with a card deck and saved conclusions, proofs and check reports. The conformance suite has 1381 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
 
@@ -44,7 +44,7 @@ Prolog, Datalog, N3 and SRL already exist, and eyemind adds no new logic: rules
44
44
  - eyemind proofs include the hard parts:
45
45
  - "nothing matched" (negation and collections), backed by a search certificate whose listings must be closed (C9);
46
46
  - what a rule says exists, as the Skolem term of that rule firing (C8);
47
- - whether each answer really answers the question asked (C10).
47
+ - whether each answer really answers the question asked, and whether every answer of the question is there (C10).
48
48
  - A forged proof must never pass the check, so a result is something you can hand to someone who does not trust your engine.
49
49
  2. **Programs are plain JavaScript.**
50
50
  - There is no syntax to learn, no parser to install and no dependency.
@@ -436,7 +436,7 @@ Checking applies ten conditions:
436
436
  | **C7** | relevance | Every claim answers the question, and every step serves a claim |
437
437
  | **C8** | witness integrity | Every "something exists" uses the Skolem term of its own firing |
438
438
  | **C9** | search closure | Every absence and collection the search certificate settles holds |
439
- | **C10** | call fidelity | Each answer is an actual answer of the original question |
439
+ | **C10** | call fidelity | Each answer is an actual answer of the original question, and every answer of each question is claimed |
440
440
 
441
441
  **The checker follows the certificate:** it never calls the reasoner, so a missing step fails rather than being quietly re-derived. **The source is the authority:** clauses a proof displays cannot override the program. Proofs are read as data, so checking someone else's proof runs none of their code, and every proof eyemind generates is checked before it is returned. The report is a document too:
442
442
 
@@ -456,7 +456,7 @@ condition('C6', 'boundary_consistency', 'ok', 0)
456
456
  condition('C7', 'relevance', 'ok', 5)
457
457
  condition('C8', 'witness_integrity', 'ok', 0)
458
458
  condition('C9', 'search_closure', 'ok', 0)
459
- condition('C10', 'call_fidelity', 'ok', 2)
459
+ condition('C10', 'call_fidelity', 'ok', 3)
460
460
 
461
461
  // Proof statistics: recorded steps and how they were checked.
462
462
  steps(3)
@@ -466,11 +466,11 @@ composed(0)
466
466
  trusted(0)
467
467
  claims(2)
468
468
 
469
- // This verdict applies to the claims above; it does not establish completeness.
469
+ // This verdict also establishes that the claims above are every answer of the original questions.
470
470
  verdict('checked')
471
471
  ```
472
472
 
473
- A failed check gives `failure(Condition, Conclusion, Detail)` facts, `verdict(failed(N))` and exit code 2. What a certificate cannot settle stays an `obligation(...)` with the verdict `checked_with_obligations`; `--strict-proof` rejects those. To check answers to `--goal` questions, pass the same goals when checking. [SPEC §11](https://eyereasoner.github.io/eyemind/SPEC#11-proof-checking) defines every condition.
473
+ A `checked` verdict thus establishes two things: every claim follows from the program, and the claims are every answer of the original questions. The `called/2` table of each question lists all its answers and is checked against the program, so a proof that omits one fails C10, and a question with no claims is shown to have no answers. A failed check gives `failure(Condition, Conclusion, Detail)` facts, `verdict(failed(N))` and exit code 2. What a certificate cannot settle stays an `obligation(...)` with the verdict `checked_with_obligations`, among them `obligation('call_fidelity', 'all_answers', Question)` for a question whose answers it cannot show complete; `--strict-proof` rejects those. To check answers to `--goal` questions, pass the same goals when checking. [SPEC §11](https://eyereasoner.github.io/eyemind/SPEC#11-proof-checking) defines every condition.
474
474
 
475
475
  ### Why negation and collection are safe
476
476
 
@@ -480,7 +480,7 @@ A negation `not(G)` concludes from what is *absent* and a collection `findall(T,
480
480
  - **Negate only what is bound.** The variables of `not(G)` must be bound when it runs; write `not(q(X, _))` for "no value at all".
481
481
  - **Check the search, not just its result.** A proof ends with a search certificate: `searched(Call, Answers)` lists each call's answers and `derived(Pattern, Facts)` each consulted relation. The checker expands each call one level against the program, so a wrong table shows up as a disagreement.
482
482
  - **Say what was taken on trust.** Anything the certificate cannot settle becomes an obligation, and evidence in the proof can still refute it (C6).
483
- - **Certify relational negation.** Supported, closed listings can establish the original calls of ground relational rules with bound negations, including inside conjunctions and disjunctions. A proof within this fragment can be `checked` with no obligation, even under `--strict-proof`. Collections of derived facts, whose order a listing cannot show, and dependencies on `restricted` rules with new witnesses keep an obligation.
483
+ - **Certify the original questions.** Supported, closed listings establish the original calls, and that the claims are all their answers, when no rule they depend on can observe bindings or evaluation order. A mode analysis checks this: primitives such as arithmetic run with their inputs bound, negations with their variables bound, and `once` and `findall` bind nothing other goals use. A proof within this fragment can be `checked` with no obligation, even under `--strict-proof`. Tests of whether a variable is bound, collections of derived facts, whose order a listing cannot show, templates and `restricted` rules with new witnesses keep an obligation.
484
484
 
485
485
  ## Checking the translation
486
486
 
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.21
5
+ Version: eyemind 0.5.22
6
6
  ```
7
7
 
8
8
  This document specifies the syntax and meaning of eyemind programs and data
@@ -216,12 +216,16 @@ Proofs:
216
216
  certificate and checked by C10 ([Section 10.5](#105-call-fidelity-certificates)).
217
217
  - **Original question**: each external goal; without external goals, the
218
218
  body of each query; without queries, each ordinary forward head. C10
219
- checks the claims answering them ([Section 11.13](#1113-c10-call-fidelity)).
219
+ checks that the claims are exactly their answers ([Section 11.13](#1113-c10-call-fidelity)).
220
+ - **Answer completeness**: of a proof, that its claims include every answer
221
+ of every original question; an unconditional `checked` verdict
222
+ establishes it ([Section 11.1](#111-scope-of-a-valid-proof)).
220
223
  - **Settled**: established by its search certificate, as a boundary is when
221
224
  C9 accepts that certificate ([Section 11.12](#1112-c9-search-closure)).
222
225
  - **Trusted boundary**: a boundary that is not settled. A valid proof
223
226
  assumes it, and its check report lists it as an **obligation**, as it
224
- lists each claim whose call fidelity remains unproved (Sections [11.9](#119-c6-boundary-consistency),
227
+ lists each claim whose call fidelity and each question whose answer
228
+ completeness remains unproved (Sections [11.9](#119-c6-boundary-consistency),
225
229
  [11.13](#1113-c10-call-fidelity) and [12](#12-check-reports)).
226
230
  - **Check report**: what a checker writes: the claims, the outcome of each
227
231
  of C1–C10, failures, obligations, counts and a verdict ([Section 12](#12-check-reports)).
@@ -1090,8 +1094,10 @@ infinite closure. A finite model does not ensure search termination:
1090
1094
  `implied_by(p(X), p(X))` has an empty least model, but searching `p('a')`
1091
1095
  recurs indefinitely. Exceeding a resource bound raises an error ([Section
1092
1096
  8.3](#83-resource-bounds)). Contradictions halt without completing the closure ([Section 8.5](#85-contradictions)).
1093
- A valid proof establishes only its claims subject to its trusted boundaries
1094
- ([Section 11.1](#111-scope-of-a-valid-proof)), not completeness of the model or the answers. Its search
1097
+ A valid proof establishes its claims subject to its obligations and, when
1098
+ it checks without obligations, that they are every answer of the original
1099
+ questions ([Section 11.1](#111-scope-of-a-valid-proof)); it does not
1100
+ establish termination of the whole program. Its search
1095
1101
  certificate settles the negations and collections it can ([Section 10.4](#104-search-certificates)).
1096
1102
 
1097
1103
  ## 8. Evaluation and Conclusions
@@ -1288,8 +1294,8 @@ would extend: the run stopped before its fixpoint, so its derived facts need
1288
1294
  not be closed under the rules. A
1289
1295
  reasoner MUST check every proof it generates ([Section 11](#11-proof-checking)) before returning it,
1290
1296
  and MUST fail with an error rather than return a proof that does not pass. A
1291
- run without conclusions has a proof without claims, which is valid and
1292
- certifies nothing.
1297
+ run without conclusions has a proof without claims; its call tables, when
1298
+ they settle, certify that the original questions have no answers.
1293
1299
 
1294
1300
  A **state test** is `is_var/1`, `not_identical/2` or `compare/3`: a test a
1295
1301
  later binding can make false. A goal such as `is_var(X)` followed by
@@ -1620,7 +1626,7 @@ The ten conditions answer different questions:
1620
1626
  | [C7 Relevance](#1110-c7-relevance) | Does the evidence serve the claimed answers to the program's questions? |
1621
1627
  | [C8 Witness integrity](#1111-c8-witness-integrity) | Does each existential witness identify the correct rule firing? |
1622
1628
  | [C9 Search closure](#1112-c9-search-closure) | Does the certificate establish the recorded negation or collection? |
1623
- | [C10 Call fidelity](#1113-c10-call-fidelity) | Can the original question return this answer? |
1629
+ | [C10 Call fidelity](#1113-c10-call-fidelity) | Can the original question return this answer, and is each of its answers claimed? |
1624
1630
 
1625
1631
  C9 checks the search behind a recorded step; C10 checks the original call
1626
1632
  before the proof's final bindings. This distinction matters for negation,
@@ -1639,9 +1645,10 @@ can instead leave an obligation. The verdict distinguishes these outcomes:
1639
1645
  | `checked_with_obligations` | No condition failed, but the claims depend on the reported obligations. |
1640
1646
  | `failed(N)` | The checker recorded `N` failures. |
1641
1647
 
1642
- Strict checking forbids unresolved obligations. Even `checked` establishes
1643
- only the claimed answers, not that the proof contains every answer or that
1644
- the whole program terminates ([Section 11.1](#111-scope-of-a-valid-proof)).
1648
+ Strict checking forbids unresolved obligations. A `checked` verdict
1649
+ establishes the claimed answers and that they are every answer of the
1650
+ original questions, but not that the whole program terminates
1651
+ ([Section 11.1](#111-scope-of-a-valid-proof)).
1645
1652
 
1646
1653
  ### 11.1 Scope of a valid proof
1647
1654
 
@@ -1649,7 +1656,10 @@ A valid proof establishes that each claim follows from the source program
1649
1656
  by the recorded steps, conditional on any reported obligations. A settled
1650
1657
  boundary is established by its search certificate. An unconditional
1651
1658
  `checked` verdict also establishes operational query fidelity
1652
- ([Section 11.2](#112-operational-query-fidelity)).
1659
+ ([Section 11.2](#112-operational-query-fidelity)) and **answer
1660
+ completeness**: the claims include every answer of every original question
1661
+ ([Section 11.13](#1113-c10-call-fidelity)). Every question asked has a
1662
+ certified answer set, and every answer in it is claimed.
1653
1663
 
1654
1664
  For a program with negation, "follows" is relative to the facts the
1655
1665
  certificate lists: C9 establishes that they are supported by steps, closed
@@ -1663,14 +1673,16 @@ rejects it. Independent claims may still check strictly.
1663
1673
 
1664
1674
  It does not establish:
1665
1675
 
1666
- - that the proof contains all conclusions of the program;
1676
+ - answer completeness for a halted proof, whose claims contain `'false'`;
1667
1677
  - that the program derives no `'false'`;
1668
1678
  - that execution of the whole program terminates or reaches every question;
1669
1679
  - that the supplied program expresses the author's intended model.
1670
1680
 
1671
- A proof MAY omit conclusions. A run's own proof contains exactly that
1672
- run's conclusions. An empty proof establishes no answers, including no
1673
- claim that a question has no answers.
1681
+ A run's own proof contains exactly that run's conclusions. A proof that
1682
+ omits an answer its certificate establishes fails C10. One without the
1683
+ certificate to show its answers complete is valid only conditionally: an
1684
+ empty proof establishes no answers and leaves each original question whose
1685
+ answers need a call table as an obligation.
1674
1686
 
1675
1687
  ### 11.2 Operational query fidelity
1676
1688
 
@@ -1722,8 +1734,9 @@ MUST NOT invoke the reasoner to fill gaps.
1722
1734
 
1723
1735
  C10 supplies this certificate check in [Section 11.13](#1113-c10-call-fidelity).
1724
1736
  A C1–C9 verdict alone MUST NOT be presented as establishing operational
1725
- query fidelity. Fidelity does not establish completeness, avoidance of an
1726
- earlier contradiction, or termination of preceding questions.
1737
+ query fidelity. Fidelity alone does not establish answer completeness,
1738
+ which C10 checks separately, avoidance of an earlier contradiction, or
1739
+ termination of preceding questions.
1727
1740
 
1728
1741
  ### 11.3 Reading the document
1729
1742
 
@@ -1815,8 +1828,9 @@ C4 checks that the proof has no missing premises:
1815
1828
  as premises, but claims still require steps.
1816
1829
 
1817
1830
  For a missing use, the failure's conclusion is the goal of the step that
1818
- uses it. A document without claims certifies nothing; it is valid if no
1819
- condition fails.
1831
+ uses it. A document without claims establishes no answers; it is valid if
1832
+ no condition fails, and C10 decides whether it shows that the original
1833
+ questions have none.
1820
1834
 
1821
1835
  ### 11.8 C5 Re-decision
1822
1836
 
@@ -2127,13 +2141,13 @@ obligation rather than an unconditional `checked` verdict.
2127
2141
  Otherwise, if any forward rule has a head `'true'`, use those rules' bodies
2128
2142
  as conjunctions. Otherwise use the ordinary forward heads, excluding
2129
2143
  `'false'`. Do not instantiate these questions with the proof's final
2130
- bindings. Only questions of which a claim is an instance need a
2131
- certificate.
2144
+ bindings. Every question needs a certificate, including one of which no
2145
+ claim is an instance: its answers must still be shown to be claimed.
2132
2146
 
2133
2147
  When the claims contain `'false'`, C10 is inapplicable: it covers no
2134
2148
  answers and adds no call-fidelity obligations for that halted proof.
2135
- Empty proofs certify no answers and do not establish that a question has
2136
- none.
2149
+ A proof without claims certifies that a question has no answers only
2150
+ through that question's certificate.
2137
2151
 
2138
2152
  **Checking calls.** For each relevant original question, use the one-level
2139
2153
  expansion and closure checks of [Section 11.12](#1112-c9-search-closure),
@@ -2174,36 +2188,79 @@ first, and `once` selects it. Thus `q('a')` is an answer and `q('b')` is
2174
2188
  excluded. Substituting `called(p('b'), [p('b')])` cannot establish the
2175
2189
  different call `p(X)`.
2176
2190
 
2177
- **Supported forward listings.** A forward listing's **ground dependency
2178
- closure** contains its relation and each ordinary body relation, inside a
2179
- negation or not, of every source fact, backward rule or forward rule
2180
- defining any relation in that closure. To use a listing for C10:
2181
-
2182
- - All source facts in the closure MUST be ground.
2183
- - Rule bodies MUST contain only ordinary calls, `'true'`, conjunction,
2184
- disjunction and negations of these. Templates, captures and source
2185
- inspection are excluded.
2191
+ **Supported forward listings.** A listing supports C10 when a search of
2192
+ each rule body it depends on, in source order, finds exactly the ground
2193
+ instances of that body that hold. Its steps, whose primitives C5 re-decides
2194
+ on their ground instances, then show firings that a search makes. This holds
2195
+ when no goal can observe the bindings or the order in which it runs. The
2196
+ checker establishes it by a **mode analysis** of the rules the listing
2197
+ depends on. A **mode** of a call gives, for each argument, whether it is
2198
+ ground when the call runs: an argument is ground when every variable in it
2199
+ is **grounded** at that point.
2200
+
2201
+ The analysis starts from the listed relation and its forward rules, and
2202
+ follows each ordinary body call, inside a negation or not, to the called
2203
+ relation in the mode of that call: its forward rules once, and its backward
2204
+ rules once in each mode. A forward rule's body starts with no grounded
2205
+ variable. A backward rule's body starts with the variables of the head
2206
+ arguments that are ground in the mode. Body goals are taken in order, each
2207
+ with the variables grounded before it:
2208
+
2209
+ - `'true'` grounds nothing. Conjunction accumulates the grounded variables
2210
+ of its parts. Disjunction grounds only those grounded by both
2211
+ alternatives. `call(G)` is `G`.
2212
+ - A call to an ordinary relation grounds its variables when every source
2213
+ fact of the relation is ground once the arguments ground in the mode are
2214
+ unified with it, and the relation is not **loose** in that mode;
2215
+ otherwise it grounds nothing.
2186
2216
  - A negation grounds nothing. Each of its variables other than anonymous
2187
- ones MUST be grounded by the body goals before it, and it MUST NOT contain
2188
- a negation.
2189
- - A body call to an ordinary relation grounds its variables. Conjunction
2190
- accumulates the grounded variables of its parts; disjunction grounds only
2191
- those grounded by both alternatives.
2192
- - Every backward head variable MUST be grounded by its body.
2193
- - Every forward head variable MUST either be grounded by its body or be a
2194
- head-only witness checked by C8.
2195
- - A restricted rule's guard is a negation, so a closure with a restricted
2196
- rule that has head-only variables is not supported: which firings a
2197
- restricted rule makes can depend on the order of rule applications.
2217
+ ones MUST be grounded before it, and it MUST NOT contain a negation.
2218
+ - `once(G)` grounds nothing. `G` MUST satisfy these conditions. Each named
2219
+ variable of `G` that occurs elsewhere in the clause MUST be grounded before
2220
+ it, so the choice of a first answer binds nothing another goal uses.
2221
+ - `findall(T, G, L)` follows the same rule for `T` and `G`. It grounds the
2222
+ variables of `L` when `G` grounds every variable of `T`.
2223
+ - A primitive whose variables are all grounded before it is a test, and
2224
+ grounds nothing. `unify/2` with one side ground grounds the other, and
2225
+ with neither ground grounds nothing. Otherwise the primitive MUST be
2226
+ called in one of the modes below, its input arguments ground, and it
2227
+ grounds its variables.
2228
+ - Source inspection, templates, captures and restricted rules are not
2229
+ supported. A restricted rule's guard is a negation, but which firings the
2230
+ rule makes can depend on the order of rule applications.
2231
+
2232
+ After its body, every head variable of a forward rule MUST be grounded or
2233
+ be a head-only witness checked by C8. If a head variable of a backward rule
2234
+ is not grounded, the relation is loose in that mode, and the analysis
2235
+ starts again with that call grounding nothing.
2236
+
2237
+ | Primitive | Inputs → outputs |
2238
+ | --- | --- |
2239
+ | `is/2` | expression → result |
2240
+ | `compare/3` | both compared terms → order |
2241
+ | `atom_chars/2`, `atom_codes/2` | atom → list, or list → atom |
2242
+ | `number_chars/2` | list → number |
2243
+ | `atom_length/2`, `atom_lower/2`, `atom_upper/2`, `term_text/2` | first → second |
2244
+ | `atom_concat/3` | both parts → whole, or whole → both parts |
2245
+ | `regex_find/3`, `digest/3` | first two → third |
2246
+ | `float64/4` | first three → fourth |
2247
+
2248
+ In each listed mode, a call with ground inputs has exactly the solutions
2249
+ whose ground instances C5 re-decides as holding. `number_chars/2` re-decides
2250
+ a ground instance by reading its characters, so only that direction is
2251
+ listed. A host-math result accepted by C5 only within its tolerance
2252
+ ([Section 11.8](#118-c5-re-decision)) need not be the result a search
2253
+ finds. A proof with such a step therefore supports no listing for C10.
2198
2254
 
2199
2255
  Supported facts and closed listings then establish the least ground
2200
- positive closure and, with negations, a set of facts that is supported,
2201
- closed under the rules and consistent with each negation, every negation
2202
- being decided by the listed facts alone. A stratified or chain-stratified
2203
- program has exactly one such set ([Section 7.4](#74-negation-and-collection)), its result, so the
2204
- listings are the facts the original calls consult. More general forward
2205
- execution requires publication evidence this format does not supply,
2206
- leaving call fidelity unproved.
2256
+ closure and, with negations, a set of facts that is supported, closed under
2257
+ the rules and consistent with each negation, every negation being decided
2258
+ by the listed facts alone. A stratified or chain-stratified program has
2259
+ exactly one such set ([Section 7.4](#74-negation-and-collection)), its
2260
+ result, so the listings are the facts the original calls consult. A rule
2261
+ outside the analysis, for example one that tests whether a variable is
2262
+ bound or keeps the first of several answers it uses, requires publication
2263
+ evidence this format does not supply, leaving call fidelity unproved.
2207
2264
 
2208
2265
  **Deciding claims.** Every relevant call certificate MUST be valid. Each
2209
2266
  claim MUST be identical, up to variable renaming, to an answer of at least
@@ -2227,6 +2284,30 @@ forbidden, each such obligation fails C10. C10 does not discharge C6/C9
2227
2284
  obligations: both the recorded boundary and the original call need their
2228
2285
  respective evidence.
2229
2286
 
2287
+ **Answer completeness.** A valid certificate for an original question
2288
+ gives all of its answers, so C10 also checks the converse: each answer is
2289
+ claimed. The **required answers** of a question are its certificate's
2290
+ answers when the conclusions answer goals or `query()` rules. When the
2291
+ conclusions are the derived facts ([Section 8.6](#86-reported-conclusions)),
2292
+ they are the facts of the question's relation in its consulted listing
2293
+ that are instances of the question, since a source fact or a backward
2294
+ answer is no derived fact. For each original question, in question order:
2295
+
2296
+ | Evidence for the question | C10 result |
2297
+ | --- | --- |
2298
+ | Its certificate is false. | Fail the question once, unless a claim that is an instance of it already failed for that certificate. |
2299
+ | Its certificate is valid and complete, and every required answer is identical, up to renaming, to a claim. | Establish answer completeness for the question. |
2300
+ | Its certificate is valid and complete, and a required answer is not claimed. | Fail once for each required answer not claimed. |
2301
+ | Its certificate is missing, incomplete or unsupported. | Leave `obligation('call_fidelity', 'all_answers', Question)`. |
2302
+
2303
+ For example, with `fact(p('a'), p('b'))` and `query(p(X))`, a proof that
2304
+ claims only `p('a')` fails C10 for `p('b')`, though `p('a')` follows. With
2305
+ `implied_by(r(X), p(X))` and `query(r('c'))`, the proof without claims
2306
+ holding `called(r('c'), [])` establishes that the question has no answers;
2307
+ an empty document leaves `r('c')` as an obligation. A question answered
2308
+ from source facts alone needs no table, so its required answers come from
2309
+ the facts.
2310
+
2230
2311
  **Limits and production of certificates.** The current format requires
2231
2312
  complete tables, even for a relation called under `once`. Later recursion
2232
2313
  or an error may prevent a table from closing although `once` itself
@@ -2245,13 +2326,14 @@ units of answer text.
2245
2326
  **Relevance and counts.** Call tables and their supporting listings serve
2246
2327
  the claims for C7; their listed facts are reachable through that evidence.
2247
2328
  C10 does not change C1–C9 covered counts. Its own covered count includes
2248
- claims whose call fidelity is established or refuted, excluding unresolved
2249
- claims. Report failures in claim order, after checking boundaries and
2250
- before C7 and C2 ([Section 12](#12-check-reports)).
2329
+ claims whose call fidelity is established or refuted and questions whose
2330
+ answer completeness is established or refuted, excluding unresolved ones.
2331
+ Report failures in claim order, then in question order, after checking
2332
+ boundaries and before C7 and C2 ([Section 12](#12-check-reports)).
2251
2333
 
2252
- These checks establish membership of claimed answers in an original
2253
- question's results. They do not establish that all answers were claimed
2254
- or that preceding distinct questions terminated.
2334
+ These checks establish that the claims are exactly the answers of the
2335
+ original questions, up to renaming. They do not establish that preceding
2336
+ distinct questions terminated.
2255
2337
 
2256
2338
  ### 11.14 Counts and validity
2257
2339
 
@@ -2270,7 +2352,7 @@ negation, collection or original call that remains an obligation.
2270
2352
  | C7 relevance | claims plus steps |
2271
2353
  | C8 witness_integrity | `clause` steps with witnesses in their forward head or enclosing generators that passed C8 |
2272
2354
  | C9 search_closure | boundaries their search certificate settled or refuted |
2273
- | C10 call_fidelity | claims whose call fidelity is established or refuted |
2355
+ | C10 call_fidelity | claims whose call fidelity, and questions whose answer completeness, is established or refuted |
2274
2356
 
2275
2357
  A check also records these totals:
2276
2358
 
@@ -2280,7 +2362,8 @@ A check also records these totals:
2280
2362
  - **recomputed**: the `'builtin'` and `called(Called)` steps that passed C5;
2281
2363
  - **composed**: the `'control'` steps that passed C5;
2282
2364
  - **trusted**: the `'absent'` and `'collected'` steps C9 did not settle,
2283
- plus each claim whose call fidelity remains unproved by C10.
2365
+ plus each claim whose call fidelity and each question whose answer
2366
+ completeness remains unproved by C10.
2284
2367
 
2285
2368
  A proof is **valid** when no condition failed. It is valid *conditional on*
2286
2369
  any obligations that remain. Section [12](#12-check-reports) specifies the
@@ -2299,7 +2382,8 @@ the following report facts, one per line:
2299
2382
  3. `obligation(Kind, 'theory_scoped', Goal)` per trusted boundary, in step
2300
2383
  order, where `Kind` is `'absent'` or `'collected'`, followed by
2301
2384
  `obligation('call_fidelity', 'original_call', Claim)` per unresolved claim,
2302
- in claim order;
2385
+ in claim order, then `obligation('call_fidelity', 'all_answers', Question)`
2386
+ per question whose answer completeness is unresolved, in question order;
2303
2387
  4. `steps(N)`, `verified(N)`, `recomputed(N)`, `composed(N)`, `trusted(N)`,
2304
2388
  `claims(N)`, the counts of [Section 11.14](#1114-counts-and-validity);
2305
2389
  5. `verdict(V)`, where `V` is `failed(N)` when `N` failures were recorded,
@@ -2310,9 +2394,11 @@ Comments MUST identify these initial terms as checked answers only when the
2310
2394
  report is valid with no obligations. A valid report with obligations MUST
2311
2395
  label them as conditional on those obligations. A failed report MUST label
2312
2396
  them as unverified claims; their inclusion does not validate them. A valid
2313
- report with no claims MUST say it establishes no conclusions. Comments also
2314
- explain the C1-C10 order, failures and obligations when present, the statistics,
2315
- and that the verdict does not establish completeness. Comments are informative
2397
+ report with no claims MUST say it establishes no conclusions, unless it is
2398
+ valid with no obligations: it then establishes that the original questions
2399
+ have no answers. Comments also explain the C1-C10 order, failures and
2400
+ obligations when present, the statistics, and whether the verdict
2401
+ establishes that the claims are every answer. Comments are informative
2316
2402
  and MAY be worded differently. They are ignored when the document is read.
2317
2403
 
2318
2404
  Failures are listed in the order they are found: those of reading the
@@ -2320,7 +2406,7 @@ document ([Section 11.3](#113-reading-the-document)), in document order; C4 for
2320
2406
  order; then for each step, in document order, C4 for its uses and the C1, C3,
2321
2407
  C5 or C8 failure of its justification; for each boundary, in step order, the
2322
2408
  C9 failures of its search certificate in the order found, or else its C6
2323
- failure; C10 for each claim; C7 for each claim, then
2409
+ failure; C10 for each claim, then for each question; C7 for each claim, then
2324
2410
  for each step, then for each table and listing, in document order; and C2.
2325
2411
 
2326
2412
  `Detail` is informative text identifying what failed; its wording is not
@@ -2338,7 +2424,8 @@ texts, including unverified claims when `valid` is false. It also has `valid` (b
2338
2424
  `claims`, `verified`, `redecided` (the count `recomputed`), `composed`,
2339
2425
  `uses` (the number of uses of all steps, integers), `trusted`
2340
2426
  (a list of `{kind, conclusion, reason?}`, with `reason: 'original_call'`
2341
- for call-fidelity obligations), `failures` (a list of
2427
+ for a claim's call-fidelity obligation and `reason: 'all_answers'` for a
2428
+ question's answer-completeness obligation), `failures` (a list of
2342
2429
  `{condition, detail, conclusion?}`) and `conditions` (a list of
2343
2430
  `{id, name, covered, failed}`), where `conclusion` is a canonical text.
2344
2431
  Its variables keep the names the document gives them, rather than being
@@ -2679,7 +2766,7 @@ condition('C6', 'boundary_consistency', 'ok', 0)
2679
2766
  condition('C7', 'relevance', 'ok', 5)
2680
2767
  condition('C8', 'witness_integrity', 'ok', 0)
2681
2768
  condition('C9', 'search_closure', 'ok', 0)
2682
- condition('C10', 'call_fidelity', 'ok', 2)
2769
+ condition('C10', 'call_fidelity', 'ok', 3)
2683
2770
 
2684
2771
  // Proof statistics: recorded steps and how they were checked.
2685
2772
  steps(3)
@@ -2689,6 +2776,6 @@ composed(0)
2689
2776
  trusted(0)
2690
2777
  claims(2)
2691
2778
 
2692
- // This verdict applies to the claims above; it does not establish completeness.
2779
+ // This verdict also establishes that the claims above are every answer of the original questions.
2693
2780
  verdict('checked')
2694
2781
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyemind",
3
- "version": "0.5.21",
3
+ "version": "0.5.22",
4
4
  "description": "A dependency-free JavaScript rule language with forward and backward reasoning and checkable proofs.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/fidelity.js CHANGED
@@ -1,13 +1,15 @@
1
- // C10: answers of the original questions, checked from source call tables.
2
- // Unlike logical steps, these searches start before a final substitution.
1
+ // C10: answers of the original questions, checked from source call tables:
2
+ // each claim is an answer, and each answer is claimed. Unlike logical steps,
3
+ // these searches start before a final substitution.
3
4
  import { PRIMITIVE_KEYS } from './builtins.js';
4
5
  import { Settler } from './closure.js';
5
6
  import { text, variant } from './common.js';
6
7
  import { goalTerm } from './goals.js';
7
8
  import { INSPECTION_KEYS } from './inspection.js';
8
9
  import {
9
- Env, conjunction, copyResolved, freshTerm, isAnonymous, isCallable, isGround, isTerm, key, unify, variables,
10
+ Env, Struct, Var, conjunction, copyResolved, freshTerm, isAnonymous, isCallable, isGround, isTerm, key, listFromItems, unify, variables,
10
11
  } from './terms.js';
12
+ import { Lettering, write } from './writer.js';
11
13
 
12
14
  function instance(goal, pattern) {
13
15
  const renamed = freshTerm(pattern, 'callQuestion');
@@ -16,6 +18,7 @@ function instance(goal, pattern) {
16
18
  }
17
19
 
18
20
  // The original questions of Section 8.6, without specializing them to claims.
21
+ // A halted run answers none of them.
19
22
  export function callQuestions(program, goals, claims) {
20
23
  if (claims.includes('false')) return [];
21
24
  let questions = (goals || []).map(goalTerm);
@@ -28,22 +31,96 @@ export function callQuestions(program, goals, claims) {
28
31
  const seen = new Set();
29
32
  return questions.filter((question) => {
30
33
  const id = variant(question, true);
31
- if (seen.has(id) || !claims.some((claim) => instance(claim, question))) return false;
34
+ if (seen.has(id)) return false;
32
35
  seen.add(id);
33
36
  return true;
34
37
  });
35
38
  }
36
39
 
37
- // C9's support plus closure establishes the least ground positive model,
38
- // and with negations the one stable model of a stratified or
39
- // chain-stratified program: a negation whose named variables earlier goals
40
- // bind is decided by the listed facts alone. For forward rules that observe
41
- // bindings or order, and for restricted rules, whose guard another order of
42
- // firings could decide otherwise, a final listing alone does not establish
43
- // which firings occurred. Refuse that stronger promise.
40
+ // Primitives that compute their outputs from ground inputs, in each mode an
41
+ // argument's positions of the inputs, then of the outputs. With its inputs
42
+ // ground such a call has exactly the solutions whose ground instances hold,
43
+ // re-decided as C5 re-decides them, so a search finds what C5 accepts.
44
+ // number_chars/2 re-decides by reading its characters, so only that mode.
45
+ const MODES = new Map([
46
+ ['is/2', [[[1], [0]]]],
47
+ ['compare/3', [[[1, 2], [0]]]],
48
+ ['atom_chars/2', [[[0], [1]], [[1], [0]]]],
49
+ ['atom_codes/2', [[[0], [1]], [[1], [0]]]],
50
+ ['number_chars/2', [[[1], [0]]]],
51
+ ['atom_length/2', [[[0], [1]]]],
52
+ ['atom_lower/2', [[[0], [1]]]],
53
+ ['atom_upper/2', [[[0], [1]]]],
54
+ ['atom_concat/3', [[[0, 1], [2]], [[2], [0, 1]]]],
55
+ ['regex_find/3', [[[0, 1], [2]]]],
56
+ ['digest/3', [[[0, 1], [2]]]],
57
+ ['term_text/2', [[[0], [1]]]],
58
+ ['float64/4', [[[0, 1, 2], [3]]]],
59
+ ]);
60
+
61
+ // The variables of a head's arguments that a call in mode grounds.
62
+ function inputs(head, mode) {
63
+ const names = new Set();
64
+ if (head instanceof Struct) {
65
+ head.args.forEach((arg, i) => {
66
+ if (mode[i] === 'g') for (const name of variables(arg).keys()) names.add(name);
67
+ });
68
+ }
69
+ return names;
70
+ }
71
+
72
+ // How often each variable occurs in term, by name.
73
+ function occurrences(term, counts = new Map()) {
74
+ const pending = [term];
75
+ while (pending.length) {
76
+ const item = pending.pop();
77
+ if (item instanceof Struct) pending.push(...item.args);
78
+ else if (item instanceof Var) counts.set(item.name, (counts.get(item.name) || 0) + 1);
79
+ }
80
+ return counts;
81
+ }
82
+
83
+ // C9's support plus closure establishes the least ground model, and with
84
+ // negations the one stable model of a stratified or chain-stratified
85
+ // program, when a search of each rule body in source order finds exactly the
86
+ // ground instances that hold: then the steps that support a listed fact,
87
+ // re-decided on their ground instances, show a firing a search makes. That
88
+ // holds when no goal observes bindings: each primitive runs with its inputs
89
+ // ground, each negation with its named variables ground, and once/1 and
90
+ // findall/3 bind nothing other goals use. A backward rule is analyzed for
91
+ // each mode it is called in, the head arguments a call grounds being ground
92
+ // on entry, and must ground the rest of its head. A relation with a
93
+ // nonground source fact grounds nothing. Rules that observe bindings or
94
+ // order, templates, and restricted rules, whose guard another order of
95
+ // firings could decide otherwise, leave which firings occurred
96
+ // unestablished: refuse that promise.
44
97
  export function positiveListings(program, listings) {
45
- const pending = [...listings];
98
+ // Calls, by relation and mode, found to answer with nonground terms; the
99
+ // analysis starts again whenever it finds another, assuming fewer grounded.
100
+ const loose = new Set();
101
+ for (;;) {
102
+ const result = groundedListings(program, listings, loose);
103
+ if (result !== 'again') return result;
104
+ }
105
+ }
106
+
107
+ function groundedListings(program, listings, loose) {
108
+ // A listed relation and the forward rules concluding it, or a called
109
+ // relation and its mode: 'g' for each argument ground at the call, else 'f'.
110
+ const pending = listings.map((goalKey) => [goalKey, null]);
46
111
  const seen = new Set();
112
+ // Whether every source fact of a relation is ground once a call in this
113
+ // mode has unified it: only then does the call ground its arguments.
114
+ const groundsFacts = (goalKey, mode) => !loose.has(`${goalKey} ${mode}`) &&
115
+ (program.groups.get(goalKey) || []).every((clause) => clause.body.length ||
116
+ [...variables(clause.head).keys()].every((name) => inputs(clause.head, mode).has(name)));
117
+ let outside = null;
118
+ // The variables of goal used elsewhere in the clause, other than in goal.
119
+ const shared = (goal) => {
120
+ const inside = occurrences(goal);
121
+ return [...variables(goal)].filter(([name, variable]) => !isAnonymous(variable) && outside.get(name) > inside.get(name))
122
+ .map(([name]) => name);
123
+ };
47
124
  function bound(goal, grounded, negated = false) {
48
125
  if (goal === 'true') return grounded;
49
126
  if (isTerm(goal, 'and', 2) || isTerm(goal, 'or', 2)) {
@@ -61,40 +138,85 @@ export function positiveListings(program, listings) {
61
138
  }
62
139
  return bound(goal.args[0], grounded, true) === null ? null : grounded;
63
140
  }
141
+ if (isTerm(goal, 'call', 1)) return bound(goal.args[0], grounded, negated);
142
+ // A first answer or a collection binds nothing it shares, so which answer
143
+ // came first, or which bindings a later goal makes, cannot matter.
144
+ if (isTerm(goal, 'once', 1)) {
145
+ const inner = bound(goal.args[0], grounded, negated);
146
+ return inner === null || shared(goal).some((name) => !grounded.has(name)) ? null : grounded;
147
+ }
148
+ if (isTerm(goal, 'findall', 3)) {
149
+ const inner = bound(goal.args[1], grounded, negated);
150
+ const collected = new Struct('-', [goal.args[0], goal.args[1]]);
151
+ if (inner === null || shared(collected).some((name) => !grounded.has(name))) return null;
152
+ const items = [...variables(goal.args[0]).keys()].every((name) => inner.has(name));
153
+ return items ? new Set([...grounded, ...variables(goal.args[2]).keys()]) : grounded;
154
+ }
64
155
  if (!isCallable(goal)) return null;
65
156
  const goalKey = key(goal);
66
- if (PRIMITIVE_KEYS.has(goalKey) || INSPECTION_KEYS.has(goalKey) ||
67
- ['not/1', 'findall/3', 'once/1', 'call/1'].includes(goalKey)) return null;
68
- pending.push(goalKey);
69
- return new Set([...grounded, ...variables(goal).keys()]);
157
+ if (INSPECTION_KEYS.has(goalKey)) return null;
158
+ if (PRIMITIVE_KEYS.has(goalKey)) {
159
+ const free = (term) => [...variables(term).keys()].filter((name) => !grounded.has(name));
160
+ const args = goal instanceof Struct ? goal.args : [];
161
+ if (args.every((arg) => !free(arg).length)) return grounded;
162
+ if (goalKey === 'unify/2') {
163
+ // Unification is pure; a ground side grounds the other.
164
+ const [left, right] = args;
165
+ if (!free(left).length || !free(right).length) return new Set([...grounded, ...variables(goal).keys()]);
166
+ return grounded;
167
+ }
168
+ const modes = MODES.get(goalKey) || [];
169
+ if (!modes.some(([inputs]) => inputs.every((i) => !free(args[i]).length))) return null;
170
+ return new Set([...grounded, ...variables(goal).keys()]);
171
+ }
172
+ const args = goal instanceof Struct ? goal.args : [];
173
+ const mode = args.map((arg) => ([...variables(arg).keys()].every((name) => grounded.has(name)) ? 'g' : 'f')).join('');
174
+ pending.push([goalKey, mode]);
175
+ return groundsFacts(goalKey, mode) ? new Set([...grounded, ...variables(goal).keys()]) : grounded;
70
176
  }
71
177
  while (pending.length) {
72
- const goalKey = pending.pop();
73
- if (seen.has(goalKey)) continue;
74
- seen.add(goalKey);
75
- const clauses = [...(program.groups.get(goalKey) || []), ...program.forward.filter((clause) =>
76
- clause.plainHeads.some((head) => isCallable(head) && key(head) === goalKey))];
178
+ const [goalKey, mode] = pending.pop();
179
+ const clauses = [];
180
+ if (!seen.has(goalKey)) {
181
+ seen.add(goalKey);
182
+ clauses.push(...(program.groups.get(goalKey) || []).filter((clause) => !clause.body.length),
183
+ ...program.forward.filter((clause) => clause.plainHeads.some((head) => isCallable(head) && key(head) === goalKey)));
184
+ }
185
+ if (mode !== null && !seen.has(`${goalKey} ${mode}`)) {
186
+ seen.add(`${goalKey} ${mode}`);
187
+ clauses.push(...(program.groups.get(goalKey) || []).filter((clause) => clause.body.length));
188
+ }
77
189
  for (const clause of clauses) {
78
190
  if (clause.parentId !== null || clause.templates.length || clause.captures !== null || clause.guard !== null) return false;
79
- if (!clause.forward && !clause.body.length) {
80
- if (!isGround(clause.head)) return false;
81
- continue;
82
- }
83
- let grounded = new Set();
191
+ if (!clause.forward && !clause.body.length) continue;
192
+ outside = occurrences(new Struct('-', [clause.head, listFromItems(clause.body)]));
193
+ let grounded = clause.forward ? new Set() : inputs(clause.head, mode);
84
194
  for (const goal of clause.body) {
85
195
  grounded = bound(goal, grounded);
86
196
  if (grounded === null) return false;
87
197
  }
198
+ // A call in a mode whose facts stay nonground grounds nothing, so its
199
+ // rules need not ground their heads either.
200
+ if (!clause.forward && !groundsFacts(goalKey, mode)) continue;
88
201
  const witnesses = new Set(clause.forward ? clause.witnessNames : []);
89
202
  for (const name of variables(clause.head).keys()) {
90
- if (!grounded.has(name) && !witnesses.has(name)) return false;
203
+ if (grounded.has(name) || witnesses.has(name)) continue;
204
+ if (clause.forward) return false;
205
+ loose.add(`${goalKey} ${mode}`);
206
+ return 'again';
91
207
  }
92
208
  }
93
209
  }
94
210
  return true;
95
211
  }
96
212
 
97
- export function checkCalls(program, claims, goals, certificate, steps, spellings, fail, allowTrusted, name) {
213
+ // Both directions of C10: each claim is an answer of an original question,
214
+ // and each answer of a certified question is claimed. When the conclusions
215
+ // are the derived facts, a question's answers that are not derived (source
216
+ // facts, backward answers) are no conclusions, so only its listed facts are.
217
+ // A proof with a primitive only within host-math tolerance (C5) supports no
218
+ // listing for C10: its derived facts need not be what a search here finds.
219
+ export function checkCalls(program, claims, goals, certificate, steps, spellings, fail, allowTrusted, name, inexact = false) {
98
220
  const settler = new Settler(program, {
99
221
  answers: (call) => certificate.calls.get(variant(call, true)) ?? null,
100
222
  facts: (goalKey) => certificate.listings.get(goalKey) ?? null,
@@ -103,7 +225,7 @@ export function checkCalls(program, claims, goals, certificate, steps, spellings
103
225
  if (claims.includes('false')) return { settler, outcomes: [], unresolved: [], covered: 0 };
104
226
  const outcomes = callQuestions(program, goals, claims).map((question) => {
105
227
  const outcome = settler.answers(question);
106
- if (outcome.status === 'settled' && !positiveListings(program, outcome.listings)) {
228
+ if (outcome.status === 'settled' && ((inexact && outcome.listings.length) || !positiveListings(program, outcome.listings))) {
107
229
  return { question, ...outcome, status: 'unsupported' };
108
230
  }
109
231
  return { question, ...outcome };
@@ -127,5 +249,31 @@ export function checkCalls(program, claims, goals, certificate, steps, spellings
127
249
  covered++;
128
250
  if (detail !== null) fail.add('C10', `${detail}: ${text(claim)}`, claim);
129
251
  }
252
+ const derivedOnly = !(goals || []).length && !program.forward.some((clause) => clause.heads.includes('true'));
253
+ const claimed = new Set(claims.map((claim) => variant(claim)));
254
+ for (const { question, status, answers } of outcomes) {
255
+ if (status === 'failed') {
256
+ // A claim of this question already failed with its certificate.
257
+ if (!claims.some((claim) => instance(claim, question))) {
258
+ fail.add('C10', `the original call has an invalid search certificate: ${text(question)}`, question);
259
+ }
260
+ covered++;
261
+ continue;
262
+ }
263
+ if (status !== 'settled') {
264
+ unresolved.push([{ kind: 'call_fidelity', reason: 'all_answers', conclusion: text(question) }, question]);
265
+ if (!allowTrusted) fail.add('C10', `answer completeness remains unproved: ${text(question)}`, question);
266
+ continue;
267
+ }
268
+ const required = derivedOnly
269
+ ? (settler.listings.get(key(question))?.facts || []).filter((fact) => instance(fact, question))
270
+ : answers;
271
+ covered++;
272
+ for (const answer of required) {
273
+ if (!claimed.has(variant(answer))) {
274
+ fail.add('C10', `the proof omits an answer of the original call: ${write(answer, null, new Lettering())}`, answer);
275
+ }
276
+ }
277
+ }
130
278
  return { settler, outcomes, unresolved, covered };
131
279
  }
package/src/proof.js CHANGED
@@ -208,11 +208,19 @@ export function renderProof(program, claims, roots, checkable = false, heading =
208
208
  }
209
209
  };
210
210
  walk(roots);
211
- const boundaries = [...steps.values()].filter((node) => node.by === 'absent' || node.by === 'collected')
211
+ const boundariesOf = () => [...steps.values()].filter((node) => node.by === 'absent' || node.by === 'collected')
212
212
  .map((node) => node.goal);
213
- const certificate = certify !== null ? certify(boundaries) : { tables: [], listings: [] };
213
+ let boundaries = boundariesOf();
214
+ let certificate = certify !== null ? certify(boundaries) : { tables: [], listings: [] };
214
215
  // A listed derived fact is shown by its own steps, after the claims' steps.
215
- walk(certificate.listings.flatMap(([, nodes]) => nodes));
216
+ // Their negations and collections need certificates too, which can list
217
+ // further facts: certify again until no new boundary appears.
218
+ for (;;) {
219
+ walk(certificate.listings.flatMap(([, nodes]) => nodes));
220
+ if (certify === null || boundariesOf().length === boundaries.length) break;
221
+ boundaries = boundariesOf();
222
+ certificate = certify(boundaries);
223
+ }
216
224
  // Variables are named A, B, ... in the order the document first shows
217
225
  // them, the claims written first, as in the run's conclusions.
218
226
  const lettering = new Lettering();
@@ -342,7 +350,7 @@ function check(program, claims, steps, certificate, goals, allowTrusted, fail, s
342
350
  const provenance = new WitnessProvenance(program, steps, certificate, settlement.outcomes, spellings);
343
351
  const tally = checkSteps(program, steps, allowTrusted, fail, spellings, name, settlement.outcomes, provenance);
344
352
  const [confronted, closed] = checkBoundaries(program, steps, tally.boundaries, fail, settlement.outcomes, spellings);
345
- settlement.calls = checkCalls(program, claims, goals, certificate, steps, spellings, fail, allowTrusted, name);
353
+ settlement.calls = checkCalls(program, claims, goals, certificate, steps, spellings, fail, allowTrusted, name, tally.inexact);
346
354
  tally.trusted.push(...settlement.calls.unresolved);
347
355
  checkRelevance(program, claims, steps, goals || [], fail, spellings, settlement, certificate);
348
356
  checkWellFounded(steps, fail, spellings);
@@ -381,13 +389,15 @@ function check(program, claims, steps, certificate, goals, allowTrusted, fail, s
381
389
 
382
390
  // The verdict allowTrusted false would give, from a report without it.
383
391
  // Without failures, strict checking adds C5 failures for trusted boundaries
384
- // and C10 failures for unresolved original calls, in obligation order. It
392
+ // and C10 failures for unresolved original calls and questions whose
393
+ // answers are not shown complete, in obligation order. It
385
394
  // needs no second reading. A report with failures returns null: check again.
386
395
  export function strict(report) {
387
396
  if (report.failures.length) return null;
388
397
  const failures = report.trusted.map((record) => ({
389
398
  condition: record.kind === 'call_fidelity' ? 'C10' : 'C5',
390
- detail: record.kind === 'call_fidelity' ? `call fidelity remains unproved: ${record.conclusion}` : `trusted boundary forbidden: ${record.kind}`,
399
+ detail: record.reason === 'all_answers' ? `answer completeness remains unproved: ${record.conclusion}`
400
+ : record.kind === 'call_fidelity' ? `call fidelity remains unproved: ${record.conclusion}` : `trusted boundary forbidden: ${record.kind}`,
391
401
  conclusion: record.conclusion,
392
402
  }));
393
403
  const conditions = report.conditions.map((condition) => (
@@ -480,7 +490,7 @@ const CONTROL_BY = 'control';
480
490
  // instance of the clause it cites, a recomputed primitive, a control composed
481
491
  // of its uses, or a trusted boundary the later checks confront.
482
492
  function checkSteps(program, steps, allowTrusted, fail, spellings, name, outcomes, provenance) {
483
- const tally = { verified: 0, redecided: 0, composed: 0, witnessed: 0, boundaries: [], trusted: [] };
493
+ const tally = { verified: 0, redecided: 0, composed: 0, witnessed: 0, boundaries: [], trusted: [], inexact: false };
484
494
 
485
495
  function covered(goal) {
486
496
  if (isTerm(goal, 'and', 2)) return flattenConjunction(goal).every(covered);
@@ -510,9 +520,11 @@ function checkSteps(program, steps, allowTrusted, fail, spellings, name, outcome
510
520
  fail.add('C3', 'invalid builtin justification', goal);
511
521
  continue;
512
522
  }
513
- const agrees = redecides(goal);
514
- if (!agrees) fail.add('C5', `primitive disagrees: ${text(goal)}`, goal);
523
+ const exact = redecidesExactly(goal);
524
+ if (!exact && !nearHostMath(goal)) fail.add('C5', `primitive disagrees: ${text(goal)}`, goal);
515
525
  else tally.redecided++;
526
+ // Host math within its tolerance is not the result a search here finds.
527
+ if (!exact) tally.inexact = true;
516
528
  } else if (isTerm(by, 'called', 1)) {
517
529
  if (bindings.length || uses.length || !isCallable(goal) || !STATE_TESTS.has(key(goal))) {
518
530
  fail.add('C3', 'invalid called justification', goal);
@@ -551,6 +563,10 @@ function checkSteps(program, steps, allowTrusted, fail, spellings, name, outcome
551
563
  }
552
564
 
553
565
  function redecides(goal) {
566
+ return redecidesExactly(goal) || nearHostMath(goal);
567
+ }
568
+
569
+ function redecidesExactly(goal) {
554
570
  try {
555
571
  for (const env of primitive(goal, new Env())) {
556
572
  if (resolvesTo(goal, env, goal)) return true;
@@ -558,7 +574,7 @@ function redecides(goal) {
558
574
  } catch (error) {
559
575
  if (!(error instanceof EyemindError)) throw error;
560
576
  }
561
- return nearHostMath(goal);
577
+ return false;
562
578
  }
563
579
 
564
580
  // A state test recorded as called: the called goal, renamed apart, holds as
@@ -1127,7 +1143,8 @@ export function checkReport(report) {
1127
1143
  }
1128
1144
  facts.push(new Struct('verdict', [verdict(report)]));
1129
1145
  const heading = !report.valid ? '// Unverified claims: proof checking failed.'
1130
- : !report.answers.length ? '// No answers claimed; this check establishes no conclusions.'
1146
+ : !report.answers.length && report.trusted.length ? '// No answers claimed; this check establishes no conclusions.'
1147
+ : !report.answers.length ? '// No answers: the original questions have none.'
1131
1148
  : report.trusted.length ? '// Answers checked subject to the obligations below.'
1132
1149
  : '// Checked answers: these follow from the input program.';
1133
1150
  const lines = [heading, ...report.answers, '',
@@ -1139,10 +1156,14 @@ export function checkReport(report) {
1139
1156
  lines.push('', '// Failures: the claims above have not passed every check.');
1140
1157
  }
1141
1158
  if (fact.name === 'obligation' && previous !== 'obligation') {
1142
- lines.push('', '// Obligations: absence, collection or original-call evidence remains unproved.');
1159
+ lines.push('', '// Obligations: absence, collection, original-call or all-answers evidence remains unproved.');
1143
1160
  }
1144
1161
  if (fact.name === 'steps') lines.push('', '// Proof statistics: recorded steps and how they were checked.');
1145
- if (fact.name === 'verdict') lines.push('', '// This verdict applies to the claims above; it does not establish completeness.');
1162
+ if (fact.name === 'verdict') {
1163
+ lines.push('', report.valid && !report.trusted.length && !report.answers.includes("'false'")
1164
+ ? '// This verdict also establishes that the claims above are every answer of the original questions.'
1165
+ : '// This verdict applies to the claims above; it does not establish that they are every answer.');
1166
+ }
1146
1167
  lines.push(text(lettered(fact)));
1147
1168
  previous = fact.name;
1148
1169
  }
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.5.21';
2
+ export const VERSION = '0.5.22';