#[allow(unused_imports)]
use alloc::{boxed::Box, format, string::String, string::ToString, vec, vec::Vec};
use core::marker::PhantomData;
use crate::category::laws::functor_law_axioms;
use crate::category::{Category, FinitelyGenerated, Functor};
use crate::logic::proof::{Verdict, combine_verdicts};
use crate::ontology::meta::{Citation, Label, ModulePath, OntologyName, Provenance};
pub struct Analogy<F: Functor> {
_marker: PhantomData<F>,
}
impl<F: Functor> Analogy<F> {
pub fn validate() -> Verdict
where
F: 'static,
<F::Source as Category>::Morphism: PartialEq + 'static,
<F::Target as Category>::Morphism: PartialEq + 'static,
<F::Source as Category>::Object: FinitelyGenerated,
{
let subverdicts: Vec<Verdict> = functor_law_axioms::<F>()
.iter()
.map(|l| l.verify())
.collect();
combine_verdicts(
Provenance {
name: OntologyName::new_static("AnalogyValidation"),
description: Label::new_static(
"analogy preserves functor laws (identity and composition)",
),
citation: Citation::parse_static(
"Mac Lane (1971) Categories for the Working Mathematician Ch. II ยง1",
),
module_path: ModulePath::new_static(module_path!()),
},
subverdicts,
)
}
pub fn translate(obj: &<F::Source as Category>::Object) -> <F::Target as Category>::Object {
F::map_object(obj)
}
pub fn translate_morphism(
m: &<F::Source as Category>::Morphism,
) -> <F::Target as Category>::Morphism {
F::map_morphism(m)
}
}