Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.
Rust ai-nativedescription-logicsformal-verificationinfrastructure-as-codeisabelle-languageknowledge-graphleanlean4mcpmcp-serverontologyowlowl2reasoningrustshaclsparqltheorem-proving
Certify every class, and say in the report which constructs the certificate does not cover
FABIOTESScaf9a6be6a8c
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex f63fbc02..26f5be19 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -326,6 +326,10 @@ jobs:# forces every target into the default set and this step measures the# verified evaluator, so both halves of that failure are closed.run: OO_REQUIRE_FIXTURES=1 cargo test --test shacl_core_verified_test -- --nocapture+ - name: Check the description-logic model certificates+ run: OO_REQUIRE_FIXTURES=1 cargo test --test dl_model_certificate_test -- --nocapture+ - name: Check the refutation certificates+ run: OO_REQUIRE_FIXTURES=1 cargo test --test lean_refutation_test -- --nocapture- name: Check the mixed certificate layerrun: OO_REQUIRE_FIXTURES=1 cargo test --test lean_mixed_certificate_test -- --nocapture- name: Check the generic Horn-rule layer, and that a user rule cannot earn the absolute verdictdiff --git a/docs/decisions/0002-an-inference-carries-a-certificate.md b/docs/decisions/0002-an-inference-carries-a-certificate.mdindex d69ef6d9..8c24991d 100644--- a/docs/decisions/0002-an-inference-carries-a-certificate.md+++ b/docs/decisions/0002-an-inference-carries-a-certificate.md@@ -5,7 +5,9 @@checker in `lean/` with `OOCert.certificate_sound` machine-checked, axioms pinned by`#guard_msgs` · every shipped ontology certified in CI (`tests/lean_certificate_test.rs`) ·**opt-in, default unchanged** · the `owl-dl` tableaux path refuses the flag rather than- pretending · not covered: SHACL, the tableaux reasoner, the parsers+ pretending · the SHIQ tableaux reasoner now certifies its POSITIVE answers+ (`Dl.satisfiable_of_checkModel`, decision 0004); its negative answers and the+ parsers remain uncovered- **Written**: 2026-09-13- **Related**: decision 0001 (an inference is not an assertion); issues #131 and #132, fixed thesame day; `tests/reason_rl_ext_soundness_test.rs`, the first thing the layer caught@@ -64,5 +66,9 @@ on the engine's author having thought of the bug.It does not make ontologies "correct". It makes every OWL-RL inference the engine reportsindependently checkable against a formal semantics with a proved checker. Whether an ontology sayswhat its author meant is a different question and no proof answers it. The SHACL validator, the-SHIQ tableaux reasoner and the RDF parsers are outside the theorem; the differential oracle+RDF parsers are outside the theorem. The SHIQ tableaux reasoner is partly inside it now: when it+answers that a class is satisfiable or an ontology consistent it has built a completion graph, that+graph is a model, and `Dl.checkModel` verifies it. When it answers unsatisfiable or inconsistent it+still carries no certificate, because that needs a refutation rather than a model, and the report+says so rather than leaving the reader to assume symmetry. The differential oracleagainst pyshacl (`tools/shacl_differential.py`) remains the gate for SHACL.diff --git a/lean/Shacl/Agreement.lean b/lean/Shacl/Agreement.leanindex 4b07c7a3..99e40030 100644--- a/lean/Shacl/Agreement.lean+++ b/lean/Shacl/Agreement.lean@@ -18,6 +18,22 @@ Both are conditional on `eval` having returned `.ok`. When it refuses there isnothing to be sound about, and the refusal is reported rather than rounded into averdict.+## This has been seen to fail++Replacing the refusal in `evalCompare` with `.ok []`, so that a comparison the term+model cannot make is reported as CONFORMING rather than declined, does not compile:++```text+error: Shacl/Agreement.lean:319:49: unsolved goals+ hc : cmpTerms c f = none+ h : Except.ok [] = Except.ok rs+ ⊢ ¬rs = []+```++That is the whole point of the exercise. `Conf` says a node whose comparison is+unknown does not conform, so an evaluator that answers `conforms` there cannot be+proved to agree with it, and the build stops. An evaluator that refuses can.+## What is NOT claimed* Nothing here says the specification in `Spec.lean` IS the W3C Recommendation.@@ -31,11 +47,17 @@ verdict.the licensing theorem. It pins `blamed` and `blamedNode`, which are what make aresult true or false; the other fields are presentation.* **Completeness is claimed for the VERDICT, not for the result list.** `sh:and`,- `sh:or`, `sh:not` and `sh:node` each report ONE result for a whole failing- subtree, which is what the Recommendation asks for, so "one result per failing- atomic constraint" is neither claimed nor true. What is claimed is that the report- is empty exactly when the node conforms, which is the property a consumer of+ `sh:or`, `sh:not`, `sh:node` and `sh:xone` each report ONE result for a whole+ failing subtree, which is what the Recommendation asks for, so "one result per+ failing atomic constraint" is neither claimed nor true. What is claimed is that the+ report is empty exactly when the node conforms, which is the property a consumer of`sh:conforms` relies on.+* **The property-pair constraints report one result per focus node, where the+ Recommendation asks for one per offending value.** `sh:equals`, `sh:disjoint`,+ `sh:lessThan` and `sh:lessThanOrEquals` are the four; see `violationPair` in+ `Shacl/Eval.lean`. The verdict is unaffected and every result produced is licensed,+ but a consumer counting results will count fewer than a fully conforming validator+ would. `sh:closed` does report one per offending triple.-/namespace Shacl@@ -69,9 +91,9 @@ theorem check_spec {b : Bool} {r : Result} {rs : List Result} (h : check b r = ./-- The shape every leaf constraint takes: a decision whose truth is exactly thespecification's condition, and, when it is false, one result blaming that very-constraint at that very node. Stating it once keeps eleven cases of the induction-below to three lines each, and keeps the licensing argument from being retyped-eleven times with a chance to drift. -/+constraint at that very node. Stating it once keeps most cases of the induction+below to three lines each, and keeps the licensing argument from being retyped once+per constraint with a chance to drift. -/theorem leafCase {G : Graph} {b : Bool} {r : Result} {rs : List Result} {s : Shape} {f : Term}(h : check b r = .ok rs) (hb : b = true ↔ Conf G s f)(hbl : r.blamed = s) (hbn : r.blamedNode = f) :diff --git a/lean/Shacl/Eval.lean b/lean/Shacl/Eval.leanindex b080b0a7..ff507c20 100644--- a/lean/Shacl/Eval.lean+++ b/lean/Shacl/Eval.lean@@ -10,25 +10,31 @@ with `Shacl/Spec.lean`.## The third answer`eval` returns `Except Refusal (List Result)`, and the error side is not a crash.-It is the evaluator declining to decide, in the two places where deciding would+It is the evaluator declining to decide, in the four places where deciding wouldmean guessing:* a literal carries the datatype a `sh:datatype` constraint asks for, and thisdevelopment does not know that datatype's lexical space, so it cannot say whetherthe literal is well formed;+* a value-range or property-pair constraint has to order two terms and `cmpTerms`+ knows no rule that orders them. Note that this is NOT the case where SPARQL's `<`+ raises a type error: that one is a verdict and produces a violation;+* a length or pattern constraint has to read the string a spelling denotes and the+ spelling carries a backslash escape, which nothing here decodes;* the `rdfs:subClassOf` closure did not reach a fixpoint inside the iterationbudget, so the set of superclasses computed is not known to be complete.-Both are reported by name. A refusal propagates: one undecidable constraint makes-the whole run undetermined rather than letting the rest of the report imply a+All four are reported by name. A refusal propagates: one undecidable constraint+makes the whole run undetermined rather than letting the rest of the report imply averdict the undecided part could have overturned. The alternative, answering`conforms` because the hard constraint was skipped, is the failure mode thisrepository exists to catch.-The second refusal has never been observed to fire: `subIter` runs `|G| + 1`+The last refusal has never been observed to fire: `subIter` runs `|G| + 1`rounds and the closure of a subclass graph with `|G|` edges settles in at most`|G|`. It is a guard against an argument, not against a measurement, and the guard-is cheap enough to keep.+is cheap enough to keep. The first three all fire against the W3C suite or against+the fixtures in `tests/fixtures/shaclcore/`.## Performancediff --git a/lean/Shacl/Report.lean b/lean/Shacl/Report.leanindex 3f2c21a6..4b899b48 100644--- a/lean/Shacl/Report.lean+++ b/lean/Shacl/Report.lean@@ -196,8 +196,9 @@ theorem validate_spec {G : Graph} :/-! ## Axioms, pinned-The same three the derivation checker in `lean/OOCert/` depends on. A `sorry` or a-`native_decide` anywhere under these theorems changes this list and fails the+The same three the derivation checker in `lean/OOCert/` depends on, except where a+theorem genuinely needs fewer, in which case the pin says so. A `sorry` or a+`native_decide` anywhere under these theorems changes the list and fails thebuild. -//-- info: 'Shacl.eval_conforms_iff' depends on axioms: [propext, Classical.choice, Quot.sound] -/@@ -216,4 +217,21 @@ build. -/#guard_msgs in#print axioms mem_focusNodes+-- The path semantics: the enumeration and the specification are the same set.+-- `sh:minCount` and everything else that counts value nodes rests on this one.+/-- info: 'Shacl.mem_valueNodes' depends on axioms: [propext, Classical.choice, Quot.sound] -/+#guard_msgs in+#print axioms mem_valueNodes++-- The pattern matcher decides the pattern relation. A strict SUBSET of the+-- footprint above, pinned at what it actually is: the matcher and its proof never+-- reach `Classical.choice`.+/-- info: 'Shacl.regexMatchB_iff' depends on axioms: [propext, Quot.sound] -/+#guard_msgs in+#print axioms regexMatchB_iff++/-- info: 'Shacl.mem_qualifyingNodes' depends on axioms: [propext, Classical.choice, Quot.sound] -/+#guard_msgs in+#print axioms mem_qualifyingNodes+end Shacldiff --git a/lean/Shacl/Term.lean b/lean/Shacl/Term.leanindex 211367bb..bd3ca970 100644--- a/lean/Shacl/Term.lean+++ b/lean/Shacl/Term.lean@@ -187,7 +187,7 @@ def NodeKind.admits : NodeKind → Kind → Bool| .iriOrLiteral, .lit => true| _, _ => false-/-! ## Lexical spaces, for the five datatypes this module is willing to judge -/+/-! ## Lexical spaces, for the datatypes this module is willing to judge -/def isDigits (cs : List Char) : Bool := !cs.isEmpty && cs.all Char.isDigitdiff --git a/lean/Shacl/Witness.lean b/lean/Shacl/Witness.leanindex 96ba2c68..675abf55 100644--- a/lean/Shacl/Witness.lean+++ b/lean/Shacl/Witness.lean@@ -30,6 +30,22 @@ derivation checker.| `a_sequence_path_does_not_stop_halfway` | and the intermediate node is not a value node || `zero_or_one_admits_the_focus_node` | `sh:zeroOrOnePath` gives a bare focus node one value node |+## These have been seen to fail++Changing `strRep` so that a blank node reports `chars []` rather than `noString`,+which is the natural mistake (a blank node has no string, so treat it as the empty+one), leaves the whole development compiling and the agreement theorem true, because+the specification and the evaluator both read `strRep`. This file is what stops it:++```text+error: Shacl/Witness.lean:284:62: Tactic `decide` proved that the proposition+ ¬Conf [] (Shape.minLength 0) "_:b"+is false+```++A witness pins a reading of the Recommendation that no proof about internal+agreement can pin. That is why they are here and why each one comes in a pair.+The two counting theorems are the ones worth reading. SHACL counts distinct valuenodes, so a triple asserted twice must not make a `sh:maxCount 1` fail. An enginethat counts SPARQL solutions rather than value nodes gets that wrong, and the@@ -223,7 +239,7 @@ theorem the_refused_literal_does_not_conform :subst thisexact absurd hok (by decide)-/-! ## The parameters added after the first eleven+/-! ## The parameters added after the first eleven componentsEach one below exhibits a model and something the semantics does NOT entail, thesame discipline the two counting theorems follow. A one-sided witness would leavediff --git a/lean/ShaclMain.lean b/lean/ShaclMain.leanindex 8cd898e0..a2af6e69 100644--- a/lean/ShaclMain.lean+++ b/lean/ShaclMain.lean@@ -11,10 +11,11 @@ Exit codes, chosen so that a harness cannot mistake one answer for another:* `0` a verdict was reached. `"conforms"` is `true` or `false`.* `2` a file could not be read or parsed. No verdict.* `3` UNDETERMINED. The shapes graph uses something this development does not- implement, or the evaluator declined to judge a literal. No verdict, and the- reason is printed. This is the code that matters: it is the difference between- "everything conforms" and "I did not check everything", and collapsing the two- is the failure this whole layer exists to avoid.+ implement, or the evaluator declined to judge a literal, to order two terms, or to+ count the characters of an escaped spelling. No verdict, and the reason is printed.+ This is the code that matters: it is the difference between "everything conforms"+ and "I did not check everything", and collapsing the two is the failure this whole+ layer exists to avoid.The verdict and the results carry `"theorem": "Shacl.validate_spec"`, which is themachine-checked statement they are covered by: the report is empty exactly whendiff --git a/src/tableaux.rs b/src/tableaux.rsindex 67291bce..b77c4bc8 100644--- a/src/tableaux.rs+++ b/src/tableaux.rs@@ -2723,12 +2723,36 @@ impl DlReasoner {Ok(o) => o.describe(),Err(e) => format!("no certificate: {e}"),};+ // Per class as well as per ontology. TBox consistency is honestly+ // witnessed by a single point with empty extensions, which really+ // is what consistency means and is a weak-looking artefact; the+ // per-class certificates are the informative ones, and the sweep+ // that validated this layer used them.+ let mut classes = serde_json::Map::new();+ for (i, class) in reasoner.named_class_names().iter().enumerate() {+ let sub = root.join("classes").join(i.to_string());+ classes.insert(+ class.clone(),+ serde_json::json!(describe(reasoner.certify_class_satisfiable(class, &sub))),+ );+ }+ let unmodelled = DlReasoner::unmodelled_constructs(graph);output["model_certificate"] = serde_json::json!({"dir": root.display().to_string(),"tbox": describe(reasoner.certify_tbox_consistent(&root.join("tbox"))),"abox": describe(reasoner.certify_abox_consistent(&root.join("abox"))),+ "classes": classes,"checker": "oo-dlmodel","theorem": "Dl.satisfiable_of_checkModel",+ // The constructs below are IN THE GRAPH and NOT in the axioms+ // the certificate is about, so where this list is non-empty the+ // certificate describes a weaker axiom set than the ontology+ // states. Read the verdict against this list, not on its own.+ "certifies_a_weaker_axiom_set": !unmodelled.is_empty(),+ "constructs_not_modelled": unmodelled+ .iter()+ .map(|(k, n)| serde_json::json!({"construct": k, "occurrences": n}))+ .collect::<Vec<_>>(),"not_covered": "unsatisfiability and inconsistency carry no certificate",});}@@ -3747,6 +3771,60 @@ impl DlReasoner {/// No `nonempty` line is needed: `Dl.WellFormed` already requires the domain/// to be non-empty, so a model of the axiom set alone is exactly what TBox/// consistency asserts.+ /// The named classes, in the interner's order, so a caller can certify each+ /// one. `run` uses it because TBox consistency alone is witnessed by a+ /// single point with empty extensions, which is honest and uninformative.+ pub fn named_class_names(&self) -> Vec<String> {+ let mut v: Vec<String> = self+ .named_classes+ .iter()+ .map(|id| self.interner.resolve(*id).to_string())+ .collect();+ v.sort();+ v+ }++ /// The OWL constructs present in the graph that this certificate layer does+ /// not model, with a count of each.+ ///+ /// This matters more than it looks. The emitter certifies that a finite+ /// interpretation satisfies THE AXIOMS IT EMITTED, and a construct the+ /// parser does not recognise is absent from both sides. So an ontology+ /// leaning on nominals, role chains, `owl:sameAs` or datatypes gets a+ /// perfectly valid certificate about a WEAKER axiom set than the one it+ /// actually states, and a reader who is not told that will draw a stronger+ /// conclusion than the proof supports. Naming them in a source comment is+ /// not enough: it has to be in the report, next to the verdict.+ pub fn unmodelled_constructs(graph: &Arc<GraphStore>) -> Vec<(String, u64)> {+ const NOT_MODELLED: [(&str, &str); 8] = [+ ("owl:sameAs", "http://www.w3.org/2002/07/owl#sameAs"),+ ("owl:differentFrom", "http://www.w3.org/2002/07/owl#differentFrom"),+ ("owl:oneOf", "http://www.w3.org/2002/07/owl#oneOf"),+ ("owl:hasValue", "http://www.w3.org/2002/07/owl#hasValue"),+ ("owl:propertyChainAxiom", "http://www.w3.org/2002/07/owl#propertyChainAxiom"),+ ("owl:hasKey", "http://www.w3.org/2002/07/owl#hasKey"),+ ("owl:ReflexiveProperty", "http://www.w3.org/2002/07/owl#ReflexiveProperty"),+ ("owl:IrreflexiveProperty", "http://www.w3.org/2002/07/owl#IrreflexiveProperty"),+ ];+ let mut found = Vec::new();+ for (label, iri) in NOT_MODELLED {+ let q = format!(+ "SELECT (COUNT(*) AS ?n) WHERE {{ {{ ?s <{iri}> ?o }} UNION {{ ?s ?p <{iri}> }} }}"+ );+ let Ok(raw) = graph.sparql_select_union(&q) else { continue };+ let Ok(v) = serde_json::from_str::<serde_json::Value>(&raw) else { continue };+ let n = v["results"][0]["n"]+ .as_str()+ .and_then(|s| s.trim_matches('"').split('"').next())+ .and_then(|s| s.parse::<u64>().ok())+ .unwrap_or(0);+ if n > 0 {+ found.push((label.to_string(), n));+ }+ }+ found+ }+pub fn certify_tbox_consistent(&self, dir: &Path) -> anyhow::Result<ModelOutcome> {let mut tableau = Tableau::with_deadline(Arc::clone(&self.tbox), self.deadline);tableau.capture = true;diff --git a/tests/dl_model_certificate_test.rs b/tests/dl_model_certificate_test.rsindex 7d2e50c6..bddc2200 100644--- a/tests/dl_model_certificate_test.rs+++ b/tests/dl_model_certificate_test.rs@@ -606,3 +606,42 @@ fn a_shipped_ontology_certifies_class_by_class() {);assert_eq!(certified, accepted);}++/// An ontology using constructs the certificate layer does not model gets a+/// perfectly valid certificate about a WEAKER axiom set than it states, and the+/// report has to say so next to the verdict rather than in a source comment.+/// A reader who is not told will draw a stronger conclusion than the proof+/// supports, which is the failure this whole layer exists to avoid.+#[test]+fn a_certificate_over_a_weaker_axiom_set_says_so() {+ let dir = std::env::temp_dir().join(format!("oo-dl-weaker-{}", std::process::id()));+ let _ = std::fs::remove_dir_all(&dir);+ std::fs::create_dir_all(&dir).unwrap();+ let ttl = r#"+ @prefix : <http://ex.org/> .+ @prefix owl: <http://www.w3.org/2002/07/owl#> .+ :Person a owl:Class .+ :alice a :Person .+ :alice owl:sameAs :alicia .+ :grandparentOf owl:propertyChainAxiom ( :parentOf :parentOf ) .+ "#;+ let store = std::sync::Arc::new(open_ontologies::graph::GraphStore::new());+ store.load_turtle(ttl, None).unwrap();++ let dropped = open_ontologies::tableaux::DlReasoner::unmodelled_constructs(&store);+ let names: Vec<&str> = dropped.iter().map(|(k, _)| k.as_str()).collect();+ assert!(+ names.contains(&"owl:sameAs") && names.contains(&"owl:propertyChainAxiom"),+ "both unmodelled constructs must be named, got {names:?}"+ );++ // And the other direction, so the disclosure cannot be a constant.+ let plain = std::sync::Arc::new(open_ontologies::graph::GraphStore::new());+ plain+ .load_turtle("@prefix : <http://ex.org/> . :Person a <http://www.w3.org/2002/07/owl#Class> .", None)+ .unwrap();+ assert!(+ open_ontologies::tableaux::DlReasoner::unmodelled_constructs(&plain).is_empty(),+ "an ontology using nothing unmodelled must report nothing dropped"+ );+}diff --git a/tests/fixtures/shaclcore/baseline.json b/tests/fixtures/shaclcore/baseline.jsonindex e1a4d4ff..10299204 100644--- a/tests/fixtures/shaclcore/baseline.json+++ b/tests/fixtures/shaclcore/baseline.json@@ -3,12 +3,12 @@"suite_commit": "94d8bc2bd4fc4fdc6f2964d1ec4a892329e05f06","counts": {"total": 120,- "pass": 46,+ "pass": 91,"fail": 0,- "undetermined": 74,+ "undetermined": 29,"error": 0},- "partial_compliance": 46,+ "partial_compliance": 91,"outcomes": {"core/complex/personexample": "UNDETERMINED","core/complex/shacl-shacl": "UNDETERMINED",@@ -22,84 +22,84 @@"core/node/class-001": "PASS","core/node/class-002": "PASS","core/node/class-003": "PASS",- "core/node/closed-001": "UNDETERMINED",- "core/node/closed-002": "UNDETERMINED",+ "core/node/closed-001": "PASS",+ "core/node/closed-002": "PASS","core/node/datatype-001": "PASS","core/node/datatype-002": "PASS",- "core/node/disjoint-001": "UNDETERMINED",- "core/node/equals-001": "UNDETERMINED",+ "core/node/disjoint-001": "PASS",+ "core/node/equals-001": "PASS","core/node/hasValue-001": "PASS","core/node/in-001": "PASS",- "core/node/languageIn-001": "UNDETERMINED",- "core/node/maxExclusive-001": "UNDETERMINED",- "core/node/maxInclusive-001": "UNDETERMINED",- "core/node/maxLength-001": "UNDETERMINED",- "core/node/minExclusive-001": "UNDETERMINED",- "core/node/minInclusive-001": "UNDETERMINED",- "core/node/minInclusive-002": "UNDETERMINED",- "core/node/minInclusive-003": "UNDETERMINED",- "core/node/minLength-001": "UNDETERMINED",+ "core/node/languageIn-001": "PASS",+ "core/node/maxExclusive-001": "PASS",+ "core/node/maxInclusive-001": "PASS",+ "core/node/maxLength-001": "PASS",+ "core/node/minExclusive-001": "PASS",+ "core/node/minInclusive-001": "PASS",+ "core/node/minInclusive-002": "PASS",+ "core/node/minInclusive-003": "PASS",+ "core/node/minLength-001": "PASS","core/node/node-001": "PASS","core/node/nodeKind-001": "PASS","core/node/not-001": "PASS","core/node/not-002": "PASS","core/node/or-001": "PASS",- "core/node/pattern-001": "UNDETERMINED",- "core/node/pattern-002": "UNDETERMINED",- "core/node/qualified-001": "UNDETERMINED",- "core/node/xone-001": "UNDETERMINED",- "core/node/xone-duplicate": "UNDETERMINED",- "core/path/path-alternative-001": "UNDETERMINED",+ "core/node/pattern-001": "PASS",+ "core/node/pattern-002": "PASS",+ "core/node/qualified-001": "PASS",+ "core/node/xone-001": "PASS",+ "core/node/xone-duplicate": "PASS",+ "core/path/path-alternative-001": "PASS","core/path/path-complex-001": "UNDETERMINED",- "core/path/path-complex-002": "UNDETERMINED",+ "core/path/path-complex-002": "PASS","core/path/path-inverse-001": "PASS","core/path/path-oneOrMore-001": "UNDETERMINED",- "core/path/path-sequence-001": "UNDETERMINED",- "core/path/path-sequence-002": "UNDETERMINED",- "core/path/path-sequence-duplicate-001": "UNDETERMINED",+ "core/path/path-sequence-001": "PASS",+ "core/path/path-sequence-002": "PASS",+ "core/path/path-sequence-duplicate-001": "PASS","core/path/path-strange-001": "UNDETERMINED","core/path/path-strange-002": "UNDETERMINED","core/path/path-unused-001": "PASS","core/path/path-zeroOrMore-001": "UNDETERMINED",- "core/path/path-zeroOrOne-001": "UNDETERMINED",+ "core/path/path-zeroOrOne-001": "PASS","core/property/and-001": "PASS","core/property/class-001": "PASS",- "core/property/datatype-001": "UNDETERMINED",+ "core/property/datatype-001": "PASS","core/property/datatype-002": "PASS","core/property/datatype-003": "PASS","core/property/datatype-ill-formed": "PASS",- "core/property/disjoint-001": "UNDETERMINED",- "core/property/equals-001": "UNDETERMINED",+ "core/property/disjoint-001": "PASS",+ "core/property/equals-001": "PASS","core/property/hasValue-001": "PASS","core/property/in-001": "PASS",- "core/property/languageIn-001": "UNDETERMINED",- "core/property/lessThan-001": "UNDETERMINED",- "core/property/lessThan-002": "UNDETERMINED",- "core/property/lessThanOrEquals-001": "UNDETERMINED",+ "core/property/languageIn-001": "PASS",+ "core/property/lessThan-001": "PASS",+ "core/property/lessThan-002": "PASS",+ "core/property/lessThanOrEquals-001": "PASS","core/property/maxCount-001": "PASS","core/property/maxCount-002": "PASS",- "core/property/maxExclusive-001": "UNDETERMINED",- "core/property/maxInclusive-001": "UNDETERMINED",- "core/property/maxLength-001": "UNDETERMINED",+ "core/property/maxExclusive-001": "PASS",+ "core/property/maxInclusive-001": "PASS",+ "core/property/maxLength-001": "PASS","core/property/minCount-001": "PASS","core/property/minCount-002": "PASS",- "core/property/minExclusive-001": "UNDETERMINED",- "core/property/minExclusive-002": "UNDETERMINED",- "core/property/minLength-001": "UNDETERMINED",+ "core/property/minExclusive-001": "PASS",+ "core/property/minExclusive-002": "PASS",+ "core/property/minLength-001": "PASS","core/property/node-001": "PASS","core/property/node-002": "PASS","core/property/nodeKind-001": "PASS","core/property/not-001": "PASS","core/property/or-001": "PASS",- "core/property/or-datatypes-001": "UNDETERMINED",- "core/property/pattern-001": "UNDETERMINED",- "core/property/pattern-002": "UNDETERMINED",+ "core/property/or-datatypes-001": "PASS",+ "core/property/pattern-001": "PASS",+ "core/property/pattern-002": "PASS","core/property/property-001": "PASS",- "core/property/qualifiedMinCountDisjoint-001": "UNDETERMINED",- "core/property/qualifiedValueShape-001": "UNDETERMINED",- "core/property/qualifiedValueShapesDisjoint-001": "UNDETERMINED",- "core/property/uniqueLang-001": "UNDETERMINED",- "core/property/uniqueLang-002": "UNDETERMINED",+ "core/property/qualifiedMinCountDisjoint-001": "PASS",+ "core/property/qualifiedValueShape-001": "PASS",+ "core/property/qualifiedValueShapesDisjoint-001": "PASS",+ "core/property/uniqueLang-001": "PASS",+ "core/property/uniqueLang-002": "PASS","core/targets/multipleTargets-001": "PASS","core/targets/targetClass-001": "PASS","core/targets/targetClassImplicit-001": "PASS",diff --git a/tests/shacl_core_verified_test.rs b/tests/shacl_core_verified_test.rsindex ea11e812..370fc4a8 100644--- a/tests/shacl_core_verified_test.rs+++ b/tests/shacl_core_verified_test.rs@@ -20,19 +20,36 @@//! evaluator over the same 120 tests, under the same comparison, in the same four//! buckets, and prints the number.//!-//! # The number is allowed to be small, and it is+//! # A zero in the FAIL column is the claim, not the size of the PASS column//!-//! The Lean development covers eleven constraint components, four target forms and-//! two path forms. Everything else is REFUSED by the compiler in-//! `lean/Shacl/Compile.lean`, which lands in UNDETERMINED. A low PASS count with a-//! zero FAIL count is the shape this should have: it means the coverage is narrow-//! and nothing inside it is wrong. A FAIL is the serious bucket, because a FAIL is-//! the verified evaluator giving an answer that disagrees with the Working Group.+//! The Lean development covers every SHACL Core constraint component, all four+//! target forms, and four of the six path forms. Everything else is REFUSED by the+//! compiler in `lean/Shacl/Compile.lean`, which lands in UNDETERMINED. A zero FAIL+//! count is the shape this must have: a FAIL is the verified evaluator giving an+//! answer that disagrees with the Working Group, which means either the+//! specification in `lean/Shacl/Spec.lean` misreads the Recommendation or the+//! compiler misreads a shapes graph.+//!+//! What is still refused, and why, each named where it lives:+//!+//! * `sh:sparql` and user-defined constraint components, 22 of the 120 tests. That+//! is the SHACL extension mechanism and it needs a SPARQL evaluator. Avoiding+//! SPARQL is the entire reason this development can exist, so these are out of+//! scope rather than unfinished.+//! * `sh:zeroOrMorePath` and `sh:oneOrMorePath`, 4 tests. Every other path form is+//! decided by a recursion over the path itself; these two are transitive closures+//! over the DATA graph. See the `Path` type in `lean/Shacl/Shape.lean`.+//! * A path node carrying two path forms at once, 2 tests. Deliberate: SHACL allows+//! exactly one, the shapes graph is ill formed, and no reading of it is chosen.+//! * A `sh:pattern` whose lexical form carries a backslash, 1 test. Nothing in this+//! development decodes an N-Triples escape, so it cannot tell a literal backslash+//! from an escape sequence.//!//! The Rust engine's own number, under its own harness at the same suite commit, is//! PASS 36 / FAIL 24 / UNDETERMINED 60 of 120. That is the comparison to hold this-//! against, and it is not an apples-to-apples one: the Rust engine answers many more-//! tests and gets 24 of them wrong.+//! against, and it is not an apples-to-apples one: the two answer different SETS of+//! tests. What is comparable is that the SPARQL-backed engine answers 60 of the 120+//! and is wrong on 24 of them, and this one answers 91 and is wrong on none.//!//! # The comparison, which is the same one the other harness uses//!@@ -54,8 +71,8 @@//! `sht:Failure` and the bridge reported an error.//! FAIL the evaluator answered and the answer is wrong.//! UNDETERMINED exit 3: the compiler refused the shapes graph, or the evaluator-//! declined to judge a literal. Not a pass and not a failure. NOT-//! credit.+//! declined to judge a literal, to order two terms, or to read an+//! escaped spelling. Not a pass and not a failure. NOT credit.//! ERROR exit 2, or a graph that would not load or re-serialise.//!//! # The gate@@ -64,10 +81,10 @@//! PASS may not drop, FAIL may not rise, and no named PASS may regress. Re-cut with//! `OO_SHACL_CORE_UPDATE_BASELINE=1 cargo test --test shacl_core_verified_test`.//!-//! `the_bridge_refuses_what_it_cannot_check` feeds the bridge four shapes graphs it+//! `the_bridge_refuses_what_it_cannot_check` feeds the bridge six shapes graphs it//! must refuse and three data graphs whose verdicts must differ, and requires the//! exact exit code and a reason that names the thing refused. Its own docstring-//! records the run in which it was seen to fail.+//! records the runs in which it was seen to fail.mod common;@@ -581,6 +598,12 @@ fn run_case(tc: &TestCase, idx: usize) -> (Outcome, Option<u64>) {return (Outcome::Error(format!("cannot write scratch shapes graph: {e}")), None);}+ // `OO_SHACL_DUMP=core/property/uniqueLang-002 cargo test --test+ // shacl_core_verified_test -- --nocapture` prints the exact N-Triples the+ // validator was handed for one test. It is here because a disagreement is as+ // likely to be the conversion above distorting a term as it is to be the+ // evaluator, and reading the actual input is the only way to tell which. It+ // found the `GraphStore` round trip documented on `to_ntriples`.if std::env::var("OO_SHACL_DUMP").as_deref() == Ok(tc.name.as_str()) {eprintln!("---- {} data ----\n{data_nt}\n---- shapes ----\n{shapes_nt}", tc.name);}@@ -692,6 +715,20 @@ fn refusal_class(detail: &str) -> String {if detail.contains("lexical space") {return "datatype lexical space not implemented".to_string();}+ if detail.contains("value comparison") {+ return "value comparison: no rule orders these two terms".to_string();+ }+ if detail.contains("string length") {+ return "string length: the spelling carries a backslash escape".to_string();+ }+ if detail.contains("carries a backslash") {+ return "sh:pattern: the pattern carries a backslash escape".to_string();+ }+ if detail.contains("regular-expression construct") {+ let i = detail.find('\'').map(|i| i + 1).unwrap_or(0);+ let c = detail[i..].chars().next().unwrap_or('?');+ return format!("sh:pattern: the regular-expression construct '{c}' is not implemented");+ }if detail.contains("is not implemented") {let i = detail.rfind(": ").map(|i| i + 2).unwrap_or(0);return format!("path form: {}", &detail[i..]);@@ -864,6 +901,20 @@ fn pct(n: usize, d: usize) -> f64 {////// That is the failure mode this whole layer exists to catch: a validator reporting/// `conforms` about constraints it never evaluated. Both gates caught it.+///+/// It was seen to fail a second time, without anyone arranging it. `sh:pattern` was+/// implemented, `unsupported-shapes.nt` had used `sh:pattern "^A"` as its example of+/// something the compiler could not read, and the fixture stopped being refused:+///+/// ```text+/// test the_bridge_refuses_what_it_cannot_check ... FAILED+/// unsupported-shapes.nt: expected exit 3 (undetermined), got 0.+/// {"status":"verdict","conforms":true,"shapes":1,"data_triples":2,"results":[]}+/// ```+///+/// The fixture now uses `sh:prefixes`, and two more were added beside it, one per+/// remaining way to decline: an unimplemented path form and a regular expression+/// outside the proved subset.#[test]fn the_bridge_refuses_what_it_cannot_check() {if skip() {@@ -1006,7 +1057,10 @@ fn the_verified_conformance_report() {);eprintln!("\n for comparison, the SPARQL-backed Rust engine under its own harness at the same\n \- suite commit: PASS 36 / FAIL 24 / UNDETERMINED 60. It answers more and is wrong more."+ suite commit: PASS 36 / FAIL 24 / UNDETERMINED 60. It ANSWERS {} of the 120 and gets\n \+ 24 of those wrong; this one answers {} and gets none wrong.",+ 36 + 24,+ c.pass + c.fail);// Where the undetermined tests went, clustered, with every test named under@@ -1059,6 +1113,25 @@ fn the_verified_conformance_report() {}/// The ratchet. PASS may not drop, FAIL may not rise, no named PASS may regress.+///+/// Seen to fail. `langMatches` in `lean/Shacl/Term.lean` implements BCP 47 basic+/// filtering, under which the range `en` matches the tag `en-NZ`. Dropping the+/// subtag-boundary half of it, so that only an exact tag matches, compiles, proves,+/// and passes every witness, because nothing in the Lean development pins that+/// behaviour. This gate is what caught it:+///+/// ```text+/// test the_verified_evaluator_does_not_regress ... FAILED+/// the verified SHACL evaluator regressed against .../baseline.json:+/// PASS dropped from 91 to 90+/// FAIL rose from 0 to 1+/// 1 test(s) that passed in the baseline no longer pass: core/property/languageIn-001+/// ```+///+/// That is the division of labour this file exists for. A proof cannot tell you that+/// `Shacl/Spec.lean` misreads the Recommendation, because the proof is about the+/// agreement between the specification and the evaluator, not about the prose. The+/// Working Group's suite is the only thing that can, and it did.#[test]fn the_verified_evaluator_does_not_regress() {if skip() {