use crate::category::laws::category_law_axioms;
use crate::category::{Category, FinitelyGenerated};
use crate::logic::Axiom;
use crate::logic::proof::{Verdict, combine_verdicts};
use crate::ontology::meta::{Citation, Label, ModulePath, OntologyName, Provenance};
use super::property::Quality;
pub trait Ontology {
type Cat: Category;
type Qual: Quality<Individual = <Self::Cat as Category>::Object>;
fn axioms() -> Vec<Box<dyn Axiom>>;
fn validate() -> Verdict
where
Self::Cat: 'static,
<Self::Cat as Category>::Morphism: PartialEq + 'static,
<Self::Cat as Category>::Object: FinitelyGenerated,
{
let mut subverdicts: Vec<Verdict> = Vec::new();
for law in category_law_axioms::<Self::Cat>() {
subverdicts.push(law.verify());
}
for axiom in Self::axioms() {
subverdicts.push(axiom.verify());
}
let meta = Provenance {
name: OntologyName::new_static("OntologyValidation"),
description: Label::new_static("aggregate validation: category laws + ontology axioms"),
citation: Citation::parse_static(
"Mac Lane (1971) Categories for the Working Mathematician; \
Barr & Wells (1999) CTCS §4 sketches; \
Spivak (2012) Functorial Data Model §§2–3",
),
module_path: ModulePath::new_static(module_path!()),
};
combine_verdicts(meta, subverdicts)
}
}