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
refute: seventeen OWL 2 RL rules conclude false, not sixteen, and say which one cannot be expressed
FABIOTESSe37a6acf0ca9
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 993c50af..27d5899f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -20,6 +20,21 @@ All notable changes to Open Ontologies are documented here.trace. See docs/lean-certificates.md and decision 0002.### Fixed+- **The refutation layer counted the OWL 2 RL rules that conclude `false` as+ sixteen, and there are seventeen.** The missing one is `dt-not-type`, from+ Table 8 of OWL 2 Profiles, and the undercount reached a consumer: `oo-refute+ check` told a caller whose refutation was rejected that "fifteen other OWL 2+ RL clash rules have no condition in this checker", one fewer than the truth.+ `lean/OOCert/Refute.lean` now carries the full list with the W3C table each+ rule comes from, so the number can be re-counted rather than trusted, and it+ states the split the number hides: of the sixteen this checker does not+ implement, fifteen are expressible here and simply absent, while+ `dt-not-type` cannot be stated at all, because `OOCert.Semantics` has no+ datatype value space and says so. That is the same ground on which+ `src/reason.rs` keeps the whole `dt-*` family out of the engine, and the+ reason is now written where the count is instead of being inferable from+ another file. Prose and one report string only; no theorem changed, and the+ checker still implements exactly `cax-dw`.- **`sh:sparql` ignored `sh:prefixes` and merged every `sh:declare` in theshapes graph into one prologue.** A prefix bound to two namespaces emittedtwo `PREFIX` lines, SPARQL took the last, and which one won was decided bydiff --git a/lean/OOCert/Refute.lean b/lean/OOCert/Refute.leanindex 0161beee..0dd31476 100644--- a/lean/OOCert/Refute.lean+++ b/lean/OOCert/Refute.lean@@ -3,13 +3,37 @@ import OOCert.Soundness/-!# `oo-refute/1`: certifying that a graph has NO model-Sixteen rules in the OWL 2 RL profile conclude `false` rather than a triple.-`cax-dw` is the first of them and the one with the most axioms waiting for it:-given `c1 owl:disjointWith c2`, `x rdf:type c1` and `x rdf:type c2`, the graph-is contradictory. The certificate format in `Rules.lean` cannot express that,-because `Step.conclusion` is a `Triple` and `certificate_sound` concludes+Seventeen rules in the OWL 2 RL profile conclude `false` rather than a triple.+Counted off OWL 2 Web Ontology Language Profiles (Second Edition), W3C+Recommendation 11 December 2012, section 4.3, the whole list is:++| Table | Rules concluding `false` |+| --- | --- |+| 4, Equality | `eq-diff1`, `eq-diff2`, `eq-diff3` |+| 5, Axioms about Properties | `prp-irp`, `prp-asyp`, `prp-pdw`, `prp-adp`, `prp-npa1`, `prp-npa2` |+| 6, Classes | `cls-nothing2`, `cls-com`, `cls-maxc1`, `cls-maxqc1`, `cls-maxqc2` |+| 7, Class Axioms | `cax-dw`, `cax-adc` |+| 8, Datatypes | `dt-not-type` |++The list is written out rather than summarised because the number alone is a+claim nobody can re-check. Three plus six plus five plus two plus one is+seventeen, out of the 78 rules named across Tables 4 to 9. Table 9, Schema+Vocabulary, contributes none of them: all 20 of its rules conclude a triple, so+the ones this project implements live in `Semantics.lean` as ordinary+conditions.++`cax-dw` is the one implemented here, and the one with the most axioms waiting+for it: given `c1 owl:disjointWith c2`, `x rdf:type c1` and `x rdf:type c2`, the+graph is contradictory. The certificate format in `Rules.lean` cannot express+that, because `Step.conclusion` is a `Triple` and `certificate_sound` concludes`Entails`. There is no triple to conclude. This file adds the second format.+Sixteen of the seventeen are rules this layer can state, and it states one of+them, `cax-dw`. The seventeenth, `dt-not-type`, it cannot state at all. The+distinction is drawn where the count is, below, because a reader who meets only+the number will otherwise take "not implemented" and "not expressible" for the+same thing, and they are different claims about this checker.+## Why the negative conditions live HERE and not in `Semantics.lean``lean/OOCert/Witness.lean` proves `saturated_is_a_model`: every graph has a@@ -36,12 +60,40 @@ that reading `owl:disjointWith` as disjointness leaves no models, which is whatan OWL 2 RL consumer means by "inconsistent" and is not the same sentence.`RefuteConditions` carries exactly one field, because exactly one rule is-implemented. The other fifteen clash rules (`cax-adc`, `cls-com`,-`cls-nothing2`, `cls-maxc1`, `prp-irp`, `prp-asyp`, `prp-pdw`, `prp-adp`,-`prp-npa1`, `prp-npa2`, `eq-diff1`, `eq-diff2`, `eq-diff3` and the rest) each-need their own condition and their own field, and none of them is here. A-graph that only a missing rule could refute is not refutable by this checker,-and the checker says so by rejecting, never by passing.+implemented. The other sixteen fall into two groups, and the difference between+them is the difference between work not done and work that cannot be done here.++FIFTEEN are missing and expressible. They are `eq-diff1`, `eq-diff2`,+`eq-diff3`, `prp-irp`, `prp-asyp`, `prp-pdw`, `prp-adp`, `prp-npa1`,+`prp-npa2`, `cls-nothing2`, `cls-com`, `cls-maxc1`, `cls-maxqc1`, `cls-maxqc2`+and `cax-adc`. Each needs its own field on `RefuteConditions` and its own+constructor on `RefuteRule`, and none of them is here. Adding one is ordinary+work: the condition is a sentence about `I.iext` and `I.cext`, which `Interp`+already provides, and the four list-valued ones (`eq-diff2`, `eq-diff3`,+`prp-adp`, `cax-adc`) read their members through `Chain` as `Model` already+does for `owl:intersectionOf`. The three cardinality rules (`cls-maxc1`,+`cls-maxqc1`, `cls-maxqc2`) would match `"0"^^xsd:nonNegativeInteger` by its+spelling, as this layer matches every other term. That is sound and it is not+complete: a graph writing the same value some other way would be missed, which+is a rejection and never a false pass.++ONE is not missing. `dt-not-type` fires when the data value of a literal falls+outside the value space of the datatype it is typed with, and `Semantics.lean`+has no value spaces to fall outside of. An `Interp` there is a domain, a+denotation `ι : Term → D` and one ternary relation; a literal is its N-Triples+spelling like any other term; and that file's "What is not here" section states+the restriction and its consequence, that `Entails` must not be read as+datatype-aware. No field added to `RefuteConditions` could cover the rule,+because what it needs is absent from `Interp` rather than from the condition+structure. Covering it means extending the signature with a datatype map and a+lexical-to-value reading, which is a different piece of work from adding a+clash rule and would change what every existing theorem quantifies over.+`src/reason.rs` keeps the whole `dt-*` family out of the engine on the same+ground, and `tests/reason_rl_coverage_test.rs` pins that exclusion.++A graph that only a missing rule could refute is not refutable by this checker,+whichever group the rule falls in, and the checker says so by rejecting, never+by passing.## The explosion, and what a consumer must do about itdiff --git a/lean/OOCert/RefuteWitness.lean b/lean/OOCert/RefuteWitness.leanindex 97d193d4..603c3961 100644--- a/lean/OOCert/RefuteWitness.lean+++ b/lean/OOCert/RefuteWitness.lean@@ -228,7 +228,17 @@ theorem no_violation_means_a_joint_model (G : List Triple)refutable then its closure contains a disjointness violation. So `cax-dw` is notmerely sound for this fragment, it is the only way to be unsatisfiable in it, anda consumer who finds no violation has a positive result rather than a failure to-find one. Same `owl:sameAs` hypothesis. -/+find one. Same `owl:sameAs` hypothesis.++Read "unsatisfiable" here as `Unsat`, which is the whole content of the+statement and is narrower than a consumer's word for it. `Unsat` quantifies over+`RefuteConditions`, and `RefuteConditions` reads `owl:disjointWith` and nothing+else, so this theorem says `cax-dw` is the only clash IN THAT MODEL CLASS. It+does not say a graph with no disjointness violation is consistent under OWL 2+RL: sixteen further rules of the profile conclude `false` and none of them has a+condition here, so a graph refutable only by `prp-irp` or `cls-nothing2` passes+this test and is contradictory anyway. The positive result is "no clash of the+one kind this layer can see", and it is worth having for exactly that. -/theorem unsat_means_a_violation (G : List Triple)(hsame : ∀ a b : Term, Der G ⟨a, V.sameAs, b⟩ → a = b) (h : Unsat G) :∃ c1 c2 x : Term, Der G ⟨c1, RV.disjointWith, c2⟩ ∧ Der G ⟨x, V.type, c1⟩ ∧diff --git a/lean/RefuteMain.lean b/lean/RefuteMain.leanindex 21d2eb5e..0741f2ea 100644--- a/lean/RefuteMain.lean+++ b/lean/RefuteMain.lean@@ -33,11 +33,15 @@ refutation does not.# What a rejected refutation does NOT mean-It does not mean the graph is consistent. `RefuteConditions` carries one-condition, for `cax-dw`, and fifteen other clash rules of OWL 2 RL have no-condition here at all. A graph that only `prp-irp` or `eq-diff1` could refute is-rejected by this checker and is still contradictory. The checker is a gate, not-an oracle, in that direction as in the other.+It does not mean the graph is consistent. Seventeen OWL 2 RL rules conclude+`false`; `RefuteConditions` carries one condition, for `cax-dw`, and the other+sixteen have no condition here at all. Fifteen of those sixteen are expressible+in this layer and simply absent. The sixteenth, `dt-not-type`, is not+expressible at all, because `OOCert.Semantics` has no datatype value space.+`Refute.lean` lists all seventeen with their tables and states that split at the+count. A graph that only `prp-irp` or `eq-diff1` could refute is rejected by+this checker and is still contradictory. The checker is a gate, not an oracle,+in that direction as in the other.-/open OOCert@@ -103,7 +107,8 @@ def runCheck (gPath rPath : String) : IO UInt32 := do\"prefix\":{r.steps.length},\"rule\":{jsonStr r.final.rule.name},\\"reason\":{jsonStr (whyRejected G r)},\\"means\":\"the refutation was not accepted. That is not a proof of consistency: \- fifteen other OWL 2 RL clash rules have no condition in this checker.\"}"+ seventeen OWL 2 RL rules conclude false, this checker implements cax-dw, and the other \+ sixteen have no condition in it.\"}"return 1| .error e, _ => IO.eprintln e; return 2| _, .error e => IO.eprintln e; return 2diff --git a/tests/lean_refutation_test.rs b/tests/lean_refutation_test.rsindex 3fb34916..b2e62a09 100644--- a/tests/lean_refutation_test.rs+++ b/tests/lean_refutation_test.rs@@ -1,10 +1,17 @@//! `oo-refute/1`: certifying that a graph has NO model.//!-//! Sixteen rules in the OWL 2 RL profile conclude `false` rather than a triple.-//! The derivation certificate cannot express that, because `Step.conclusion` is-//! a `Triple` and `OOCert.certificate_sound` concludes `Entails`. There is no-//! triple to conclude. `lean/OOCert/Refute.lean` adds the second format, with-//! `cax-dw` as its one rule, and `OOCert.refutation_sound` proved about it.+//! Seventeen rules in the OWL 2 RL profile conclude `false` rather than a+//! triple; `lean/OOCert/Refute.lean` lists all seventeen with the W3C tables+//! they come from. The derivation certificate cannot express that, because+//! `Step.conclusion` is a `Triple` and `OOCert.certificate_sound` concludes+//! `Entails`. There is no triple to conclude. `Refute.lean` adds the second+//! format, with `cax-dw` as its one rule, and `OOCert.refutation_sound` proved+//! about it. Of the sixteen it does not implement, fifteen are expressible in+//! that layer and absent; `dt-not-type` is not expressible there at all,+//! because `OOCert.Semantics` has no datatype value space, which is the same+//! ground on which `the_rules_that_were_left_out_stay_out` in+//! `reason_rl_coverage_test.rs` keeps the whole `dt-*` family out of the+//! engine.//!//! # The two things this file exists to protect//!@@ -324,9 +331,9 @@ fn the_guard_passes_when_nothing_is_refuted() {assert_eq!(code, 0, "{out}");assert!(out.contains("\"refuted\":false"), "{out}");assert_eq!(field(&out, "theorem"), "OOCert.certificate_sound", "{out}");- // A pass is not a consistency proof. Only one of the sixteen OWL 2 RL clash- // rules is implemented, so "no clash found" is the honest wording and the- // report must use it.+ // A pass is not a consistency proof. Only one of the seventeen OWL 2 RL+ // rules that conclude `false` is implemented, so "no clash found" is the+ // honest wording and the report must use it.assert!(field(&out, "means").contains("not a proof of consistency"),"the passing verdict must not be read as consistency: {out}"