uor-foundation 0.3.0

UOR Foundation — typed Rust traits for the complete ontology. Import and implement.
Documentation
// @generated by uor-crate from uor-ontology — do not edit manually

//! `homology/` namespace — Simplicial complexes, chain complexes, boundary operators, and homology groups for structural reasoning..
//!
//! Space: Bridge

use crate::HostTypes;

/// A k-simplex: a finite set of k+1 vertices drawn from constraint objects.
pub trait Simplex<H: HostTypes> {
    /// The dimension k of a simplex (number of vertices minus one).
    fn dimension(&self) -> i64;
    /// Associated type for `Constraint`.
    type Constraint: crate::user::type_::Constraint<H>;
    /// A vertex of this simplex, drawn from the set of constraint objects.
    fn vertex(&self) -> &[Self::Constraint];
    /// The number of vertices in this simplex (dimension + 1).
    fn vertex_count(&self) -> u64;
    /// Associated type for `Simplex`.
    type SimplexTarget: Simplex<H>;
    /// Indicates that this simplex is a face of another simplex.
    fn is_face_of(&self) -> &[Self::SimplexTarget];
    /// Associated type for `SiteIndex`.
    type SiteIndex: crate::bridge::partition::SiteIndex<H>;
    /// A site coordinate in the partition whose intersection pins this simplex.
    fn pin_intersection(&self) -> &[Self::SiteIndex];
}

/// A simplicial complex: a set of simplices closed under taking faces.
pub trait SimplicialComplex<H: HostTypes> {
    /// Associated type for `Simplex`.
    type Simplex: Simplex<H>;
    /// A simplex belonging to this simplicial complex.
    fn has_simplex(&self) -> &[Self::Simplex];
    /// The maximum dimension of any simplex in this simplicial complex.
    fn max_dimension(&self) -> i64;
    /// The Euler characteristic of this simplicial complex: the alternating sum of simplex counts by dimension.
    fn euler_characteristic(&self) -> i64;
    /// The total number of vertices (0-simplices) in this simplicial complex.
    fn simplicial_vertex_count(&self) -> u64;
}

/// A face map d_i: removes vertex i from a simplex, producing a face.
pub trait FaceMap<H: HostTypes> {
    /// The index i of the vertex removed by this face map d_i.
    fn removes_vertex(&self) -> u64;
    /// Associated type for `Simplex`.
    type Simplex: Simplex<H>;
    /// The source simplex of this face map.
    fn source_simplex(&self) -> &Self::Simplex;
    /// The target face (result simplex) of this face map.
    fn target_face(&self) -> &Self::Simplex;
}

/// A free abelian group generated by k-simplices (the k-th chain group C_k).
pub trait ChainGroup<H: HostTypes> {
    /// The degree k of this chain group (the dimension of its generating simplices).
    fn degree(&self) -> i64;
    /// Associated type for `Simplex`.
    type Simplex: Simplex<H>;
    /// A simplex that generates this chain group.
    fn generated_by(&self) -> &[Self::Simplex];
}

/// The boundary operator ∂_k: C_k → C_{k-1}. Satisfies ∂² = 0.
pub trait BoundaryOperator<H: HostTypes> {
    /// Associated type for `ChainGroup`.
    type ChainGroup: ChainGroup<H>;
    /// The source chain group C_k of this boundary operator.
    fn source_group(&self) -> &Self::ChainGroup;
    /// The target chain group C_{k-1} of this boundary operator.
    fn target_group(&self) -> &Self::ChainGroup;
    /// Whether this boundary operator satisfies the fundamental property ∂² = 0.
    fn satisfies_boundary_squared_zero(&self) -> bool;
}

/// A chain complex: a sequence of chain groups connected by boundary operators.
pub trait ChainComplex<H: HostTypes> {
    /// Associated type for `ChainGroup`.
    type ChainGroup: ChainGroup<H>;
    /// A chain group belonging to this chain complex.
    fn has_chain_group(&self) -> &[Self::ChainGroup];
    /// Associated type for `BoundaryOperator`.
    type BoundaryOperator: BoundaryOperator<H>;
    /// A boundary operator belonging to this chain complex.
    fn has_boundary(&self) -> &[Self::BoundaryOperator];
}

/// The k-th homology group H_k = ker(∂_k) / im(∂_{k+1}). Measures k-dimensional holes.
pub trait HomologyGroup<H: HostTypes> {
    /// The degree k of this homology group H_k.
    fn homology_degree(&self) -> i64;
    /// The Betti number β_k = rank(H_k): the rank of this homology group.
    fn betti_number(&self) -> u64;
}

/// The nerve functor N: maps a set of constraints to a simplicial complex.
pub trait NerveFunctor<H: HostTypes> {}

/// The chain functor C: maps a simplicial complex to a chain complex.
pub trait ChainFunctor<H: HostTypes> {}

