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
tableau: apply domain and range to asserted edges, not only to generated successors
FABIOTESSbf00a46eef14
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d3f01c7d..999c75c4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -70,6 +70,36 @@ All notable changes to Open Ontologies are documented here.trace. See docs/lean-certificates.md and decision 0002.### Fixed+- **An ASSERTED role edge skipped its `rdfs:domain` and `rdfs:range`, so an+ inconsistent ABox was reported consistent.** Domain and range are deliberately+ not GCIs: as `∃p.⊤ ⊑ D` and `⊤ ⊑ ∀p.R` they put a disjunction on every node,+ and hqdm.owl alone carries 525 of them, so they are held as role metadata and+ applied when an edge is created. Two places create an edge and only one+ consulted that metadata. `Tableau::create_successor` applied it; the ABox+ builder wrote asserted role assertions, and the inverse back-edges it+ materialises for them, straight into the edge map. Every other role-sensitive+ rule reads edges through `successors()` and so was unaffected, which is why+ exactly these two constraints were weaker on an asserted edge than on a+ generated one. The consequence was a false clean: an ontology whose only+ contradiction is that an asserted edge forces its subject into a class+ disjoint from one it already carries came back `consistent: true` with+ `undecided: false`, the strongest answer the checker can give. Both paths now+ go through one `Tableau::add_role_edge` primitive. It also applies the+ constraints stated on the role's INVERSE, which NEITHER path applied before:+ `a r b` entails `b r⁻ a`, so `r⁻`'s domain binds `b` and its range binds `a`,+ and a symmetric role is its own inverse and rides the same clause. Found by+ the model-certificate layer, which had been refusing to certify these+ completion graphs because they are not models of the range axiom;+ `tests/dl_model_certificate_test.rs` pinned the defect and now pins the+ repair.+- **GCIs did not reach an individual named only as the object of a role+ assertion.** The ABox builder gives the GCIs to every typed individual and+ `create_successor` gives them to every generated successor, but an IRI that+ appears only as an edge's object got a bare node carrying nothing but its own+ nominal. A GCI holds of every element of the domain, so that node was a hole+ the check could not see into, and an ABox whose only contradiction landed+ there was reported consistent. Same shape as the domain/range split, found in+ the sweep for it.- **The CLIF export produced files that parse cleanly and yield NOTHING.**Every sentence was emitted as `(cl:comment '...' SENTENCE)`, the shapeISO/IEC 21838-2's BFO files use. Measured against both CLIF parsers thatdiff --git a/src/tableaux.rs b/src/tableaux.rsindex b77c4bc8..23e9d01a 100644--- a/src/tableaux.rs+++ b/src/tableaux.rs@@ -1320,25 +1320,78 @@ impl Tableau {result}- /// Create a new successor node and set up edges (including inverse back-edges).- fn create_successor(&mut self, parent_id: u32, role: u32, filler: Concept) -> u32 {- let succ = self.fresh_node(Some(parent_id), Some(role));- self.add_label(succ, filler);+ /// Add a role edge, and apply everything the edge itself entails.+ ///+ /// `rdfs:domain` binds the SOURCE and `rdfs:range` binds the TARGET. The+ /// inverse edge `to inv(role) from` holds in every model in which `from role+ /// to` does, so the inverse role's domain and range bind the same two nodes+ /// the other way round. A symmetric role is its own inverse in+ /// `inverse_roles`, so that clause covers it too.+ ///+ /// This is the ONLY sanctioned way to add an edge, and that is the whole+ /// point of it existing. `create_successor` used to be the only place+ /// `role_domain` and `role_range` were consulted, while `build_abox_tableau`+ /// wrote asserted role assertions straight into the edge map. A GENERATED+ /// successor therefore carried its domain and its range and an ASSERTED edge+ /// carried neither, so an ABox that is inconsistent precisely because an+ /// asserted edge forces its subject into a class disjoint from one it+ /// already has came back `consistent: true, undecided: false` — the+ /// strongest answer this checker can give, and wrong. The defect was the+ /// split between the two edge-creating paths, not either path on its own, so+ /// the repair is a single primitive both of them go through.+ ///+ /// Termination is unaffected. This adds labels to nodes that already exist+ /// and creates none, and the labels are drawn from the same finite+ /// sub-concept closure every other rule draws on, so no node's label set can+ /// grow without bound and blocking still fires on the same condition.+ fn add_role_edge(&mut self, from: u32, role: u32, to: u32) {+ if !self.nodes.contains_key(&from) || !self.nodes.contains_key(&to) {+ return;+ }+ self.nodes+ .get_mut(&from)+ .unwrap()+ .edges+ .entry(role)+ .or_default()+ .insert(to);- // rdfs:range binds the target, rdfs:domain binds the source. Doing it- // here keeps both out of the GCI list, so they cost one label each on- // the two nodes actually involved instead of a disjunction on every- // node in the tableau.+ // Keeping domain and range out of the GCI list is deliberate: as GCIs+ // they are `∃p.⊤ ⊑ D` and `⊤ ⊑ ∀p.R`, both with a non-atomic left-hand+ // side, so both land a disjunction on every node in the tableau. Applied+ // here they cost one label each on the two nodes actually involved.+ if let Some(ds) = self.tbox.role_domain.get(&role).cloned() {+ for c in ds {+ self.add_label(from, c);+ }+ }if let Some(rs) = self.tbox.role_range.get(&role).cloned() {for c in rs {- self.add_label(succ, c);+ self.add_label(to, c);}}- if let Some(ds) = self.tbox.role_domain.get(&role).cloned() {- for c in ds {- self.add_label(parent_id, c);++ if let Some(&inv) = self.tbox.inverse_roles.get(&role) {+ if let Some(ds) = self.tbox.role_domain.get(&inv).cloned() {+ for c in ds {+ self.add_label(to, c);+ }+ }+ if let Some(rs) = self.tbox.role_range.get(&inv).cloned() {+ for c in rs {+ self.add_label(from, c);+ }}}+ }++ /// Create a new successor node and set up edges (including inverse back-edges).+ fn create_successor(&mut self, parent_id: u32, role: u32, filler: Concept) -> u32 {+ let succ = self.fresh_node(Some(parent_id), Some(role));+ // The edge goes in through the shared primitive, which is what applies+ // rdfs:domain to this node and rdfs:range to the new one.+ self.add_role_edge(parent_id, role, succ);+ self.add_label(succ, filler);// Add GCIs to new nodefor gci in self.tbox.gcis.clone() {@@ -1378,14 +1431,8 @@ impl Tableau {}}- // Add forward edge- self.nodes- .get_mut(&parent_id)- .unwrap()- .edges- .entry(role)- .or_default()- .insert(succ);+ // The forward edge was added by `add_role_edge` above, together with the+ // domain and range it entails.self.trace.record(&format!("∃-rule: node {} creates successor {} via role {}",@@ -2478,6 +2525,17 @@ impl DlReasoner {let node_id = tableau.fresh_node(None, None);ind_to_node.insert(b, node_id);tableau.add_label(node_id, Concept::Atom(b));+ // A GCI holds of EVERY element of the domain, so a node that does not+ // carry the GCIs is a hole this check cannot see into. These nodes were+ // the only ones in the tableau created without them — the loop above+ // adds them to every typed individual and `create_successor` adds them+ // to every generated successor — and the omission was a second false+ // clean of the same shape as the domain/range one: an ABox whose only+ // contradiction lands on an individual named just as the object of a+ // role assertion was reported consistent.+ for gci in tableau.tbox.gcis.clone() {+ tableau.add_label(node_id, gci);+ }}// Add role assertions as edges. An asserted edge a R b also means b has an@@ -2487,25 +2545,16 @@ impl DlReasoner {// `inverse_roles`, a symmetric) role is silently missed. Unlike the tree// tableau, ABox individuals form an arbitrary graph, so the parent back-link// successors() uses cannot stand in for the inverse neighbour. Materialise it.+ //+ // Both edges go in through `add_role_edge`, which is what applies rdfs:domain+ // and rdfs:range. Writing them into the edge map directly, as this used to,+ // is what made an asserted edge weaker than a generated one.for &(a, r, b) in &self.role_assertions {if let (Some(&a_node), Some(&b_node)) = (ind_to_node.get(&a), ind_to_node.get(&b)) {- tableau- .nodes- .get_mut(&a_node)- .unwrap()- .edges- .entry(r)- .or_default()- .insert(b_node);- if let Some(&r_inv) = tableau.tbox.inverse_roles.get(&r) {- tableau- .nodes- .get_mut(&b_node)- .unwrap()- .edges- .entry(r_inv)- .or_default()- .insert(a_node);+ let r_inv = tableau.tbox.inverse_roles.get(&r).copied();+ tableau.add_role_edge(a_node, r, b_node);+ if let Some(r_inv) = r_inv {+ tableau.add_role_edge(b_node, r_inv, a_node);}}}diff --git a/tests/dl_model_certificate_test.rs b/tests/dl_model_certificate_test.rsindex bddc2200..64d4f9df 100644--- a/tests/dl_model_certificate_test.rs+++ b/tests/dl_model_certificate_test.rs@@ -20,9 +20,12 @@//! 3. The negative answers carry NOTHING, and the emitter says so rather than//! inventing a certificate. An unsatisfiable class produces `Refuted` and//! writes no file.-//! 4. The emitter refuses instead of emitting something that will not check.-//! One case where it refuses is not a limitation of the certificate layer-//! but a defect in the reasoner, and that case is pinned here.+//! 4. The emitter writes nothing instead of emitting something that will not+//! check. The case pinned here was found by this layer as a defect in the+//! reasoner rather than in the certificate layer: an asserted edge skipped+//! its `rdfs:range`, so the reasoner called an inconsistent ABox consistent+//! and the emitter caught the discrepancy on the way out. The reasoner has+//! since been fixed and the test now pins the repair.//!//! The checker needs a Lean toolchain (`lake`) AND the `oo-dlmodel` target in//! `lean/lakefile.toml`. Without either these tests skip loudly through@@ -415,30 +418,39 @@ fn an_unsatisfiable_class_gets_no_certificate() {);}-// ── 4. The emitter refuses rather than emitting something that will not check ──+// ── 4. The emitter writes nothing rather than something that will not check ──-/// The first thing this layer caught, pinned.+/// The first thing this layer caught, and now the regression for its repair.///-/// `check_abox` inserts an asserted role assertion straight into the edge map-/// rather than through `create_successor`, and `create_successor` is the ONLY-/// place `rdfs:domain` and `rdfs:range` are applied. So on an asserted edge-/// neither constraint ever reaches the individuals.+/// THIS TEST USED TO ENCODE THE BUG. `build_abox_tableau` wrote an asserted role+/// assertion straight into the edge map, and `create_successor` was the ONLY+/// place `rdfs:domain` and `rdfs:range` were consulted, so on an asserted edge+/// neither constraint ever reached the individuals. The assertion below read+/// `abox.consistent && !abox.undecided` and said in its own message that the+/// answer was wrong and that the test should be rewritten once the reasoner was+/// fixed. It has been: both edge-creating paths now go through+/// `Tableau::add_role_edge`, which applies domain and range wherever the edge+/// came from. The assertion is now on the CORRECT behaviour.////// The ontology below is inconsistent and it takes three axioms to see why:/// `worksFor` has range `Company`, `alice worksFor carol` forces carol into/// `Company`, carol is asserted a `Person`, and `Person` and `Company` are-/// disjoint. `check_abox` reports it CONSISTENT, and reports `undecided: false`,-/// so the claim is not hedged. That is a wrong positive answer, which is the-/// direction that matters: an ontology with a contradiction in it passes.+/// disjoint. `check_abox` must report it INCONSISTENT, and must report+/// `undecided: false`, because it really did find the clash rather than run out+/// of budget. A false `consistent` here is the failure that matters: an ontology+/// with a contradiction in it passing.///-/// The certificate layer cannot fix that and does not try. What it does is-/// refuse to certify: the completion graph is not a model of the range axiom, so-/// no file is written and the refusal names the axiom. The assertion below is on-/// the CURRENT behaviour of both. When the reasoner is fixed, `abox_consistent`-/// becomes false and this test has to be rewritten, which is the correct moment-/// to notice.+/// The certificate layer's half of this test is unchanged in meaning and only in+/// verdict. It never certifies something that will not check, and an ABox with no+/// model has nothing to certify, so it writes no file. What changed is which+/// negative it returns: it used to hand back `Refused`, because the reasoner+/// claimed a completion graph that was not in fact a model of the range axiom and+/// the emitter caught the discrepancy on the way out. Now the reasoner finds the+/// clash itself, so the emitter gets no completion graph at all and returns+/// `Refuted`, the same answer it gives for any unsatisfiable input. Either way+/// the gate holds: nothing is written.#[test]-fn an_asserted_edge_skips_its_range_and_the_emitter_refuses_to_certify() {+fn an_asserted_edge_applies_its_range_and_the_emitter_certifies_nothing() {let dir = scratch("range-gap");let reasoner = reasoner_for(&format!(r#"{PREFIXES}@@ -452,28 +464,30 @@ fn an_asserted_edge_skips_its_range_and_the_emitter_refuses_to_certify() {"#));- // The reasoner's own answer, and it is wrong.+ // The reasoner's own answer, and it is now right.let abox = reasoner.check_abox();assert!(- abox.consistent && !abox.undecided,- "this test exists because the reasoner reports this inconsistent ABox as consistent; \- if that has been fixed, rewrite the test rather than deleting it"+ !abox.consistent,+ "the asserted edge forces carol into Company, which is disjoint from the \+ Person she is asserted to be; reporting this ABox consistent is a false clean"+ );+ assert!(+ !abox.undecided,+ "the clash is reachable well inside the budget, so this must be a proof \+ and not a hedge");let outcome = reasoner.certify_abox_consistent(&dir).unwrap();match &outcome {- ModelOutcome::Refused(why) => assert!(- why.contains("range"),- "the refusal should name the axiom that fails: {why}"- ),+ ModelOutcome::Refuted => {}other => panic!(- "expected a refusal because the asserted edge never had its range applied, got {}",+ "an ABox with no model must be refuted and carry no certificate, got {}",other.describe()),}assert!(- !dir.join("axioms.tsv").exists(),- "a refusal must write nothing"+ !dir.join("axioms.tsv").exists() && !dir.join("model.tsv").exists(),+ "a negative answer must write nothing");}diff --git a/tests/reasoner_soundness_test.rs b/tests/reasoner_soundness_test.rsindex 5492c089..1c2d3a13 100644--- a/tests/reasoner_soundness_test.rs+++ b/tests/reasoner_soundness_test.rs@@ -206,34 +206,57 @@ const RS_PREFIXES: &str = "@prefix owl: <http://www.w3.org/2002/07/owl#> .\n\ex:D a owl:Class . ex:E a owl:Class . ex:D owl:disjointWith ex:E .\n\ex:r a owl:ObjectProperty . ex:s a owl:ObjectProperty ; owl:inverseOf ex:r .\n";-/// Read the consistency verdict, refusing to accept one the reasoner never-/// proved.+/// Read the ABox verdict, refusing to accept one the reasoner never proved.////// `consistent` starts true and is falsified by finding a clash, so an-/// unfinished run reports `consistent: true` with `complete: false`. Reading-/// the first field and ignoring the second treats "I ran out of budget" as-/// "I proved it", which is the exact confusion `incomplete_runs_are_declared_in_the_output`-/// exists to prevent, and it made these two tests fail intermittently on a-/// loaded machine with a message accusing the reasoner of unsoundness. The-/// engine was right; the reading was wrong. Fail on the unfinished run and say-/// what actually happened.-fn is_consistent(body: &str) -> bool {- let result = classify(&format!("{RS_PREFIXES}{body}"));- assert_ne!(- result.get("complete").and_then(|v| v.as_bool()),- Some(false),- "the reasoner hit a budget before finishing, so this run proves nothing either way. Raise [reasoner] tableaux_max_nodes / tableaux_max_depth, or give the run more time, rather than reading an unfinished run as a verdict. Full result: {result}"+/// unfinished run reports `consistent: true` with `undecided: true`. Reading the+/// first field and ignoring the second treats "I ran out of budget" as "I proved+/// it", which is the exact confusion `incomplete_runs_are_declared_in_the_output`+/// exists to prevent, and it made these tests fail intermittently on a loaded+/// machine with a message accusing the reasoner of unsoundness. The engine was+/// right; the reading was wrong. Fail on the unfinished run and say what+/// actually happened.+///+/// This asks `check_abox` directly rather than going through `DlReasoner::run`,+/// and that is not a shortcut, it is what these tests are about. `run` also+/// classifies every class and every ordered pair of classes across a rayon pool+/// sized to the machine, and none of these tests reads the classification. The+/// cost was not just wasted: every tableau in a run shares ONE wall-clock+/// deadline fixed when the reasoner is built, `cargo test` runs this file's+/// tests concurrently, and each opens a pool of its own, so on a machine with+/// fewer cores than that product the subsumption sweep starved, burned the whole+/// deadline on six trivial pairs, and the ABox check that runs after it reported+/// `undecided` on an ontology it decides in under a millisecond. The three tests+/// below failed about half the time on `fol-export` for that reason alone, with+/// no defect in the reasoner. Asking the ABox question directly removes the+/// dependency on a sweep nobody reads. The headline `consistent` flag, which+/// must carry an ABox contradiction rather than report around it, is covered by+/// `tests/tableaux_test.rs::test_dl_asserted_edge_applies_its_domain`, which+/// keeps the whole pipeline in the loop and lives in a binary that does not+/// deliberately exhaust budgets.+fn abox_is_consistent(body: &str) -> bool {+ let ttl = format!("{RS_PREFIXES}{body}");+ let store = Arc::new(GraphStore::new());+ store.load_turtle(&ttl, None).expect("ontology must parse");+ let reasoner = DlReasoner::from_graph(&store).expect("reasoner must build");+ let abox = reasoner.check_abox();+ assert!(+ !abox.undecided,+ "the ABox check hit a budget before finishing, so this run proves nothing \+ either way. Raise [reasoner] tableaux_max_nodes / tableaux_max_depth, or \+ give the run more time, rather than reading an unfinished run as a verdict."+ );+ assert!(+ abox.individuals_checked > 0,+ "no individual was checked, so this test would pass on an empty ABox");- result- .get("consistent")- .and_then(|v| v.as_bool())- .expect("consistent must be present")+ abox.consistent}#[test]fn direct_role_clash_is_detected_control() {// B forces its r-fillers to be D; b is E; D disjoint E. a r b => clash on b.- let inconsistent = !is_consistent(+ let inconsistent = !abox_is_consistent("ex:B a owl:Class ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty ex:r ; owl:allValuesFrom ex:D ] .\n\ex:a a ex:B ; ex:r ex:b .\n\ex:b a ex:E .\n",@@ -245,7 +268,7 @@ fn direct_role_clash_is_detected_control() {fn inverse_role_clash_is_detected() {// Same clash but reachable only through the inverse role s = r-inverse.// b:B forces its s-fillers to be D; a r b => b s a => a:D; a also E => clash.- let inconsistent = !is_consistent(+ let inconsistent = !abox_is_consistent("ex:B a owl:Class ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty ex:s ; owl:allValuesFrom ex:D ] .\n\ex:b a ex:B .\n\ex:a a ex:E ; ex:unused ex:noop .\n\@@ -258,7 +281,7 @@ fn inverse_role_clash_is_detected() {fn symmetric_role_clash_is_detected() {// A symmetric role is its own inverse. p symmetric, a p b => b p a.// B forces p-fillers to D; a:B and a p b => b:D; b:E; D disjoint E => clash.- let inconsistent = !is_consistent(+ let inconsistent = !abox_is_consistent("ex:p a owl:SymmetricProperty .\n\ex:B a owl:Class ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty ex:p ; owl:allValuesFrom ex:D ] .\n\ex:m a ex:B, ex:E ; ex:p ex:n .\n\@@ -307,7 +330,7 @@ fn anonymous_class_type_on_individual_is_enforced() {// a is directly typed by the anonymous (∀r.D); a r b; b is E.// ∀r.D forces b:D; b is E; D disjoint E => clash. Requires the anonymous type// to be enforced, which it was not before the fix.- let inconsistent = !is_consistent(+ let inconsistent = !abox_is_consistent("ex:a a [ a owl:Restriction ; owl:onProperty ex:r ; owl:allValuesFrom ex:D ] ; ex:r ex:b .\n\ex:b a ex:E .\n\ex:a2 a ex:E .\n",@@ -322,7 +345,7 @@ fn anonymous_class_type_on_individual_is_enforced() {fn anonymous_class_type_only_individual_is_still_checked() {// b typed ONLY by an anonymous restriction (∀r.D). No named class on b at all.// b r c ; c is E ; ∀r.D => c:D ; D disjoint E => clash.- let inconsistent = !is_consistent(+ let inconsistent = !abox_is_consistent("ex:b a [ a owl:Restriction ; owl:onProperty ex:r ; owl:allValuesFrom ex:D ] ; ex:r ex:c .\n\ex:c a ex:E .\n",);@@ -331,3 +354,149 @@ fn anonymous_class_type_only_individual_is_still_checked() {"an individual typed only by an anonymous class expression must still be checked");}++// ── rdfs:domain and rdfs:range on an ASSERTED edge ───────────────────────────+//+// `create_successor` was the only place the tableau consulted `role_domain` and+// `role_range`, and `build_abox_tableau` wrote asserted role assertions straight+// into the edge map without going through it. A GENERATED successor therefore+// got its domain and range and an ASSERTED edge got neither, so an ABox made+// inconsistent by an asserted edge alone came back `consistent: true` with+// `undecided: false`, the strongest answer this checker can give. Both paths now+// go through `Tableau::add_role_edge`.++/// The reported shape was `consistent: true` with `undecided: false`, the+/// strongest answer this checker can give, for an ABox with a contradiction in+/// it. That report is asserted on the whole pipeline in+/// `tests/tableaux_test.rs::test_dl_asserted_edge_applies_its_domain`, which+/// lives there because this file deliberately exhausts budgets and would starve+/// it. Here the same repair is checked against `check_abox` directly.+#[test]+fn an_asserted_edge_applies_its_domain_to_the_subject() {+ // domain(p) = D, a is E, D disjoint E, and a has an asserted p-edge out.+ // The edge alone forces a into D, which clashes with E.+ let inconsistent = !abox_is_consistent(+ "ex:p a owl:ObjectProperty ; rdfs:domain ex:D .\n\+ ex:a a ex:E ; ex:p ex:b .\n",+ );+ assert!(+ inconsistent,+ "an asserted edge must apply its rdfs:domain to the subject"+ );+}++#[test]+fn an_asserted_edge_applies_its_range_to_the_object() {+ // range(q) = D, b is E, D disjoint E, and b is the object of an asserted+ // q-edge. The edge alone forces b into D, which clashes with E.+ let inconsistent = !abox_is_consistent(+ "ex:q a owl:ObjectProperty ; rdfs:range ex:D .\n\+ ex:a a ex:E ; ex:q ex:b .\n\+ ex:b a ex:E .\n",+ );+ assert!(+ inconsistent,+ "an asserted edge must apply its rdfs:range to the object"+ );+}++/// A GENERATED successor, for contrast. This path always applied domain and+/// range, and is here so that a regression in the shared primitive cannot be+/// mistaken for the asserted-edge case coming back.+#[test]+fn a_generated_successor_still_applies_its_range_control() {+ // x is a C, C needs an r-successor in E, range(r) = D, D disjoint E. The+ // successor the tableau invents for x cannot be both.+ let inconsistent = !abox_is_consistent(+ "ex:r rdfs:range ex:D .\n\+ ex:C a owl:Class ; rdfs:subClassOf \+ [ a owl:Restriction ; owl:onProperty ex:r ; owl:someValuesFrom ex:E ] .\n\+ ex:x a ex:C .\n",+ );+ assert!(+ inconsistent,+ "a generated successor must apply its rdfs:range"+ );+}++// ── The same constraints through a role's INVERSE ────────────────────────────+//+// `a r b` entails `b inv(r) a` in every model, so domain(inv(r)) binds b and+// range(inv(r)) binds a. NEITHER path consulted the inverse role's domain or+// range at all, which is the same defect one step removed: a constraint stated+// on `s owl:inverseOf r` was invisible to every r-edge in the ontology, asserted+// or generated. A symmetric role is its own inverse in `inverse_roles`, so it+// rides on the same clause.++#[test]+fn a_generated_successor_applies_the_inverse_roles_domain() {+ // x is a C, C needs an r-successor in E. s is the inverse of r and has+ // domain D, so that successor is also a D, and D is disjoint from E.+ let inconsistent = !abox_is_consistent(+ "ex:s rdfs:domain ex:D .\n\+ ex:C a owl:Class ; rdfs:subClassOf \+ [ a owl:Restriction ; owl:onProperty ex:r ; owl:someValuesFrom ex:E ] .\n\+ ex:x a ex:C .\n",+ );+ assert!(+ inconsistent,+ "the inverse role's rdfs:domain must bind the target of the edge"+ );+}++#[test]+fn an_asserted_edge_applies_the_inverse_roles_range() {+ // s is the inverse of r and has range D, so `a r b` makes a a D. a is an E,+ // and D is disjoint from E.+ let inconsistent = !abox_is_consistent(+ "ex:s rdfs:range ex:D .\n\+ ex:a a ex:E ; ex:r ex:b .\n",+ );+ assert!(+ inconsistent,+ "the inverse role's rdfs:range must bind the source of an asserted edge"+ );+}++// ── GCIs reach every node in the ABox tableau ────────────────────────────────+//+// Found in the sweep for the same shape of mistake as the domain/range split,+// and it is the same shape: a node created outside the path that applies the+// constraint. `build_abox_tableau` gives the GCIs to every TYPED individual and+// `create_successor` gives them to every generated successor, but an individual+// named only as the OBJECT of a role assertion got a bare node carrying nothing+// but its own nominal. A GCI holds of every element of the domain, so that node+// was a hole the check could not see into, and an ABox whose only contradiction+// landed there was reported consistent.++#[test]+fn gcis_reach_an_individual_named_only_as_the_object_of_an_edge() {+ // X is equivalent to owl:Thing, which is a GCI saying every element is an X,+ // and no X is an E. B's r-fillers are all E. a is a B with an r-edge to b,+ // so b is an E and an X at once. b has no rdf:type of its own.+ let body = "ex:X a owl:Class ; owl:equivalentClass owl:Thing .\n\+ ex:X owl:disjointWith ex:E .\n\+ ex:B a owl:Class ; rdfs:subClassOf \+ [ a owl:Restriction ; owl:onProperty ex:r ; owl:allValuesFrom ex:E ] .\n\+ ex:a a ex:B ; ex:r ex:b .\n";+ assert!(+ !abox_is_consistent(body),+ "the GCIs must reach an individual that is only ever an edge's object"+ );++ // Control: the identical ontology with b given a type of its own, so it goes+ // down the path that always applied the GCIs. Both must answer the same way,+ // because whether b happens to carry an rdf:type changes nothing about+ // whether the ontology has a model.+ let typed = "ex:X a owl:Class ; owl:equivalentClass owl:Thing .\n\+ ex:X owl:disjointWith ex:E .\n\+ ex:Neutral a owl:Class .\n\+ ex:B a owl:Class ; rdfs:subClassOf \+ [ a owl:Restriction ; owl:onProperty ex:r ; owl:allValuesFrom ex:E ] .\n\+ ex:a a ex:B ; ex:r ex:b .\n\+ ex:b a ex:Neutral .\n";+ assert!(+ !abox_is_consistent(typed),+ "the control must be inconsistent too, or the test is measuring the wrong thing"+ );+}diff --git a/tests/tableaux_test.rs b/tests/tableaux_test.rsindex b7de57f9..c60bb8a5 100644--- a/tests/tableaux_test.rs+++ b/tests/tableaux_test.rs@@ -1248,3 +1248,53 @@ fn test_dl_absorbs_conjunctive_rhs() {"conjunctive-RHS absorption must preserve entailment, got {unsat:?}");}++/// An ABox made inconsistent by an ASSERTED edge, read off the reported output.+///+/// `build_abox_tableau` used to write asserted role assertions straight into the+/// edge map while `create_successor` was the only place `rdfs:domain` and+/// `rdfs:range` were consulted, so a generated successor carried both+/// constraints and an asserted edge carried neither. The report said+/// `consistent: true` with `undecided: false`, which is the strongest answer+/// this checker can give, for an ontology with a contradiction in it. Both edge+/// paths now go through `Tableau::add_role_edge`.+///+/// `tests/reasoner_soundness_test.rs` covers the same repair against `check_abox`+/// directly. This one is here because it is the reported OUTPUT that was wrong,+/// and the headline `consistent` flag has to carry an ABox contradiction rather+/// than report around it.+#[test]+fn test_dl_asserted_edge_applies_its_domain() {+ let store = Arc::new(GraphStore::new());+ store+ .load_turtle(+ r#"+ @prefix owl: <http://www.w3.org/2002/07/owl#> .+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .+ @prefix ex: <http://example.org/> .+ ex:D a owl:Class . ex:E a owl:Class . ex:D owl:disjointWith ex:E .+ ex:p a owl:ObjectProperty ; rdfs:domain ex:D .+ ex:a a ex:E ; ex:p ex:b .+ "#,+ None,+ )+ .unwrap();++ let result = Reasoner::run(&store, "owl-dl", false).unwrap();+ let parsed: serde_json::Value = serde_json::from_str(&result).unwrap();++ // An unfinished run proves nothing either way, so refuse to read one.+ assert_ne!(+ parsed["abox"]["undecided"], true,+ "the ABox check ran out of budget, so this run is not a verdict: {parsed}"+ );+ assert_eq!(+ parsed["abox"]["consistent"], false,+ "the asserted p-edge gives a the domain D, which is disjoint from the E it \+ is asserted to be: {parsed}"+ );+ assert_eq!(+ parsed["consistent"], false,+ "the headline verdict must carry the ABox contradiction: {parsed}"+ );+}