Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

Run both certificate checkers over the same bytes, and report where they part company

FABIOTESS4e058a9e1882
diff --git a/.gitattributes b/.gitattributes
index f37a8a43..2740a151 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -18,3 +18,16 @@
# RDF serialisations, for the same reason: a stray CR changes a literal.
*.ttl text eol=lf
*.trig text eol=lf
+
+# ONE EXCEPTION, and it is the exception that proves the rule above. The
+# `probe_crlf_*` files in isabelle/fixtures-differential/ exist to feed the two
+# certificate checkers a file that DOES carry carriage returns, and to pin that
+# both of them reject it for the same reason. Normalising them to LF would leave
+# a probe that tests nothing while still reporting green, which is the failure
+# this repository is built to catch. `-text` stores and checks out the bytes
+# verbatim on every platform.
+#
+# `the_untested_corners_of_the_term_format_agree` asserts the CR is present
+# before it runs them, so if this line is ever removed the test fails rather
+# than quietly passing over a normalised file.
+isabelle/fixtures-differential/probe_crlf_*.tsv -text
diff --git a/.gitignore b/.gitignore
index 89b625a0..f5b62940 100644
--- a/.gitignore
+++ b/.gitignore
@@ -62,3 +62,9 @@ OUTREACH.md
# local-only: it does not travel with the repo, it is gone on a fresh clone, and
# it is invisible to a collaborator or to an agent working in one.
benchmark/handshake_gate/
+
+# The native Isabelle checker, linked from the committed generated ML by
+# isabelle/build_native.sh. A build artefact, not a source: it is a machine-specific
+# binary linked against the Poly/ML runtime in whichever Isabelle installation was
+# found, so committing it would ship a file that runs on one machine.
+isabelle/build/
diff --git a/isabelle/README.md b/isabelle/README.md
index 11503900..7509fcf0 100644
--- a/isabelle/README.md
+++ b/isabelle/README.md
@@ -35,12 +35,115 @@ the strict and the lenient verdict. `OO_VERBOSE=1` keeps Poly/ML's chatter.
Regenerate `driver/oo_horn_generated.ML` from the theories with `isabelle/export.sh`.
+## Run the checker as a native binary
+
+`run_checker.sh` drives Poly/ML with `--use`, which recompiles 1,957 lines of generated
+ML on every invocation — about half a second each, which is the only thing that makes a
+corpus of a thousand certificates slow. `build_native.sh` links the same generated code
+into an executable instead:
+
+ isabelle/build_native.sh # -> isabelle/build/oo-horn-isabelle (gitignored)
+
+ oo-horn-isabelle check RULES.tsv ASSERTED.tsv CERT.tsv # 0 / 1 / 2, as oo-horn does
+ oo-horn-isabelle batch MANIFEST.tsv # one JSON line per row
+ oo-horn-isabelle table RULES.tsv # is this the built-in table?
+
+The CLI shape and the exit codes are `lean/HMain.lean`'s deliberately, so the differential
+compares two checkers rather than two translations of two checkers. The wrapper is
+`driver/oo_horn_cli.sml` and it is untrusted, exactly as `driver/oo_horn_driver.sml` is.
+
## Run the differential matrix
isabelle/differential_matrix.sh
-One JSON line per input triple. Run the same matrix through the other checker and diff
-the accept/reject bit and the verdict word.
+One JSON line per input triple, over the committed fixtures — the by-hand version, useful
+for looking at one row. The real comparison is a Rust test:
+
+ cargo test --test cross_kernel_differential_test -- --nocapture
+
+It builds both checkers, generates certificates with the ENGINE over every ontology the
+repository ships, mutates and fuzzes them, and runs both kernels over the lot. It skips
+loudly (`common::skip_unless`) when either proof assistant is missing, and
+`OO_REQUIRE_FIXTURES=1` turns that skip into a failure.
+
+## What the differential found
+
+1,718 certificates: 61 base, 1,291 mutated, 366 fuzzed. Both kernels accept 349, reject
+857, and refuse 465 as unparseable. **Forty-seven rows disagree, in two classes.** Nothing
+was adjusted on either side to make them go away.
+
+Both classes have ONE root cause: **Isabelle validates the binding list as a data
+structure and Lean does not.** `check_step` requires `distinct (map fst b)` and
+`binding_covers b r` before it instantiates anything; Lean's `substOf` is
+`fun v => (List.lookup v l).getD v`, which turns any binding list into a total function
+with a silent default and never inspects it.
+
+| | certificate | Lean | Isabelle |
+|---|---|---|---|
+| **D1** duplicate binding key | `fixtures-added/bad_dup_key.tsv` | accepts, `entailed` | rejects, `binding_dup_key` |
+| **D2a** binding omits a variable whose NAME is a term in the graph | `fixtures-differential/varname_unbound_cert.tsv` | accepts | rejects, `binding_incomplete` |
+| **D2b** binding omits a variable the rule's HEAD needs | `fixtures-differential/unsafehead_cert.tsv` | accepts | rejects, `binding_incomplete` |
+| **D2c** the same, **found by the fuzzer** in a rule file one character from a probe written for something else | `fixtures-differential/d2c_fuzzfound_*.tsv` | accepts | rejects, `binding_incomplete` |
+
+Neither checker is unsound. Lean's acceptances are all sound in Lean's own theorem,
+because `EntailsR` quantifies over every total substitution and the substitution Lean used
+is a real one; Isabelle's rejections are false alarms, which is the harmless direction.
+What the pair shows is that the FORMAT is underspecified in two places, and that a
+certificate's validity therefore depends on which verified checker reads it.
+
+D1's resolution rests on `List.lookup` being first-wins. That is a tie-break inside a
+standard-library function standing in for a rule about a file format, and it decides
+whether a certificate is valid. DECISION M25 in `OO_Check.thy` predicted exactly this and
+named `map_of`'s first-wins behaviour as the reason not to rely on it; `substOf`'s
+docstring on the Lean side discusses missing bindings only and says nothing about repeated
+ones.
+
+D2b is the sharp one. The rule is `?s <p> ?o -> ?s <q> ?z`, the graph is one ordinary
+triple of IRIs, and the certificate omits `z`. Lean accepts a conclusion whose object is
+the bare term `z` — not an IRI, not a blank node, not a literal, not writable RDF — minted
+out of a variable's NAME in the rule file. The engine refuses to evaluate such a rule
+(`parse_rules` in `src/reason.rs` rejects "a head variable the body never binds"), but
+that guard is in the PRODUCER, and the checker is the thing you point at a certificate
+someone else wrote.
+
+D2c is the one that settles the obvious objection to D2a, which is that nobody writes a
+graph whose subject is spelled like a variable. Nobody designed D2c either: the seeded
+fuzzer replaced one field of a probe's rule file, `?o` became a bare `?`, and both parsers
+read that as a variable whose NAME IS THE EMPTY STRING. The graph's object is an empty
+field, so Lean's default sends the unbound variable `""` to the term `""` and the step
+checks. The hole is reachable by a typo. This is also why the corpus test classifies a
+divergence by its CAUSE rather than by the edit that produced it — a quarantine keyed on
+the edit would have hidden exactly this row.
+
+D2 also falsifies, across the two checkers, something proved inside one of them.
+`coverage_implied` says removing Isabelle's coverage check cannot change its accept/reject
+bit, and that is true of Isabelle, whose instantiation is partial. It does not transfer:
+Lean's instantiation is total, so the same check is load-bearing there and in the opposite
+direction. A property proved of one formalisation's checker is not a property of the
+format.
+
+### What agreement on the other 1,671 rows is evidence of
+
+Checking a Horn certificate is purely syntactic. Neither kernel consults its semantics, so
+two checkers built on contradictory model theories agree on every certificate and every
+forgery. Agreement here is evidence about the FILE FORMAT and the CHECKING DISCIPLINE, and
+it is not a proof of anything. The evidence that the definitions agree lives in
+`OO_Builtin_Sound.thy` and `lean/OOCert/HornBuiltin.lean` — which arms each side can
+discharge, and from which conditions — and in `OO_NonVacuity.thy`, on whether the
+conditions describe anything at all.
+
+Three things the differential did settle, all of them corners neither side had a test for:
+
+* **Non-ASCII IRIs round-trip through both** and a one-byte change to one is rejected by
+ both. DECISION M38's worry — that `String.literal` is ASCII-only in the logic and the
+ fixtures are all ASCII, so the trap would stay hidden — is a trap that was avoided
+ rather than one that was never there. The verified core is over `string = char list`.
+* **`"01"^^xsd:integer` is not `"1"^^xsd:integer` on either side.** M1's scope note holds:
+ terms are opaque, no datatype-aware rule is in the table, and neither checker
+ normalises.
+* **Bracket-stripping is invisible to the accept/reject bit.** Isabelle's D-PARSE-2 maps
+ `<u>` to `Iri u` and Lean keeps the spelling; `http://ex.org/a` and `<http://ex.org/a>`
+ are distinct terms on both sides, which is the injectivity D-PARSE-2 needs.
## Files
@@ -57,8 +160,10 @@ the accept/reject bit and the verdict word.
| `OO_Fixtures.thy` | the checker run on the real fixture bytes, as build gates. Uses `eval`; no soundness theorem depends on it. |
| `OO_Audit.thy` | the oracle gate, and a check that the gate can fail. |
| `OO_Export.thy` | code generation. |
-| `driver/` | the untrusted SML driver, and the generated core. |
+| `driver/` | the untrusted SML drivers, and the generated core. |
| `fixtures-added/` | fixtures for properties the shipped set cannot reach. |
+| `fixtures-differential/` | the two divergences, and the term-format corners neither side had a test for. |
+| `build_native.sh` | links the generated core into `build/oo-horn-isabelle`. |
## Trust boundary
diff --git a/isabelle/build_native.sh b/isabelle/build_native.sh
new file mode 100755
index 00000000..addf2ecc
--- /dev/null
+++ b/isabelle/build_native.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+# Link the verified checker into a native executable, so the differential harness can
+# run hundreds of certificates without paying Poly/ML's compile time on every one.
+#
+# isabelle/build_native.sh -> isabelle/build/oo-horn-isabelle
+#
+# This is the LINK STEP ONLY. Nothing is recompiled from the theories: the input is
+# driver/oo_horn_generated.ML, which `isabelle/export.sh` writes out of the session, plus
+# driver/oo_horn_cli.sml, which is untrusted by construction.
+#
+# Why not `polyc`. Poly/ML ships one, and it does not work here: its CFLAGS carry the
+# absolute path of the machine Isabelle was BUILT on
+# (/tmp/isabelle-makarius/build.../gmp/target/lib), and `-lgmp` then resolves against a
+# directory that does not exist on this machine. The bundled runtime directory holds
+# libgmp.10.dylib but no libgmp.dylib, so the linker cannot find it there either. The two
+# steps below are what polyc does, with the gmp search path pointed somewhere real.
+set -e
+HERE=$(cd "$(dirname "$0")" && pwd)
+OUT=${1:-$HERE/build/oo-horn-isabelle}
+
+# Where Poly/ML lives. Ask Isabelle first, because ISABELLE_HOME is the only answer that
+# is right on a machine that is not this one; fall back to the macOS app bundle, and let
+# POLYDIR override both.
+ARCH=$(uname -m); [ "$ARCH" = "aarch64" ] && ARCH=arm64
+OS=$(uname -s | tr 'A-Z' 'a-z')
+if [ -z "$POLYDIR" ] && command -v isabelle >/dev/null 2>&1; then
+ IHOME=$(isabelle getenv -b ISABELLE_HOME 2>/dev/null || true)
+ [ -n "$IHOME" ] && POLYDIR=$(ls -d "$IHOME"/contrib/polyml-*/"$ARCH-$OS" 2>/dev/null | head -1)
+fi
+POLYDIR=${POLYDIR:-$(ls -d /Applications/Isabelle*.app/contrib/polyml-*/"$ARCH-$OS" 2>/dev/null | head -1)}
+[ -x "$POLYDIR/poly" ] || { echo "poly not found; set POLYDIR=/path/to/polyml/arch-dir" >&2; exit 3; }
+
+# Where libgmp actually lives on this machine. Homebrew first, then the copy Isabelle
+# bundles (which has only the versioned name, so it is linked by full path).
+if [ -f /opt/homebrew/lib/libgmp.dylib ]; then
+ GMP="-L/opt/homebrew/lib -lgmp"
+elif [ -f /usr/local/lib/libgmp.dylib ]; then
+ GMP="-L/usr/local/lib -lgmp"
+elif [ -f "$POLYDIR/libgmp.10.dylib" ]; then
+ GMP="$POLYDIR/libgmp.10.dylib"
+else
+ echo "libgmp not found; install gmp or set GMP=..." >&2; exit 3
+fi
+
+mkdir -p "$(dirname "$OUT")"
+OBJ=$(mktemp "${TMPDIR:-/tmp}/oo_horn_obj.XXXXXX").o
+
+# 1. Compile the generated core and the CLI, and export `main` as an object file.
+printf 'val () = use "%s";\nval () = use "%s";\nval () = PolyML.export("%s", main);\n' \
+ "$HERE/driver/oo_horn_generated.ML" "$HERE/driver/oo_horn_cli.sml" "$OBJ" \
+ | "$POLYDIR/poly" -q --error-exit
+
+# 2. Link it against the Poly/ML runtime.
+g++ -std=gnu++11 -O2 "$OBJ" -o "$OUT" \
+ -L"$POLYDIR" -Wl,-rpath,"$POLYDIR" -lpolymain -lpolyml $GMP -lstdc++ 2>/dev/null
+
+rm -f "$OBJ"
+echo "wrote $OUT"
diff --git a/isabelle/driver/oo_horn_cli.sml b/isabelle/driver/oo_horn_cli.sml
new file mode 100644
index 00000000..9b2c3541
--- /dev/null
+++ b/isabelle/driver/oo_horn_cli.sml
@@ -0,0 +1,197 @@
+(* oo_horn_cli.sml -- the UNTRUSTED command-line wrapper. NO THEOREM COVERS THIS FILE.
+
+ It exists so the Isabelle checker can be driven exactly as `lean/HMain.lean` drives
+ the Lean one:
+
+ oo-horn-isabelle check RULES.tsv ASSERTED.tsv CERT.tsv
+
+ with the SAME exit-code discipline: 0 accepted, 1 rejected, 2 unreadable or
+ unparseable. That symmetry is the whole point -- a differential test that had to
+ translate one side's exit codes into the other's would be comparing the translation.
+
+ Two extra modes, both harness conveniences and neither part of any theorem:
+
+ oo-horn-isabelle batch MANIFEST.tsv
+ one `RULES<TAB>ASSERTED<TAB>CERT` per line, one JSON object per line out,
+ each carrying the exit code it would have produced. Hundreds of rows in one
+ process, because starting a process per certificate is the only thing that
+ makes the comparison slow.
+
+ oo-horn-isabelle table RULES.tsv
+ prints the verdict word `verdict_of` assigns to that rule table, i.e.
+ whether the file IS the table embedded in OO_Check.thy. This is what makes
+ the verdict comparison mean anything: the Lean side pins
+ tests/fixtures/horn/builtin_rules.tsv against its own `Builtin.asHorn`, and
+ this pins the same bytes against Isabelle's `builtin_table`, so the two
+ embedded tables are shown equal THROUGH the fixture rather than assumed.
+
+ Everything outside the verified core is here and in oo_horn_driver.sml: file IO,
+ splitting bytes on LF and TAB, JSON, exit codes. Splitting is four lines, which is
+ possible only because the format has no escaping layer.
+
+ It uses SML's OWN String.explode on a native byte string, not Isabelle's, so a
+ non-ASCII byte is carried into the verified core unchanged (DECISION M38). *)
+
+fun toChar c = OOHorn.chr_of_nat (OOHorn.nat_of_integer (IntInf.fromInt (Char.ord c)));
+fun toStr s = List.map toChar (String.explode s);
+fun natToInt n = IntInf.toInt (OOHorn.integer_of_nat n);
+
+exception ReadError of string;
+
+fun readFile path =
+ (let val s = TextIO.openIn path
+ val d = TextIO.inputAll s
+ in TextIO.closeIn s; d end)
+ handle IO.Io _ => raise ReadError path
+ | OS.SysErr _ => raise ReadError path;
+
+(* the whole of the untrusted parsing *)
+fun splitOn c s = String.fields (fn x => x = c) s;
+fun rows text =
+ List.map (fn line => List.map toStr (splitOn #"\t" line))
+ (List.filter (fn l => l <> "") (splitOn #"\n" text));
+
+fun reasonStr r = case r of
+ OOHorn.R_index_out_of_range => "index_out_of_range"
+ | OOHorn.R_arity_mismatch => "arity_mismatch"
+ | OOHorn.R_binding_incomplete => "binding_incomplete"
+ | OOHorn.R_binding_dup_key => "binding_dup_key"
+ | OOHorn.R_body_mismatch j => "body_mismatch:" ^ Int.toString (natToInt j)
+ | OOHorn.R_premise_unknown j => "premise_unknown:" ^ Int.toString (natToInt j)
+ | OOHorn.R_head_mismatch => "head_mismatch";
+
+fun verdictStr v = case v of
+ OOHorn.Entailed => "entailed"
+ | OOHorn.EntailedUnderSuppliedRules => "entailed_under_supplied_rules";
+
+fun outcomeStr oc = case oc of
+ OOHorn.Ok v => "ok " ^ verdictStr v
+ | OOHorn.Rejected (j,r) => "rejected step=" ^ Int.toString (natToInt j) ^
+ " reason=" ^ reasonStr r
+ | OOHorn.ParseError => "parse_error";
+
+fun exitCode oc = case oc of
+ OOHorn.Ok _ => 0
+ | OOHorn.Rejected _ => 1
+ | OOHorn.ParseError => 2;
+
+fun jsonStr s =
+ "\"" ^ String.translate (fn #"\"" => "\\\"" | #"\\" => "\\\\" | c => String.str c) s ^ "\"";
+
+(* The theorem each outcome names, and what it means. The relativised verdict names the
+ conditional theorem BECAUSE nothing discharges a user-supplied rule: the certificate
+ carries it as an assumption. Same discipline as lean/HMain.lean, deliberately, so a
+ report from either side reads the same. *)
+fun theoremOf v = case v of
+ OOHorn.Entailed => "OOHorn.run_check_entailed_sound"
+ | OOHorn.EntailedUnderSuppliedRules => "OOHorn.run_check_sound";
+
+fun meansOf v = case v of
+ OOHorn.Entailed =>
+ "every conclusion is true in every model of the asserted graph"
+ | OOHorn.EntailedUnderSuppliedRules =>
+ "every conclusion is true in every model of the asserted graph THAT ALSO SATISFIES \
+ \the supplied rules; the rules themselves are assumed, not checked";
+
+(* One JSON object per run, carrying BOTH the strict and the lenient judgement. The
+ strict one is the verdict and the exit code; the lenient one is reported beside it
+ because strict_implies_lenient makes a disagreement between the two a KNOWN class of
+ input (premises listed out of order but all asserted) rather than a surprise. *)
+fun reportJson rulesF assertedF certF strict lenient =
+ let
+ val head =
+ "{\"checker\":\"isabelle-OOHorn\"" ^
+ ",\"rules\":" ^ jsonStr rulesF ^
+ ",\"asserted\":" ^ jsonStr assertedF ^
+ ",\"certificate\":" ^ jsonStr certF ^
+ ",\"strict\":" ^ jsonStr (outcomeStr strict) ^
+ ",\"lenient\":" ^ jsonStr (outcomeStr lenient) ^
+ ",\"exit\":" ^ Int.toString (exitCode strict)
+ val body = case strict of
+ OOHorn.Ok v =>
+ ",\"ok\":true,\"verdict\":" ^ jsonStr (verdictStr v) ^
+ ",\"theorem\":" ^ jsonStr (theoremOf v) ^
+ ",\"means\":" ^ jsonStr (meansOf v)
+ | OOHorn.Rejected (j,r) =>
+ ",\"ok\":false,\"step\":" ^ Int.toString (natToInt j) ^
+ ",\"reason\":" ^ jsonStr (reasonStr r)
+ | OOHorn.ParseError => ",\"ok\":false,\"error\":\"parse\""
+ in head ^ body ^ "}" end;
+
+fun runOne rulesF assertedF certF =
+ let
+ val R = rows (readFile rulesF)
+ val G = rows (readFile assertedF)
+ val C = rows (readFile certF)
+ val strict = OOHorn.run_check R G C
+ val lenient = OOHorn.run_check_lenient R G C
+ in
+ (reportJson rulesF assertedF certF strict lenient, exitCode strict)
+ end
+ handle ReadError p =>
+ (* An unreadable file is exit 2, the same as an unparseable one and the same as the
+ Lean side. It must never look like a rejection: exit 1 says a step was checked
+ and found wanting, and nothing was checked here. *)
+ ("{\"checker\":\"isabelle-OOHorn\",\"ok\":false,\"error\":\"read\",\"path\":" ^
+ jsonStr p ^ ",\"exit\":2}", 2);
+
+(* OS.Process.exit only offers success and failure, so exact exit codes go through
+ Posix.Process.exit. *)
+fun exitWith 0 = OS.Process.exit OS.Process.success
+ | exitWith n = Posix.Process.exit (Word8.fromInt n);
+
+fun checkMode r a c =
+ let val (json, code) = runOne r a c
+ in
+ print (json ^ "\n");
+ if code = 2 then TextIO.output (TextIO.stdErr, "cannot read or parse one of the inputs\n")
+ else ();
+ exitWith code
+ end;
+
+fun batchMode manifest =
+ let
+ val text = readFile manifest
+ val lines = List.filter (fn l => l <> "") (splitOn #"\n" text)
+ fun one line =
+ case splitOn #"\t" line of
+ [r,a,c] => print (#1 (runOne r a c) ^ "\n")
+ | _ => print ("{\"checker\":\"isabelle-OOHorn\",\"ok\":false,\"error\":\"manifest\"," ^
+ "\"line\":" ^ jsonStr line ^ ",\"exit\":3}\n")
+ in
+ List.app one lines;
+ exitWith 0
+ end
+ handle ReadError p =>
+ (TextIO.output (TextIO.stdErr, "cannot read manifest " ^ p ^ "\n"); exitWith 2);
+
+(* Is this file the table embedded in OO_Check.thy? verdict_of answers by equality
+ against builtin_table, so `entailed` here means the bytes ARE the embedded table. *)
+fun tableMode rulesF =
+ let val R = rows (readFile rulesF)
+ in
+ case OOHorn.parse_rules R of
+ NONE => (print "{\"checker\":\"isabelle-OOHorn\",\"ok\":false,\"error\":\"parse\"}\n";
+ exitWith 2)
+ | SOME rs =>
+ (print ("{\"checker\":\"isabelle-OOHorn\",\"table_verdict\":" ^
+ jsonStr (verdictStr (OOHorn.verdict_of rs)) ^ "}\n");
+ exitWith 0)
+ end
+ handle ReadError p =>
+ (TextIO.output (TextIO.stdErr, "cannot read " ^ p ^ "\n"); exitWith 2);
+
+fun usage () =
+ (TextIO.output (TextIO.stdErr,
+ "usage: oo-horn-isabelle check RULES.tsv ASSERTED.tsv CERT.tsv\n\
+ \ oo-horn-isabelle batch MANIFEST.tsv\n\
+ \ oo-horn-isabelle table RULES.tsv\n");
+ exitWith 2);
+
+fun main () =
+ case CommandLine.arguments () of
+ ["check", r, a, c] => checkMode r a c
+ | [r, a, c] => checkMode r a c (* the shape run_checker.sh already uses *)
+ | ["batch", m] => batchMode m
+ | ["table", r] => tableMode r
+ | _ => usage ();
diff --git a/isabelle/fixtures-differential/README.md b/isabelle/fixtures-differential/README.md
new file mode 100644
index 00000000..337d2349
--- /dev/null
+++ b/isabelle/fixtures-differential/README.md
@@ -0,0 +1,78 @@
+# `fixtures-differential/` — where the two kernels part company, and where they do not
+
+Committed bytes for `tests/cross_kernel_differential_test.rs`. Two kinds of file.
+
+## The divergences
+
+Certificates that `lean/.lake/build/bin/oo-horn` and `isabelle/build/oo-horn-isabelle`
+judge **differently**. They are committed so the result is reproducible from the
+repository rather than from a generator, and neither checker was adjusted to make them
+agree.
+
+| files | what it is | Lean | Isabelle |
+|---|---|---|---|
+| `varname_rules.tsv`, `varname_asserted.tsv`, `varname_unbound_cert.tsv` | **D2a.** The binding omits `s`; the graph's subject is the bare term `s`, spelled exactly like the rule's variable. Lean's `substOf` sends an unbound variable to its own name, so the step checks. | accepts | rejects, `binding_incomplete` |
+| `varname_bound_cert.tsv` | the control for D2a: bind `s` as well and both accept. Without it the divergence could be about anything in those three files. | accepts | accepts |
+| `unsafehead_rules.tsv`, `unsafehead_asserted.tsv`, `unsafehead_cert.tsv` | **D2b**, the sharp form. The rule's head carries `?z`, which its body never binds, and the certificate omits `z`. Lean accepts a conclusion whose object is the bare term `z` — not an IRI, not a blank node, not a literal — minted out of a variable's name. | accepts | rejects, `binding_incomplete` |
+| `d2c_fuzzfound_rules.tsv`, `d2c_fuzzfound_asserted.tsv`, `d2c_fuzzfound_cert.tsv` | **D2c**, and nobody designed it. The seeded fuzzer changed one field of `probe_degen2_rules.tsv`: `?o` became a bare `?`, which both parsers read as a variable whose NAME IS THE EMPTY STRING. The graph's object is an empty field, so Lean's default sends `""` to `""` and the step checks. The hole is reachable by a typo. | accepts | rejects, `binding_incomplete` |
+
+**D1** needs no file here: it is `../fixtures-added/bad_dup_key.tsv`, which binds `x` twice.
+Isabelle rejects a repeated binding key as malformed; Lean resolves it with `List.lookup`,
+which is first-wins, and accepts with the ABSOLUTE verdict.
+
+All three have one root cause. Isabelle's `check_step` validates the binding list as a
+data structure — `distinct (map fst b)`, then `binding_covers b r` — before instantiating
+anything. Lean's `substOf` is `fun v => (List.lookup v l).getD v`: it turns any binding
+list into a total function with a silent default and never inspects it.
+
+Neither checker is unsound. Lean's acceptances hold in Lean's own theorem, because
+`EntailsR` quantifies over every total substitution and the one Lean used is real;
+Isabelle's rejections are false alarms. What is wrong is the FORMAT, which does not say
+whether a binding must have distinct keys or must cover the cited rule's variables. Until
+it does, a certificate's validity depends on which verified checker reads it.
+
+## The probes
+
+`probe_<name>_{rules,asserted,cert}.tsv`. Corners of the term format that **no generated
+certificate reaches**, because the engine writes IRIs and every RDF fixture in this
+repository is ASCII. Both kernels agree on all of them; the expected answer is written
+down in `the_untested_corners_of_the_term_format_agree`, because agreement on the WRONG
+answer is the one failure a differential cannot see by itself.
+
+| probe | what it exercises | expected |
+|---|---|---|
+| `utf8` | non-ASCII IRIs (`café`, CJK, an emoji) in rule, graph and certificate | accepted |
+| `utf8bad` | one byte of a non-ASCII IRI altered in the certificate | rejected |
+| `literals` | a language-tagged literal and a datatyped literal | accepted |
+| `litdt` | `"01"^^xsd:integer` standing in for `"1"^^xsd:integer` — one value, two terms | rejected |
+| `bnode` | blank node labels in subject and object | accepted |
+| `degen` | the degenerate spellings `<>` and `_:` | accepted |
+| `degen2` | a bare `<` and an empty field, as terms | accepted |
+| `inject` | `http://ex.org/a` without its brackets, against `<http://ex.org/a>` with them | rejected |
+| `emptybody` | a rule with an empty body, cited with no premises | accepted |
+| `repeated` | a rule whose body repeats one atom, cited twice | accepted |
+| `extrabind` | a binding for a variable the rule never mentions | accepted |
+| `qmarkkey` | binding keys written WITH the leading `?` | rejected |
+| `emptyall` | an empty rule table and an empty certificate | accepted |
+| `emptyrules` | an empty rule table and a step citing rule 0 | rejected |
+| `emptygraph` | an empty graph and a rule with an empty body | accepted |
+| `allempty` | all three files empty | accepted |
+| `duprow` | the built-in table with one row duplicated AFTER the cited index | accepted, relativised verdict |
+| `trailtab` | a trailing tab on every certificate line | exit 2 |
+| `crlf` | CRLF endings, so every last field carries a stray carriage return | rejected |
+| `blank` | blank lines at the start and end of all three files | accepted |
+| `nonl` | no trailing newline anywhere | accepted |
+| `hugeidx` | a rule index of 200 digits | rejected |
+
+The expected answer is an EXIT CODE, not a bit, because 2 is a third answer: a checker
+that quietly turned an unparseable file into a rejection would still look like agreement
+on the accept/reject bit alone.
+
+`utf8` settles DECISION M38's open worry: the fixtures being pure ASCII is "exactly the
+circumstance in which a `String.literal` implementation would stay silent", and the
+verified core is over `string = char list`, so the bytes reach the theorem unchanged.
+`litdt` settles M1's scope note. `inject` settles the injectivity that D-PARSE-2 needs for
+bracket-stripping to be invisible to the accept/reject bit.
+
+These also join the corpus as base cases, so they are mutated and fuzzed like everything
+else rather than only being checked once.
diff --git a/isabelle/fixtures-differential/d2c_fuzzfound_asserted.tsv b/isabelle/fixtures-differential/d2c_fuzzfound_asserted.tsv
new file mode 100644
index 00000000..f9f923ac
--- /dev/null
+++ b/isabelle/fixtures-differential/d2c_fuzzfound_asserted.tsv
@@ -0,0 +1 @@
+< <http://ex.org/p>
diff --git a/isabelle/fixtures-differential/d2c_fuzzfound_cert.tsv b/isabelle/fixtures-differential/d2c_fuzzfound_cert.tsv
new file mode 100644
index 00000000..1b3e63aa
--- /dev/null
+++ b/isabelle/fixtures-differential/d2c_fuzzfound_cert.tsv
@@ -0,0 +1 @@
+0 2 s < o < <http://ex.org/q> < <http://ex.org/p>
diff --git a/isabelle/fixtures-differential/d2c_fuzzfound_rules.tsv b/isabelle/fixtures-differential/d2c_fuzzfound_rules.tsv
new file mode 100644
index 00000000..b3cc34fc
--- /dev/null
+++ b/isabelle/fixtures-differential/d2c_fuzzfound_rules.tsv
@@ -0,0 +1 @@
+deg 1 ?s <http://ex.org/p> ? ?s <http://ex.org/q> ?o
diff --git a/isabelle/fixtures-differential/probe_allempty_asserted.tsv b/isabelle/fixtures-differential/probe_allempty_asserted.tsv
new file mode 100644
index 00000000..e69de29b
diff --git a/isabelle/fixtures-differential/probe_allempty_cert.tsv b/isabelle/fixtures-differential/probe_allempty_cert.tsv
new file mode 100644
index 00000000..e69de29b
diff --git a/isabelle/fixtures-differential/probe_allempty_rules.tsv b/isabelle/fixtures-differential/probe_allempty_rules.tsv
new file mode 100644
index 00000000..e69de29b
diff --git a/isabelle/fixtures-differential/probe_blank_asserted.tsv b/isabelle/fixtures-differential/probe_blank_asserted.tsv
new file mode 100644
index 00000000..db061eda
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_blank_asserted.tsv
@@ -0,0 +1,2 @@
+<http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
+
diff --git a/isabelle/fixtures-differential/probe_blank_cert.tsv b/isabelle/fixtures-differential/probe_blank_cert.tsv
new file mode 100644
index 00000000..3ce6fc85
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_blank_cert.tsv
@@ -0,0 +1,3 @@
+
+0 2 s <http://ex.org/a> o <http://ex.org/b> <http://ex.org/a> <http://ex.org/q> <http://ex.org/b> <http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
+
diff --git a/isabelle/fixtures-differential/probe_blank_rules.tsv b/isabelle/fixtures-differential/probe_blank_rules.tsv
new file mode 100644
index 00000000..f6dc2aaf
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_blank_rules.tsv
@@ -0,0 +1,2 @@
+r 1 ?s <http://ex.org/p> ?o ?s <http://ex.org/q> ?o
+
diff --git a/isabelle/fixtures-differential/probe_bnode_asserted.tsv b/isabelle/fixtures-differential/probe_bnode_asserted.tsv
new file mode 100644
index 00000000..f2f3b475
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_bnode_asserted.tsv
@@ -0,0 +1 @@
+_:b1 <http://ex.org/p> _:b2
diff --git a/isabelle/fixtures-differential/probe_bnode_cert.tsv b/isabelle/fixtures-differential/probe_bnode_cert.tsv
new file mode 100644
index 00000000..cb822ec1
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_bnode_cert.tsv
@@ -0,0 +1 @@
+0 2 s _:b1 o _:b2 _:b1 <http://ex.org/q> _:b2 _:b1 <http://ex.org/p> _:b2
diff --git a/isabelle/fixtures-differential/probe_bnode_rules.tsv b/isabelle/fixtures-differential/probe_bnode_rules.tsv
new file mode 100644
index 00000000..d5cff4da
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_bnode_rules.tsv
@@ -0,0 +1 @@
+bn 1 ?s <http://ex.org/p> ?o ?s <http://ex.org/q> ?o
diff --git a/isabelle/fixtures-differential/probe_crlf_asserted.tsv b/isabelle/fixtures-differential/probe_crlf_asserted.tsv
new file mode 100644
index 00000000..5d16351c
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_crlf_asserted.tsv
@@ -0,0 +1,2 @@
+<http://ex.org/a> <http://ex.org/t> <http://ex.org/A>
+<http://ex.org/A> <http://ex.org/sc> <http://ex.org/B>
diff --git a/isabelle/fixtures-differential/probe_crlf_cert.tsv b/isabelle/fixtures-differential/probe_crlf_cert.tsv
new file mode 100644
index 00000000..2ec91a2d
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_crlf_cert.tsv
@@ -0,0 +1 @@
+0 3 x <http://ex.org/a> a <http://ex.org/A> b <http://ex.org/B> <http://ex.org/a> <http://ex.org/t> <http://ex.org/B> <http://ex.org/a> <http://ex.org/t> <http://ex.org/A> <http://ex.org/A> <http://ex.org/sc> <http://ex.org/B>
diff --git a/isabelle/fixtures-differential/probe_crlf_rules.tsv b/isabelle/fixtures-differential/probe_crlf_rules.tsv
new file mode 100644
index 00000000..88059c8c
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_crlf_rules.tsv
@@ -0,0 +1 @@
+rdfs9ish 2 ?x <http://ex.org/t> ?a ?a <http://ex.org/sc> ?b ?x <http://ex.org/t> ?b
diff --git a/isabelle/fixtures-differential/probe_degen2_asserted.tsv b/isabelle/fixtures-differential/probe_degen2_asserted.tsv
new file mode 100644
index 00000000..f9f923ac
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_degen2_asserted.tsv
@@ -0,0 +1 @@
+< <http://ex.org/p>
diff --git a/isabelle/fixtures-differential/probe_degen2_cert.tsv b/isabelle/fixtures-differential/probe_degen2_cert.tsv
new file mode 100644
index 00000000..1b3e63aa
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_degen2_cert.tsv
@@ -0,0 +1 @@
+0 2 s < o < <http://ex.org/q> < <http://ex.org/p>
diff --git a/isabelle/fixtures-differential/probe_degen2_rules.tsv b/isabelle/fixtures-differential/probe_degen2_rules.tsv
new file mode 100644
index 00000000..1b9081f8
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_degen2_rules.tsv
@@ -0,0 +1 @@
+deg 1 ?s <http://ex.org/p> ?o ?s <http://ex.org/q> ?o
diff --git a/isabelle/fixtures-differential/probe_degen_asserted.tsv b/isabelle/fixtures-differential/probe_degen_asserted.tsv
new file mode 100644
index 00000000..4feb1202
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_degen_asserted.tsv
@@ -0,0 +1 @@
+<> <http://ex.org/p> _:
diff --git a/isabelle/fixtures-differential/probe_degen_cert.tsv b/isabelle/fixtures-differential/probe_degen_cert.tsv
new file mode 100644
index 00000000..21360cb8
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_degen_cert.tsv
@@ -0,0 +1 @@
+0 2 s <> o _: <> <http://ex.org/q> _: <> <http://ex.org/p> _:
diff --git a/isabelle/fixtures-differential/probe_degen_rules.tsv b/isabelle/fixtures-differential/probe_degen_rules.tsv
new file mode 100644
index 00000000..1b9081f8
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_degen_rules.tsv
@@ -0,0 +1 @@
+deg 1 ?s <http://ex.org/p> ?o ?s <http://ex.org/q> ?o
diff --git a/isabelle/fixtures-differential/probe_duprow_asserted.tsv b/isabelle/fixtures-differential/probe_duprow_asserted.tsv
new file mode 100644
index 00000000..388a220d
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_duprow_asserted.tsv
@@ -0,0 +1,2 @@
+<http://ex.org/a> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://ex.org/A>
+<http://ex.org/A> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ex.org/B>
diff --git a/isabelle/fixtures-differential/probe_duprow_cert.tsv b/isabelle/fixtures-differential/probe_duprow_cert.tsv
new file mode 100644
index 00000000..e73ccd68
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_duprow_cert.tsv
@@ -0,0 +1 @@
+4 3 x <http://ex.org/a> a <http://ex.org/A> b <http://ex.org/B> <http://ex.org/a> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://ex.org/B> <http://ex.org/a> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://ex.org/A> <http://ex.org/A> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ex.org/B>
diff --git a/isabelle/fixtures-differential/probe_duprow_rules.tsv b/isabelle/fixtures-differential/probe_duprow_rules.tsv
new file mode 100644
index 00000000..0025e463
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_duprow_rules.tsv
@@ -0,0 +1,28 @@
+rdfs2 2 ?s ?p ?o ?p <http://www.w3.org/2000/01/rdf-schema#domain> ?c ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?c
+rdfs3 2 ?s ?p ?o ?p <http://www.w3.org/2000/01/rdf-schema#range> ?c ?o <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?c
+rdfs5 2 ?a <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?b ?b <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?c ?a <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?c
+rdfs7 2 ?s ?p ?o ?p <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?q ?s ?q ?o
+rdfs9 2 ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?a ?a <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?b ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?b
+rdfs9 2 ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?a ?a <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?b ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?b
+rdfs11 2 ?a <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?b ?b <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c ?a <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c
+prp-trp 3 ?p <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#TransitiveProperty> ?x ?p ?y ?y ?p ?z ?x ?p ?z
+prp-symp 2 ?p <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#SymmetricProperty> ?x ?p ?y ?y ?p ?x
+prp-inv1 2 ?p <http://www.w3.org/2002/07/owl#inverseOf> ?q ?x ?p ?y ?y ?q ?x
+prp-inv2 2 ?p <http://www.w3.org/2002/07/owl#inverseOf> ?q ?x ?q ?y ?y ?p ?x
+eq-sym 1 ?a <http://www.w3.org/2002/07/owl#sameAs> ?b ?b <http://www.w3.org/2002/07/owl#sameAs> ?a
+scm-eqc1 1 ?a <http://www.w3.org/2002/07/owl#equivalentClass> ?b ?a <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?b
+scm-eqc1 1 ?a <http://www.w3.org/2002/07/owl#equivalentClass> ?b ?b <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?a
+scm-eqp1 1 ?a <http://www.w3.org/2002/07/owl#equivalentProperty> ?b ?a <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?b
+scm-eqp1 1 ?a <http://www.w3.org/2002/07/owl#equivalentProperty> ?b ?b <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?a
+cls-svf1 4 ?r <http://www.w3.org/2002/07/owl#onProperty> ?p ?r <http://www.w3.org/2002/07/owl#someValuesFrom> ?c ?x ?p ?y ?y <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?c ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?r
+cls-avf 4 ?r <http://www.w3.org/2002/07/owl#onProperty> ?p ?r <http://www.w3.org/2002/07/owl#allValuesFrom> ?c ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?r ?x ?p ?y ?y <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?c
+cls-hv1 3 ?r <http://www.w3.org/2002/07/owl#onProperty> ?p ?r <http://www.w3.org/2002/07/owl#hasValue> ?v ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?r ?x ?p ?v
+cls-hv2 3 ?r <http://www.w3.org/2002/07/owl#onProperty> ?p ?r <http://www.w3.org/2002/07/owl#hasValue> ?v ?x ?p ?v ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?r
+scm-svf1 5 ?c1 <http://www.w3.org/2002/07/owl#someValuesFrom> ?y1 ?c1 <http://www.w3.org/2002/07/owl#onProperty> ?p ?c2 <http://www.w3.org/2002/07/owl#someValuesFrom> ?y2 ?c2 <http://www.w3.org/2002/07/owl#onProperty> ?p ?y1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?y2 ?c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c2
+scm-svf2 5 ?c1 <http://www.w3.org/2002/07/owl#someValuesFrom> ?y ?c1 <http://www.w3.org/2002/07/owl#onProperty> ?p1 ?c2 <http://www.w3.org/2002/07/owl#someValuesFrom> ?y ?c2 <http://www.w3.org/2002/07/owl#onProperty> ?p2 ?p1 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?p2 ?c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c2
+scm-avf1 5 ?c1 <http://www.w3.org/2002/07/owl#allValuesFrom> ?y1 ?c1 <http://www.w3.org/2002/07/owl#onProperty> ?p ?c2 <http://www.w3.org/2002/07/owl#allValuesFrom> ?y2 ?c2 <http://www.w3.org/2002/07/owl#onProperty> ?p ?y1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?y2 ?c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c2
+scm-avf2 5 ?c1 <http://www.w3.org/2002/07/owl#allValuesFrom> ?y ?c1 <http://www.w3.org/2002/07/owl#onProperty> ?p1 ?c2 <http://www.w3.org/2002/07/owl#allValuesFrom> ?y ?c2 <http://www.w3.org/2002/07/owl#onProperty> ?p2 ?p1 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?p2 ?c2 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c1
+scm-dom1 2 ?p <http://www.w3.org/2000/01/rdf-schema#domain> ?c1 ?c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c2 ?p <http://www.w3.org/2000/01/rdf-schema#domain> ?c2
+scm-dom2 2 ?p2 <http://www.w3.org/2000/01/rdf-schema#domain> ?c ?p1 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?p2 ?p1 <http://www.w3.org/2000/01/rdf-schema#domain> ?c
+scm-rng1 2 ?p <http://www.w3.org/2000/01/rdf-schema#range> ?c1 ?c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c2 ?p <http://www.w3.org/2000/01/rdf-schema#range> ?c2
+scm-rng2 2 ?p2 <http://www.w3.org/2000/01/rdf-schema#range> ?c ?p1 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?p2 ?p1 <http://www.w3.org/2000/01/rdf-schema#range> ?c
diff --git a/isabelle/fixtures-differential/probe_emptyall_asserted.tsv b/isabelle/fixtures-differential/probe_emptyall_asserted.tsv
new file mode 100644
index 00000000..e9647e44
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_emptyall_asserted.tsv
@@ -0,0 +1 @@
+<http://ex.org/a> <http://ex.org/b> <http://ex.org/c>
diff --git a/isabelle/fixtures-differential/probe_emptyall_cert.tsv b/isabelle/fixtures-differential/probe_emptyall_cert.tsv
new file mode 100644
index 00000000..e69de29b
diff --git a/isabelle/fixtures-differential/probe_emptyall_rules.tsv b/isabelle/fixtures-differential/probe_emptyall_rules.tsv
new file mode 100644
index 00000000..e69de29b
diff --git a/isabelle/fixtures-differential/probe_emptybody_asserted.tsv b/isabelle/fixtures-differential/probe_emptybody_asserted.tsv
new file mode 100644
index 00000000..535462f5
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_emptybody_asserted.tsv
@@ -0,0 +1 @@
+<http://ex.org/x> <http://ex.org/y> <http://ex.org/z>
diff --git a/isabelle/fixtures-differential/probe_emptybody_cert.tsv b/isabelle/fixtures-differential/probe_emptybody_cert.tsv
new file mode 100644
index 00000000..05e6d677
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_emptybody_cert.tsv
@@ -0,0 +1 @@
+0 0 <http://ex.org/a> <http://ex.org/b> <http://ex.org/c>
diff --git a/isabelle/fixtures-differential/probe_emptybody_rules.tsv b/isabelle/fixtures-differential/probe_emptybody_rules.tsv
new file mode 100644
index 00000000..746944e8
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_emptybody_rules.tsv
@@ -0,0 +1 @@
+fact 0 <http://ex.org/a> <http://ex.org/b> <http://ex.org/c>
diff --git a/isabelle/fixtures-differential/probe_emptygraph_asserted.tsv b/isabelle/fixtures-differential/probe_emptygraph_asserted.tsv
new file mode 100644
index 00000000..e69de29b
diff --git a/isabelle/fixtures-differential/probe_emptygraph_cert.tsv b/isabelle/fixtures-differential/probe_emptygraph_cert.tsv
new file mode 100644
index 00000000..05e6d677
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_emptygraph_cert.tsv
@@ -0,0 +1 @@
+0 0 <http://ex.org/a> <http://ex.org/b> <http://ex.org/c>
diff --git a/isabelle/fixtures-differential/probe_emptygraph_rules.tsv b/isabelle/fixtures-differential/probe_emptygraph_rules.tsv
new file mode 100644
index 00000000..746944e8
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_emptygraph_rules.tsv
@@ -0,0 +1 @@
+fact 0 <http://ex.org/a> <http://ex.org/b> <http://ex.org/c>
diff --git a/isabelle/fixtures-differential/probe_emptyrules_asserted.tsv b/isabelle/fixtures-differential/probe_emptyrules_asserted.tsv
new file mode 100644
index 00000000..e9647e44
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_emptyrules_asserted.tsv
@@ -0,0 +1 @@
+<http://ex.org/a> <http://ex.org/b> <http://ex.org/c>
diff --git a/isabelle/fixtures-differential/probe_emptyrules_cert.tsv b/isabelle/fixtures-differential/probe_emptyrules_cert.tsv
new file mode 100644
index 00000000..05e6d677
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_emptyrules_cert.tsv
@@ -0,0 +1 @@
+0 0 <http://ex.org/a> <http://ex.org/b> <http://ex.org/c>
diff --git a/isabelle/fixtures-differential/probe_emptyrules_rules.tsv b/isabelle/fixtures-differential/probe_emptyrules_rules.tsv
new file mode 100644
index 00000000..e69de29b
diff --git a/isabelle/fixtures-differential/probe_extrabind_asserted.tsv b/isabelle/fixtures-differential/probe_extrabind_asserted.tsv
new file mode 100644
index 00000000..58006dbc
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_extrabind_asserted.tsv
@@ -0,0 +1 @@
+<http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
diff --git a/isabelle/fixtures-differential/probe_extrabind_cert.tsv b/isabelle/fixtures-differential/probe_extrabind_cert.tsv
new file mode 100644
index 00000000..f6940e5f
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_extrabind_cert.tsv
@@ -0,0 +1 @@
+0 3 x <http://ex.org/a> y <http://ex.org/b> GHOST <http://ex.org/zzz> <http://ex.org/a> <http://ex.org/q> <http://ex.org/b> <http://ex.org/a> <http://ex.org/p> <http://ex.org/b> <http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
diff --git a/isabelle/fixtures-differential/probe_extrabind_rules.tsv b/isabelle/fixtures-differential/probe_extrabind_rules.tsv
new file mode 100644
index 00000000..1766897d
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_extrabind_rules.tsv
@@ -0,0 +1 @@
+rep 2 ?x <http://ex.org/p> ?y ?x <http://ex.org/p> ?y ?x <http://ex.org/q> ?y
diff --git a/isabelle/fixtures-differential/probe_hugeidx_asserted.tsv b/isabelle/fixtures-differential/probe_hugeidx_asserted.tsv
new file mode 100644
index 00000000..db061eda
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_hugeidx_asserted.tsv
@@ -0,0 +1,2 @@
+<http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
+
diff --git a/isabelle/fixtures-differential/probe_hugeidx_cert.tsv b/isabelle/fixtures-differential/probe_hugeidx_cert.tsv
new file mode 100644
index 00000000..817028bc
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_hugeidx_cert.tsv
@@ -0,0 +1 @@
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005 2 s <http://ex.org/a> o <http://ex.org/b> <http://ex.org/a> <http://ex.org/q> <http://ex.org/b> <http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
diff --git a/isabelle/fixtures-differential/probe_hugeidx_rules.tsv b/isabelle/fixtures-differential/probe_hugeidx_rules.tsv
new file mode 100644
index 00000000..f6dc2aaf
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_hugeidx_rules.tsv
@@ -0,0 +1,2 @@
+r 1 ?s <http://ex.org/p> ?o ?s <http://ex.org/q> ?o
+
diff --git a/isabelle/fixtures-differential/probe_inject_asserted.tsv b/isabelle/fixtures-differential/probe_inject_asserted.tsv
new file mode 100644
index 00000000..a467fa80
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_inject_asserted.tsv
@@ -0,0 +1 @@
+http://ex.org/a <http://ex.org/p> <http://ex.org/b>
diff --git a/isabelle/fixtures-differential/probe_inject_cert.tsv b/isabelle/fixtures-differential/probe_inject_cert.tsv
new file mode 100644
index 00000000..5c19472d
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_inject_cert.tsv
@@ -0,0 +1 @@
+0 2 s <http://ex.org/a> o <http://ex.org/b> <http://ex.org/a> <http://ex.org/q> <http://ex.org/b> <http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
diff --git a/isabelle/fixtures-differential/probe_inject_rules.tsv b/isabelle/fixtures-differential/probe_inject_rules.tsv
new file mode 100644
index 00000000..e3184951
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_inject_rules.tsv
@@ -0,0 +1 @@
+inj 1 ?s <http://ex.org/p> ?o ?s <http://ex.org/q> ?o
diff --git a/isabelle/fixtures-differential/probe_litdt_asserted.tsv b/isabelle/fixtures-differential/probe_litdt_asserted.tsv
new file mode 100644
index 00000000..7a7c8775
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_litdt_asserted.tsv
@@ -0,0 +1 @@
+<http://ex.org/a> <http://ex.org/label> "01"^^<http://www.w3.org/2001/XMLSchema#integer>
diff --git a/isabelle/fixtures-differential/probe_litdt_cert.tsv b/isabelle/fixtures-differential/probe_litdt_cert.tsv
new file mode 100644
index 00000000..0f95bbfc
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_litdt_cert.tsv
@@ -0,0 +1 @@
+0 2 s <http://ex.org/a> o "1"^^<http://www.w3.org/2001/XMLSchema#integer> <http://ex.org/a> <http://ex.org/tag> "1"^^<http://www.w3.org/2001/XMLSchema#integer> <http://ex.org/a> <http://ex.org/label> "1"^^<http://www.w3.org/2001/XMLSchema#integer>
diff --git a/isabelle/fixtures-differential/probe_litdt_rules.tsv b/isabelle/fixtures-differential/probe_litdt_rules.tsv
new file mode 100644
index 00000000..6bf19304
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_litdt_rules.tsv
@@ -0,0 +1 @@
+lit 1 ?s <http://ex.org/label> ?o ?s <http://ex.org/tag> ?o
diff --git a/isabelle/fixtures-differential/probe_literals_asserted.tsv b/isabelle/fixtures-differential/probe_literals_asserted.tsv
new file mode 100644
index 00000000..654a2f29
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_literals_asserted.tsv
@@ -0,0 +1,2 @@
+<http://ex.org/a> <http://ex.org/label> "hello"@en
+<http://ex.org/b> <http://ex.org/label> "42"^^<http://www.w3.org/2001/XMLSchema#integer>
diff --git a/isabelle/fixtures-differential/probe_literals_cert.tsv b/isabelle/fixtures-differential/probe_literals_cert.tsv
new file mode 100644
index 00000000..87df5048
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_literals_cert.tsv
@@ -0,0 +1,2 @@
+0 2 s <http://ex.org/a> o "hello"@en <http://ex.org/a> <http://ex.org/tag> "hello"@en <http://ex.org/a> <http://ex.org/label> "hello"@en
+0 2 s <http://ex.org/b> o "42"^^<http://www.w3.org/2001/XMLSchema#integer> <http://ex.org/b> <http://ex.org/tag> "42"^^<http://www.w3.org/2001/XMLSchema#integer> <http://ex.org/b> <http://ex.org/label> "42"^^<http://www.w3.org/2001/XMLSchema#integer>
diff --git a/isabelle/fixtures-differential/probe_literals_rules.tsv b/isabelle/fixtures-differential/probe_literals_rules.tsv
new file mode 100644
index 00000000..6bf19304
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_literals_rules.tsv
@@ -0,0 +1 @@
+lit 1 ?s <http://ex.org/label> ?o ?s <http://ex.org/tag> ?o
diff --git a/isabelle/fixtures-differential/probe_nonl_asserted.tsv b/isabelle/fixtures-differential/probe_nonl_asserted.tsv
new file mode 100644
index 00000000..c78f867d
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_nonl_asserted.tsv
@@ -0,0 +1 @@
+<http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
\ No newline at end of file
diff --git a/isabelle/fixtures-differential/probe_nonl_cert.tsv b/isabelle/fixtures-differential/probe_nonl_cert.tsv
new file mode 100644
index 00000000..1c967486
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_nonl_cert.tsv
@@ -0,0 +1 @@
+0 2 s <http://ex.org/a> o <http://ex.org/b> <http://ex.org/a> <http://ex.org/q> <http://ex.org/b> <http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
\ No newline at end of file
diff --git a/isabelle/fixtures-differential/probe_nonl_rules.tsv b/isabelle/fixtures-differential/probe_nonl_rules.tsv
new file mode 100644
index 00000000..0387da3f
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_nonl_rules.tsv
@@ -0,0 +1 @@
+r 1 ?s <http://ex.org/p> ?o ?s <http://ex.org/q> ?o
\ No newline at end of file
diff --git a/isabelle/fixtures-differential/probe_qmarkkey_asserted.tsv b/isabelle/fixtures-differential/probe_qmarkkey_asserted.tsv
new file mode 100644
index 00000000..58006dbc
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_qmarkkey_asserted.tsv
@@ -0,0 +1 @@
+<http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
diff --git a/isabelle/fixtures-differential/probe_qmarkkey_cert.tsv b/isabelle/fixtures-differential/probe_qmarkkey_cert.tsv
new file mode 100644
index 00000000..1c12ba74
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_qmarkkey_cert.tsv
@@ -0,0 +1 @@
+0 2 ?x <http://ex.org/a> ?y <http://ex.org/b> <http://ex.org/a> <http://ex.org/q> <http://ex.org/b> <http://ex.org/a> <http://ex.org/p> <http://ex.org/b> <http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
diff --git a/isabelle/fixtures-differential/probe_qmarkkey_rules.tsv b/isabelle/fixtures-differential/probe_qmarkkey_rules.tsv
new file mode 100644
index 00000000..1766897d
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_qmarkkey_rules.tsv
@@ -0,0 +1 @@
+rep 2 ?x <http://ex.org/p> ?y ?x <http://ex.org/p> ?y ?x <http://ex.org/q> ?y
diff --git a/isabelle/fixtures-differential/probe_repeated_asserted.tsv b/isabelle/fixtures-differential/probe_repeated_asserted.tsv
new file mode 100644
index 00000000..58006dbc
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_repeated_asserted.tsv
@@ -0,0 +1 @@
+<http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
diff --git a/isabelle/fixtures-differential/probe_repeated_cert.tsv b/isabelle/fixtures-differential/probe_repeated_cert.tsv
new file mode 100644
index 00000000..fad8ec51
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_repeated_cert.tsv
@@ -0,0 +1 @@
+0 2 x <http://ex.org/a> y <http://ex.org/b> <http://ex.org/a> <http://ex.org/q> <http://ex.org/b> <http://ex.org/a> <http://ex.org/p> <http://ex.org/b> <http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
diff --git a/isabelle/fixtures-differential/probe_repeated_rules.tsv b/isabelle/fixtures-differential/probe_repeated_rules.tsv
new file mode 100644
index 00000000..1766897d
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_repeated_rules.tsv
@@ -0,0 +1 @@
+rep 2 ?x <http://ex.org/p> ?y ?x <http://ex.org/p> ?y ?x <http://ex.org/q> ?y
diff --git a/isabelle/fixtures-differential/probe_trailtab_asserted.tsv b/isabelle/fixtures-differential/probe_trailtab_asserted.tsv
new file mode 100644
index 00000000..388a220d
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_trailtab_asserted.tsv
@@ -0,0 +1,2 @@
+<http://ex.org/a> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://ex.org/A>
+<http://ex.org/A> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ex.org/B>
diff --git a/isabelle/fixtures-differential/probe_trailtab_cert.tsv b/isabelle/fixtures-differential/probe_trailtab_cert.tsv
new file mode 100644
index 00000000..57d3094d
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_trailtab_cert.tsv
@@ -0,0 +1 @@
+4 3 x <http://ex.org/a> a <http://ex.org/A> b <http://ex.org/B> <http://ex.org/a> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://ex.org/B> <http://ex.org/a> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://ex.org/A> <http://ex.org/A> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ex.org/B>
diff --git a/isabelle/fixtures-differential/probe_trailtab_rules.tsv b/isabelle/fixtures-differential/probe_trailtab_rules.tsv
new file mode 100644
index 00000000..19ffe87e
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_trailtab_rules.tsv
@@ -0,0 +1,27 @@
+rdfs2 2 ?s ?p ?o ?p <http://www.w3.org/2000/01/rdf-schema#domain> ?c ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?c
+rdfs3 2 ?s ?p ?o ?p <http://www.w3.org/2000/01/rdf-schema#range> ?c ?o <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?c
+rdfs5 2 ?a <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?b ?b <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?c ?a <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?c
+rdfs7 2 ?s ?p ?o ?p <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?q ?s ?q ?o
+rdfs9 2 ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?a ?a <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?b ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?b
+rdfs11 2 ?a <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?b ?b <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c ?a <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c
+prp-trp 3 ?p <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#TransitiveProperty> ?x ?p ?y ?y ?p ?z ?x ?p ?z
+prp-symp 2 ?p <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#SymmetricProperty> ?x ?p ?y ?y ?p ?x
+prp-inv1 2 ?p <http://www.w3.org/2002/07/owl#inverseOf> ?q ?x ?p ?y ?y ?q ?x
+prp-inv2 2 ?p <http://www.w3.org/2002/07/owl#inverseOf> ?q ?x ?q ?y ?y ?p ?x
+eq-sym 1 ?a <http://www.w3.org/2002/07/owl#sameAs> ?b ?b <http://www.w3.org/2002/07/owl#sameAs> ?a
+scm-eqc1 1 ?a <http://www.w3.org/2002/07/owl#equivalentClass> ?b ?a <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?b
+scm-eqc1 1 ?a <http://www.w3.org/2002/07/owl#equivalentClass> ?b ?b <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?a
+scm-eqp1 1 ?a <http://www.w3.org/2002/07/owl#equivalentProperty> ?b ?a <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?b
+scm-eqp1 1 ?a <http://www.w3.org/2002/07/owl#equivalentProperty> ?b ?b <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?a
+cls-svf1 4 ?r <http://www.w3.org/2002/07/owl#onProperty> ?p ?r <http://www.w3.org/2002/07/owl#someValuesFrom> ?c ?x ?p ?y ?y <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?c ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?r
+cls-avf 4 ?r <http://www.w3.org/2002/07/owl#onProperty> ?p ?r <http://www.w3.org/2002/07/owl#allValuesFrom> ?c ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?r ?x ?p ?y ?y <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?c
+cls-hv1 3 ?r <http://www.w3.org/2002/07/owl#onProperty> ?p ?r <http://www.w3.org/2002/07/owl#hasValue> ?v ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?r ?x ?p ?v
+cls-hv2 3 ?r <http://www.w3.org/2002/07/owl#onProperty> ?p ?r <http://www.w3.org/2002/07/owl#hasValue> ?v ?x ?p ?v ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?r
+scm-svf1 5 ?c1 <http://www.w3.org/2002/07/owl#someValuesFrom> ?y1 ?c1 <http://www.w3.org/2002/07/owl#onProperty> ?p ?c2 <http://www.w3.org/2002/07/owl#someValuesFrom> ?y2 ?c2 <http://www.w3.org/2002/07/owl#onProperty> ?p ?y1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?y2 ?c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c2
+scm-svf2 5 ?c1 <http://www.w3.org/2002/07/owl#someValuesFrom> ?y ?c1 <http://www.w3.org/2002/07/owl#onProperty> ?p1 ?c2 <http://www.w3.org/2002/07/owl#someValuesFrom> ?y ?c2 <http://www.w3.org/2002/07/owl#onProperty> ?p2 ?p1 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?p2 ?c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c2
+scm-avf1 5 ?c1 <http://www.w3.org/2002/07/owl#allValuesFrom> ?y1 ?c1 <http://www.w3.org/2002/07/owl#onProperty> ?p ?c2 <http://www.w3.org/2002/07/owl#allValuesFrom> ?y2 ?c2 <http://www.w3.org/2002/07/owl#onProperty> ?p ?y1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?y2 ?c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c2
+scm-avf2 5 ?c1 <http://www.w3.org/2002/07/owl#allValuesFrom> ?y ?c1 <http://www.w3.org/2002/07/owl#onProperty> ?p1 ?c2 <http://www.w3.org/2002/07/owl#allValuesFrom> ?y ?c2 <http://www.w3.org/2002/07/owl#onProperty> ?p2 ?p1 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?p2 ?c2 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c1
+scm-dom1 2 ?p <http://www.w3.org/2000/01/rdf-schema#domain> ?c1 ?c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c2 ?p <http://www.w3.org/2000/01/rdf-schema#domain> ?c2
+scm-dom2 2 ?p2 <http://www.w3.org/2000/01/rdf-schema#domain> ?c ?p1 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?p2 ?p1 <http://www.w3.org/2000/01/rdf-schema#domain> ?c
+scm-rng1 2 ?p <http://www.w3.org/2000/01/rdf-schema#range> ?c1 ?c1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?c2 ?p <http://www.w3.org/2000/01/rdf-schema#range> ?c2
+scm-rng2 2 ?p2 <http://www.w3.org/2000/01/rdf-schema#range> ?c ?p1 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> ?p2 ?p1 <http://www.w3.org/2000/01/rdf-schema#range> ?c
diff --git a/isabelle/fixtures-differential/probe_utf8_asserted.tsv b/isabelle/fixtures-differential/probe_utf8_asserted.tsv
new file mode 100644
index 00000000..dad77f02
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_utf8_asserted.tsv
@@ -0,0 +1,2 @@
+<http://ex.org/café> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://ex.org/中文>
+<http://ex.org/中文> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ex.org/🎯>
diff --git a/isabelle/fixtures-differential/probe_utf8_cert.tsv b/isabelle/fixtures-differential/probe_utf8_cert.tsv
new file mode 100644
index 00000000..362cdce4
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_utf8_cert.tsv
@@ -0,0 +1 @@
+0 3 x <http://ex.org/café> a <http://ex.org/中文> b <http://ex.org/🎯> <http://ex.org/café> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://ex.org/🎯> <http://ex.org/café> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://ex.org/中文> <http://ex.org/中文> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ex.org/🎯>
diff --git a/isabelle/fixtures-differential/probe_utf8_rules.tsv b/isabelle/fixtures-differential/probe_utf8_rules.tsv
new file mode 100644
index 00000000..84bba3f2
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_utf8_rules.tsv
@@ -0,0 +1 @@
+rdfs9ish 2 ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?a ?a <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?b ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?b
diff --git a/isabelle/fixtures-differential/probe_utf8bad_asserted.tsv b/isabelle/fixtures-differential/probe_utf8bad_asserted.tsv
new file mode 100644
index 00000000..dad77f02
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_utf8bad_asserted.tsv
@@ -0,0 +1,2 @@
+<http://ex.org/café> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://ex.org/中文>
+<http://ex.org/中文> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ex.org/🎯>
diff --git a/isabelle/fixtures-differential/probe_utf8bad_cert.tsv b/isabelle/fixtures-differential/probe_utf8bad_cert.tsv
new file mode 100644
index 00000000..9c95fa91
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_utf8bad_cert.tsv
@@ -0,0 +1 @@
+0 3 x <http://ex.org/café> a <http://ex.org/中文> b <http://ex.org/🎯> <http://ex.org/café> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://ex.org/🚀> <http://ex.org/café> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://ex.org/中文> <http://ex.org/中文> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ex.org/🎯>
diff --git a/isabelle/fixtures-differential/probe_utf8bad_rules.tsv b/isabelle/fixtures-differential/probe_utf8bad_rules.tsv
new file mode 100644
index 00000000..84bba3f2
--- /dev/null
+++ b/isabelle/fixtures-differential/probe_utf8bad_rules.tsv
@@ -0,0 +1 @@
+rdfs9ish 2 ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?a ?a <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?b ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?b
diff --git a/isabelle/fixtures-differential/unsafehead_asserted.tsv b/isabelle/fixtures-differential/unsafehead_asserted.tsv
new file mode 100644
index 00000000..58006dbc
--- /dev/null
+++ b/isabelle/fixtures-differential/unsafehead_asserted.tsv
@@ -0,0 +1 @@
+<http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
diff --git a/isabelle/fixtures-differential/unsafehead_cert.tsv b/isabelle/fixtures-differential/unsafehead_cert.tsv
new file mode 100644
index 00000000..d028891b
--- /dev/null
+++ b/isabelle/fixtures-differential/unsafehead_cert.tsv
@@ -0,0 +1 @@
+0 2 s <http://ex.org/a> o <http://ex.org/b> <http://ex.org/a> <http://ex.org/q> z <http://ex.org/a> <http://ex.org/p> <http://ex.org/b>
diff --git a/isabelle/fixtures-differential/unsafehead_rules.tsv b/isabelle/fixtures-differential/unsafehead_rules.tsv
new file mode 100644
index 00000000..71172bac
--- /dev/null
+++ b/isabelle/fixtures-differential/unsafehead_rules.tsv
@@ -0,0 +1 @@
+unsafe 1 ?s <http://ex.org/p> ?o ?s <http://ex.org/q> ?z
diff --git a/isabelle/fixtures-differential/varname_asserted.tsv b/isabelle/fixtures-differential/varname_asserted.tsv
new file mode 100644
index 00000000..5d47a0ff
--- /dev/null
+++ b/isabelle/fixtures-differential/varname_asserted.tsv
@@ -0,0 +1 @@
+s <http://ex.org/p> <http://ex.org/b>
diff --git a/isabelle/fixtures-differential/varname_bound_cert.tsv b/isabelle/fixtures-differential/varname_bound_cert.tsv
new file mode 100644
index 00000000..d936e08d
--- /dev/null
+++ b/isabelle/fixtures-differential/varname_bound_cert.tsv
@@ -0,0 +1 @@
+0 2 s s o <http://ex.org/b> s <http://ex.org/q> <http://ex.org/b> s <http://ex.org/p> <http://ex.org/b>
diff --git a/isabelle/fixtures-differential/varname_rules.tsv b/isabelle/fixtures-differential/varname_rules.tsv
new file mode 100644
index 00000000..b7a296bc
--- /dev/null
+++ b/isabelle/fixtures-differential/varname_rules.tsv
@@ -0,0 +1 @@
+r0 1 ?s <http://ex.org/p> ?o ?s <http://ex.org/q> ?o
diff --git a/isabelle/fixtures-differential/varname_unbound_cert.tsv b/isabelle/fixtures-differential/varname_unbound_cert.tsv
new file mode 100644
index 00000000..eac35acc
--- /dev/null
+++ b/isabelle/fixtures-differential/varname_unbound_cert.tsv
@@ -0,0 +1 @@
+0 1 o <http://ex.org/b> s <http://ex.org/q> <http://ex.org/b> s <http://ex.org/p> <http://ex.org/b>
diff --git a/tests/cross_kernel_differential_test.rs b/tests/cross_kernel_differential_test.rs
new file mode 100644
index 00000000..ac2625ed
--- /dev/null
+++ b/tests/cross_kernel_differential_test.rs
@@ -0,0 +1,1610 @@
+//! Two proof assistants, one certificate format, and the question of whether the two
+//! formalisations actually say the same thing.
+//!
+//! `lean/OOCert/Horn.lean` and `isabelle/OO_Check.thy` are independent formalisations of
+//! the same Horn-certificate checker. The Isabelle one was written from the W3C primary
+//! sources and the fixture DATA, with nothing under `lean/` read; a transliteration would
+//! have been worthless, because a shared definitional bug survives translation untouched.
+//! This file runs both over the same bytes and requires them to agree.
+//!
+//! # What agreement here is, and is not
+//!
+//! Checking a Horn certificate is PURELY SYNTACTIC. Neither checker consults its own
+//! semantics: no interpretation, no domain, no truth. Two checkers built on contradictory
+//! model theories agree on every certificate and on every forgery. So agreement in this
+//! file is evidence about the FILE FORMAT and the CHECKING DISCIPLINE — how a binding is
+//! read, whether premise order is part of the contract, what an out-of-range index is —
+//! and it is not a proof of anything. It does not show the two semantics agree, it does
+//! not add a theorem to either side, and it must never be reported as if it did.
+//!
+//! The evidence that the DEFINITIONS agree lives elsewhere: in which rule arms each side
+//! can discharge and from which conditions (`isabelle/OO_Builtin_Sound.thy`,
+//! `lean/OOCert/HornBuiltin.lean`), and in whether the conditions describe anything at
+//! all (`isabelle/OO_NonVacuity.thy`, `lean/OOCert/HornWitness.lean`).
+//!
+//! What agreement here DOES buy is real and worth having: wherever the two checkers
+//! accept and reject the same files, the certificate format has one meaning rather than
+//! two. Where they do not, it has two, and that is the interesting part.
+//!
+//! # The disagreements
+//!
+//! Four were found, in two classes, and none is papered over. They are pinned by
+//! `divergence_d1_*`, `divergence_d2_*`, `divergence_d2b_*` and `divergence_d2c_*` below,
+//! their certificates are committed under `isabelle/fixtures-differential/`, and the
+//! corpus test classifies each disagreement BY ITS CAUSE and fails on any it cannot
+//! account for. Read those tests: the analysis is there, not here.
+//!
+//! Three were designed after reading both checkers. The fourth was found by the fuzzer,
+//! in a rule file one character away from a probe written for something else, which is
+//! why `binding_defect` classifies by cause rather than by which edit produced the row: a
+//! quarantine keyed on the edit would have hidden it.
+//!
+//! All three have ONE root cause. **Isabelle validates the binding list as a data
+//! structure and Lean does not.** `check_step` requires `distinct (map fst b)` and
+//! `binding_covers b r` before it instantiates anything; Lean's `substOf` is
+//! `fun v => (List.lookup v l).getD v`, which turns any binding list into a total
+//! function with a silent default and never inspects it. D1 is the duplicate key, D2 the
+//! missing one.
+//!
+//! Neither checker is unsound. In all three Lean accepts and Isabelle rejects, and Lean's
+//! acceptance holds in Lean's own theorem, because `EntailsR` quantifies over every total
+//! substitution and the one Lean used is a real one; Isabelle's rejections are false
+//! alarms, which is the harmless direction. What is defective is the FORMAT: it does not
+//! say whether a binding must have distinct keys or must cover the cited rule's
+//! variables, so Lean's answer to the first is whatever `List.lookup` happens to do, and
+//! its answer to the second fabricates a term out of a variable's name and puts it in the
+//! conclusion. Until the format says, a certificate's validity depends on which verified
+//! checker reads it.
+
+mod common;
+
+use std::collections::BTreeMap;
+use std::path::{Path, PathBuf};
+use std::process::Command;
+use std::sync::{Arc, OnceLock};
+
+// ── where things live ───────────────────────────────────────────────────────
+
+fn repo() -> PathBuf {
+ PathBuf::from(env!("CARGO_MANIFEST_DIR"))
+}
+
+fn lean_dir() -> PathBuf {
+ repo().join("lean")
+}
+
+fn isabelle_dir() -> PathBuf {
+ repo().join("isabelle")
+}
+
+fn horn_fixture(name: &str) -> PathBuf {
+ repo().join("tests").join("fixtures").join("horn").join(name)
+}
+
+fn differential_fixture(name: &str) -> PathBuf {
+ isabelle_dir().join("fixtures-differential").join(name)
+}
+
+// ── availability, and a loud skip ───────────────────────────────────────────
+
+fn lake_available() -> bool {
+ // `.current_dir(lean_dir())`: elan resolves the toolchain from the working
+ // directory, and the crate root has no `lean-toolchain` in its ancestry.
+ Command::new("lake")
+ .arg("--version")
+ .current_dir(lean_dir())
+ .output()
+ .map(|o| o.status.success())
+ .unwrap_or(false)
+}
+
+/// The Isabelle side needs Poly/ML to link the exported checker, and the exported
+/// checker itself, which `isabelle/export.sh` writes out of the session and which is
+/// committed so this test does not need a full Isabelle build to run.
+///
+/// The same search `isabelle/build_native.sh` does, and for the same reason: asking
+/// `isabelle getenv ISABELLE_HOME` is the only answer that is right on a machine that is
+/// not this one, and the macOS app bundle is only the fallback.
+fn poly_dir() -> Option<PathBuf> {
+ let arch = if cfg!(target_arch = "aarch64") { "arm64" } else { "x86_64" };
+ let os = if cfg!(target_os = "macos") { "darwin" } else { "linux" };
+ let platform = format!("{arch}-{os}");
+
+ let mut roots: Vec<PathBuf> = Vec::new();
+ if let Ok(out) = Command::new("isabelle").args(["getenv", "-b", "ISABELLE_HOME"]).output()
+ && out.status.success()
+ {
+ let home = String::from_utf8_lossy(&out.stdout).trim().to_string();
+ if !home.is_empty() {
+ roots.push(PathBuf::from(home));
+ }
+ }
+ if let Ok(entries) = std::fs::read_dir("/Applications") {
+ roots.extend(entries.flatten().map(|e| e.path()));
+ }
+
+ let mut found: Vec<PathBuf> = Vec::new();
+ for root in roots {
+ let contrib = root.join("contrib");
+ let Ok(cs) = std::fs::read_dir(&contrib) else { continue };
+ for c in cs.flatten() {
+ if c.file_name().to_string_lossy().starts_with("polyml-") {
+ let d = c.path().join(&platform);
+ if d.join("poly").exists() {
+ found.push(d);
+ }
+ }
+ }
+ }
+ found.sort();
+ found.pop()
+}
+
+fn isabelle_available() -> bool {
+ poly_dir().is_some() && isabelle_dir().join("driver").join("oo_horn_generated.ML").exists()
+}
+
+/// Both halves are needed, and a skip has to say WHICH half is missing. A test that
+/// returns early reports `ok`, so `common::skip_unless` prints a marker and, under
+/// `OO_REQUIRE_FIXTURES=1`, turns the skip into a failure.
+fn skip() -> bool {
+ if common::skip_unless(
+ lake_available(),
+ "lake (the Lean 4 build tool), for the Lean half of the differential",
+ "install elan from https://github.com/leanprover/elan; lean/lean-toolchain pins the version",
+ ) {
+ return true;
+ }
+ common::skip_unless(
+ isabelle_available(),
+ "Poly/ML (bundled with Isabelle) and isabelle/driver/oo_horn_generated.ML, \
+ for the Isabelle half of the differential",
+ "install Isabelle2025-2 from https://isabelle.in.tum.de; the generated ML is \
+ committed, and isabelle/export.sh regenerates it from the session",
+ )
+}
+
+// ── building the two checkers, once per test binary ─────────────────────────
+
+/// The Lean proofs are part of `lake build`, so a failure here is a failure and never a
+/// skip: the binary that comes out of it is the one the theorems are about.
+fn lean_checker() -> &'static Path {
+ static BUILT: OnceLock<PathBuf> = OnceLock::new();
+ BUILT.get_or_init(|| {
+ let out = Command::new("lake")
+ .arg("build")
+ .current_dir(lean_dir())
+ .output()
+ .expect("run lake build");
+ assert!(
+ out.status.success(),
+ "lake build failed:\n{}\n{}",
+ String::from_utf8_lossy(&out.stdout),
+ String::from_utf8_lossy(&out.stderr)
+ );
+ let exe = lean_dir().join(".lake").join("build").join("bin").join("oo-horn");
+ assert!(exe.exists(), "checker binary missing at {}", exe.display());
+ exe
+ })
+}
+
+/// The Isabelle side links the code `export_code` wrote into a native executable. The
+/// LINK is what happens here; nothing is re-derived from the theories, and the theories
+/// are checked by `isabelle build -d isabelle -c OOHorn`, which this test does not run.
+fn isabelle_checker() -> &'static Path {
+ static BUILT: OnceLock<PathBuf> = OnceLock::new();
+ BUILT.get_or_init(|| {
+ let script = isabelle_dir().join("build_native.sh");
+ let out = Command::new("sh")
+ .arg(&script)
+ .current_dir(repo())
+ .output()
+ .expect("run isabelle/build_native.sh");
+ assert!(
+ out.status.success(),
+ "isabelle/build_native.sh failed:\n{}\n{}",
+ String::from_utf8_lossy(&out.stdout),
+ String::from_utf8_lossy(&out.stderr)
+ );
+ let exe = isabelle_dir().join("build").join("oo-horn-isabelle");
+ assert!(exe.exists(), "checker binary missing at {}", exe.display());
+ exe
+ })
+}
+
+// ── one run of one checker ──────────────────────────────────────────────────
+
+/// What a run of either checker says, reduced to the three things that are comparable.
+/// `exit` is the discipline both sides implement: 0 accepted, 1 rejected, 2 unreadable or
+/// unparseable. `verdict` is present only when the run accepted.
+#[derive(Debug, Clone, PartialEq, Eq)]
+struct Outcome {
+ exit: i32,
+ verdict: Option<String>,
+}
+
+fn json_field(json: &str, key: &str) -> Option<String> {
+ let pat = format!("\"{key}\":\"");
+ let start = json.find(&pat)? + pat.len();
+ let rest = &json[start..];
+ Some(rest[..rest.find('"')?].to_string())
+}
+
+fn run_lean(rules: &Path, asserted: &Path, cert: &Path) -> Outcome {
+ let out = Command::new(lean_checker())
+ .arg("check")
+ .arg(rules)
+ .arg(asserted)
+ .arg(cert)
+ .output()
+ .expect("run oo-horn");
+ let stdout = String::from_utf8_lossy(&out.stdout).to_string();
+ let exit = out.status.code().unwrap_or(-1);
+ Outcome { exit, verdict: if exit == 0 { json_field(&stdout, "verdict") } else { None } }
+}
+
+fn run_isabelle(rules: &Path, asserted: &Path, cert: &Path) -> Outcome {
+ let out = Command::new(isabelle_checker())
+ .arg("check")
+ .arg(rules)
+ .arg(asserted)
+ .arg(cert)
+ .output()
+ .expect("run oo-horn-isabelle");
+ let stdout = String::from_utf8_lossy(&out.stdout).to_string();
+ let exit = out.status.code().unwrap_or(-1);
+ Outcome { exit, verdict: if exit == 0 { json_field(&stdout, "verdict") } else { None } }
+}
+
+// ── the certificate format, as data, so it can be mutated ───────────────────
+
+/// One line of `horn.tsv`:
+/// `idx TAB k TAB (var TAB term)*k TAB cs TAB cp TAB co TAB (ps TAB pp TAB po)*m`.
+///
+/// Note what this parser does NOT need: the rule table. The field count is
+/// `2 + 2k + 3 + 3m` and `k` is field 1, so `m` is recoverable from the line alone. Both
+/// checkers parse this way; it is why an out-of-range rule index is a rejection (exit 1)
+/// on both sides rather than a parse error (exit 2) on either.
+#[derive(Debug, Clone)]
+struct Step {
+ idx: String,
+ binds: Vec<(String, String)>,
+ concl: [String; 3],
+ prems: Vec<[String; 3]>,
+}
+
+fn parse_step(line: &str) -> Option<Step> {
+ let f: Vec<&str> = line.split('\t').collect();
+ if f.len() < 5 {
+ return None;
+ }
+ let k: usize = f[1].parse().ok()?;
+ if f.len() < 5 + 2 * k || !(f.len() - 5 - 2 * k).is_multiple_of(3) {
+ return None;
+ }
+ let binds =
+ (0..k).map(|i| (f[2 + 2 * i].to_string(), f[3 + 2 * i].to_string())).collect::<Vec<_>>();
+ let c = 2 + 2 * k;
+ let concl = [f[c].to_string(), f[c + 1].to_string(), f[c + 2].to_string()];
+ let mut prems = Vec::new();
+ let mut i = c + 3;
+ while i + 2 < f.len() {
+ prems.push([f[i].to_string(), f[i + 1].to_string(), f[i + 2].to_string()]);
+ i += 3;
+ }
+ Some(Step { idx: f[0].to_string(), binds, concl, prems })
+}
+
+fn render_step(s: &Step) -> String {
+ let mut parts = vec![s.idx.clone(), s.binds.len().to_string()];
+ for (v, t) in &s.binds {
+ parts.push(v.clone());
+ parts.push(t.clone());
+ }
+ for t in std::iter::once(&s.concl).chain(s.prems.iter()) {
+ parts.extend(t.iter().cloned());
+ }
+ parts.join("\t")
+}
+
+fn parse_cert(text: &str) -> Option<Vec<Step>> {
+ text.lines().filter(|l| !l.is_empty()).map(parse_step).collect()
+}
+
+fn render_cert(steps: &[Step]) -> String {
+ let mut s = String::new();
+ for st in steps {
+ s.push_str(&render_step(st));
+ s.push('\n');
+ }
+ s
+}
+
+// ── the mutations ───────────────────────────────────────────────────────────
+
+/// A fresh IRI no fixture mentions, so substituting it is always a lie.
+const ALIEN: &str = "<http://ex.invalid/never-derived>";
+
+/// Each mutation is a named, deterministic edit of a certificate's TEXT. Returning
+/// `None` means the mutation does not apply to this certificate (too few steps,
+/// bindings or premises) and the row is simply not generated.
+type Mutation = (&'static str, fn(&str) -> Option<String>);
+
+fn mutations() -> Vec<Mutation> {
+ vec![
+ ("rule_index_plus_one", |t| {
+ let mut c = parse_cert(t)?;
+ let n: usize = c.first()?.idx.parse().ok()?;
+ c[0].idx = (n + 1).to_string();
+ Some(render_cert(&c))
+ }),
+ ("rule_index_out_of_range", |t| {
+ let mut c = parse_cert(t)?;
+ c.first()?;
+ c[0].idx = "9999".to_string();
+ Some(render_cert(&c))
+ }),
+ ("rule_index_not_a_number", |t| {
+ let mut c = parse_cert(t)?;
+ c.first()?;
+ c[0].idx = "four".to_string();
+ Some(render_cert(&c))
+ }),
+ ("permute_binding_values", |t| {
+ let mut c = parse_cert(t)?;
+ if c.first()?.binds.len() < 2 {
+ return None;
+ }
+ let v0 = c[0].binds[0].1.clone();
+ c[0].binds[0].1 = c[0].binds[1].1.clone();
+ c[0].binds[1].1 = v0;
+ Some(render_cert(&c))
+ }),
+ ("binding_value_replaced", |t| {
+ let mut c = parse_cert(t)?;
+ if c.first()?.binds.is_empty() {
+ return None;
+ }
+ c[0].binds[0].1 = ALIEN.to_string();
+ Some(render_cert(&c))
+ }),
+ // D1. The key is duplicated with a WRONG second value. Whether this is a
+ // rejection depends entirely on how a duplicate key is resolved, which is the
+ // thing the format does not say. See `divergence_d1_duplicate_binding_key`.
+ ("duplicate_binding_key", |t| {
+ let mut c = parse_cert(t)?;
+ if c.first()?.binds.is_empty() {
+ return None;
+ }
+ let key = c[0].binds[0].0.clone();
+ c[0].binds.push((key, ALIEN.to_string()));
+ Some(render_cert(&c))
+ }),
+ // D2's shape, though over ordinary IRI terms it does NOT diverge: Lean
+ // substitutes the variable's own name, which is not an IRI, so both reject. The
+ // case where it does diverge is hand-built in `fixtures-differential/`.
+ ("drop_binding_pair", |t| {
+ let mut c = parse_cert(t)?;
+ if c.first()?.binds.is_empty() {
+ return None;
+ }
+ c[0].binds.remove(0);
+ Some(render_cert(&c))
+ }),
+ ("drop_last_premise", |t| {
+ let mut c = parse_cert(t)?;
+ if c.first()?.prems.is_empty() {
+ return None;
+ }
+ c[0].prems.pop();
+ Some(render_cert(&c))
+ }),
+ ("permute_premises", |t| {
+ let mut c = parse_cert(t)?;
+ if c.first()?.prems.len() < 2 {
+ return None;
+ }
+ c[0].prems.swap(0, 1);
+ Some(render_cert(&c))
+ }),
+ ("premise_object_replaced", |t| {
+ let mut c = parse_cert(t)?;
+ if c.first()?.prems.is_empty() {
+ return None;
+ }
+ c[0].prems[0][2] = ALIEN.to_string();
+ Some(render_cert(&c))
+ }),
+ ("conclusion_object_replaced", |t| {
+ let mut c = parse_cert(t)?;
+ c.first()?;
+ c[0].concl[2] = ALIEN.to_string();
+ Some(render_cert(&c))
+ }),
+ // The step now cites its own conclusion as its first premise. On a rule whose
+ // body and head differ this also breaks instantiation, which is why no shipped
+ // fixture reaches the no-self-support property on its own.
+ ("step_cites_own_conclusion", |t| {
+ let mut c = parse_cert(t)?;
+ if c.first()?.prems.is_empty() {
+ return None;
+ }
+ let concl = c[0].concl.clone();
+ c[0].prems[0] = concl;
+ Some(render_cert(&c))
+ }),
+ ("reverse_steps", |t| {
+ let mut c = parse_cert(t)?;
+ if c.len() < 2 {
+ return None;
+ }
+ c.reverse();
+ Some(render_cert(&c))
+ }),
+ ("swap_first_two_steps", |t| {
+ let mut c = parse_cert(t)?;
+ if c.len() < 2 {
+ return None;
+ }
+ c.swap(0, 1);
+ Some(render_cert(&c))
+ }),
+ // Accepting mutations, so the corpus is not all rejections. A duplicated step is
+ // redundant, and a prefix of a valid certificate is a valid certificate.
+ ("duplicate_first_step", |t| {
+ let mut c = parse_cert(t)?;
+ let first = c.first()?.clone();
+ c.push(first);
+ Some(render_cert(&c))
+ }),
+ ("drop_last_step", |t| {
+ let mut c = parse_cert(t)?;
+ if c.len() < 2 {
+ return None;
+ }
+ c.pop();
+ Some(render_cert(&c))
+ }),
+ // The field separator, injected into a term. One tab shifts the field count by
+ // one, so `(NF - 5 - 2k)` stops being a multiple of three and the line is
+ // unparseable on both sides: exit 2, not a rejection.
+ ("tab_inside_a_term", |t| {
+ let first = t.lines().find(|l| !l.is_empty())?;
+ let s = parse_step(first)?;
+ let broken = first.replacen(&s.concl[0], &format!("{}\t{}", s.concl[0], "x"), 1);
+ Some(t.replacen(first, &broken, 1))
+ }),
+ // Three tabs keep the count a multiple of three, so the line PARSES — into a
+ // different step, with a spurious premise. It must be rejected, not accepted.
+ ("three_tabs_inside_terms", |t| {
+ let first = t.lines().find(|l| !l.is_empty())?;
+ let s = parse_step(first)?;
+ let broken = first.replacen(&s.concl[0], &format!("{}\tx\ty\tz", s.concl[0]), 1);
+ Some(t.replacen(first, &broken, 1))
+ }),
+ ("truncate_last_field", |t| {
+ let first = t.lines().find(|l| !l.is_empty())?;
+ let cut = first.rfind('\t')?;
+ Some(t.replacen(first, &first[..cut], 1))
+ }),
+ ("empty_certificate", |_| Some(String::new())),
+ ]
+}
+
+/// Edits of the RULE TABLE rather than the certificate. These are where the VERDICT
+/// WORD is at stake: a table that is not the built-in one must earn the relativised
+/// verdict on both sides, and a certificate over it may still check.
+type RuleMutation = (&'static str, fn(&str) -> Option<String>);
+
+fn rule_mutations() -> Vec<RuleMutation> {
+ vec![
+ // Names are labels, not keys: the certificate cites an INDEX. Both sides must
+ // still accept, and both must downgrade the verdict, because both decide the
+ // absolute verdict by comparing the whole table.
+ ("rule_renamed", |t| {
+ let first = t.lines().find(|l| !l.is_empty())?;
+ let name = first.split('\t').next()?;
+ Some(t.replacen(&format!("{name}\t"), "renamed-rule\t", 1))
+ }),
+ ("rules_reversed", |t| {
+ let mut ls: Vec<&str> = t.lines().filter(|l| !l.is_empty()).collect();
+ if ls.len() < 2 {
+ return None;
+ }
+ ls.reverse();
+ Some(ls.join("\n") + "\n")
+ }),
+ ("rule_appended", |t| {
+ Some(
+ t.to_string()
+ + "invented\t1\t?s\t<http://ex.invalid/p>\t?o\t?s\t<http://ex.invalid/q>\t?o\n",
+ )
+ }),
+ ("rules_truncated_to_two", |t| {
+ let ls: Vec<&str> = t.lines().filter(|l| !l.is_empty()).collect();
+ if ls.len() < 3 {
+ return None;
+ }
+ Some(ls[..2].join("\n") + "\n")
+ }),
+ ("rule_variable_renamed", |t| {
+ let first = t.lines().find(|l| !l.is_empty())?;
+ if !first.contains("?x") {
+ return None;
+ }
+ Some(t.replacen(first, &first.replace("?x", "?renamedvar"), 1))
+ }),
+ ("rule_body_length_wrong", |t| {
+ let first = t.lines().find(|l| !l.is_empty())?;
+ let f: Vec<&str> = first.split('\t').collect();
+ let n: usize = f[1].parse().ok()?;
+ let mut g = f.clone();
+ let bumped = (n + 1).to_string();
+ g[1] = &bumped;
+ Some(t.replacen(first, &g.join("\t"), 1))
+ }),
+ ]
+}
+
+// ── the corpus ──────────────────────────────────────────────────────────────
+
+struct Case {
+ name: String,
+ /// The mutation that produced it, or `"base"`. Disagreements are classified by this.
+ kind: String,
+ rules: PathBuf,
+ asserted: PathBuf,
+ cert: PathBuf,
+}
+
+/// The repository's own RDF, as source graphs. Directories rather than a hand-typed file
+/// list, so a fixture added to the repository is picked up rather than silently missed.
+/// Sorted, so the corpus is the same on every run.
+fn source_graphs() -> Vec<PathBuf> {
+ let dirs = [
+ "benchmark/reference",
+ "benchmark/generated",
+ "benchmark/data",
+ "benchmark/epc",
+ "benchmark/gvr",
+ "benchmark/mushroom",
+ "demo/derived",
+ "demo/corpus/dcat-us",
+ "tests/w3c-shacl/core/complex",
+ "tests/data",
+ ];
+ let mut out: Vec<PathBuf> = Vec::new();
+ for d in dirs {
+ let dir = repo().join(d);
+ let Ok(entries) = std::fs::read_dir(&dir) else { continue };
+ for e in entries.flatten() {
+ let p = e.path();
+ if p.extension().and_then(|s| s.to_str()) == Some("ttl") {
+ out.push(p);
+ }
+ }
+ }
+ out.push(repo().join("tests").join("test_ontology.ttl"));
+ out.sort();
+ out
+}
+
+/// Generate one certificate per (graph, rule table) pair, using the engine as the
+/// producer. Steps are capped: a prefix of a valid certificate is a valid certificate,
+/// because a step may only cite what came strictly before it, so truncation cannot turn
+/// a bad certificate into a good one.
+const MAX_STEPS: usize = 30;
+
+fn generate_base_certificates(scratch: &Path) -> Vec<Case> {
+ use open_ontologies::graph::GraphStore;
+ use open_ontologies::reason::Reasoner;
+
+ let mut cases = Vec::new();
+ for (i, graph) in source_graphs().iter().enumerate() {
+ let Ok(ttl) = std::fs::read_to_string(graph) else { continue };
+ let store = Arc::new(GraphStore::new());
+ if store.load_turtle(&ttl, None).is_err() {
+ continue;
+ }
+ for table in ["builtin_rules.tsv", "user_rules.tsv"] {
+ let stem = graph.file_stem().and_then(|s| s.to_str()).unwrap_or("graph").to_string();
+ let tag = format!("{i:02}-{stem}-{}", table.trim_end_matches(".tsv"));
+ let dir = scratch.join(&tag);
+ if std::fs::create_dir_all(&dir).is_err() {
+ continue;
+ }
+ if Reasoner::run_horn(&store, &horn_fixture(table), &dir).is_err() {
+ continue;
+ }
+ let Ok(horn) = std::fs::read_to_string(dir.join("horn.tsv")) else { continue };
+ let steps: Vec<&str> = horn.lines().filter(|l| !l.is_empty()).collect();
+ if steps.is_empty() {
+ // A graph the table derives nothing from certifies nothing. Keeping it
+ // would pad the count with rows on which both checkers accept the empty
+ // certificate, which is agreement about nothing.
+ continue;
+ }
+ let capped: String =
+ steps.iter().take(MAX_STEPS).map(|l| format!("{l}\n")).collect::<String>();
+ let cert = dir.join("cert.tsv");
+ std::fs::write(&cert, &capped).unwrap();
+ cases.push(Case {
+ name: tag,
+ kind: "base".to_string(),
+ rules: dir.join("rules.tsv"),
+ asserted: dir.join("asserted.tsv"),
+ cert,
+ });
+ }
+ }
+ cases
+}
+
+/// Every committed fixture, including the ones `isabelle/fixtures-added/` carries for
+/// properties the shipped set cannot reach.
+fn fixture_cases() -> Vec<Case> {
+ let added = |n: &str| isabelle_dir().join("fixtures-added").join(n);
+ let rows: Vec<(&str, PathBuf, PathBuf, PathBuf)> = vec![
+ ("fx-good", horn_fixture("builtin_rules.tsv"), horn_fixture("asserted.tsv"), horn_fixture("good.tsv")),
+ ("fx-good-user-table", horn_fixture("user_rules.tsv"), horn_fixture("asserted.tsv"), horn_fixture("good.tsv")),
+ ("fx-good-short-table", horn_fixture("short_rules.tsv"), horn_fixture("asserted.tsv"), horn_fixture("good.tsv")),
+ ("fx-bad-index", horn_fixture("builtin_rules.tsv"), horn_fixture("asserted.tsv"), horn_fixture("bad_index.tsv")),
+ ("fx-bad-binding", horn_fixture("builtin_rules.tsv"), horn_fixture("asserted.tsv"), horn_fixture("bad_binding.tsv")),
+ ("fx-bad-conclusion", horn_fixture("builtin_rules.tsv"), horn_fixture("asserted.tsv"), horn_fixture("bad_conclusion.tsv")),
+ ("fx-bad-premise", horn_fixture("builtin_rules.tsv"), horn_fixture("asserted.tsv"), horn_fixture("bad_premise.tsv")),
+ ("fx-bad-self", horn_fixture("builtin_rules.tsv"), horn_fixture("asserted.tsv"), horn_fixture("bad_self.tsv")),
+ ("fx-good-chain", horn_fixture("builtin_rules.tsv"), added("asserted_chain.tsv"), added("good_chain.tsv")),
+ ("fx-bad-self-chain", horn_fixture("builtin_rules.tsv"), added("asserted_chain.tsv"), added("bad_self_chain.tsv")),
+ ("fx-bad-order", horn_fixture("builtin_rules.tsv"), horn_fixture("asserted.tsv"), added("bad_order.tsv")),
+ // The D1 certificate is in the corpus like every other committed fixture, and
+ // not held back because it is the one that disagrees. `binding_defect` classifies
+ // it, `divergence_d1_duplicate_binding_key` pins it, and its mutants are checked
+ // like anything else.
+ ("fx-bad-dup-key", horn_fixture("builtin_rules.tsv"), horn_fixture("asserted.tsv"), added("bad_dup_key.tsv")),
+ ("fx-generalized", horn_fixture("builtin_rules.tsv"), added("asserted_gen.tsv"), added("generalized.tsv")),
+ ];
+ rows.into_iter()
+ .filter(|(_, r, a, c)| r.exists() && a.exists() && c.exists())
+ .map(|(n, r, a, c)| Case {
+ name: n.to_string(),
+ kind: "base".to_string(),
+ rules: r,
+ asserted: a,
+ cert: c,
+ })
+ .collect()
+}
+
+/// The corners of the term format that NO generated certificate reaches, because the
+/// engine writes IRIs and the repository's fixtures are ASCII. Each is a committed
+/// `probe_<name>_{rules,asserted,cert}.tsv` triple under `isabelle/fixtures-differential/`.
+/// They join the corpus as base cases, so they are mutated and fuzzed like everything
+/// else; `the_untested_corners_of_the_term_format_agree` pins what each one should do.
+fn probe_cases() -> Vec<Case> {
+ let dir = isabelle_dir().join("fixtures-differential");
+ let Ok(entries) = std::fs::read_dir(&dir) else { return Vec::new() };
+ let mut names: Vec<String> = entries
+ .flatten()
+ .filter_map(|e| {
+ let f = e.file_name().to_string_lossy().to_string();
+ f.strip_prefix("probe_")
+ .and_then(|r| r.strip_suffix("_rules.tsv"))
+ .map(|s| s.to_string())
+ })
+ .collect();
+ names.sort();
+ names
+ .into_iter()
+ .map(|n| Case {
+ name: format!("probe-{n}"),
+ kind: "base".to_string(),
+ rules: dir.join(format!("probe_{n}_rules.tsv")),
+ asserted: dir.join(format!("probe_{n}_asserted.tsv")),
+ cert: dir.join(format!("probe_{n}_cert.tsv")),
+ })
+ .filter(|c| c.rules.exists() && c.asserted.exists() && c.cert.exists())
+ .collect()
+}
+
+/// Expand each base case into its mutants.
+fn mutate(bases: &[Case], scratch: &Path) -> Vec<Case> {
+ let mut out = Vec::new();
+ for base in bases {
+ let Ok(cert_text) = std::fs::read_to_string(&base.cert) else { continue };
+ let Ok(rules_text) = std::fs::read_to_string(&base.rules) else { continue };
+ let dir = scratch.join("mut").join(&base.name);
+ if std::fs::create_dir_all(&dir).is_err() {
+ continue;
+ }
+ for (name, f) in mutations() {
+ let Some(text) = f(&cert_text) else { continue };
+ if text == cert_text {
+ continue;
+ }
+ let p = dir.join(format!("{name}.tsv"));
+ if std::fs::write(&p, &text).is_err() {
+ continue;
+ }
+ out.push(Case {
+ name: format!("{}/{name}", base.name),
+ kind: name.to_string(),
+ rules: base.rules.clone(),
+ asserted: base.asserted.clone(),
+ cert: p,
+ });
+ }
+ for (name, f) in rule_mutations() {
+ let Some(text) = f(&rules_text) else { continue };
+ if text == rules_text {
+ continue;
+ }
+ let p = dir.join(format!("rules-{name}.tsv"));
+ if std::fs::write(&p, &text).is_err() {
+ continue;
+ }
+ out.push(Case {
+ name: format!("{}/{name}", base.name),
+ kind: name.to_string(),
+ rules: p,
+ asserted: base.asserted.clone(),
+ cert: base.cert.clone(),
+ });
+ }
+ }
+ out
+}
+
+fn scratch_dir() -> PathBuf {
+ let d = std::env::temp_dir().join(format!("oo-cross-kernel-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&d);
+ std::fs::create_dir_all(&d).expect("create scratch dir");
+ d
+}
+
+// ── classifying a divergence by its cause, not by the edit that produced it ──
+
+/// A rule, read far enough to know which variables it has. Not a third checker: this is
+/// used only to EXPLAIN a divergence the two checkers have already produced, never to
+/// decide whether they agree. If it is wrong, a row goes unexplained and the test fails,
+/// which is the safe direction.
+struct Rule {
+ vars: Vec<String>,
+}
+
+fn parse_rule_line(line: &str) -> Option<Rule> {
+ let f: Vec<&str> = line.split('\t').collect();
+ if f.len() < 5 {
+ return None;
+ }
+ let n: usize = f[1].parse().ok()?;
+ if f.len() != 5 + 3 * n {
+ return None;
+ }
+ let mut vars = Vec::new();
+ for field in &f[2..] {
+ if let Some(v) = field.strip_prefix('?')
+ && !vars.iter().any(|x| x == v)
+ {
+ vars.push(v.to_string());
+ }
+ }
+ Some(Rule { vars })
+}
+
+/// Why the two kernels differ on these files, if the reason is the one known root cause:
+/// **Isabelle validates the binding list as a data structure and Lean does not.**
+///
+/// Isabelle's `check_step` runs `distinct (map fst b)` and then `binding_covers b r`
+/// before instantiating anything. Lean's `substOf` is `fun v => (List.lookup v l).getD v`
+/// — a total function with a silent default, built without looking at the list at all. So
+/// a binding with a repeated key (D1) or with a variable missing (D2) is rejected by one
+/// and silently resolved by the other.
+///
+/// This is a POSITIVE test of that diagnosis, and that is the point. Excusing a
+/// divergence because of the EDIT that produced it would hide a second, unrelated
+/// divergence arriving through the same edit — and would have hidden the one the fuzzer
+/// found through a one-character change to a rule file. Excusing it because the binding
+/// list really is malformed, in a specific way, at the step in question, cannot.
+fn binding_defect(rules_path: &Path, cert_path: &Path) -> Option<&'static str> {
+ let rules_text = std::fs::read_to_string(rules_path).ok()?;
+ let rules: Vec<Rule> =
+ rules_text.lines().filter(|l| !l.is_empty()).map(parse_rule_line).collect::<Option<_>>()?;
+ let cert_text = std::fs::read_to_string(cert_path).ok()?;
+ let steps = parse_cert(&cert_text)?;
+
+ for step in &steps {
+ let Ok(idx) = step.idx.parse::<usize>() else { return None };
+ let Some(rule) = rules.get(idx) else { continue };
+ let mut seen: Vec<&str> = Vec::new();
+ for (k, _) in &step.binds {
+ if seen.contains(&k.as_str()) {
+ return Some(
+ "D1: the binding list repeats a key. Isabelle rejects it as malformed \
+ (R_binding_dup_key); Lean resolves it with List.lookup, which is \
+ first-wins, and accepts.",
+ );
+ }
+ seen.push(k);
+ }
+ if rule.vars.iter().any(|v| !seen.contains(&v.as_str())) {
+ return Some(
+ "D2: the binding does not cover every variable of the cited rule. Isabelle \
+ rejects (R_binding_incomplete); Lean's substOf sends the unbound variable \
+ to its own NAME and carries on, so the step checks whenever that name is \
+ the term the certificate used.",
+ );
+ }
+ }
+ None
+}
+
+/// A divergence is excused only when Lean ACCEPTED, Isabelle REJECTED, and the binding
+/// list really is malformed in one of the two known ways. Every other shape — Isabelle
+/// accepting where Lean rejects, a divergence on an exit code of 2, a divergence over a
+/// well-formed binding — is unexplained and fails the corpus test.
+fn known_divergence(
+ rules: &Path,
+ cert: &Path,
+ lean: &Outcome,
+ isabelle: &Outcome,
+) -> Option<&'static str> {
+ if lean.exit != 0 || isabelle.exit != 1 {
+ return None;
+ }
+ binding_defect(rules, cert)
+}
+
+// ── a seeded fuzzer over the file format ────────────────────────────────────
+
+/// The hand-written mutations above test the failures someone thought of. This tests the
+/// ones nobody did, and it is aimed squarely at the PARSERS, which is where two
+/// independent readers of one format are most likely to part company: field counts,
+/// numbers that are not numbers, empty fields, and the field separator appearing inside
+/// a term.
+///
+/// Seeded, so a run is reproducible. It is NOT stable across changes to the corpus: one
+/// stream feeds every base in order, so adding a base shifts every draw after it and a
+/// given row stops being generated. That is why a row the fuzzer finds interesting gets
+/// COMMITTED as a fixture with its own test — `divergence_d2c_*` is one it found and
+/// this configuration no longer reaches. The fuzzer is a search, and the fixtures are
+/// what the search found.
+struct Rng(u64);
+
+impl Rng {
+ fn next_u64(&mut self) -> u64 {
+ // xorshift64*. Written out rather than pulled in: a dev-dependency for four
+ // lines of arithmetic is a dependency in the trust surface of a test whose whole
+ // subject is trust surfaces.
+ let mut x = self.0;
+ x ^= x >> 12;
+ x ^= x << 25;
+ x ^= x >> 27;
+ self.0 = x;
+ x.wrapping_mul(0x2545_F491_4F6C_DD1D)
+ }
+
+ fn below(&mut self, n: usize) -> usize {
+ if n == 0 { 0 } else { (self.next_u64() % n as u64) as usize }
+ }
+}
+
+/// Tokens a corrupted field may be replaced with, chosen to hit the dispatch points both
+/// parsers have: the `?` that makes a rule field a variable, the `<`/`>` that make a term
+/// an IRI, the `_:` that make it a blank node, a quote, an empty field, numbers in and
+/// out of range, and a raw TAB.
+const FUZZ_TOKENS: &[&str] = &[
+ "",
+ "?",
+ "?x",
+ "?renamed",
+ "<http://ex.org/a>",
+ "<",
+ ">",
+ "<>",
+ "_:b",
+ "_:",
+ "\"lit\"",
+ "\"lit\"@en",
+ "0",
+ "1",
+ "4",
+ "27",
+ "9999",
+ "-1",
+ "007",
+ "not-a-number",
+ "x",
+ "a\tb",
+];
+
+fn fuzz_tsv(text: &str, rng: &mut Rng, edits: usize) -> String {
+ let mut lines: Vec<Vec<String>> = text
+ .lines()
+ .filter(|l| !l.is_empty())
+ .map(|l| l.split('\t').map(|s| s.to_string()).collect())
+ .collect();
+ if lines.is_empty() {
+ return text.to_string();
+ }
+ for _ in 0..edits {
+ let li = rng.below(lines.len());
+ if lines[li].is_empty() {
+ continue;
+ }
+ let fi = rng.below(lines[li].len());
+ match rng.below(6) {
+ 0 => {
+ lines[li].remove(fi);
+ }
+ 1 => {
+ let v = lines[li][fi].clone();
+ lines[li].insert(fi, v);
+ }
+ 2 => {
+ let fj = rng.below(lines[li].len());
+ lines[li].swap(fi, fj);
+ }
+ 3 => {
+ lines[li][fi] = FUZZ_TOKENS[rng.below(FUZZ_TOKENS.len())].to_string();
+ }
+ 4 => {
+ let n: u64 = lines[li][fi].parse().unwrap_or(0);
+ lines[li][fi] = n.wrapping_add(1 + rng.below(3) as u64).to_string();
+ }
+ _ => {
+ let t = FUZZ_TOKENS[rng.below(FUZZ_TOKENS.len())];
+ lines[li][fi] = format!("{}{t}", lines[li][fi]);
+ }
+ }
+ }
+ lines.iter().map(|f| f.join("\t") + "\n").collect()
+}
+
+const FUZZ_SEED: u64 = 0x0000_00D1_FFED_0001;
+
+/// Six fuzzed variants of each base, three corrupting the certificate and three the rule
+/// table, with a growing number of edits.
+fn fuzz(bases: &[Case], scratch: &Path) -> Vec<Case> {
+ let mut rng = Rng(FUZZ_SEED);
+ let mut out = Vec::new();
+ for base in bases {
+ let Ok(cert_text) = std::fs::read_to_string(&base.cert) else { continue };
+ let Ok(rules_text) = std::fs::read_to_string(&base.rules) else { continue };
+ let dir = scratch.join("fuzz").join(&base.name);
+ if std::fs::create_dir_all(&dir).is_err() {
+ continue;
+ }
+ for edits in 1..=3 {
+ let text = fuzz_tsv(&cert_text, &mut rng, edits);
+ let p = dir.join(format!("cert-{edits}.tsv"));
+ if std::fs::write(&p, &text).is_ok() {
+ out.push(Case {
+ name: format!("{}/fuzz-cert-{edits}", base.name),
+ kind: format!("fuzz_cert_{edits}"),
+ rules: base.rules.clone(),
+ asserted: base.asserted.clone(),
+ cert: p,
+ });
+ }
+ let text = fuzz_tsv(&rules_text, &mut rng, edits);
+ let p = dir.join(format!("rules-{edits}.tsv"));
+ if std::fs::write(&p, &text).is_ok() {
+ out.push(Case {
+ name: format!("{}/fuzz-rules-{edits}", base.name),
+ kind: format!("fuzz_rules_{edits}"),
+ rules: p,
+ asserted: base.asserted.clone(),
+ cert: base.cert.clone(),
+ });
+ }
+ }
+ }
+ out
+}
+
+// ── the tests ───────────────────────────────────────────────────────────────
+
+#[test]
+fn the_skip_says_which_half_is_missing() {
+ // The skip path is the one nobody looks at until CI is silently green over nothing,
+ // so it is exercised here rather than assumed. `skip_unless` returns false when the
+ // thing IS available, and prints a SKIPPED_FIXTURE marker when it is not.
+ let present = common::skip_unless(true, "a thing that is here", "nothing to do");
+ assert!(!present, "skip_unless must not skip when the tool is available");
+ if lake_available() && isabelle_available() {
+ assert!(!skip(), "both toolchains are present, so this must not skip");
+ } else {
+ assert!(skip(), "a missing toolchain must skip loudly, not run half a differential");
+ }
+}
+
+/// The two embedded rule tables are shown equal THROUGH the committed fixture, which is
+/// what makes comparing the verdict word mean anything.
+///
+/// `lean_horn_certificate_test.rs` already pins `oo-horn rules` against
+/// `tests/fixtures/horn/builtin_rules.tsv` byte for byte. This adds the other half:
+/// `verdict_of` assigns the ABSOLUTE verdict to a table only when that table IS
+/// `builtin_table`, so `table_verdict: entailed` over the same bytes says Isabelle's
+/// embedded table is the fixture too. Lean's `Builtin.asHorn` and Isabelle's
+/// `builtin_table` are therefore the same 27 rules, by two independent comparisons
+/// against one file, rather than by anybody's say-so.
+#[test]
+fn both_embedded_rule_tables_are_the_committed_fixture() {
+ if skip() {
+ return;
+ }
+ let lean = Command::new(lean_checker()).arg("rules").output().expect("oo-horn rules");
+ assert!(lean.status.success());
+ let printed = String::from_utf8_lossy(&lean.stdout).to_string();
+ let committed = std::fs::read_to_string(horn_fixture("builtin_rules.tsv")).unwrap();
+ assert_eq!(
+ printed.trim_end(),
+ committed.trim_end(),
+ "Lean's built-in table has drifted from the committed fixture"
+ );
+
+ let isa = Command::new(isabelle_checker())
+ .arg("table")
+ .arg(horn_fixture("builtin_rules.tsv"))
+ .output()
+ .expect("oo-horn-isabelle table");
+ let out = String::from_utf8_lossy(&isa.stdout).to_string();
+ assert_eq!(
+ json_field(&out, "table_verdict").as_deref(),
+ Some("entailed"),
+ "Isabelle's verdict_of must call the committed fixture the built-in table; if it \
+ does not, the two embedded tables differ and every verdict comparison below is \
+ comparing two different things: {out}"
+ );
+
+ // And the negative, or the assertion above is unfalsifiable: a table that is NOT the
+ // built-in one must not earn the absolute verdict on either side.
+ let isa = Command::new(isabelle_checker())
+ .arg("table")
+ .arg(horn_fixture("user_rules.tsv"))
+ .output()
+ .expect("oo-horn-isabelle table");
+ let out = String::from_utf8_lossy(&isa.stdout).to_string();
+ assert_eq!(
+ json_field(&out, "table_verdict").as_deref(),
+ Some("entailed_under_supplied_rules"),
+ "a user table must not be mistaken for the built-in one: {out}"
+ );
+}
+
+/// **The differential.** Both checkers, every certificate, the accept/reject bit, the
+/// exit code and the verdict word.
+#[test]
+fn the_two_kernels_agree_on_the_whole_corpus() {
+ if skip() {
+ return;
+ }
+ let scratch = scratch_dir();
+ let mut bases = fixture_cases();
+ bases.extend(probe_cases());
+ bases.extend(generate_base_certificates(&scratch));
+ let mutants = mutate(&bases, &scratch);
+ let fuzzed = fuzz(&bases, &scratch);
+ let total = bases.len() + mutants.len() + fuzzed.len();
+
+ assert!(
+ total >= 200,
+ "a differential over {total} certificates is not evidence of anything. Agreement \
+ on a handful of hand-written files is what a shared bug looks like. Something \
+ has gone wrong in corpus generation"
+ );
+
+ let mut agree_accept = 0usize;
+ let mut agree_reject = 0usize;
+ let mut agree_unreadable = 0usize;
+ let mut classified: BTreeMap<String, usize> = BTreeMap::new();
+ let mut unexplained: Vec<String> = Vec::new();
+
+ for case in bases.iter().chain(mutants.iter()).chain(fuzzed.iter()) {
+ let l = run_lean(&case.rules, &case.asserted, &case.cert);
+ let i = run_isabelle(&case.rules, &case.asserted, &case.cert);
+ if l == i {
+ match l.exit {
+ 0 => agree_accept += 1,
+ 1 => agree_reject += 1,
+ _ => agree_unreadable += 1,
+ }
+ continue;
+ }
+ match known_divergence(&case.rules, &case.cert, &l, &i) {
+ Some(why) => {
+ let class = if why.starts_with("D1") { "D1 duplicate key" } else { "D2 missing" };
+ *classified.entry(format!("{class} [{}]", case.kind)).or_default() += 1;
+ }
+ None => unexplained.push(format!(
+ "{}\n lean: exit {} verdict {:?}\n isabelle: exit {} verdict {:?}\n \
+ rules={} asserted={} cert={}",
+ case.name,
+ l.exit,
+ l.verdict,
+ i.exit,
+ i.verdict,
+ case.rules.display(),
+ case.asserted.display(),
+ case.cert.display()
+ )),
+ }
+ }
+
+ let known: usize = classified.values().sum();
+ println!(
+ "cross-kernel differential\n \
+ certificates: {total} ({} base, {} mutated, {} fuzzed, seed {FUZZ_SEED:#x})\n \
+ both accept: {agree_accept}\n \
+ both reject: {agree_reject}\n \
+ both exit 2: {agree_unreadable}\n \
+ known divergence: {known}\n \
+ unexplained: {}",
+ bases.len(),
+ mutants.len(),
+ fuzzed.len(),
+ unexplained.len()
+ );
+ for (kind, n) in &classified {
+ println!(" {kind}: {n} rows");
+ }
+
+ assert!(
+ unexplained.is_empty(),
+ "THE TWO KERNELS DISAGREE, and not in a way this file has an account of. A \
+ disagreement is the headline result of this test, not a nuisance: do not adjust \
+ either checker to make it go away, and do not add it to `known_divergence` \
+ without first deciding from the specification which side is wrong.\n\n{}",
+ unexplained.join("\n\n")
+ );
+
+ // A corpus that is all rejections would prove only that both sides can say no.
+ assert!(agree_accept >= 20, "only {agree_accept} certificates were accepted by both");
+ assert!(agree_reject >= 100, "only {agree_reject} certificates were rejected by both");
+ assert!(agree_unreadable >= 10, "only {agree_unreadable} inputs were unparseable on both");
+
+ let _ = std::fs::remove_dir_all(&scratch);
+}
+
+/// **Divergence D1.** A binding list with a repeated key.
+///
+/// `isabelle/fixtures-added/bad_dup_key.tsv` binds `x` twice: first to `<http://ex.org/a>`,
+/// which is the value that makes the step check, then to `<http://ex.org/zzz>`, which
+/// does not.
+///
+/// * Isabelle: `check_step` tests `distinct (map fst b)` first and returns
+/// `R_binding_dup_key`. Decision M25 records this as a deliberate STRICTNESS and
+/// uncertainty U10 records it as a coin-flip between two honest authors.
+/// * Lean: `substOf` is `fun v => (List.lookup v l).getD v`, and `List.lookup` returns
+/// the FIRST match. `x` resolves to `<http://ex.org/a>`, the step checks, and the run
+/// earns the ABSOLUTE verdict.
+///
+/// Which is wrong? Neither, on soundness. `checkHornStep_sound` quantifies over the
+/// substitution `substOf st.binds`, which is a perfectly good total substitution
+/// whichever value it picks, so Lean's acceptance is sound in Lean's own theorem, and
+/// Isabelle's rejection is a false alarm rather than a missed forgery.
+///
+/// The defect is in the FORMAT, and it is real. `docs/lean-certificates.md` and decision
+/// 0003 do not say what a repeated binding key means, so Lean's answer is whatever
+/// `List.lookup` happens to do. That is a tie-break inside a standard-library function
+/// standing in for a rule about the file format, and it decides whether a certificate is
+/// valid. Isabelle's `binding_covers` comment predicted exactly this and named `map_of`'s
+/// first-wins behaviour as the reason not to rely on it; the Lean side has no comment on
+/// duplicate keys at all — `substOf`'s docstring discusses MISSING bindings only.
+///
+/// The repair belongs on the Lean side (reject a repeated key, or write the first-wins
+/// rule into the format as normative), and it is not made here: the instruction for this
+/// exercise is that a disagreement is the result, and a disagreement quietly fixed is a
+/// disagreement hidden.
+#[test]
+fn divergence_d1_duplicate_binding_key() {
+ if skip() {
+ return;
+ }
+ let cert = isabelle_dir().join("fixtures-added").join("bad_dup_key.tsv");
+ if common::skip_unless(cert.exists(), "isabelle/fixtures-added/bad_dup_key.tsv", "it is committed") {
+ return;
+ }
+ let rules = horn_fixture("builtin_rules.tsv");
+ let asserted = horn_fixture("asserted.tsv");
+ let lean = run_lean(&rules, &asserted, &cert);
+ let isa = run_isabelle(&rules, &asserted, &cert);
+
+ assert_eq!(lean.exit, 0, "Lean accepts a duplicate binding key, first-wins");
+ assert_eq!(
+ lean.verdict.as_deref(),
+ Some("entailed"),
+ "and it accepts with the ABSOLUTE verdict, which is what makes the divergence \
+ worth reporting rather than filing"
+ );
+ assert_eq!(isa.exit, 1, "Isabelle rejects it as malformed");
+ assert_ne!(lean, isa, "if these ever agree, D1 has been resolved and this test should say how");
+}
+
+/// **Divergence D2.** A binding that does not cover every variable of the rule, where
+/// the missing variable's NAME is itself a term in the graph.
+///
+/// The certificate in `isabelle/fixtures-differential/` cites a one-atom rule
+/// `?s <p> ?o -> ?s <q> ?o` over a graph whose only triple is `s <p> <b>` — note the
+/// subject is the bare term `s`, spelled exactly like the rule's variable. The binding
+/// supplies `o` and omits `s`.
+///
+/// * Isabelle: `binding_covers` requires every variable of the rule to have a binding,
+/// and returns `R_binding_incomplete`. Its instantiation `iptriple` is PARTIAL, so an
+/// unbound variable has no value at all and there is nothing to fall through to.
+/// * Lean: `substOf` is total by construction — `(List.lookup v l).getD v` — so an
+/// unbound variable takes its own NAME as its value. `s` becomes the term `s`, the
+/// body instantiates to the asserted triple, the head instantiates to the claimed
+/// conclusion, and the step checks.
+///
+/// Which side is wrong depends on which question is being asked, and the two questions
+/// have opposite answers. That is worth saying plainly rather than picking a winner.
+///
+/// On "is the conclusion entailed under this rule table?", LEAN IS RIGHT. `EntailsR`
+/// quantifies over every total substitution, so a step whose body instantiates into known
+/// triples under SOME total substitution really does entail its conclusion, and the
+/// substitution Lean used is a real one. Isabelle's rejection is incompleteness, and a
+/// false alarm is the harmless direction.
+///
+/// On "is this a well-formed certificate?", ISABELLE IS RIGHT, and
+/// `divergence_d2b_unsafe_rule_head` is why: Lean's default does not merely admit more
+/// certificates, it FABRICATES a term out of a variable's name and puts it in the
+/// conclusion. A certificate can therefore be accepted whose conclusion is not a writable
+/// RDF triple at all.
+///
+/// This also contradicts, ACROSS the two checkers, a claim proved inside one of them.
+/// Isabelle's `coverage_implied` says removing the coverage check cannot change its
+/// accept/reject bit, and that is true — of Isabelle, where instantiation is partial, so
+/// a missing binding kills the step anyway. It does not transfer: Lean's instantiation is
+/// total, so the same check is load-bearing there and in the opposite direction. A
+/// property proved of one formalisation's checker is not a property of the format, and
+/// this is what that looks like when it bites.
+///
+/// Neither side is adjusted. What the pair needs is a sentence in the format saying
+/// whether a binding must be total over the rule's variables; until there is one, a
+/// certificate's validity depends on which verified checker reads it.
+#[test]
+fn divergence_d2_binding_omits_a_variable_named_like_a_term() {
+ if skip() {
+ return;
+ }
+ let rules = differential_fixture("varname_rules.tsv");
+ let asserted = differential_fixture("varname_asserted.tsv");
+ let cert = differential_fixture("varname_unbound_cert.tsv");
+ if common::skip_unless(
+ rules.exists() && asserted.exists() && cert.exists(),
+ "isabelle/fixtures-differential/varname_*.tsv",
+ "they are committed",
+ ) {
+ return;
+ }
+
+ let lean = run_lean(&rules, &asserted, &cert);
+ let isa = run_isabelle(&rules, &asserted, &cert);
+ assert_eq!(lean.exit, 0, "Lean accepts: the omitted variable takes its own name, which matches");
+ assert_eq!(
+ lean.verdict.as_deref(),
+ Some("entailed_under_supplied_rules"),
+ "relativised, because this is a user table and nothing discharges it"
+ );
+ assert_eq!(isa.exit, 1, "Isabelle rejects: binding_incomplete");
+ assert_ne!(lean, isa, "if these ever agree, D2 has been resolved and this test should say how");
+
+ // The control. Bind `s` as well and both accept, so the divergence is about the
+ // MISSING binding and not about anything else in these three files.
+ let full = differential_fixture("varname_bound_cert.tsv");
+ if full.exists() {
+ let lean = run_lean(&rules, &asserted, &full);
+ let isa = run_isabelle(&rules, &asserted, &full);
+ assert_eq!(lean.exit, 0, "the fully bound certificate must be accepted by Lean");
+ assert_eq!(isa.exit, 0, "and by Isabelle");
+ assert_eq!(lean, isa, "with the same verdict");
+ }
+}
+
+/// **Divergence D2c: the same hole, found by the fuzzer rather than designed.**
+///
+/// The three files here are not hand-built. `d2c_fuzzfound_rules.tsv` is
+/// `probe_degen2_rules.tsv` with ONE field replaced by the seeded fuzzer: the body's
+/// object pattern `?o` became a bare `?`, which both parsers read as a variable whose
+/// NAME IS THE EMPTY STRING. The graph's object is an empty field. So Lean's default
+/// sends the unbound variable `""` to the term `""`, the body instantiates to the
+/// asserted triple, and the step checks. Isabelle wants a binding for `""` and does not
+/// find one.
+///
+/// It is worth its own test because of where it came from. D2a needed a graph whose
+/// subject was spelled like a variable, and the obvious objection is that nobody writes
+/// such a graph. This one needed a single character to change in a rule file. The hole is
+/// reachable by a typo, and `substOf`'s silent default is what turns a typo into an
+/// accepted certificate rather than an error.
+#[test]
+fn divergence_d2c_fuzzer_found_the_same_hole_through_a_typo() {
+ if skip() {
+ return;
+ }
+ let rules = differential_fixture("d2c_fuzzfound_rules.tsv");
+ let asserted = differential_fixture("d2c_fuzzfound_asserted.tsv");
+ let cert = differential_fixture("d2c_fuzzfound_cert.tsv");
+ if common::skip_unless(
+ rules.exists() && asserted.exists() && cert.exists(),
+ "isabelle/fixtures-differential/d2c_fuzzfound_*.tsv",
+ "they are committed",
+ ) {
+ return;
+ }
+
+ // One field apart from the probe it was fuzzed from, and that field is the bare `?`.
+ let original = std::fs::read_to_string(differential_fixture("probe_degen2_rules.tsv")).unwrap();
+ let fuzzed = std::fs::read_to_string(&rules).unwrap();
+ let a: Vec<&str> = original.trim_end().split('\t').collect();
+ let b: Vec<&str> = fuzzed.trim_end().split('\t').collect();
+ assert_eq!(a.len(), b.len(), "the fuzzer changed a field, not the field count");
+ let differing: Vec<usize> = (0..a.len()).filter(|i| a[*i] != b[*i]).collect();
+ assert_eq!(differing.len(), 1, "exactly one field differs: {a:?} vs {b:?}");
+ assert_eq!(b[differing[0]], "?", "and the one that differs is a bare question mark");
+
+ assert_eq!(
+ binding_defect(&rules, &cert),
+ Some(
+ "D2: the binding does not cover every variable of the cited rule. Isabelle \
+ rejects (R_binding_incomplete); Lean's substOf sends the unbound variable \
+ to its own NAME and carries on, so the step checks whenever that name is \
+ the term the certificate used."
+ ),
+ "this must be classified as D2 and not as something new"
+ );
+
+ let lean = run_lean(&rules, &asserted, &cert);
+ let isa = run_isabelle(&rules, &asserted, &cert);
+ assert_eq!(lean.exit, 0, "Lean accepts: the empty-named variable takes the empty term");
+ assert_eq!(isa.exit, 1, "Isabelle rejects: binding_incomplete");
+ assert_ne!(lean, isa);
+}
+
+/// **Divergence D2b, the sharp form of D2.** A rule whose HEAD carries a variable its
+/// body never binds, and a certificate that does not bind it either.
+///
+/// The rule is `?s <p> ?o -> ?s <q> ?z`. The graph is one ordinary triple of IRIs,
+/// `<a> <p> <b>`; nothing about it is contrived. The certificate binds `s` and `o`, omits
+/// `z`, and claims the conclusion `<a> <q> z`.
+///
+/// Lean accepts it. `substOf` sends the unbound `z` to the string `"z"`, the head
+/// instantiates to exactly the claimed conclusion, and the run reports
+/// `entailed_under_supplied_rules`. Isabelle rejects it, `R_binding_incomplete`.
+///
+/// This is the same hole as D2 and a worse consequence. The accepted conclusion contains
+/// the term `z`, which is not an IRI, not a blank node and not a literal: it is not RDF,
+/// and no serialiser can write it. Lean's term type is an opaque string, so nothing in
+/// the checker notices. The term was never written by the certificate's author; it was
+/// minted out of a VARIABLE NAME in the rule file.
+///
+/// It is still not unsoundness. `EntailsR` is a statement about `Interp`, whose `ι` is
+/// total over terms, so `<a> <q> z` genuinely holds in every interpretation that models
+/// the graph and satisfies the rule. The theorem is true. What is false is the thing a
+/// reader takes the theorem to be about.
+///
+/// The engine already refuses to EVALUATE such a rule: `parse_rules` in `src/reason.rs`
+/// rejects "a head variable the body never binds", and `reason_horn_emit_test.rs` gates
+/// it. That guard is in the PRODUCER only. `oo-horn` is a checker anyone may point at any
+/// rule file, and it has no such guard, so the guarantee evaporates exactly when the
+/// certificate did not come from this engine — which is the only case in which an
+/// independent checker is worth having.
+#[test]
+fn divergence_d2b_unsafe_rule_head() {
+ if skip() {
+ return;
+ }
+ let rules = differential_fixture("unsafehead_rules.tsv");
+ let asserted = differential_fixture("unsafehead_asserted.tsv");
+ let cert = differential_fixture("unsafehead_cert.tsv");
+ if common::skip_unless(
+ rules.exists() && asserted.exists() && cert.exists(),
+ "isabelle/fixtures-differential/unsafehead_*.tsv",
+ "they are committed",
+ ) {
+ return;
+ }
+
+ // The conclusion the certificate claims really does carry a bare `z`. If this ever
+ // stops being true the test below is checking something else.
+ let text = std::fs::read_to_string(&cert).unwrap();
+ let step = parse_step(text.lines().next().unwrap()).expect("the probe must parse");
+ assert_eq!(step.concl[2], "z", "the claimed conclusion must carry the bare term `z`: {text}");
+ assert!(
+ !step.binds.iter().any(|(k, _)| k == "z"),
+ "and the binding must NOT mention z, or there is nothing to fabricate: {text}"
+ );
+
+ let lean = run_lean(&rules, &asserted, &cert);
+ let isa = run_isabelle(&rules, &asserted, &cert);
+ assert_eq!(
+ lean.exit, 0,
+ "Lean accepts a conclusion containing a term minted from a variable's name"
+ );
+ assert_eq!(lean.verdict.as_deref(), Some("entailed_under_supplied_rules"));
+ assert_eq!(isa.exit, 1, "Isabelle rejects: binding_incomplete");
+ assert_ne!(lean, isa, "if these ever agree, D2b has been resolved and this test should say how");
+}
+
+/// The corners of the term format that no generated certificate reaches. Both
+/// formalisations flag them as untested and each names a different reason to worry:
+/// Isabelle's DECISION M38 says the fixtures are pure ASCII, "which is exactly the
+/// circumstance in which a String.literal implementation would stay silent", and its M1
+/// says terms are opaque byte strings with no value-space normalisation.
+///
+/// Both concerns are settled here, empirically, in the agreeing direction:
+///
+/// * A non-ASCII IRI round-trips through both checkers, and altering one byte of it is
+/// rejected by both. Isabelle's verified core is over `string = char list` and its
+/// driver uses SML's own `String.explode` on a byte string, so the bytes reach the
+/// theorem unchanged; the ASCII trap M38 warns about is a trap that was avoided, not
+/// one that was never there.
+/// * `"01"^^xsd:integer` and `"1"^^xsd:integer` are ONE value and TWO terms, and both
+/// checkers reject a certificate that swaps one for the other. M1's scope note holds
+/// on both sides: no datatype-aware rule is in the table, and neither checker
+/// normalises.
+/// * `http://ex.org/a` without angle brackets does not collide with `<http://ex.org/a>`
+/// on either side, which is the injectivity that Isabelle's DECISION D-PARSE-2 needs
+/// for bracket-stripping to be invisible to the accept/reject bit. Isabelle strips the
+/// brackets and Lean does not, so if the renaming were not injective this is where the
+/// two would part company.
+#[test]
+fn the_untested_corners_of_the_term_format_agree() {
+ if skip() {
+ return;
+ }
+ // (probe, expected exit, what it is for). The exit code rather than a bare bit,
+ // because 2 is a THIRD answer and a checker that turned an unparseable file into a
+ // rejection would still look like agreement on the accept/reject bit alone.
+ let expected: &[(&str, i32, &str)] = &[
+ ("utf8", 0, "non-ASCII UTF-8 IRIs in the rule, the graph and the certificate"),
+ ("utf8bad", 1, "one byte of a non-ASCII IRI altered in the certificate"),
+ ("literals", 0, "a language-tagged literal and a datatyped literal"),
+ ("litdt", 1, "\"01\"^^xsd:integer standing in for \"1\"^^xsd:integer"),
+ ("bnode", 0, "blank node labels in every position"),
+ ("degen", 0, "the degenerate spellings <> and _:"),
+ ("degen2", 0, "a bare < and an empty field as terms"),
+ ("inject", 1, "an IRI without its angle brackets, against one with them"),
+ ("emptybody", 0, "a rule with an empty body, cited with no premises"),
+ ("repeated", 0, "a rule whose body repeats one atom, cited twice"),
+ ("extrabind", 0, "a binding for a variable the rule never mentions"),
+ ("qmarkkey", 1, "binding keys written WITH the question mark"),
+ // Degenerate files, where an off-by-one in either parser would show up.
+ ("emptyall", 0, "an empty rule table and an empty certificate"),
+ ("emptyrules", 1, "an empty rule table and a step that cites rule 0"),
+ ("emptygraph", 0, "an empty graph and a rule with an empty body"),
+ ("allempty", 0, "all three files empty"),
+ ("duprow", 0, "the built-in table with one row duplicated after the cited index"),
+ ("trailtab", 2, "a trailing tab on every certificate line"),
+ ("crlf", 1, "CRLF line endings, so every last field carries a stray carriage return"),
+ ("blank", 0, "blank lines at the start and end of all three files"),
+ ("nonl", 0, "no trailing newline anywhere"),
+ ("hugeidx", 1, "a rule index of 200 digits"),
+ ];
+ let dir = isabelle_dir().join("fixtures-differential");
+
+ // Two probes are about BYTES, and `.gitattributes` says `*.tsv text eol=lf`, which
+ // would rewrite one of them into a file that tests nothing while still reporting
+ // green. A `-text` exception keeps the carriage returns; this is the guard that
+ // notices if the exception is ever dropped, because a probe that has been normalised
+ // away passes silently and that is the failure this repository exists to catch.
+ for f in ["probe_crlf_rules.tsv", "probe_crlf_asserted.tsv", "probe_crlf_cert.tsv"] {
+ let p = dir.join(f);
+ if p.exists() {
+ let bytes = std::fs::read(&p).unwrap();
+ assert!(
+ bytes.contains(&b'\r'),
+ "{f} has lost its carriage returns. `.gitattributes` normalises *.tsv to \
+ LF and this file needs the `-text` exception; without the CR it is a \
+ probe that passes without probing anything"
+ );
+ }
+ }
+ let p = dir.join("probe_nonl_cert.tsv");
+ if p.exists() {
+ let bytes = std::fs::read(&p).unwrap();
+ assert!(
+ !bytes.ends_with(b"\n"),
+ "probe_nonl_cert.tsv is supposed to end WITHOUT a newline; something has \
+ added one and the probe now tests the ordinary case"
+ );
+ }
+
+ let mut checked = 0;
+ for (name, want_exit, what) in expected {
+ let r = dir.join(format!("probe_{name}_rules.tsv"));
+ let a = dir.join(format!("probe_{name}_asserted.tsv"));
+ let c = dir.join(format!("probe_{name}_cert.tsv"));
+ if common::skip_unless(
+ r.exists() && a.exists() && c.exists(),
+ &format!("isabelle/fixtures-differential/probe_{name}_*.tsv"),
+ "they are committed",
+ ) {
+ continue;
+ }
+ let lean = run_lean(&r, &a, &c);
+ let isa = run_isabelle(&r, &a, &c);
+ assert_eq!(lean, isa, "the two kernels disagree on {name} ({what})");
+ assert_eq!(
+ lean.exit, *want_exit,
+ "{name} ({what}) was expected to exit {want_exit}, and both kernels say \
+ {}. Agreement on the WRONG answer is the failure mode a differential cannot \
+ see on its own, which is why the expected answer is written down here",
+ lean.exit
+ );
+ checked += 1;
+ }
+ assert_eq!(checked, expected.len(), "every probe must have run");
+
+ // Every committed probe must appear in the table above. Without this, adding a
+ // fixture and forgetting to say what it should do would leave it checked for
+ // agreement only, which is the weaker half.
+ let listed: std::collections::BTreeSet<&str> = expected.iter().map(|(n, _, _)| *n).collect();
+ let on_disk: Vec<String> = probe_cases()
+ .iter()
+ .map(|c| c.name.trim_start_matches("probe-").to_string())
+ .collect();
+ for name in &on_disk {
+ assert!(
+ listed.contains(name.as_str()),
+ "isabelle/fixtures-differential/probe_{name}_*.tsv is committed but this test \
+ does not say what it should do"
+ );
+ }
+}
+
+/// Agreement is about the checking discipline. It is not a proof, and nothing in this
+/// file's output may be read as one.
+///
+/// This test exists because the claim is easy to overstate and the overstatement is the
+/// exact failure the project is built to catch. It pins the two facts that bound what
+/// the differential can mean: a certificate that is accepted over a USER table earns the
+/// relativised verdict on BOTH sides, and the two sides name DIFFERENT theorems for it,
+/// because each side's warrant is its own.
+#[test]
+fn agreement_is_about_the_definitions_and_is_not_itself_a_proof() {
+ if skip() {
+ return;
+ }
+ let rules = horn_fixture("user_rules.tsv");
+ let asserted = horn_fixture("asserted.tsv");
+ let cert = horn_fixture("good.tsv");
+
+ let lean_out = Command::new(lean_checker())
+ .arg("check")
+ .arg(&rules)
+ .arg(&asserted)
+ .arg(&cert)
+ .output()
+ .expect("run oo-horn");
+ let lean_json = String::from_utf8_lossy(&lean_out.stdout).to_string();
+ let isa_out = Command::new(isabelle_checker())
+ .arg("check")
+ .arg(&rules)
+ .arg(&asserted)
+ .arg(&cert)
+ .output()
+ .expect("run oo-horn-isabelle");
+ let isa_json = String::from_utf8_lossy(&isa_out.stdout).to_string();
+
+ assert_eq!(json_field(&lean_json, "verdict").as_deref(), Some("entailed_under_supplied_rules"));
+ assert_eq!(json_field(&isa_json, "verdict").as_deref(), Some("entailed_under_supplied_rules"));
+
+ let lean_thm = json_field(&lean_json, "theorem").unwrap();
+ let isa_thm = json_field(&isa_json, "theorem").unwrap();
+ assert_ne!(
+ lean_thm, isa_thm,
+ "each side must name ITS OWN theorem. If they ever printed the same string, a \
+ reader could take one side's agreement as the other side's warrant, which is \
+ precisely the laundering this layer exists to prevent"
+ );
+ assert!(lean_thm.starts_with("OOCert."), "{lean_thm}");
+ assert!(isa_thm.starts_with("OOHorn."), "{isa_thm}");
+
+ for json in [&lean_json, &isa_json] {
+ assert!(
+ json.contains("assumed, not checked"),
+ "a run over a user table must say the rules are assumed: {json}"
+ );
+ }
+}