/// A simplicial set satisfying the Kan extension condition. The constraint nerve, when promoted from a SimplicialComplex to a KanComplex, carries a full homotopy type — not just its homology groups.
pub trait KanComplex<H: HostTypes>: SimplicialComplex<H> {
    /// Associated type for `HornFiller`.
    type HornFiller: HornFiller<H>;
    /// A horn filler witnessing the Kan condition for this complex.
    fn kan_witness(&self) -> &[Self::HornFiller];
}

/// A witness that a given horn (an incomplete simplex boundary) can be filled, certifying the Kan condition at a specific dimension and position.
pub trait HornFiller<H: HostTypes> {
    /// The dimension of the horn that this filler completes.
    fn horn_dimension(&self) -> u64;
    /// The position (missing face index) of the horn that this filler completes.
    fn horn_position(&self) -> u64;
}

/// The k-th Postnikov truncation τ≤k of the constraint nerve: a KanComplex whose homotopy groups πj vanish for j > k.
pub trait PostnikovTruncation<H: HostTypes> {
    /// The truncation level k of this Postnikov truncation τ≤k.
    fn truncation_level(&self) -> u64;
    /// Associated type for `KanComplex`.
    type KanComplex: KanComplex<H>;
    /// The KanComplex from which this Postnikov truncation is derived.
    fn truncation_source(&self) -> &Self::KanComplex;
    /// Associated type for `KInvariant`.
    type KInvariant: KInvariant<H>;
    /// The k-invariant classifying the extension at this truncation level.
    fn k_invariant(&self) -> &Self::KInvariant;
}

/// The k-invariant κk that classifies the extension from the (k−1)-truncation to the k-truncation of the Postnikov tower. Trivial κk means the truncation splits as a product.
pub trait KInvariant<H: HostTypes> {
    /// True iff this k-invariant is trivial, meaning the Postnikov truncation splits as a product.
    fn k_invariant_trivial(&self) -> bool;
}

/// The deformation complex of a CompleteType T: a chain complex whose H⁰ = automorphisms, H¹ = first-order deformations, H² = obstructions to extending deformations.
pub trait DeformationComplex<H: HostTypes>: ChainComplex<H> {
    /// Associated type for `CompleteType`.
    type CompleteType: crate::user::type_::CompleteType<H>;
    /// The CompleteType whose deformation complex this is.
    fn deformation_base(&self) -> &Self::CompleteType;
    /// The dimension of the tangent space H¹(Def(T)): the number of first-order deformations.
    fn tangent_dimension(&self) -> u64;
    /// The dimension of the obstruction space H²(Def(T)): the number of independent obstructions to extending deformations.
    fn obstruction_dimension(&self) -> u64;
}

/// ∂² = 0: the boundary of a boundary is zero.
pub mod boundary_squared_zero {
    /// `forAll` -> `term_boundarySquaredZero_forAll`
    pub const FOR_ALL: &str = "https://uor.foundation/schema/term_boundarySquaredZero_forAll";
    /// `lhs` -> `term_boundarySquaredZero_lhs`
    pub const LHS: &str = "https://uor.foundation/schema/term_boundarySquaredZero_lhs";
    /// `rhs` -> `term_boundarySquaredZero_rhs`
    pub const RHS: &str = "https://uor.foundation/schema/term_boundarySquaredZero_rhs";
    /// `verificationDomain` -> `Topological`
    pub const VERIFICATION_DOMAIN: &str = "https://uor.foundation/op/Topological";
}

/// The nerve functor N: constraints → simplicial complex.
pub mod nerve_functor_n {}

/// The chain functor C: simplicial complex → chain complex.
pub mod chain_functor_c {}

/// ψ_4: HomologyGroups → BettiNumbers (extraction functor).
pub mod psi_4 {
    /// `forAll` -> `term_psi_4_forAll`
    pub const FOR_ALL: &str = "https://uor.foundation/schema/term_psi_4_forAll";
    /// `lhs` -> `term_psi_4_lhs`
    pub const LHS: &str = "https://uor.foundation/schema/term_psi_4_lhs";
    /// `rhs` -> `term_psi_4_rhs`
    pub const RHS: &str = "https://uor.foundation/schema/term_psi_4_rhs";
    /// `verificationDomain` -> `Topological`
    pub const VERIFICATION_DOMAIN: &str = "https://uor.foundation/op/Topological";
}

/// Index bridge: connects Euler characteristic to alternating Betti sum.
pub mod index_bridge {
    /// `forAll` -> `term_indexBridge_forAll`
    pub const FOR_ALL: &str = "https://uor.foundation/schema/term_indexBridge_forAll";
    /// `lhs` -> `term_indexBridge_lhs`
    pub const LHS: &str = "https://uor.foundation/schema/term_indexBridge_lhs";
    /// `rhs` -> `term_indexBridge_rhs`
    pub const RHS: &str = "https://uor.foundation/schema/term_indexBridge_rhs";
    /// `verificationDomain` -> `Topological`
    pub const VERIFICATION_DOMAIN: &str = "https://uor.foundation/op/Topological";
}