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.

Widen the refutation checker from one clash rule to twelve (#215)

Fabio Rovai0a5234834322
diff --git a/docs/concurrency-inventory.md b/docs/concurrency-inventory.md
index ce8c8c68..c180e38f 100644
--- a/docs/concurrency-inventory.md
+++ b/docs/concurrency-inventory.md
@@ -259,7 +259,7 @@ A disables it again.
### Defect D: the store can drift between hashing and reasoning. KNOWN, DOCUMENTED, OPEN.
-`Reasoner::run_horn` takes `&Arc<GraphStore>` (`src/reason.rs:2915`) and reads the store at line 2935.
+`Reasoner::run_horn` takes `&Arc<GraphStore>` (`src/reason.rs:3107`) and reads the store at line 3134.
This is already
[decision 0010](decisions/0010-the-input-is-a-value-and-not-a-store.md), which names it, calls the
window a race in as many words, and specifies `CertifiedInput` to dissolve it by copying once. It is
diff --git a/docs/decisions/0014-a-verifier-that-cannot-read-the-code-verifies-a-rewrite.md b/docs/decisions/0014-a-verifier-that-cannot-read-the-code-verifies-a-rewrite.md
index 4aafb3a6..a0eb54b7 100644
--- a/docs/decisions/0014-a-verifier-that-cannot-read-the-code-verifies-a-rewrite.md
+++ b/docs/decisions/0014-a-verifier-that-cannot-read-the-code-verifies-a-rewrite.md
@@ -83,7 +83,7 @@ nobody knows is load-bearing.
**The hazard is latent and it is not live, and saying so is part of the finding.** Only two places
construct a `RulePattern`, and both are closed:
-- `src/reason.rs:2740`, inside `parse_rules` itself. Its fields come from splitting a line on tabs,
+- `src/reason.rs:2858`, inside `parse_rules` itself. Its fields come from splitting a line on tabs,
so none of them can contain a tab, and the line came from splitting on newlines.
- `src/rulesyntax.rs:179`, in `Import::accept`, which is the front end a user's RIF, SWRL or Datalog
reaches. It already renders the rule to a `rules.tsv` line, re-parses it with `parse_rules`, and
diff --git a/lean/OOCert/Refute.lean b/lean/OOCert/Refute.lean
index 1a90cb94..5678fdf2 100644
--- a/lean/OOCert/Refute.lean
+++ b/lean/OOCert/Refute.lean
@@ -59,23 +59,30 @@ or not, because `saturated` ignores disjointness. `Unsat G` is the statement
that reading `owl:disjointWith` as disjointness leaves no models, which is what
an 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 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.
+`RefuteConditions` carries TWELVE fields, one per certifiable rule: `cax-dw`,
+`cls-com`, `cls-nothing2`, `prp-irp`, `prp-asyp`, `prp-pdw`, `eq-diff1`,
+`prp-npa1`, `prp-npa2`, `cls-maxc1`, `cls-maxqc1` and `cls-maxqc2`. It carried
+one until #163, and the widening is the reason this paragraph reads differently
+from the rest of the file's history.
+
+The three cardinality rules are here because the profile's cardinality clashes
+are the ZERO cases and nothing else. `cls-maxc1` fires on `owl:maxCardinality 0`
+plus a single edge, which needs the literal and no counting. A rule that had to
+COUNT successors could not be stated in this step format at all, so their
+presence is not evidence that counting arrived.
+
+They 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 is missed, which is a rejection and never a false pass.
+
+FOUR are missing and expressible: `cax-adc`, `prp-adp`, `eq-diff2` and
+`eq-diff3`. Each states its members in an `rdf:List`, and `RefuteStep.premises`
+is a fixed-length list of triples, so a premise of unbounded length has no
+spelling here. Adding them is ordinary work rather than new mathematics: `Model`
+already reads lists through `Chain` for `owl:intersectionOf`, and the step
+format would have to carry one. The PAIRWISE form of all four is covered
+already, by `cax-dw`, `prp-pdw` and `eq-diff1`, which is why they are worth
+calling not done rather than impossible.
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`
@@ -139,20 +146,87 @@ engine's interner produces. -/
namespace RV
/-- `owl:disjointWith`. -/
def disjointWith : Term := "<http://www.w3.org/2002/07/owl#disjointWith>"
+def complementOf : Term := "<http://www.w3.org/2002/07/owl#complementOf>"
+def nothing : Term := "<http://www.w3.org/2002/07/owl#Nothing>"
+def irreflexiveProperty : Term := "<http://www.w3.org/2002/07/owl#IrreflexiveProperty>"
+def asymmetricProperty : Term := "<http://www.w3.org/2002/07/owl#AsymmetricProperty>"
+def propertyDisjointWith : Term := "<http://www.w3.org/2002/07/owl#propertyDisjointWith>"
+def differentFrom : Term := "<http://www.w3.org/2002/07/owl#differentFrom>"
+def sourceIndividual : Term := "<http://www.w3.org/2002/07/owl#sourceIndividual>"
+def assertionProperty : Term := "<http://www.w3.org/2002/07/owl#assertionProperty>"
+def targetIndividual : Term := "<http://www.w3.org/2002/07/owl#targetIndividual>"
+def targetValue : Term := "<http://www.w3.org/2002/07/owl#targetValue>"
+def maxCardinality : Term := "<http://www.w3.org/2002/07/owl#maxCardinality>"
+def maxQualifiedCardinality : Term :=
+ "<http://www.w3.org/2002/07/owl#maxQualifiedCardinality>"
+def onClass : Term := "<http://www.w3.org/2002/07/owl#onClass>"
+def thing : Term := "<http://www.w3.org/2002/07/owl#Thing>"
+/-- The literal `"0"^^xsd:nonNegativeInteger`, in the spelling the rules use.
+
+The three cardinality rules of the profile that conclude `false` are the ZERO
+cases and nothing else, which is why they are here at all: `cls-maxc1` says a
+class with `owl:maxCardinality 0` on a property cannot have a member with that
+property, and deciding that needs no counting, only the literal. A rule that
+needed to COUNT successors could not be stated in this format. -/
+def zero : Term :=
+ "\"0\"^^<http://www.w3.org/2001/XMLSchema#nonNegativeInteger>"
end RV
/-! ## The negative conditions -/
/-- The conditions a model must satisfy for a REFUTATION to mean anything.
-Minimal by design: one field, for the one rule implemented.
-
-`dw` is the semantic reading of `owl:disjointWith`: if `(a, b)` is in the
-extension of `owl:disjointWith` then no domain element is in both class
-extensions. It is the *if* direction only, which is all `cax-dw` uses, and it is
-a consequence of the OWL 2 condition rather than a strengthening of it. -/
+Twelve fields, one per certifiable clash rule.
+
+Each is the *if* direction only, which is all the corresponding rule uses, and
+each is a consequence of the OWL 2 condition rather than a strengthening of it.
+Adding a field makes `RModel` HARDER to satisfy, so it makes `Unsat` easier to
+prove and `¬ Unsat` harder: the non-vacuity witness below has to discharge every
+one of them, which is the price of each rule and is paid there rather than
+asserted here.
+
+**Twelve of seventeen, and the five that are missing are missing for two
+different reasons.** `cax-adc`, `prp-adp`, `eq-diff2` and `eq-diff3` read an
+`rdf:List` of members, which this step format cannot carry: its premises are a
+fixed-length list of triples and a list of unbounded length is not one.
+`dt-not-type` needs a datatype value space, which this development does not
+have at all. The first four are NOT IMPLEMENTED and the fifth is NOT
+EXPRESSIBLE, and a reader who meets only the number would take those for the
+same claim. -/
structure RefuteConditions (I : Interp) : Prop where
- /-- cax-dw. -/
+ /-- cax-dw. Nothing is in two disjoint classes. -/
dw : ∀ a b, I.iext (I.ι RV.disjointWith) a b → ∀ x, I.cext a x → I.cext b x → False
+ /-- cls-com. Nothing is in a class and its complement. -/
+ com : ∀ a b, I.iext (I.ι RV.complementOf) a b → ∀ x, I.cext a x → I.cext b x → False
+ /-- cls-nothing2. `owl:Nothing` is empty. -/
+ nothing : ∀ x, I.cext (I.ι RV.nothing) x → False
+ /-- prp-irp. An irreflexive property relates nothing to itself. -/
+ irp : ∀ p, I.cext (I.ι RV.irreflexiveProperty) p → ∀ x, I.iext p x x → False
+ /-- prp-asyp. An asymmetric property does not relate both ways. -/
+ asyp : ∀ p, I.cext (I.ι RV.asymmetricProperty) p → ∀ x y, I.iext p x y → I.iext p y x → False
+ /-- prp-pdw. Disjoint properties share no pair. -/
+ pdw : ∀ p q, I.iext (I.ι RV.propertyDisjointWith) p q →
+ ∀ x y, I.iext p x y → I.iext q x y → False
+ /-- eq-diff1. Nothing is both the same as and different from something. -/
+ diff : ∀ x y, I.iext (I.ι V.sameAs) x y → I.iext (I.ι RV.differentFrom) x y → False
+ /-- prp-npa1. A negative object property assertion is not satisfied. -/
+ npa1 : ∀ n i p j, I.iext (I.ι RV.sourceIndividual) n i →
+ I.iext (I.ι RV.assertionProperty) n p → I.iext (I.ι RV.targetIndividual) n j →
+ I.iext p i j → False
+ /-- prp-npa2. The same for a data value. -/
+ npa2 : ∀ n i p j, I.iext (I.ι RV.sourceIndividual) n i →
+ I.iext (I.ι RV.assertionProperty) n p → I.iext (I.ι RV.targetValue) n j →
+ I.iext p i j → False
+ /-- cls-maxc1. A `≤0` restriction has no member with the property. -/
+ maxc1 : ∀ c p, I.iext (I.ι RV.maxCardinality) c (I.ι RV.zero) →
+ I.iext (I.ι V.onProperty) c p → ∀ u v, I.cext c u → I.iext p u v → False
+ /-- cls-maxqc1. The qualified `≤0`, with the filler checked. -/
+ maxqc1 : ∀ c p k, I.iext (I.ι RV.maxQualifiedCardinality) c (I.ι RV.zero) →
+ I.iext (I.ι V.onProperty) c p → I.iext (I.ι RV.onClass) c k →
+ ∀ u v, I.cext c u → I.iext p u v → I.cext k v → False
+ /-- cls-maxqc2. The qualified `≤0` onto `owl:Thing`, where the filler is free. -/
+ maxqc2 : ∀ c p, I.iext (I.ι RV.maxQualifiedCardinality) c (I.ι RV.zero) →
+ I.iext (I.ι V.onProperty) c p → I.iext (I.ι RV.onClass) c (I.ι RV.thing) →
+ ∀ u v, I.cext c u → I.iext p u v → False
/-- A model of `G` that ALSO respects disjointness. Named apart from `Model` so
that no verdict can quietly move between the two classes. -/
@@ -170,13 +244,27 @@ theorem RModel.model {G : List Triple} {I : Interp} (h : RModel G I) : Model I G
/-- The clash rules, one constructor per rule implemented. One so far. -/
inductive RefuteRule
- | caxDw
+ | caxDw | clsCom | clsNothing2 | prpIrp | prpAsyp | prpPdw | eqDiff1
+ | prpNpa1 | prpNpa2 | clsMaxc1 | clsMaxqc1 | clsMaxqc2
deriving DecidableEq, Repr
def RefuteRule.name : RefuteRule → String
| .caxDw => "cax-dw"
-
-def RefuteRule.all : List RefuteRule := [.caxDw]
+ | .clsCom => "cls-com"
+ | .clsNothing2 => "cls-nothing2"
+ | .prpIrp => "prp-irp"
+ | .prpAsyp => "prp-asyp"
+ | .prpPdw => "prp-pdw"
+ | .eqDiff1 => "eq-diff1"
+ | .prpNpa1 => "prp-npa1"
+ | .prpNpa2 => "prp-npa2"
+ | .clsMaxc1 => "cls-maxc1"
+ | .clsMaxqc1 => "cls-maxqc1"
+ | .clsMaxqc2 => "cls-maxqc2"
+
+def RefuteRule.all : List RefuteRule :=
+ [.caxDw, .clsCom, .clsNothing2, .prpIrp, .prpAsyp, .prpPdw, .eqDiff1,
+ .prpNpa1, .prpNpa2, .clsMaxc1, .clsMaxqc1, .clsMaxqc2]
def RefuteRule.ofName? (s : String) : Option RefuteRule :=
RefuteRule.all.find? (fun r => r.name == s)
@@ -226,6 +314,50 @@ def checkRefuteStep (k : Triple → Bool) (rs : RefuteStep) : Bool :=
dw = RV.disjointWith ∧ t1 = V.type ∧ c1' = c1 ∧
x' = x ∧ t2 = V.type ∧ c2' = c2 ∧
k ⟨c1, dw, c2⟩ ∧ k ⟨x, t1, c1'⟩ ∧ k ⟨x', t2, c2'⟩
+ | .clsCom, [⟨c1, co, c2⟩, ⟨x, t1, c1'⟩, ⟨x', t2, c2'⟩] =>
+ co = RV.complementOf ∧ t1 = V.type ∧ c1' = c1 ∧
+ x' = x ∧ t2 = V.type ∧ c2' = c2 ∧
+ k ⟨c1, co, c2⟩ ∧ k ⟨x, t1, c1'⟩ ∧ k ⟨x', t2, c2'⟩
+ | .clsNothing2, [⟨x, t1, n⟩] =>
+ t1 = V.type ∧ n = RV.nothing ∧ k ⟨x, t1, n⟩
+ | .prpIrp, [⟨p, t1, irp⟩, ⟨x, p', x'⟩] =>
+ t1 = V.type ∧ irp = RV.irreflexiveProperty ∧ p' = p ∧ x' = x ∧
+ k ⟨p, t1, irp⟩ ∧ k ⟨x, p', x'⟩
+ | .prpAsyp, [⟨p, t1, asy⟩, ⟨x, p1, y⟩, ⟨y', p2, x'⟩] =>
+ t1 = V.type ∧ asy = RV.asymmetricProperty ∧ p1 = p ∧ p2 = p ∧
+ y' = y ∧ x' = x ∧
+ k ⟨p, t1, asy⟩ ∧ k ⟨x, p1, y⟩ ∧ k ⟨y', p2, x'⟩
+ | .prpPdw, [⟨p1, pdw, p2⟩, ⟨x, q1, y⟩, ⟨x', q2, y'⟩] =>
+ pdw = RV.propertyDisjointWith ∧ q1 = p1 ∧ q2 = p2 ∧ x' = x ∧ y' = y ∧
+ k ⟨p1, pdw, p2⟩ ∧ k ⟨x, q1, y⟩ ∧ k ⟨x', q2, y'⟩
+ | .eqDiff1, [⟨x, sa, y⟩, ⟨x', df, y'⟩] =>
+ sa = V.sameAs ∧ df = RV.differentFrom ∧ x' = x ∧ y' = y ∧
+ k ⟨x, sa, y⟩ ∧ k ⟨x', df, y'⟩
+ | .prpNpa1, [⟨n, si, i⟩, ⟨n1, ap, p⟩, ⟨n2, ti, j⟩, ⟨i', p', j'⟩] =>
+ si = RV.sourceIndividual ∧ ap = RV.assertionProperty ∧
+ ti = RV.targetIndividual ∧ n1 = n ∧ n2 = n ∧ i' = i ∧ p' = p ∧ j' = j ∧
+ k ⟨n, si, i⟩ ∧ k ⟨n1, ap, p⟩ ∧ k ⟨n2, ti, j⟩ ∧ k ⟨i', p', j'⟩
+ | .prpNpa2, [⟨n, si, i⟩, ⟨n1, ap, p⟩, ⟨n2, tv, j⟩, ⟨i', p', j'⟩] =>
+ si = RV.sourceIndividual ∧ ap = RV.assertionProperty ∧
+ tv = RV.targetValue ∧ n1 = n ∧ n2 = n ∧ i' = i ∧ p' = p ∧ j' = j ∧
+ k ⟨n, si, i⟩ ∧ k ⟨n1, ap, p⟩ ∧ k ⟨n2, tv, j⟩ ∧ k ⟨i', p', j'⟩
+ | .clsMaxc1, [⟨c, mc, z⟩, ⟨c1, op, p⟩, ⟨u, t1, c2⟩, ⟨u', p', v⟩] =>
+ mc = RV.maxCardinality ∧ z = RV.zero ∧ op = V.onProperty ∧ c1 = c ∧
+ t1 = V.type ∧ c2 = c ∧ u' = u ∧ p' = p ∧
+ k ⟨c, mc, z⟩ ∧ k ⟨c1, op, p⟩ ∧ k ⟨u, t1, c2⟩ ∧ k ⟨u', p', v⟩
+ | .clsMaxqc1, [⟨c, mq, z⟩, ⟨c1, op, p⟩, ⟨c2, oc, f⟩, ⟨u, t1, c3⟩, ⟨u', p', v⟩,
+ ⟨v', t2, f'⟩] =>
+ mq = RV.maxQualifiedCardinality ∧ z = RV.zero ∧ op = V.onProperty ∧
+ oc = RV.onClass ∧ c1 = c ∧ c2 = c ∧ t1 = V.type ∧ c3 = c ∧ u' = u ∧
+ p' = p ∧ v' = v ∧ t2 = V.type ∧ f' = f ∧
+ k ⟨c, mq, z⟩ ∧ k ⟨c1, op, p⟩ ∧ k ⟨c2, oc, f⟩ ∧ k ⟨u, t1, c3⟩ ∧
+ k ⟨u', p', v⟩ ∧ k ⟨v', t2, f'⟩
+ | .clsMaxqc2, [⟨c, mq, z⟩, ⟨c1, op, p⟩, ⟨c2, oc, th⟩, ⟨u, t1, c3⟩, ⟨u', p', v⟩] =>
+ mq = RV.maxQualifiedCardinality ∧ z = RV.zero ∧ op = V.onProperty ∧
+ oc = RV.onClass ∧ th = RV.thing ∧ c1 = c ∧ c2 = c ∧ t1 = V.type ∧
+ c3 = c ∧ u' = u ∧ p' = p ∧
+ k ⟨c, mq, z⟩ ∧ k ⟨c1, op, p⟩ ∧ k ⟨c2, oc, th⟩ ∧ k ⟨u, t1, c3⟩ ∧
+ k ⟨u', p', v⟩
| _, _ => false
/-- The conclusions the prefix made available to the contradiction step. A
@@ -294,6 +426,10 @@ theorem checkRefuteStep_sound {G : List Triple} {k : Triple → Bool} {rs : Refu
obtain ⟨rule, premises⟩ := rs
unfold checkRefuteStep at h
dsimp only at h
+ -- One case per rule, and every one is the same two moves: take the decided
+ -- side conditions apart, then hand the premises to the condition of
+ -- `RefuteConditions` that has exactly that shape. No case reasons about the
+ -- semantics; the reasoning is in the condition.
cases rule
case caxDw =>
rcases premises with
@@ -302,6 +438,86 @@ theorem checkRefuteStep_sound {G : List Triple} {k : Triple → Bool} {rs : Refu
obtain ⟨rfl, rfl, rfl, rfl, rfl, rfl, h1, h2, h3⟩ := h
intro I hI
exact hI.2.dw _ _ (hk _ h1 I hI) _ (hk _ h2 I hI) (hk _ h3 I hI)
+ case clsCom =>
+ rcases premises with
+ _ | ⟨⟨c1, co, c2⟩, _ | ⟨⟨x, t1, c1'⟩, _ | ⟨⟨x', t2, c2'⟩, _ | _⟩⟩⟩ <;>
+ simp only [decide_eq_true_eq, Bool.false_eq_true] at h
+ obtain ⟨rfl, rfl, rfl, rfl, rfl, rfl, h1, h2, h3⟩ := h
+ intro I hI
+ exact hI.2.com _ _ (hk _ h1 I hI) _ (hk _ h2 I hI) (hk _ h3 I hI)
+ case clsNothing2 =>
+ rcases premises with _ | ⟨⟨x, t1, n⟩, _ | _⟩ <;>
+ simp only [decide_eq_true_eq, Bool.false_eq_true] at h
+ obtain ⟨rfl, rfl, h1⟩ := h
+ intro I hI
+ exact hI.2.nothing _ (hk _ h1 I hI)
+ case prpIrp =>
+ rcases premises with _ | ⟨⟨p, t1, irp⟩, _ | ⟨⟨x, p', x'⟩, _ | _⟩⟩ <;>
+ simp only [decide_eq_true_eq, Bool.false_eq_true] at h
+ obtain ⟨rfl, rfl, rfl, rfl, h1, h2⟩ := h
+ intro I hI
+ exact hI.2.irp _ (hk _ h1 I hI) _ (hk _ h2 I hI)
+ case prpAsyp =>
+ rcases premises with
+ _ | ⟨⟨p, t1, asy⟩, _ | ⟨⟨x, p1, y⟩, _ | ⟨⟨y', p2, x'⟩, _ | _⟩⟩⟩ <;>
+ simp only [decide_eq_true_eq, Bool.false_eq_true] at h
+ obtain ⟨rfl, rfl, rfl, rfl, rfl, rfl, h1, h2, h3⟩ := h
+ intro I hI
+ exact hI.2.asyp _ (hk _ h1 I hI) _ _ (hk _ h2 I hI) (hk _ h3 I hI)
+ case prpPdw =>
+ rcases premises with
+ _ | ⟨⟨p1, pdw, p2⟩, _ | ⟨⟨x, q1, y⟩, _ | ⟨⟨x', q2, y'⟩, _ | _⟩⟩⟩ <;>
+ simp only [decide_eq_true_eq, Bool.false_eq_true] at h
+ obtain ⟨rfl, rfl, rfl, rfl, rfl, h1, h2, h3⟩ := h
+ intro I hI
+ exact hI.2.pdw _ _ (hk _ h1 I hI) _ _ (hk _ h2 I hI) (hk _ h3 I hI)
+ case eqDiff1 =>
+ rcases premises with _ | ⟨⟨x, sa, y⟩, _ | ⟨⟨x', df, y'⟩, _ | _⟩⟩ <;>
+ simp only [decide_eq_true_eq, Bool.false_eq_true] at h
+ obtain ⟨rfl, rfl, rfl, rfl, h1, h2⟩ := h
+ intro I hI
+ exact hI.2.diff _ _ (hk _ h1 I hI) (hk _ h2 I hI)
+ case prpNpa1 =>
+ rcases premises with
+ _ | ⟨⟨n, si, i⟩, _ | ⟨⟨n1, ap, p⟩, _ | ⟨⟨n2, ti, j⟩, _ | ⟨⟨i', p', j'⟩, _ | _⟩⟩⟩⟩ <;>
+ simp only [decide_eq_true_eq, Bool.false_eq_true] at h
+ obtain ⟨rfl, rfl, rfl, rfl, rfl, rfl, rfl, rfl, h1, h2, h3, h4⟩ := h
+ intro I hI
+ exact hI.2.npa1 _ _ _ _ (hk _ h1 I hI) (hk _ h2 I hI) (hk _ h3 I hI) (hk _ h4 I hI)
+ case prpNpa2 =>
+ rcases premises with
+ _ | ⟨⟨n, si, i⟩, _ | ⟨⟨n1, ap, p⟩, _ | ⟨⟨n2, tv, j⟩, _ | ⟨⟨i', p', j'⟩, _ | _⟩⟩⟩⟩ <;>
+ simp only [decide_eq_true_eq, Bool.false_eq_true] at h
+ obtain ⟨rfl, rfl, rfl, rfl, rfl, rfl, rfl, rfl, h1, h2, h3, h4⟩ := h
+ intro I hI
+ exact hI.2.npa2 _ _ _ _ (hk _ h1 I hI) (hk _ h2 I hI) (hk _ h3 I hI) (hk _ h4 I hI)
+ case clsMaxc1 =>
+ rcases premises with
+ _ | ⟨⟨c, mc, z⟩, _ | ⟨⟨c1, op, p⟩, _ | ⟨⟨u, t1, c2⟩, _ | ⟨⟨u', p', v⟩, _ | _⟩⟩⟩⟩ <;>
+ simp only [decide_eq_true_eq, Bool.false_eq_true] at h
+ obtain ⟨rfl, rfl, rfl, rfl, rfl, rfl, rfl, rfl, h1, h2, h3, h4⟩ := h
+ intro I hI
+ exact hI.2.maxc1 _ _ (hk _ h1 I hI) (hk _ h2 I hI) _ _ (hk _ h3 I hI) (hk _ h4 I hI)
+ case clsMaxqc1 =>
+ rcases premises with
+ _ | ⟨⟨c, mq, z⟩, _ | ⟨⟨c1, op, p⟩, _ | ⟨⟨c2, oc, f⟩, _ | ⟨⟨u, t1, c3⟩, _ |
+ ⟨⟨u', p', v⟩, _ | ⟨⟨v', t2, f'⟩, _ | _⟩⟩⟩⟩⟩⟩ <;>
+ simp only [decide_eq_true_eq, Bool.false_eq_true] at h
+ obtain ⟨rfl, rfl, rfl, rfl, rfl, rfl, rfl, rfl, rfl, rfl, rfl, rfl, rfl,
+ h1, h2, h3, h4, h5, h6⟩ := h
+ intro I hI
+ exact hI.2.maxqc1 _ _ _ (hk _ h1 I hI) (hk _ h2 I hI) (hk _ h3 I hI) _ _
+ (hk _ h4 I hI) (hk _ h5 I hI) (hk _ h6 I hI)
+ case clsMaxqc2 =>
+ rcases premises with
+ _ | ⟨⟨c, mq, z⟩, _ | ⟨⟨c1, op, p⟩, _ | ⟨⟨c2, oc, th⟩, _ | ⟨⟨u, t1, c3⟩, _ |
+ ⟨⟨u', p', v⟩, _ | _⟩⟩⟩⟩⟩ <;>
+ simp only [decide_eq_true_eq, Bool.false_eq_true] at h
+ obtain ⟨rfl, rfl, rfl, rfl, rfl, rfl, rfl, rfl, rfl, rfl, rfl,
+ h1, h2, h3, h4, h5⟩ := h
+ intro I hI
+ exact hI.2.maxqc2 _ _ (hk _ h1 I hI) (hk _ h2 I hI) (hk _ h3 I hI) _ _
+ (hk _ h4 I hI) (hk _ h5 I hI)
/-- **The theorem the refutation checker is trusted for.** An accepted
refutation means no interpretation models `G` and respects disjointness.
@@ -401,9 +617,44 @@ def herbrandL (H : List Triple) : Interp := herbrandP (fun t => t ∈ H)
theorem joint_model_of_closure {G : List Triple} {D : Triple → Prop}
(hD : Model (herbrandP D) G)
(hdw : ∀ c1 c2 x, D ⟨c1, RV.disjointWith, c2⟩ → D ⟨x, V.type, c1⟩ →
- D ⟨x, V.type, c2⟩ → False) :
+ D ⟨x, V.type, c2⟩ → False)
+ (hcom : ∀ c1 c2 x, D ⟨c1, RV.complementOf, c2⟩ → D ⟨x, V.type, c1⟩ →
+ D ⟨x, V.type, c2⟩ → False)
+ (hnothing : ∀ x, D ⟨x, V.type, RV.nothing⟩ → False)
+ (hirp : ∀ p x, D ⟨p, V.type, RV.irreflexiveProperty⟩ → D ⟨x, p, x⟩ → False)
+ (hasyp : ∀ p x y, D ⟨p, V.type, RV.asymmetricProperty⟩ → D ⟨x, p, y⟩ →
+ D ⟨y, p, x⟩ → False)
+ (hpdw : ∀ p q x y, D ⟨p, RV.propertyDisjointWith, q⟩ → D ⟨x, p, y⟩ →
+ D ⟨x, q, y⟩ → False)
+ (hdiff : ∀ x y, D ⟨x, V.sameAs, y⟩ → D ⟨x, RV.differentFrom, y⟩ → False)
+ (hnpa1 : ∀ n i p j, D ⟨n, RV.sourceIndividual, i⟩ →
+ D ⟨n, RV.assertionProperty, p⟩ → D ⟨n, RV.targetIndividual, j⟩ →
+ D ⟨i, p, j⟩ → False)
+ (hnpa2 : ∀ n i p j, D ⟨n, RV.sourceIndividual, i⟩ →
+ D ⟨n, RV.assertionProperty, p⟩ → D ⟨n, RV.targetValue, j⟩ →
+ D ⟨i, p, j⟩ → False)
+ (hmaxc1 : ∀ c p u v, D ⟨c, RV.maxCardinality, RV.zero⟩ →
+ D ⟨c, V.onProperty, p⟩ → D ⟨u, V.type, c⟩ → D ⟨u, p, v⟩ → False)
+ (hmaxqc1 : ∀ c p f u v, D ⟨c, RV.maxQualifiedCardinality, RV.zero⟩ →
+ D ⟨c, V.onProperty, p⟩ → D ⟨c, RV.onClass, f⟩ → D ⟨u, V.type, c⟩ →
+ D ⟨u, p, v⟩ → D ⟨v, V.type, f⟩ → False)
+ (hmaxqc2 : ∀ c p u v, D ⟨c, RV.maxQualifiedCardinality, RV.zero⟩ →
+ D ⟨c, V.onProperty, p⟩ → D ⟨c, RV.onClass, RV.thing⟩ → D ⟨u, V.type, c⟩ →
+ D ⟨u, p, v⟩ → False) :
∃ I : Interp, Model I G ∧ RefuteConditions I :=
- ⟨herbrandP D, hD, ⟨fun a b hab x h1 h2 => hdw a b x hab h1 h2⟩⟩
+ ⟨herbrandP D, hD,
+ ⟨fun a b hab x h1 h2 => hdw a b x hab h1 h2,
+ fun a b hab x h1 h2 => hcom a b x hab h1 h2,
+ fun x hx => hnothing x hx,
+ fun p hp x hx => hirp p x hp hx,
+ fun p hp x y h1 h2 => hasyp p x y hp h1 h2,
+ fun p q hpq x y h1 h2 => hpdw p q x y hpq h1 h2,
+ fun x y h1 h2 => hdiff x y h1 h2,
+ fun n i p j h1 h2 h3 h4 => hnpa1 n i p j h1 h2 h3 h4,
+ fun n i p j h1 h2 h3 h4 => hnpa2 n i p j h1 h2 h3 h4,
+ fun c p h1 h2 u v h3 h4 => hmaxc1 c p u v h1 h2 h3 h4,
+ fun c p f h1 h2 h3 u v h4 h5 h6 => hmaxqc1 c p f u v h1 h2 h3 h4 h5 h6,
+ fun c p h1 h2 h3 u v h4 h5 => hmaxqc2 c p u v h1 h2 h3 h4 h5⟩⟩
/-- A graph with a joint model is not refutable, so `refutation_sound` is not a
theorem about an empty model class.
diff --git a/lean/OOCert/RefuteWitness.lean b/lean/OOCert/RefuteWitness.lean
index 65a7fbb4..3301ee78 100644
--- a/lean/OOCert/RefuteWitness.lean
+++ b/lean/OOCert/RefuteWitness.lean
@@ -225,33 +225,125 @@ Conditional on the `owl:sameAs` hypothesis, which is stated and not buried. -/
theorem no_violation_means_a_joint_model (G : List Triple)
(hsame : ∀ a b : Term, Der G ⟨a, V.sameAs, b⟩ → a = b)
(hdw : ∀ c1 c2 x : Term, Der G ⟨c1, RV.disjointWith, c2⟩ → Der G ⟨x, V.type, c1⟩ →
- Der G ⟨x, V.type, c2⟩ → False) :
+ Der G ⟨x, V.type, c2⟩ → False)
+ (hcom : ∀ c1 c2 x : Term, Der G ⟨c1, RV.complementOf, c2⟩ → Der G ⟨x, V.type, c1⟩ →
+ Der G ⟨x, V.type, c2⟩ → False)
+ (hnothing : ∀ x : Term, Der G ⟨x, V.type, RV.nothing⟩ → False)
+ (hirp : ∀ p x : Term, Der G ⟨p, V.type, RV.irreflexiveProperty⟩ →
+ Der G ⟨x, p, x⟩ → False)
+ (hasyp : ∀ p x y : Term, Der G ⟨p, V.type, RV.asymmetricProperty⟩ →
+ Der G ⟨x, p, y⟩ → Der G ⟨y, p, x⟩ → False)
+ (hpdw : ∀ p q x y : Term, Der G ⟨p, RV.propertyDisjointWith, q⟩ →
+ Der G ⟨x, p, y⟩ → Der G ⟨x, q, y⟩ → False)
+ (hdiff : ∀ x y : Term, Der G ⟨x, V.sameAs, y⟩ →
+ Der G ⟨x, RV.differentFrom, y⟩ → False)
+ (hnpa1 : ∀ n i p j : Term, Der G ⟨n, RV.sourceIndividual, i⟩ →
+ Der G ⟨n, RV.assertionProperty, p⟩ → Der G ⟨n, RV.targetIndividual, j⟩ →
+ Der G ⟨i, p, j⟩ → False)
+ (hnpa2 : ∀ n i p j : Term, Der G ⟨n, RV.sourceIndividual, i⟩ →
+ Der G ⟨n, RV.assertionProperty, p⟩ → Der G ⟨n, RV.targetValue, j⟩ →
+ Der G ⟨i, p, j⟩ → False)
+ (hmaxc1 : ∀ c p u v : Term, Der G ⟨c, RV.maxCardinality, RV.zero⟩ →
+ Der G ⟨c, V.onProperty, p⟩ → Der G ⟨u, V.type, c⟩ → Der G ⟨u, p, v⟩ → False)
+ (hmaxqc1 : ∀ c p f u v : Term, Der G ⟨c, RV.maxQualifiedCardinality, RV.zero⟩ →
+ Der G ⟨c, V.onProperty, p⟩ → Der G ⟨c, RV.onClass, f⟩ → Der G ⟨u, V.type, c⟩ →
+ Der G ⟨u, p, v⟩ → Der G ⟨v, V.type, f⟩ → False)
+ (hmaxqc2 : ∀ c p u v : Term, Der G ⟨c, RV.maxQualifiedCardinality, RV.zero⟩ →
+ Der G ⟨c, V.onProperty, p⟩ → Der G ⟨c, RV.onClass, RV.thing⟩ →
+ Der G ⟨u, V.type, c⟩ → Der G ⟨u, p, v⟩ → False) :
∃ I : Interp, Model I G ∧ RefuteConditions I :=
- joint_model_of_closure (closure_is_a_model G hsame) hdw
+ joint_model_of_closure (closure_is_a_model G hsame) hdw hcom hnothing hirp hasyp
+ hpdw hdiff hnpa1 hnpa2 hmaxc1 hmaxqc1 hmaxqc2
+
+/-- A violation of ONE OF the twelve conditions, in the closure of `G`.
+
+Written as a named predicate rather than inline, because the statement below
+used to be a single existential over a disjointness violation and is now a
+twelve-way disjunction. That is not a presentational change: with one condition
+the theorem said "the only way to be unsatisfiable here is a disjointness
+clash", and with twelve it cannot say that about any one of them. What it still
+says is that the twelve are jointly exhaustive OF THIS MODEL CLASS, which is the
+useful half. -/
+def Violation (G : List Triple) : Prop :=
+ (∃ c1 c2 x, Der G ⟨c1, RV.disjointWith, c2⟩ ∧ Der G ⟨x, V.type, c1⟩ ∧
+ Der G ⟨x, V.type, c2⟩) ∨
+ (∃ c1 c2 x, Der G ⟨c1, RV.complementOf, c2⟩ ∧ Der G ⟨x, V.type, c1⟩ ∧
+ Der G ⟨x, V.type, c2⟩) ∨
+ (∃ x, Der G ⟨x, V.type, RV.nothing⟩) ∨
+ (∃ p x, Der G ⟨p, V.type, RV.irreflexiveProperty⟩ ∧ Der G ⟨x, p, x⟩) ∨
+ (∃ p x y, Der G ⟨p, V.type, RV.asymmetricProperty⟩ ∧ Der G ⟨x, p, y⟩ ∧
+ Der G ⟨y, p, x⟩) ∨
+ (∃ p q x y, Der G ⟨p, RV.propertyDisjointWith, q⟩ ∧ Der G ⟨x, p, y⟩ ∧
+ Der G ⟨x, q, y⟩) ∨
+ (∃ x y, Der G ⟨x, V.sameAs, y⟩ ∧ Der G ⟨x, RV.differentFrom, y⟩) ∨
+ (∃ n i p j, Der G ⟨n, RV.sourceIndividual, i⟩ ∧ Der G ⟨n, RV.assertionProperty, p⟩ ∧
+ Der G ⟨n, RV.targetIndividual, j⟩ ∧ Der G ⟨i, p, j⟩) ∨
+ (∃ n i p j, Der G ⟨n, RV.sourceIndividual, i⟩ ∧ Der G ⟨n, RV.assertionProperty, p⟩ ∧
+ Der G ⟨n, RV.targetValue, j⟩ ∧ Der G ⟨i, p, j⟩) ∨
+ (∃ c p u v, Der G ⟨c, RV.maxCardinality, RV.zero⟩ ∧ Der G ⟨c, V.onProperty, p⟩ ∧
+ Der G ⟨u, V.type, c⟩ ∧ Der G ⟨u, p, v⟩) ∨
+ (∃ c p f u v, Der G ⟨c, RV.maxQualifiedCardinality, RV.zero⟩ ∧
+ Der G ⟨c, V.onProperty, p⟩ ∧ Der G ⟨c, RV.onClass, f⟩ ∧ Der G ⟨u, V.type, c⟩ ∧
+ Der G ⟨u, p, v⟩ ∧ Der G ⟨v, V.type, f⟩) ∨
+ (∃ c p u v, Der G ⟨c, RV.maxQualifiedCardinality, RV.zero⟩ ∧
+ Der G ⟨c, V.onProperty, p⟩ ∧ Der G ⟨c, RV.onClass, RV.thing⟩ ∧
+ Der G ⟨u, V.type, c⟩ ∧ Der G ⟨u, p, v⟩)
/-- The converse, and the more useful direction in practice: if a graph IS
-refutable then its closure contains a disjointness violation. So `cax-dw` is not
-merely sound for this fragment, it is the only way to be unsatisfiable in it, and
-a consumer who finds no violation has a positive result rather than a failure to
-find one. Same `owl:sameAs` hypothesis.
+refutable then its closure contains a violation of one of the twelve conditions.
+A consumer who finds none has a positive result rather than a failure to find
+one. Same `owl:sameAs` hypothesis.
+
+**This statement got weaker when the rules got wider, and the direction is worth
+being explicit about.** With one condition it said the only way to be
+unsatisfiable here is a disjointness clash, which is a sharp claim about a
+single rule. With twelve it cannot say that about any one of them, because a
+graph can now be `Unsat` through `prp-irp` and carry no disjointness violation
+at all. What survives, and is the useful half, is that the twelve are jointly
+EXHAUSTIVE of this model class: `Unsat` and no violation of any of them is a
+contradiction.
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. -/
+`RefuteConditions`, and `RefuteConditions` now reads twelve of the seventeen
+rules of the profile that conclude `false`. The five it does not read are
+`cax-adc`, `prp-adp`, `eq-diff2` and `eq-diff3`, which need an `rdf:List` this
+step format cannot carry, and `dt-not-type`, which needs a datatype value space
+this development does not have. So a graph refutable only by one of those five
+still passes this test and is contradictory anyway, and the positive result is
+"no clash of the twelve kinds this layer can see". -/
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⟩ ∧
- Der G ⟨x, V.type, c2⟩ :=
+ Violation G :=
Classical.byContradiction fun hno =>
not_unsat_of_joint_model
(no_violation_means_a_joint_model G hsame
- (fun c1 c2 x h1 h2 h3 => hno ⟨c1, c2, x, h1, h2, h3⟩)) h
+ (fun c1 c2 x h1 h2 h3 => hno (Or.inl ⟨c1, c2, x, h1, h2, h3⟩))
+ (fun c1 c2 x h1 h2 h3 => hno (.inr (.inl ⟨c1, c2, x, h1, h2, h3⟩)))
+ (fun x h1 => hno (.inr (.inr (.inl ⟨x, h1⟩))))
+ (fun p x h1 h2 => hno (.inr (.inr (.inr (.inl ⟨p, x, h1, h2⟩)))))
+ (fun p x y h1 h2 h3 =>
+ hno (.inr (.inr (.inr (.inr (.inl ⟨p, x, y, h1, h2, h3⟩))))))
+ (fun p q x y h1 h2 h3 =>
+ hno (.inr (.inr (.inr (.inr (.inr (.inl ⟨p, q, x, y, h1, h2, h3⟩)))))))
+ (fun x y h1 h2 =>
+ hno (.inr (.inr (.inr (.inr (.inr (.inr (.inl ⟨x, y, h1, h2⟩))))))))
+ (fun n i p j h1 h2 h3 h4 =>
+ hno (.inr (.inr (.inr (.inr (.inr (.inr (.inr (.inl
+ ⟨n, i, p, j, h1, h2, h3, h4⟩)))))))))
+ (fun n i p j h1 h2 h3 h4 =>
+ hno (.inr (.inr (.inr (.inr (.inr (.inr (.inr (.inr (.inl
+ ⟨n, i, p, j, h1, h2, h3, h4⟩))))))))))
+ (fun c p u v h1 h2 h3 h4 =>
+ hno (.inr (.inr (.inr (.inr (.inr (.inr (.inr (.inr (.inr (.inl
+ ⟨c, p, u, v, h1, h2, h3, h4⟩)))))))))))
+ (fun c p f u v h1 h2 h3 h4 h5 h6 =>
+ hno (.inr (.inr (.inr (.inr (.inr (.inr (.inr (.inr (.inr (.inr (.inl
+ ⟨c, p, f, u, v, h1, h2, h3, h4, h5, h6⟩))))))))))))
+ (fun c p u v h1 h2 h3 h4 h5 =>
+ hno (.inr (.inr (.inr (.inr (.inr (.inr (.inr (.inr (.inr (.inr (.inr
+ ⟨c, p, u, v, h1, h2, h3, h4, h5⟩)))))))))))))
+ h
/-! ## A fragment in which a plain Herbrand model is easy to exhibit
@@ -516,19 +608,89 @@ was recorded only in `Semantics.lean`'s docstring, with a reason that turned out
to be wrong, and this file was byte-identical to the one that predates
`W3C.lean`. -/
+/-- `feed`'s closure carries no `rdf:type` to any of the three class or property
+names the new conditions read. Needed because `Plain.absent` rules out a
+PREDICATE outside the fragment, and these three premises use `rdf:type`, which is
+inside it: what has to be ruled out is the OBJECT. -/
+private theorem feed_closure_no_type_to :
+ ∀ t ∈ feedClosure, t.p = V.type →
+ t.o ≠ RV.nothing ∧ t.o ≠ RV.irreflexiveProperty ∧ t.o ≠ RV.asymmetricProperty := by
+ decide
+
/-- **A graph with a disjointness axiom that is NOT refutable.** Without this the
refutation layer would be consistent with a checker that accepts everything.
Relative to `Conditions` and to `RefuteConditions`. The same sentence over the
specification's model class is `feed_is_not_w3c_refuted` at the end of this
-file, which is strictly stronger and implies this one. -/
+file, which is strictly stronger and implies this one.
+
+**Now against all twelve conditions rather than one.**
+
+Eleven of them are discharged the same way and it is the dull way, which is the
+honest one to record: `feed` uses `rdf:type`, `rdfs:subClassOf` and
+`owl:disjointWith` and nothing else, so `Plain.absent` rules out every premise
+whose predicate is outside that fragment, and the three premises that do use
+`rdf:type` are ruled out by their object instead. No new mathematics; the cost
+of a wider rule set is paid here in bookkeeping, once. -/
theorem feed_is_not_refuted : ¬ Unsat feed := by
- refine not_unsat_of_joint_model (no_violation_means_a_joint_model feed feed_has_no_sameAs ?_)
- intro c1 c2 x h1 h2 h3
- have m1 := feed_closure_is_plain.der_mem feed_inside_its_closure h1
- have m2 := feed_closure_is_plain.der_mem feed_inside_its_closure h2
- have m3 := feed_closure_is_plain.der_mem feed_inside_its_closure h3
- exact feed_closure_has_no_clash _ m1 _ m2 _ m3 ⟨rfl, rfl, rfl, rfl, rfl, rfl⟩
+ refine not_unsat_of_joint_model (no_violation_means_a_joint_model feed feed_has_no_sameAs
+ ?dw ?com ?nothing ?irp ?asyp ?pdw ?diff ?npa1 ?npa2 ?maxc1 ?maxqc1 ?maxqc2)
+ case dw =>
+ intro c1 c2 x h1 h2 h3
+ have m1 := feed_closure_is_plain.der_mem feed_inside_its_closure h1
+ have m2 := feed_closure_is_plain.der_mem feed_inside_its_closure h2
+ have m3 := feed_closure_is_plain.der_mem feed_inside_its_closure h3
+ exact feed_closure_has_no_clash _ m1 _ m2 _ m3 ⟨rfl, rfl, rfl, rfl, rfl, rfl⟩
+ case com =>
+ intro c1 c2 _ h1 _ _
+ exact absurd (feed_closure_is_plain.der_mem feed_inside_its_closure h1)
+ (feed_closure_is_plain.absent RV.complementOf (by decide) (by decide) (by decide) c1 c2)
+ case nothing =>
+ intro x h1
+ exact ((feed_closure_no_type_to _
+ (feed_closure_is_plain.der_mem feed_inside_its_closure h1) rfl).1) rfl
+ case irp =>
+ intro p _ h1 _
+ exact ((feed_closure_no_type_to _
+ (feed_closure_is_plain.der_mem feed_inside_its_closure h1) rfl).2.1) rfl
+ case asyp =>
+ intro p _ _ h1 _ _
+ exact ((feed_closure_no_type_to _
+ (feed_closure_is_plain.der_mem feed_inside_its_closure h1) rfl).2.2) rfl
+ case pdw =>
+ intro p q _ _ h1 _ _
+ exact absurd (feed_closure_is_plain.der_mem feed_inside_its_closure h1)
+ (feed_closure_is_plain.absent RV.propertyDisjointWith (by decide) (by decide)
+ (by decide) p q)
+ case diff =>
+ intro x y _ h2
+ exact absurd (feed_closure_is_plain.der_mem feed_inside_its_closure h2)
+ (feed_closure_is_plain.absent RV.differentFrom (by decide) (by decide) (by decide) x y)
+ case npa1 =>
+ intro n i _ _ h1 _ _ _
+ exact absurd (feed_closure_is_plain.der_mem feed_inside_its_closure h1)
+ (feed_closure_is_plain.absent RV.sourceIndividual (by decide) (by decide)
+ (by decide) n i)
+ case npa2 =>
+ intro n i _ _ h1 _ _ _
+ exact absurd (feed_closure_is_plain.der_mem feed_inside_its_closure h1)
+ (feed_closure_is_plain.absent RV.sourceIndividual (by decide) (by decide)
+ (by decide) n i)
+ case maxc1 =>
+ intro c _ _ _ h1 _ _ _
+ exact absurd (feed_closure_is_plain.der_mem feed_inside_its_closure h1)
+ (feed_closure_is_plain.absent RV.maxCardinality (by decide) (by decide)
+ (by decide) c RV.zero)
+ case maxqc1 =>
+ intro c _ _ _ _ h1 _ _ _ _ _
+ exact absurd (feed_closure_is_plain.der_mem feed_inside_its_closure h1)
+ (feed_closure_is_plain.absent RV.maxQualifiedCardinality (by decide) (by decide)
+ (by decide) c RV.zero)
+ case maxqc2 =>
+ intro c _ _ _ h1 _ _ _ _
+ exact absurd (feed_closure_is_plain.der_mem feed_inside_its_closure h1)
+ (feed_closure_is_plain.absent RV.maxQualifiedCardinality (by decide) (by decide)
+ (by decide) c RV.zero)
/-- The attempt to refute the consistent graph, which differs from the accepted
refutation only in that `leo rdf:type Herbivore` is not available. -/
@@ -888,14 +1050,96 @@ theorem grazeI_is_a_w3c_model : W3CModel (refI true) refIP graze where
uni_eq := fun c l _ hc => absurd hc (not_mem_pred graze V.unionOf (by decide) c l)
oneOf_eq := fun c l _ hc => absurd hc (not_mem_pred graze V.oneOf (by decide) c l)
+/-- The eleven further negative conditions, over the same concrete model.
+
+Each is stated in the `= true` form `ref_feed_dw` uses rather than through
+`Interp.cext`, and that is not decoration: `cext` unfolds to an application of
+`I.ι`, which instance search will not reduce, so `decide` cannot find a
+`Decidable` instance for the `Interp`-level statement. Written over `refIext`
+the kernel can just run them.
+
+They hold for the dull reason, which is the one worth stating: `feed` mentions
+none of this vocabulary, so every premise is unmet. What the theorem below needs
+is that ONE interpretation satisfies all twelve at once, and this is it. -/
+theorem ref_feed_com :
+ ∀ a b : RefD, refIext false (refι RV.complementOf) a b = true →
+ ∀ x, refIext false .ty x a = true → refIext false .ty x b = true → False := by decide
+
+theorem ref_feed_nothing :
+ ∀ x : RefD, refIext false .ty x (refι RV.nothing) = true → False := by decide
+
+theorem ref_feed_irp :
+ ∀ p : RefD, refIext false .ty p (refι RV.irreflexiveProperty) = true →
+ ∀ x, refIext false p x x = true → False := by decide
+
+theorem ref_feed_asyp :
+ ∀ p : RefD, refIext false .ty p (refι RV.asymmetricProperty) = true →
+ ∀ x y, refIext false p x y = true → refIext false p y x = true → False := by decide
+
+theorem ref_feed_pdw :
+ ∀ p q : RefD, refIext false (refι RV.propertyDisjointWith) p q = true →
+ ∀ x y, refIext false p x y = true → refIext false q x y = true → False := by decide
+
+theorem ref_feed_diff :
+ ∀ x y : RefD, refIext false (refι V.sameAs) x y = true →
+ refIext false (refι RV.differentFrom) x y = true → False := by decide
+
+theorem ref_feed_npa1 :
+ ∀ n i p j : RefD, refIext false (refι RV.sourceIndividual) n i = true →
+ refIext false (refι RV.assertionProperty) n p = true →
+ refIext false (refι RV.targetIndividual) n j = true →
+ refIext false p i j = true → False := by decide
+
+theorem ref_feed_npa2 :
+ ∀ n i p j : RefD, refIext false (refι RV.sourceIndividual) n i = true →
+ refIext false (refι RV.assertionProperty) n p = true →
+ refIext false (refι RV.targetValue) n j = true →
+ refIext false p i j = true → False := by decide
+
+theorem ref_feed_maxc1 :
+ ∀ c p : RefD, refIext false (refι RV.maxCardinality) c (refι RV.zero) = true →
+ refIext false (refι V.onProperty) c p = true →
+ ∀ u v, refIext false .ty u c = true → refIext false p u v = true → False := by decide
+
+theorem ref_feed_maxqc1 :
+ ∀ c p f : RefD, refIext false (refι RV.maxQualifiedCardinality) c (refι RV.zero) = true →
+ refIext false (refι V.onProperty) c p = true →
+ refIext false (refι RV.onClass) c f = true →
+ ∀ u v, refIext false .ty u c = true → refIext false p u v = true →
+ refIext false .ty v f = true → False := by decide
+
+theorem ref_feed_maxqc2 :
+ ∀ c p : RefD, refIext false (refι RV.maxQualifiedCardinality) c (refι RV.zero) = true →
+ refIext false (refι V.onProperty) c p = true →
+ refIext false (refι RV.onClass) c (refι RV.thing) = true →
+ ∀ u v, refIext false .ty u c = true → refIext false p u v = true → False := by decide
+
theorem ref_feed_dw :
∀ a b : RefD, refIext false (refι RV.disjointWith) a b = true →
∀ x, refIext false .ty x a = true → refIext false .ty x b = true → False := by decide
-/-- And the `feed` model respects disjointness, which is what
-`RefuteConditions` asks and what `graze`'s model cannot do. -/
+/-- And the `feed` model respects every negative condition, which is what
+`RefuteConditions` asks and what `graze`'s model cannot do.
+
+Eleven of the twelve are `by decide`: `refI false` is a concrete interpretation
+over a finite carrier, and `feed` mentions none of the vocabulary those rules
+read, so each condition holds because its premise is never met. That is the
+cheap case and it is the honest one to state, because what this theorem has to
+establish is that SOMETHING satisfies all twelve at once, not that the eleven
+were hard. -/
theorem feedI_respects_disjointness : RefuteConditions (refI false) where
dw := ref_feed_dw
+ com := ref_feed_com
+ nothing := ref_feed_nothing
+ irp := ref_feed_irp
+ asyp := ref_feed_asyp
+ pdw := ref_feed_pdw
+ diff := ref_feed_diff
+ npa1 := ref_feed_npa1
+ npa2 := ref_feed_npa2
+ maxc1 := ref_feed_maxc1
+ maxqc1 := ref_feed_maxqc1
+ maxqc2 := ref_feed_maxqc2
theorem ref_models_are_live_raw :
(refIext false .ty .leo .lion = true ∧ refIext false .ty .leo .carn = true ∧
diff --git a/python/src/open_ontologies_lite/horn/reason.py b/python/src/open_ontologies_lite/horn/reason.py
index fec3d593..d03d874b 100644
--- a/python/src/open_ontologies_lite/horn/reason.py
+++ b/python/src/open_ontologies_lite/horn/reason.py
@@ -246,7 +246,7 @@ def _facts(store, graphs) -> tuple[list[Fact], list[str]]:
The default is the DEFAULT GRAPH ALONE, which is where `OntologyEngine.load()`
puts everything, so this package's own users lose nothing by it. The Rust
engine flattens every named graph here EXCEPT the inferred one
- (`src/reason.rs:3110`, `graph.triples_in_scope(&scope)`). Before
+ (`src/reason.rs:3134`, `graph.triples_in_scope(&scope)`). Before
15 September 2026 it excepted nothing, which was the defect above: a store
holding a prior materialisation turned derived triples into assertions.
"""
diff --git a/python/tests/test_horn_differential.py b/python/tests/test_horn_differential.py
index d6b2db7d..3cf709e5 100644
--- a/python/tests/test_horn_differential.py
+++ b/python/tests/test_horn_differential.py
@@ -26,7 +26,7 @@ WHAT IS COMPARED, AND WHAT IS NOT.
The assertion is SET EQUALITY OF DERIVED TRIPLES against the Rust `run_horn`, over
the same `builtin_rules.tsv`. Byte identity of the two `horn.tsv` files is NOT a
goal and must not be asserted: the Rust emitter sorts interned `u32` triples
-(`src/reason.rs:3180`, `all.sort_unstable()` over `Vec<(u32,u32,u32)>`), so its
+(`src/reason.rs:3204`, `all.sort_unstable()` over `Vec<(u32,u32,u32)>`), so its
line order is first-appearance order in the store, not lexicographic order.
Reproducing it from Python would mean reimplementing the interner and betting on
identical store-iteration order across two bindings, to buy nothing the set
diff --git a/python/tests/test_horn_fixpoint_and_scope.py b/python/tests/test_horn_fixpoint_and_scope.py
index 90ee15b6..cf8ed052 100644
--- a/python/tests/test_horn_fixpoint_and_scope.py
+++ b/python/tests/test_horn_fixpoint_and_scope.py
@@ -24,7 +24,7 @@ previous materialisation in the inferred graph turned derived triples into
ASSERTIONS. The checker could not detect it: the soundness theorem is conditional
on the assertions, and it is TOLD what they are, so the result was a green
absolute verdict about a graph nobody asserted. It now reads
-`src/reason.rs:3110`, `graph.triples_in_scope(&scope)`, and the
+`src/reason.rs:3134`, `graph.triples_in_scope(&scope)`, and the
inferred graph is out of scope.
The two engines still differ in HOW, and the difference is deliberate. Rust
diff --git a/src/main.rs b/src/main.rs
index c1ab4a9b..f02e51ea 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -458,8 +458,11 @@ enum Commands {
///
/// When the run also finds a contradiction that the checker can judge,
/// a refutation.tsv lands here too, for `lake exe oo-refute check`.
- /// Only `cax-dw` is certifiable; other clash rules are reported in the
- /// response as found by this engine and nothing is written for them.
+ /// Ten clash rules are certifiable and written; the rest are reported
+ /// in the response as found by this engine, with nothing written for
+ /// them. The Lean checker holds conditions for twelve, and the two
+ /// it can check that this engine never finds are named in
+ /// `CLASH_RULES_NOT_DETECTED`.
#[arg(long)]
certificate: Option<String>,
/// Evaluate a SUPPLIED Horn rule table instead of a built-in profile,
diff --git a/src/reason.rs b/src/reason.rs
index 3eb34e79..d4190ce6 100644
--- a/src/reason.rs
+++ b/src/reason.rs
@@ -176,13 +176,24 @@ struct Capture {
// the closure the fixpoint reached, and reported in the separate `oo-refute/1`
// format.
//
-// **Only `cax-dw` can be certified**, and the reason is not this file's.
-// `OOCert.RefuteConditions` in `lean/OOCert/Refute.lean` carries exactly one
-// semantic field, for `cax-dw`, and `oo-refute` refuses a refutation naming any
-// other rule with exit 2 rather than judging it. So a clash of any other rule
-// found here is an engine opinion with nothing behind it, it is reported under
-// a different word from the certified one, and no refutation file is written
-// for it.
+// **Twelve of the seventeen can now be certified, and this engine finds ten of
+// those twelve.** `OOCert.RefuteConditions` in `lean/OOCert/Refute.lean` carries
+// twelve semantic fields and `OOCert.checkRefuteStep` twelve arms, so a
+// refutation naming any of the twelve is CHECKED rather than refused. It used to
+// carry one.
+//
+// The two numbers differ and the difference is not a defect. `cls-maxqc1` and
+// `cls-maxqc2` have a condition in the Lean and no detector here: the checker
+// would accept a refutation naming them, and this engine never writes one,
+// because nothing looks for them. The five that have no condition at all are
+// `cax-adc`, `prp-adp`, `eq-diff2` and `eq-diff3`, which state their members in
+// an RDF list that the step format cannot carry, and `dt-not-type`, which needs
+// a datatype value space this development does not have. The first four are NOT
+// IMPLEMENTED and the fifth is NOT EXPRESSIBLE.
+//
+// A clash of a rule outside the twelve is still an engine opinion with nothing
+// behind it, still reported under a different word from the certified one, and
+// still written to no refutation file.
/// One way the closure contradicts itself: the OWL 2 RL rule that concludes
/// `false` from it, and the premises that rule reads, in the order the W3C
@@ -193,17 +204,28 @@ struct Clash {
premises: Vec<Fact>,
}
-/// The clash rules `lean/` holds a semantic condition for, so that a refutation
-/// naming one can be CHECKED rather than merely asserted.
+/// The clash rules `lean/` holds a semantic condition for AND this engine
+/// detects, so that a refutation naming one can be CHECKED rather than merely
+/// asserted.
///
-/// One rule, and the list is not this file's to extend: adding a name here
+/// Ten names, and the list is not this file's to extend: adding a name here
/// without a matching field in `OOCert.RefuteConditions` and a matching arm in
/// `OOCert.checkRefuteStep` would make the engine write a file the checker
/// exits 2 on, which is the one failure mode this layer exists to prevent.
+/// `tests/refutation_producer_test.rs` asserts the two lists agree, so the
+/// mistake is a test failure rather than a bad file.
+///
+/// The Lean certifies TWELVE. `cls-maxqc1` and `cls-maxqc2` are absent here
+/// because nothing in this file looks for them, not because the checker would
+/// refuse them, and they are listed with that reason in
+/// `CLASH_RULES_NOT_DETECTED` below.
///
/// One constant, read both by the emitter and by the report, so the two cannot
/// drift into disagreeing about what was certified.
-const CLASH_RULES_CERTIFIABLE: &[&str] = &["cax-dw"];
+const CLASH_RULES_CERTIFIABLE: &[&str] = &[
+ "cax-dw", "cls-com", "cls-nothing2", "eq-diff1", "prp-irp", "prp-asyp",
+ "prp-pdw", "cls-maxc1", "prp-npa1", "prp-npa2",
+];
fn clash_is_certifiable(rule: &str) -> bool {
CLASH_RULES_CERTIFIABLE.contains(&rule)
@@ -226,8 +248,10 @@ pub const CLASH_RULES_NOT_DETECTED: &[(&str, &str)] = &[
spelling IS detected, by eq-diff1."),
("eq-diff3", "owl:AllDifferent with owl:distinctMembers is an RDF list, as above."),
("cls-maxqc1", "owl:maxQualifiedCardinality needs the qualifying owl:onClass and a type check \
- on the value. Not implemented; owl:maxCardinality 0 IS detected, by cls-maxc1."),
- ("cls-maxqc2", "the owl:Thing case of the same rule, and not implemented for the same reason."),
+ on the value. NOT DETECTED HERE, though the Lean checker does hold a condition \
+ for it: a refutation naming it would be accepted, and this engine writes none \
+ because nothing looks for it. owl:maxCardinality 0 IS detected, by cls-maxc1."),
+ ("cls-maxqc2", "the owl:Thing case of the same rule. Also certifiable and also not detected."),
("dt-not-type", "an ill-typed literal needs a datatype VALUE space. This engine, and the Lean \
semantics under it, read a literal as its N-Triples spelling and compare \
nothing by value, so there is no notion here of a literal outside its type."),
diff --git a/tests/lean_refutation_producer_test.rs b/tests/lean_refutation_producer_test.rs
index 5d7abe03..b73e7d97 100644
--- a/tests/lean_refutation_producer_test.rs
+++ b/tests/lean_refutation_producer_test.rs
@@ -365,12 +365,21 @@ fn a_forged_refutation_is_rejected() {
}
#[test]
-fn an_uncertifiable_clash_is_never_written_as_a_refutation() {
- // `OOCert.RefuteConditions` carries one field, for `cax-dw`. A refutation
- // naming any other clash rule is refused by `oo-refute` with exit 2, which
- // is a file that could not be judged rather than a graph that could not be
- // refuted. The engine must therefore say it found a clash and write
- // nothing, and the two outcomes must not share a word.
+fn every_clash_this_engine_finds_is_now_one_the_checker_can_judge() {
+ // THIS TEST CHANGED MEANING UNDER #163, and the change is the result.
+ //
+ // It used to assert that a graph clashing by `prp-irp`, `eq-diff1` and
+ // `cls-nothing2` produced NO refutation file, because `RefuteConditions`
+ // carried one field and `oo-refute` exited 2 on any other rule name. All
+ // three now have conditions, so the same graph is certified rather than
+ // merely reported, and there is no detectable-but-unjudgeable clash left to
+ // point the old assertion at: the ten rules this engine detects are exactly
+ // the ten it can certify.
+ //
+ // So the assertion is inverted rather than deleted, and it still guards the
+ // same failure. If a future detector is added without a condition in the
+ // Lean, `uncertifiable_rules_found` becomes non-empty, no file is written
+ // for it, and this test says which rule it was.
let dir = scratch("uncertifiable");
let r = reason(&ontology(UNCERTIFIABLE), "owl-rl", Some(&dir));
@@ -381,19 +390,39 @@ fn an_uncertifiable_clash_is_never_written_as_a_refutation() {
}
assert!(
!by_rule.contains_key("cax-dw"),
- "this ontology has no disjointness clash: {r}"
+ "this ontology has no disjointness clash, and the point is that it no longer needs \
+ one to be certified: {r}"
);
for c in r["inconsistency"]["clashes"].as_array().unwrap() {
- assert_eq!(c["certifiable"], false, "no clash here is certifiable: {r}");
+ assert_eq!(
+ c["certifiable"], true,
+ "a clash this engine detects and the Lean cannot judge would be written to no \
+ file and reported under a different word. There is none today: {r}"
+ );
}
- assert_eq!(r["inconsistency"]["refutation"]["written"], false, "{r}");
+ assert_eq!(
+ r["inconsistency"]["uncertifiable_rules_found"].as_array().map(|a| a.len()),
+ Some(0),
+ "{r}"
+ );
+ assert_eq!(r["inconsistency"]["refutation"]["written"], true, "{r}");
assert!(
- !dir.join("refutation.tsv").exists(),
- "no refutation file may be written for a clash the checker cannot judge"
+ dir.join("refutation.tsv").exists(),
+ "a refutation must now be written for a clash the checker can judge"
);
- let why = r["inconsistency"]["refutation"]["why"].as_str().unwrap();
- assert!(why.contains("cax-dw"), "the reason must name the one rule that IS judged: {why}");
- println!("UNCERTIFIABLE CLASH: {}", r["inconsistency"]["by_rule"]);
+ // Everything above is about the ENGINE and runs wherever the suite runs.
+ // Only the line below needs the Lean toolchain, so the guard is here rather
+ // than at the top of the test: the old version of this test never called
+ // the checker, and hoisting a `skip()` to cover one call would stop the
+ // engine assertions running in the jobs that have no `lake` — which are the
+ // jobs where a producer regression is otherwise invisible.
+ if skip() {
+ return;
+ }
+ let (code, out, err) =
+ check_refutation(&dir.join("asserted.tsv"), &dir.join("refutation.tsv"));
+ assert_eq!(code, 0, "the checker must accept it: {out}{err}");
+ println!("CERTIFIED WITHOUT cax-dw: {}", r["inconsistency"]["by_rule"]);
}
#[test]
@@ -544,3 +573,96 @@ fn two_runs_reach_the_same_contradiction() {
"two runs over one ontology must reach one contradiction"
);
}
+
+// ── The two lists must agree (#163) ────────────────────────────────────
+//
+// The producer's gate and the checker's conditions are two lists in two
+// languages, and they were both length one, so nothing could drift. Widening
+// the checker to twelve rules and the producer to ten creates exactly the
+// failure this layer exists to prevent: a name in the Rust list with no field
+// in the Lean makes the engine write a file `oo-refute` exits 2 on.
+//
+// Read out of the source rather than restated here, so these tests measure the
+// code instead of a copy of it.
+
+fn rust_certifiable() -> Vec<String> {
+ let src = std::fs::read_to_string(repo().join("src/reason.rs")).expect("src/reason.rs");
+ let i = src
+ .find("const CLASH_RULES_CERTIFIABLE")
+ .expect("the producer's gate");
+ // From the `= &[`, not from the first `[`: the first one is inside the
+ // type annotation `&[&str]`, and reading that gave the list one member
+ // called "&str".
+ let eq = src[i..].find("= &[").expect("the list literal") + i;
+ let open = eq + 3;
+ let close = src[open..].find(']').expect("an end") + open;
+ src[open + 1..close]
+ .split(',')
+ .filter_map(|p| {
+ let p = p.trim().trim_matches('"');
+ (!p.is_empty()).then(|| p.to_string())
+ })
+ .collect()
+}
+
+fn lean_conditions() -> Vec<String> {
+ let src = std::fs::read_to_string(repo().join("lean/OOCert/Refute.lean"))
+ .expect("lean/OOCert/Refute.lean");
+ // `RefuteRule.name` is the mapping from constructor to the W3C rule name,
+ // and it is the thing `oo-refute` parses, so it is the authority here.
+ let i = src.find("def RefuteRule.name").expect("the rule names");
+ let end = src[i..].find("\n\ndef ").map(|e| e + i).unwrap_or(src.len());
+ src[i..end]
+ .lines()
+ .filter_map(|l| {
+ let l = l.trim();
+ let q = l.find("=> \"")? + 4;
+ let r = l[q..].find('"')? + q;
+ Some(l[q..r].to_string())
+ })
+ .collect()
+}
+
+#[test]
+fn every_rule_the_producer_certifies_has_a_condition_in_the_lean() {
+ let (rust, lean) = (rust_certifiable(), lean_conditions());
+ assert!(!rust.is_empty() && !lean.is_empty(), "the lists were not found: {rust:?} {lean:?}");
+ let missing: Vec<_> = rust.iter().filter(|r| !lean.contains(r)).collect();
+ assert!(
+ missing.is_empty(),
+ "the producer would write a refutation naming {missing:?}, and the Lean checker has \
+ no condition for it, so `oo-refute` would exit 2 on a file this engine wrote. Add \
+ the field to OOCert.RefuteConditions and the arm to OOCert.checkRefuteStep, or take \
+ the name out of CLASH_RULES_CERTIFIABLE."
+ );
+}
+
+/// The other direction is NOT an error, and the test says so rather than
+/// asserting equality: the Lean may hold a condition this engine never finds.
+/// `cls-maxqc1` and `cls-maxqc2` are exactly that today.
+#[test]
+fn a_rule_the_lean_can_check_but_the_producer_never_finds_is_declared() {
+ let (rust, lean) = (rust_certifiable(), lean_conditions());
+ let checkable_unfound: Vec<_> = lean.iter().filter(|l| !rust.contains(l)).collect();
+ let src = std::fs::read_to_string(repo().join("src/reason.rs")).expect("src/reason.rs");
+ for rule in &checkable_unfound {
+ assert!(
+ src.contains(&format!("(\"{rule}\"")),
+ "the Lean holds a condition for {rule} and this engine does not certify it, and \
+ CLASH_RULES_NOT_DETECTED does not say why. A capability nobody can reach and \
+ nobody has written down is indistinguishable from one that does not exist."
+ );
+ }
+ assert_eq!(
+ lean.len(),
+ 12,
+ "the checker is meant to hold twelve conditions; it holds {}",
+ lean.len()
+ );
+ assert_eq!(
+ rust.len(),
+ 10,
+ "the producer is meant to certify ten; it certifies {}",
+ rust.len()
+ );
+}