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.

Mu: a question the ontology cannot be asked is returned unasked (#232)

Fabio Rovaiafcbddca3b48
diff --git a/docs/first-order-export.md b/docs/first-order-export.md
index 57f4b226..eeb18b19 100644
--- a/docs/first-order-export.md
+++ b/docs/first-order-export.md
@@ -193,7 +193,7 @@ variables. **Everything else is named and counted as unchecked**, with a reason:
Skolemisation, AVATAR splitting, every SAT-solver step, and every step of E's whose premise is an
inline inference record and therefore carries no formula.
-### The verdict is one of eight words
+### The verdict is one of ten words
| verdict | means |
|---|---|
@@ -205,6 +205,8 @@ inline inference record and therefore carries no formula.
| `refutation_structure_checked` | structure holds, no step replayed |
| `refutation_partially_replayed` | structure holds, some steps replayed. The normal outcome |
| `refutation_fully_replayed` | structure holds, EVERY step replayed. Still not unsatisfiability |
+| `refutation_certified` | the derivation was translated into `lean/Fo`'s certificate and `oo-fores` accepted it: `Fo.unsat_of_check`. The one word that rests on a theorem; earned by itself for any goal in the clausal fragment, which every OWL 2 RL ontology is |
+| `mu` | returned UNASKED. The goal puts in class position a term the ontology never uses as a class: undeclared, or only an individual, or typed `skos:Concept` and never classified with. No prover is asked; its answer would be about a symbol no axiom mentions. The report names the term, its position and what the file calls it |
**An unchecked step prevents the strongest word**, and so does a leaf the prover invented. That is
mechanical and it is the reason the ladder has three rungs rather than a boolean. Even
diff --git a/src/server.rs b/src/server.rs
index ec414036..6fc220cf 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -2210,7 +2210,7 @@ impl OpenOntologiesServer {
.unwrap_or_else(Self::err_json)
}
- #[tool(name = "onto_fol_export", description = "Export the loaded ontology as first-order logic, so it can be handed to the automated-theorem-proving ecosystem. FOUR syntaxes over ONE translation: `tptp` (FOF, what E, Vampire and every other first-order prover read), `clif` (ISO/IEC 24707 Common Logic Interchange Format, restricted to the first-order-equivalent fragment: no sequence markers, fixed arity, no quantification into a predicate position), `smtlib` (SMT-LIB 2, what Z3 reads) and `ladr` (what Mace4 reads, with every symbol MANGLED and the table written beside it as symbols.tsv, because LADR reads a name beginning with u, v, w, x, y or z as a VARIABLE and has no quoting construct that survives an IRI). The last two are read by MODEL FINDERS, so they assert the NEGATED goal rather than declaring a conjecture: a countermodel to `G |= phi` is a model of `G + {not phi}`. With `smtlib`, omit `smt_domain` for the UNBOUNDED encoding, where `unsat` really is unsatisfiability, or set it to k for an enumeration carrier of exactly k elements, where a `sat` comes with a structure `oo-folmodel` can CHECK and an `unsat` establishes only that no model of size k exists. Every run also writes `problem.tsv`, the checker's own format, with its digest, so a solver result can be handed to `oo-folmodel` without going back through the engine; use onto_fol_model to do all of that in one call. The translation is the one a MACHINE-CHECKED ADEQUACY THEOREM is about: `OwlLean.adequacy` in the sibling owl-lean project, axioms propext + Classical.choice + Quot.sound, no sorry, no Mathlib. That theorem is why the emitted file means what it says. THE CORRESPONDENCE BETWEEN THIS EMITTER AND THAT LEAN IS PINNED BY TESTS AND IS NOT ITSELF PROVED. The output includes the background axioms (the two domains are disjoint, the object domain is non-empty) and the individual typing axioms `thing(a)`, whose ABSENCE REFUTES ADEQUACY OUTRIGHT (OwlLean.Refutations.adequacy_needs_ind_axioms). Constructs outside the fragment are NOT dropped silently: `exports_a_weaker_axiom_set` and `constructs_not_exported` name every one with its count and the reason, and `reduced_to_fragment` names every construct rewritten before translation. Pass `goals_file` (a TSV of triples, e.g. the `derivations.tsv` from onto_reason with certificate_dir, with goals_skip_columns=1) to also write one problem per conjecture. A PROVER'S VERDICT ON THESE FILES IS AN ORACLE OPINION AND NEVER A CERTIFICATE: checking a superposition refutation needs a verified first-order calculus with unification, which does not exist in core Lean. Use tools/fol_differential.py, which reports disagreement between this engine and an ATP and does not adjudicate it.")]
+ #[tool(name = "onto_fol_export", description = "Export the loaded ontology as first-order logic, so it can be handed to the automated-theorem-proving ecosystem. FOUR syntaxes over ONE translation: `tptp` (FOF, what E, Vampire and every other first-order prover read), `clif` (ISO/IEC 24707 Common Logic Interchange Format, restricted to the first-order-equivalent fragment: no sequence markers, fixed arity, no quantification into a predicate position), `smtlib` (SMT-LIB 2, what Z3 reads) and `ladr` (what Mace4 reads, with every symbol MANGLED and the table written beside it as symbols.tsv, because LADR reads a name beginning with u, v, w, x, y or z as a VARIABLE and has no quoting construct that survives an IRI). The last two are read by MODEL FINDERS, so they assert the NEGATED goal rather than declaring a conjecture: a countermodel to `G |= phi` is a model of `G + {not phi}`. With `smtlib`, omit `smt_domain` for the UNBOUNDED encoding, where `unsat` really is unsatisfiability, or set it to k for an enumeration carrier of exactly k elements, where a `sat` comes with a structure `oo-folmodel` can CHECK and an `unsat` establishes only that no model of size k exists. Every run also writes `problem.tsv`, the checker's own format, with its digest, so a solver result can be handed to `oo-folmodel` without going back through the engine; use onto_fol_model to do all of that in one call. The translation is the one a MACHINE-CHECKED ADEQUACY THEOREM is about: `OwlLean.adequacy` in the sibling owl-lean project, axioms propext + Classical.choice + Quot.sound, no sorry, no Mathlib. That theorem is why the emitted file means what it says. THE CORRESPONDENCE BETWEEN THIS EMITTER AND THAT LEAN IS PINNED BY TESTS AND IS NOT ITSELF PROVED. The output includes the background axioms (the two domains are disjoint, the object domain is non-empty) and the individual typing axioms `thing(a)`, whose ABSENCE REFUTES ADEQUACY OUTRIGHT (OwlLean.Refutations.adequacy_needs_ind_axioms). Constructs outside the fragment are NOT dropped silently: `exports_a_weaker_axiom_set` and `constructs_not_exported` name every one with its count and the reason, and `reduced_to_fragment` names every construct rewritten before translation. Pass `goals_file` (a TSV of triples, e.g. the `derivations.tsv` from onto_reason with certificate_dir, with goals_skip_columns=1) to also write one problem per conjecture. A PROVER'S VERDICT ON THESE FILES IS AN ORACLE OPINION UNLESS onto_fol_prove CERTIFIES IT: a refutation of a problem in the clausal fragment (every OWL 2 RL ontology is) is translated into lean/Fo's certificate format and checked by oo-fores, Fo.unsat_of_check; a refutation that uses equality or falls outside that fragment stays an opinion, because lean/Fo has no equality yet (decision 0005, second addendum). Use tools/fol_differential.py, which reports disagreement between this engine and an ATP and does not adjudicate it.")]
async fn onto_fol_export(&self, Parameters(input): Parameters<OntoFolExportInput>) -> String {
let syntax = match crate::tptp::Syntax::parse(
input.format.as_deref().unwrap_or("tptp"),
@@ -2267,7 +2267,7 @@ impl OpenOntologiesServer {
.unwrap_or_else(Self::err_json)
}
- #[tool(name = "onto_fol_prove", description = "Run a first-order prover, READ the derivation it prints back, and RE-CHECK what can honestly be re-checked. This does NOT move the boundary decision 0005 draws: a refutation is an ORACLE OPINION and stays one, because checking a superposition proof needs a verified first-order calculus with unification that does not exist in core Lean, and the replayer here is ordinary UNVERIFIED Rust with no theorem behind it. What it adds is that the opinion stops being a single word. THREE THINGS ARE EARNED, in increasing cost: (1) THE PROVER REFUTED OUR PROBLEM: every leaf of the derivation is matched, by name AND by parsed formula AND by role, against the problem onto_fol_export emitted, so a prover pointed at a stale file, a different file, or one whose conjecture was smuggled in as an axiom is caught; (2) THE DERIVATION IS A WELL-FOUNDED DAG ENDING IN $false: every parent reference resolves, the parent relation is acyclic, and the node nothing cites is the empty clause; (3) SOME STEPS ARE REPLAYED: binary resolution (which is also exactly what a subsumption-resolution conclusion is), factoring, duplicate literal removal, trivial inequality removal, equality resolution, associative flattening and the negation of the conjecture are recomputed from their premises with a small unifier. EVERYTHING ELSE IS NAMED AND COUNTED AS UNCHECKED: clausification, Skolemisation, AVATAR splitting and every SAT-solver step are not checked and are never claimed to be. FIELDS THAT ARE NEVER COLLAPSED: `szs_status` (what the prover said about itself, echoed and untrusted), `derivation_wellformed`, `leaves_match_problem` with `leaf_match_levels` saying how much normalisation each leaf needed, `steps_checked` / `steps_unchecked` (by rule, with a count and a reason) / `steps_not_reconstructed`, `conjecture_used`, `what_was_refuted` (`axioms_and_the_negated_conjecture` or `axioms_alone`, the second meaning the axioms are inconsistent on their own), and `verdict`. THE VERDICT IS ONE OF EIGHT WORDS: `derivation_rejected` is THE CHECKER SAYING NO (a dangling parent, a cycle, or a leaf that is not a formula of the problem); `refutation_step_not_reconstructed` means a step whose rule IS implemented did not reconstruct, which is EITHER a defect in the derivation OR a gap in this checker and this tool decides neither; `refutation_structure_checked`, `refutation_partially_replayed` and `refutation_fully_replayed` are the replay ladder, AN UNCHECKED STEP PREVENTS THE STRONGEST WORD, and even the strongest is NOT `unsatisfiable` and NOT a Lean-checked anything; `no_refutation_offered`, `derivation_unparsed` and `problem_unparsed` are the non-answers. Needs vampire or eprover on PATH; its absence is reported loudly in `skipped` and never worked around. Pass `problem` and `proof` to check a recorded pair with no prover run and no store. The MODEL direction is the one that CAN be certified: see onto_fol_model and decision 0006.")]
+ #[tool(name = "onto_fol_prove", description = "Run a first-order prover, READ the derivation it prints back, and RE-CHECK what can honestly be re-checked. This moves the boundary decision 0005 drew by exactly one step, its second addendum: a refutation of a problem in the clausal fragment is CERTIFIED when lean/Fo's checker accepts its translation (`refutation_certified`, theorem Fo.unsat_of_check, no user action: OWL 2 RL goes to the prover as clauses by itself), and every other refutation is an ORACLE OPINION, because lean/Fo has no equality yet and the replayer here is ordinary UNVERIFIED Rust with no theorem behind it. What it adds is that the opinion stops being a single word. THREE THINGS ARE EARNED, in increasing cost: (1) THE PROVER REFUTED OUR PROBLEM: every leaf of the derivation is matched, by name AND by parsed formula AND by role, against the problem onto_fol_export emitted, so a prover pointed at a stale file, a different file, or one whose conjecture was smuggled in as an axiom is caught; (2) THE DERIVATION IS A WELL-FOUNDED DAG ENDING IN $false: every parent reference resolves, the parent relation is acyclic, and the node nothing cites is the empty clause; (3) SOME STEPS ARE REPLAYED: binary resolution (which is also exactly what a subsumption-resolution conclusion is), factoring, duplicate literal removal, trivial inequality removal, equality resolution, associative flattening and the negation of the conjecture are recomputed from their premises with a small unifier. EVERYTHING ELSE IS NAMED AND COUNTED AS UNCHECKED: clausification, Skolemisation, AVATAR splitting and every SAT-solver step are not checked and are never claimed to be. FIELDS THAT ARE NEVER COLLAPSED: `szs_status` (what the prover said about itself, echoed and untrusted), `derivation_wellformed`, `leaves_match_problem` with `leaf_match_levels` saying how much normalisation each leaf needed, `steps_checked` / `steps_unchecked` (by rule, with a count and a reason) / `steps_not_reconstructed`, `conjecture_used`, `what_was_refuted` (`axioms_and_the_negated_conjecture` or `axioms_alone`, the second meaning the axioms are inconsistent on their own), and `verdict`. THE VERDICT IS ONE OF TEN WORDS: `derivation_rejected` is THE CHECKER SAYING NO (a dangling parent, a cycle, or a leaf that is not a formula of the problem); `refutation_step_not_reconstructed` means a step whose rule IS implemented did not reconstruct, which is EITHER a defect in the derivation OR a gap in this checker and this tool decides neither; `refutation_structure_checked`, `refutation_partially_replayed` and `refutation_fully_replayed` are the replay ladder, AN UNCHECKED STEP PREVENTS THE STRONGEST WORD, and even the strongest is NOT `unsatisfiable` and NOT a Lean-checked anything; `no_refutation_offered`, `derivation_unparsed` and `problem_unparsed` are the non-answers; `refutation_certified` is the one word that rests on a theorem, set only when a Certified token was minted by oo-fores accepting the translated derivation; and `mu` is a question returned UNASKED, because it puts in class position a term the ontology never uses as a class (undeclared, or only ever an individual, or a skos:Concept), so neither yes nor no would be about anything and no prover is asked. Needs vampire or eprover on PATH; its absence is reported loudly in `skipped` and never worked around. Pass `problem` and `proof` to check a recorded pair with no prover run and no store. The MODEL direction is the one that CAN be certified: see onto_fol_model and decision 0006.")]
async fn onto_fol_prove(&self, Parameters(input): Parameters<OntoFolProveInput>) -> String {
use crate::tstp::{ProveOptions, Prover, check_files, prove_export};
if let (Some(p), Some(d)) = (input.problem.as_deref(), input.proof.as_deref()) {
diff --git a/src/tptp.rs b/src/tptp.rs
index 68d8784e..0671609e 100644
--- a/src/tptp.rs
+++ b/src/tptp.rs
@@ -4103,6 +4103,187 @@ pub fn read_graph(triples: Vec<(String, String, String)>) -> ReadOntology {
/// A derived triple from `reason --certificate` is one of a handful of shapes.
/// Anything else returns `None` and the caller must report it rather than
/// quietly not asking the question.
+/// Every IRI an ontology uses in CLASS position: the atoms of every class
+/// expression in its axioms. What the file treats as a class, as opposed to
+/// what it declares one.
+pub fn class_positions(axioms: &[OwlAxiom]) -> BTreeSet<String> {
+ fn atoms(c: &Concept, out: &mut BTreeSet<String>) {
+ match c {
+ Concept::Atom(a) => {
+ out.insert(a.clone());
+ }
+ Concept::Inter(a, b) | Concept::Union(a, b) => {
+ atoms(a, out);
+ atoms(b, out);
+ }
+ Concept::Compl(a)
+ | Concept::Some_(_, a)
+ | Concept::All_(_, a)
+ | Concept::MinCard(_, _, a)
+ | Concept::MaxCard(_, _, a) => atoms(a, out),
+ Concept::Top
+ | Concept::Bot
+ | Concept::OneOf(_)
+ | Concept::HasVal(..)
+ | Concept::HasSelf(_)
+ | Concept::DataSome(..)
+ | Concept::DataAll(..) => {}
+ }
+ }
+ let mut out = BTreeSet::new();
+ for ax in axioms {
+ match ax {
+ OwlAxiom::SubClass(a, b) | OwlAxiom::EquivClass(a, b) | OwlAxiom::DisjointWith(a, b) => {
+ atoms(a, &mut out);
+ atoms(b, &mut out);
+ }
+ OwlAxiom::OPropDomain(_, c)
+ | OwlAxiom::OPropRange(_, c)
+ | OwlAxiom::DPropDomain(_, c)
+ | OwlAxiom::ClassAssert(c, _) => atoms(c, &mut out),
+ _ => {}
+ }
+ }
+ out
+}
+
+/// Every IRI an ontology uses as an INDIVIDUAL, with the number of assertions
+/// it stands in. A term here and not in [`class_positions`] is something the
+/// file talks about, never something it classifies with.
+pub fn individual_positions(axioms: &[OwlAxiom]) -> std::collections::BTreeMap<String, usize> {
+ let mut out = std::collections::BTreeMap::new();
+ let mut bump = |t: &String| *out.entry(t.clone()).or_insert(0) += 1;
+ for ax in axioms {
+ match ax {
+ OwlAxiom::ClassAssert(_, a) => bump(a),
+ OwlAxiom::OPropAssert(_, a, b) | OwlAxiom::SameAs(a, b) | OwlAxiom::DifferentFrom(a, b) => {
+ bump(a);
+ bump(b);
+ }
+ _ => {}
+ }
+ }
+ out
+}
+
+/// Subjects declared `owl:Class` or `rdfs:Class`, before the triples are
+/// consumed by [`read_graph`].
+pub fn declared_classes(triples: &[(String, String, String)]) -> BTreeSet<String> {
+ let (owl_class, rdfs_class) = (owl("Class"), "http://www.w3.org/2000/01/rdf-schema#Class");
+ triples
+ .iter()
+ .filter(|(_, p, o)| bare(p) == RDF_TYPE && (bare(o) == owl_class || bare(o) == rdfs_class))
+ .map(|(s, _, _)| bare(s).to_string())
+ .collect()
+}
+
+/// `rdf:type` objects per subject, so a refusal can say WHAT the file called
+/// the term instead of a class (a `skos:Concept`, most often).
+pub fn types_of(triples: &[(String, String, String)]) -> std::collections::BTreeMap<String, Vec<String>> {
+ let mut out: std::collections::BTreeMap<String, Vec<String>> = std::collections::BTreeMap::new();
+ for (s, p, o) in triples {
+ if bare(p) == RDF_TYPE && !is_literal(o) {
+ out.entry(bare(s).to_string()).or_default().push(bare(o).to_string());
+ }
+ }
+ out
+}
+
+/// A question returned unasked.
+#[derive(Debug, Clone, serde::Serialize)]
+pub struct Unasked {
+ /// The term the question puts in class position.
+ pub term: String,
+ /// `subject` or `object`.
+ pub position: &'static str,
+ /// `undeclared` (the file never mentions it), `individual` (it appears
+ /// only in assertions about it), or `typed_not_a_class` (it has an
+ /// `rdf:type`, a `skos:Concept` say, and is never used as a class).
+ pub kind: &'static str,
+ pub why: String,
+}
+
+/// Zhaozhou's 無. A goal is refused UNASKED when it puts in class position a
+/// term the ontology never uses as a class. `triple_as_axiom` would accept it,
+/// `Concept::Atom` takes any IRI, and a prover would then answer about a symbol
+/// no axiom constrains: a countermodel to a question the file cannot be asked,
+/// reported as "not entailed" as if the file had said no. It said nothing.
+/// Neither `entailed` nor `refuted` applies; the presupposition is what fails.
+///
+/// The check is against USE, not declaration: an ontology that uses a class
+/// in `rdfs:subClassOf` without ever typing it `owl:Class` still means it as a
+/// class, and the HQDM audit shows how common that is. Declaration counts as
+/// use. `owl:Thing`, `owl:Nothing` and blank-node class expressions are never
+/// refused here; the translator handles them.
+pub fn unasked(
+ read: &ReadOntology,
+ declared: &BTreeSet<String>,
+ types: &std::collections::BTreeMap<String, Vec<String>>,
+ s: &str,
+ p: &str,
+ o: &str,
+) -> Option<Unasked> {
+ let (bs, bp, bo) = (bare(s), bare(p), bare(o));
+ let positions: Vec<(&str, &'static str)> = match bp {
+ RDFS_SUBCLASS => vec![(bs, "subject"), (bo, "object")],
+ RDF_TYPE | RDFS_DOMAIN => vec![(bo, "object")],
+ RDFS_RANGE if !read.data_properties.contains(bs) => vec![(bo, "object")],
+ _ if bp == owl("equivalentClass") || bp == owl("disjointWith") => {
+ vec![(bs, "subject"), (bo, "object")]
+ }
+ _ => return None,
+ };
+ let used = class_positions(&read.axioms);
+ let individuals = individual_positions(&read.axioms);
+ for (term, position) in positions {
+ if term.starts_with("_:")
+ || term == owl("Thing")
+ || term == owl("Nothing")
+ || term.starts_with(OWL)
+ || term.starts_with("http://www.w3.org/2000/01/rdf-schema#")
+ || is_literal(term)
+ || declared.contains(term)
+ || used.contains(term)
+ {
+ continue;
+ }
+ let typed = types.get(term).cloned().unwrap_or_default();
+ let typed_as = if typed.is_empty() {
+ String::new()
+ } else {
+ format!(", typed {}", typed.join(", "))
+ };
+ let (kind, why) = match individuals.get(term) {
+ Some(n) => (
+ "individual",
+ format!(
+ "{term} appears in this ontology only as an INDIVIDUAL, in {n} assertion(s){typed_as}, \
+ and never in class position. The question presupposes it is a class; the file never \
+ said so, and a prover would answer about a class symbol no axiom mentions"
+ ),
+ ),
+ None if !typed.is_empty() => (
+ "typed_not_a_class",
+ format!(
+ "{term} is typed {} and is never used as a class anywhere in this ontology. A \
+ skos:Concept is not a class unless the file also says it is; asking whether it is a \
+ subclass of anything is a question the file cannot be asked",
+ typed.join(", ")
+ ),
+ ),
+ None => (
+ "undeclared",
+ format!(
+ "{term} appears nowhere in this ontology, in any position. There is nothing to be \
+ entailed and nothing to be refuted about a name the file has never used"
+ ),
+ ),
+ };
+ return Some(Unasked { term: term.to_string(), position, kind, why });
+ }
+ None
+}
+
pub fn triple_as_axiom(
read: &ReadOntology,
s: &str,
diff --git a/src/tstp.rs b/src/tstp.rs
index 57a56381..ac08718c 100644
--- a/src/tstp.rs
+++ b/src/tstp.rs
@@ -1599,6 +1599,12 @@ pub fn verdict_means(v: &str) -> &'static str {
carrier. The leaves are the formulas this engine emitted \
(leaves_match_problem), so that is a refutation of OUR problem. \
This is the only word in this vocabulary that rests on a theorem",
+ "mu" => "the question was returned UNASKED. It puts in class position a term this ontology \
+ never uses as a class: undeclared, or only ever an individual, or typed skos:Concept \
+ and never classified with. Neither `entailed` nor `refuted` applies to a question \
+ outside the file's language; a prover would still answer it, with a countermodel \
+ to a symbol nobody constrained, and that answer would be about nothing. What is \
+ refused is the presupposition, not the claim",
"refutation_fully_replayed" => "the structure holds and EVERY step was recomputed. This \
is the strongest word here and it is still NOT a proof \
of unsatisfiability: the calculus's soundness is not \
@@ -2813,6 +2819,10 @@ pub fn prove_export(
.to_string());
}
let triples = graph.all_triples()?;
+ // What the file declares and types, gathered before the triples are consumed:
+ // the unasked check below needs them and `ReadOntology` keeps neither.
+ let declared = crate::tptp::declared_classes(&triples);
+ let types = crate::tptp::types_of(&triples);
let read = crate::tptp::read_graph(triples);
std::fs::create_dir_all(dir)?;
@@ -2855,6 +2865,26 @@ pub fn prove_export(
cols[goals_skip_columns + 1],
cols[goals_skip_columns + 2],
);
+ // Before the translation: a goal that puts in class position a term
+ // the ontology never uses as a class is returned UNASKED. The
+ // translator would accept it and the prover would answer, about a
+ // symbol no axiom constrains, and the answer would be filed as
+ // "not entailed" as if the file had said no.
+ if let Some(u) = crate::tptp::unasked(&read, &declared, &types, s, p, o) {
+ *counts.entry("mu").or_default() += 1;
+ goal_reports.push(serde_json::json!({
+ "triple": [s, p, o],
+ "report": {
+ "verdict": "mu",
+ "verdict_means": verdict_means("mu"),
+ "term": u.term,
+ "position": u.position,
+ "kind": u.kind,
+ "why": u.why,
+ },
+ }));
+ continue;
+ }
let ax = match crate::tptp::triple_as_axiom(&read, s, p, o) {
Ok(ax) => ax,
Err(why) => {
@@ -2882,6 +2912,7 @@ pub fn prove_export(
let rejected = counts.get("derivation_rejected").copied().unwrap_or(0);
let unreconstructed = counts.get("refutation_step_not_reconstructed").copied().unwrap_or(0);
let certified = counts.get("refutation_certified").copied().unwrap_or(0);
+ let unasked = counts.get("mu").copied().unwrap_or(0);
Ok(serde_json::json!({
"prover": opts.prover.name(),
@@ -2903,6 +2934,13 @@ pub fn prove_export(
derivation or a gap in this checker and needs a human. The \
command exits non-zero on either",
"problem_form": match &bform { ProblemForm::Cnf => "cnf", ProblemForm::Fof { .. } => "fof" },
+ "unasked": unasked,
+ "unasked_means": "goals returned with the verdict `mu`: each puts in class position a term \
+ this ontology never uses as a class (undeclared, or only ever an individual, \
+ or typed skos:Concept and nothing more). No prover was asked, because its \
+ answer would have been about a symbol no axiom mentions and would have been \
+ filed as `not entailed` as if the file had said no. The report names the \
+ term, its position and what the file does call it",
"certified": certified,
"certified_means": if certified > 0 {
"this many refutations were CHECKED BY A THEOREM: translated into lean/Fo's \
diff --git a/tests/fol_prove_mu_test.rs b/tests/fol_prove_mu_test.rs
new file mode 100644
index 00000000..cd946523
--- /dev/null
+++ b/tests/fol_prove_mu_test.rs
@@ -0,0 +1,118 @@
+//! Zhaozhou's 無: a question the ontology cannot be asked is returned unasked,
+//! with the verdict `mu`, and no prover is consulted about it.
+//!
+//! Before this, `triple_as_axiom` accepted any IRI in class position
+//! (`Concept::Atom` takes a string), the prover found a countermodel to a
+//! symbol no axiom constrains, and the run filed it as "not entailed": the
+//! file was reported as having said no to a question it never understood.
+//! ies-core carries 43 `skos:Concept` terms that are never classes and the
+//! first version of the front-page figure drew them as if they were.
+
+use std::collections::BTreeSet;
+use std::path::PathBuf;
+use std::sync::atomic::{AtomicU64, Ordering};
+
+use open_ontologies::graph::GraphStore;
+use open_ontologies::tptp::{declared_classes, read_graph, types_of, unasked};
+use open_ontologies::tstp::{prove_export, ProveOptions, Prover};
+
+const IES: &str = "benchmark/reference/ies-core.ttl";
+const IES_NS: &str = "http://purl.org/ies/core/v0/ont/";
+const SUB: &str = "http://www.w3.org/2000/01/rdf-schema#subClassOf";
+
+static NEXT: AtomicU64 = AtomicU64::new(0);
+
+fn triples() -> Vec<(String, String, String)> {
+ let ttl = std::fs::read_to_string(PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(IES)).expect("fixture");
+ let g = GraphStore::new();
+ g.load_turtle(&ttl, None).expect("turtle parses");
+ g.all_triples().unwrap()
+}
+
+fn ies(local: &str) -> String {
+ format!("<{IES_NS}{local}>")
+}
+
+/// The classifier alone, no prover: a `skos:Concept` in subject position.
+#[test]
+fn a_skos_concept_in_class_position_is_unasked() {
+ let t = triples();
+ let (declared, types) = (declared_classes(&t), types_of(&t));
+ let read = read_graph(t);
+ let u = unasked(&read, &declared, &types, &ies("Accent"), &format!("<{SUB}>"), &ies("Characteristic"))
+ .expect("Accent is a skos:Concept, never a class: the question must be returned");
+ assert_eq!(u.term, format!("{IES_NS}Accent"));
+ assert_eq!(u.position, "subject");
+ assert!(u.why.contains("skos"), "the refusal must say what the file DOES call it: {}", u.why);
+ assert!(
+ u.kind == "individual" || u.kind == "typed_not_a_class",
+ "a concept is either an individual (skos:broader made it one) or typed and never a class: {}",
+ u.kind
+ );
+}
+
+/// A name the file has never used, in object position.
+#[test]
+fn an_undeclared_term_is_unasked_and_named_as_such() {
+ let t = triples();
+ let (declared, types) = (declared_classes(&t), types_of(&t));
+ let read = read_graph(t);
+ let u = unasked(&read, &declared, &types, &ies("SetOfSigns"), &format!("<{SUB}>"), &ies("NoSuchThing"))
+ .expect("an unknown object is unasked");
+ assert_eq!(u.kind, "undeclared");
+ assert_eq!(u.position, "object");
+}
+
+/// The gate can pass: two declared classes are a question the file can be asked.
+#[test]
+fn a_question_between_two_classes_is_asked() {
+ let t = triples();
+ let (declared, types) = (declared_classes(&t), types_of(&t));
+ let read = read_graph(t);
+ assert!(
+ unasked(&read, &declared, &types, &ies("ICalRepresentation"), &format!("<{SUB}>"), &ies("SetOfSigns")).is_none()
+ );
+ // And a class used only in the hierarchy, never declared owl:Class, still counts as a class.
+ let used: BTreeSet<String> = open_ontologies::tptp::class_positions(&read.axioms);
+ assert!(used.contains(&format!("{IES_NS}SetOfSigns")), "SetOfSigns is used as a class");
+}
+
+/// End to end through `prove_export`: the unasked goals are counted, carry
+/// the verdict, and never reach the prover; the askable one still does.
+#[test]
+fn prove_export_returns_the_unasked_goals_and_asks_the_rest() {
+ if !Prover::Vampire.available() {
+ return;
+ }
+ let dir = std::env::temp_dir().join(format!("oo-prove-mu-{}-{}", std::process::id(), NEXT.fetch_add(1, Ordering::Relaxed)));
+ std::fs::create_dir_all(&dir).unwrap();
+ let goals = dir.join("goals.tsv");
+ std::fs::write(
+ &goals,
+ format!(
+ "{}\t<{SUB}>\t{}\n{}\t<{SUB}>\t{}\n{}\t<{SUB}>\t{}\n",
+ ies("Accent"), ies("Characteristic"),
+ ies("SetOfSigns"), ies("NoSuchThing"),
+ ies("ICalRepresentation"), ies("SetOfSigns"),
+ ),
+ )
+ .unwrap();
+ let ttl = std::fs::read_to_string(PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(IES)).unwrap();
+ let g = std::sync::Arc::new(GraphStore::new());
+ g.load_turtle(&ttl, None).unwrap();
+ let opts = ProveOptions { prover: Prover::Vampire, timeout_secs: 20 };
+ let out = prove_export(&g, &dir, &opts, Some(goals.as_path()), 0).expect("prove runs");
+ let j: serde_json::Value = serde_json::from_str(&out).unwrap();
+ assert_eq!(j["unasked"], 2, "{j}");
+ assert_eq!(j["verdict_counts"]["mu"], 2, "{j}");
+ let goals = j["goals"].as_array().unwrap();
+ assert_eq!(goals.len(), 3);
+ assert_eq!(goals[0]["report"]["verdict"], "mu");
+ assert_eq!(goals[0]["report"]["term"], format!("{IES_NS}Accent"));
+ assert_eq!(goals[1]["report"]["verdict"], "mu");
+ assert_eq!(goals[1]["report"]["kind"], "undeclared");
+ assert_ne!(goals[2]["report"]["verdict"], "mu", "a real question is still asked: {}", goals[2]);
+ assert!(goals[2]["report"].get("szs_status").is_some(), "the prover ran on the askable goal");
+ assert_eq!(j["not_asked"].as_array().unwrap().len(), 0, "unasked is its own list, not not_asked");
+ assert_eq!(j["stop_the_line"], 0);
+}