use crate::category::Category;
use crate::logic::Axiom;
use super::property::Quality;
pub trait Ontology {
type Cat: Category;
type Qual: Quality<Individual = <Self::Cat as Category>::Object>;
fn structural_axioms() -> Vec<Box<dyn Axiom>> {
Vec::new()
}
fn domain_axioms() -> Vec<Box<dyn Axiom>> {
Vec::new()
}
fn axioms() -> Vec<Box<dyn Axiom>> {
let mut all = Self::structural_axioms();
all.extend(Self::domain_axioms());
all
}
fn validate() -> Result<(), Vec<String>>
where
<Self::Cat as Category>::Morphism: PartialEq,
{
let mut errors = Vec::new();
if let Err(e) = crate::category::validate::check_identity_law::<Self::Cat>() {
errors.push(e);
}
if let Err(e) = crate::category::validate::check_associativity::<Self::Cat>() {
errors.push(e);
}
if let Err(e) = crate::category::validate::check_closure::<Self::Cat>() {
errors.push(e);
}
for axiom in Self::axioms() {
if !axiom.holds() {
errors.push(format!("axiom violated: {}", axiom.description()));
}
}
if errors.is_empty() {
Ok(())
} else {
Err(errors)
}
}
}