Prime-Radiant is a mathematical framework for AI interpretability, built on rigorous foundations from algebraic topology, category theory, and quantum mechanics. This document describes the domain model using Domain-Driven Design (DDD) principles.
Purpose: Analyze topological structure of representations and detect coherence failures.
Sheaf (Aggregate Root)
- Contains: Presheaf, Sections, RestrictionMaps
- Invariants: Gluing axioms, locality conditions
- Behavior: Compute cohomology, detect obstructions
ChainComplex
- Contains: ChainGroups, BoundaryMaps
- Invariants: d^2 = 0 (boundary of boundary is zero)
- Behavior: Compute homology groups
Section: Data over an open setRestrictionMap: Linear map between stalksBettiNumbers: Topological invariantsPersistenceDiagram: Multi-scale topology
CoherenceViolationDetected: When H^1 is non-trivialTopologyChanged: When underlying graph structure changesSectionUpdated: When local data is modified
Purpose: Model compositional structure and preserve mathematical properties.
Category (Aggregate Root)
- Contains: Objects, Morphisms
- Invariants: Identity, associativity
- Behavior: Compose morphisms, verify laws
Topos (Aggregate Root)
- Contains: Category, SubobjectClassifier, Products, Exponentials
- Invariants: Finite limits, exponentials exist
- Behavior: Internal logic, subobject classification
Object: An element of the categoryMorphism: A transformation between objectsFunctor: Structure-preserving map between categoriesNaturalTransformation: Morphism between functors
MorphismId: Unique identifierObjectId: Unique identifierCompositionResult: Result of morphism composition
MorphismAdded: New morphism in categoryFunctorApplied: Functor maps between categoriesCoherenceVerified: Axioms confirmed
Purpose: Provide type-theoretic foundations for proofs and equivalences.
TypeUniverse (Aggregate Root)
- Contains: Types, Terms, Judgments
- Invariants: Type formation rules
- Behavior: Type checking, univalence
Path (Entity)
- Properties: Start, End, Homotopy
- Invariants: Endpoints match types
- Behavior: Concatenation, inversion, transport
Type: A type in the universeTerm: An element of a typeEquivalence: Bidirectional map with proofsIdentityType: The type of paths between terms
PathInduction: J-eliminator for pathsTransport: Move values along pathsUnivalence: Equivalence = Identity
Purpose: Analyze eigenvalue structure and spectral invariants.
SpectralDecomposition (Aggregate Root)
- Contains: Eigenvalues, Eigenvectors
- Invariants: Orthogonality, completeness
- Behavior: Compute spectrum, effective dimension
Eigenspace: Subspace for eigenvalueSpectralGap: Distance between eigenvaluesSpectralFingerprint: Comparison signatureConditionNumber: Numerical stability measure
LanczosIteration: Efficient eigenvalue computationCheegerAnalysis: Spectral gap and graph cuts
Purpose: Implement causal abstraction for mechanistic interpretability.
CausalModel (Aggregate Root)
- Contains: Variables, Edges, StructuralEquations
- Invariants: DAG structure (no cycles)
- Behavior: Intervention, counterfactual reasoning
CausalAbstraction (Aggregate Root)
- Contains: LowModel, HighModel, VariableMapping
- Invariants: Interventional consistency
- Behavior: Verify abstraction, compute IIA
Variable: A node in the causal graphIntervention: An action on a variableCircuit: Minimal subnetwork for behavior
StructuralEquation: Functional relationshipInterventionResult: Outcome of interventionAlignmentScore: How well mechanisms match
InterventionApplied: Variable was modifiedCircuitDiscovered: Minimal mechanism foundAbstractionViolation: Models disagree under intervention
Purpose: Apply quantum-inspired methods to representation analysis.
QuantumState (Aggregate Root)
- Contains: Amplitudes
- Invariants: Normalization
- Behavior: Measure, evolve, entangle
DensityMatrix (Aggregate Root)
- Contains: Matrix elements
- Invariants: Positive semi-definite, trace 1
- Behavior: Entropy, purity, partial trace
Entanglement: Correlation measureTopologicalInvariant: Robust propertyBerryPhase: Geometric phase
EntanglementAnalysis: Compute entanglement measuresTDAService: Topological data analysis
All contexts use a unified error type hierarchy:
pub enum PrimeRadiantError {
Cohomology(CohomologyError),
Category(CategoryError),
HoTT(HoTTError),
Spectral(SpectralError),
Causal(CausalError),
Quantum(QuantumError),
}- Default epsilon: 1e-10
- Configurable per computation
- Automatic condition number checking
All value objects and aggregates implement:
serde::Serializeandserde::Deserialize- Custom formats for mathematical objects
┌─────────────────────────────────────────────────────────────────┐
│ Prime-Radiant Core │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Cohomology │────▶│ Category │────▶│ HoTT │ │
│ │ Context │ │ Context │ │ Context │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │ │ │ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Spectral │────▶│ Causal │────▶│ Quantum │ │
│ │ Context │ │ Context │ │ Context │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
Relationships:
─────────────
Cohomology ──[U]──▶ Category : Sheaves are presheaves + gluing (Upstream/Downstream)
Category ──[U]──▶ HoTT : Categories model type theory
Spectral ──[S]──▶ Cohomology: Laplacian eigenvalues for cohomology (Shared Kernel)
Causal ──[C]──▶ Category : Causal abstraction as functors (Conformist)
Quantum ──[P]──▶ Category : Quantum channels as morphisms (Partnership)
| Term | Definition |
|---|---|
| Sheaf | Assignment of data to open sets satisfying gluing axioms |
| Cohomology | Measure of obstruction to extending local sections globally |
| Morphism | Structure-preserving map between objects |
| Functor | Structure-preserving map between categories |
| Path | Continuous map from interval, proof of equality in HoTT |
| Equivalence | Bidirectional map with inverse proofs |
| Spectral Gap | Difference between consecutive eigenvalues |
| Intervention | Fixing a variable to a value (do-operator) |
| Entanglement | Non-local correlation in quantum states |
| Betti Number | Dimension of homology group |
- Keep aggregates small and focused
- Use value objects for immutable data
- Enforce invariants in aggregate root
- Emit domain events for state changes
Each aggregate root has a repository:
pub trait SheafRepository {
fn find_by_id(&self, id: SheafId) -> Option<Sheaf>;
fn save(&mut self, sheaf: Sheaf) -> Result<(), Error>;
fn find_by_topology(&self, graph: &Graph) -> Vec<Sheaf>;
}Complex aggregates use factories:
pub struct SheafFactory {
pub fn from_neural_network(network: &NeuralNetwork) -> Sheaf;
pub fn from_knowledge_graph(kg: &KnowledgeGraph) -> Sheaf;
}Cross-aggregate operations use services:
pub struct CoherenceService {
pub fn check_global_consistency(sheaf: &Sheaf) -> CoherenceReport;
pub fn optimize_sections(sheaf: &mut Sheaf) -> OptimizationResult;
}