uor-foundation 0.1.3

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

//! `observable/` namespace — Observable quantities and metrics computed by the UOR kernel. Includes ring-metric, Hamming-metric, curvature, holonomy, and catastrophe-theoretic observables..
//!
//! Space: Bridge

use crate::enums::AchievabilityStatus;
use crate::enums::MeasurementUnit;
use crate::enums::PhaseBoundaryType;
use crate::enums::QuantumLevel;
use crate::Primitives;

/// A measurable quantity in the UOR Framework. All observables are kernel-computed and user-consumed.
pub trait Observable<P: Primitives> {
    /// The numeric value of an observable measurement.
    fn value(&self) -> P::Decimal;
    /// The source object of this measurement (datum, partition, or path start point).
    fn source(&self) -> &P::String;
    /// The target object of this measurement (for metrics and path-end measurements).
    fn target(&self) -> &P::String;
    /// The measurement unit of this observable. Replaces the string-valued observable:unit property with a typed reference to a MeasurementUnit individual.
    fn has_unit(&self) -> MeasurementUnit;
}

/// An observable measuring stratum-level properties: position within the ring's layer structure.
pub trait StratumObservable<P: Primitives>: Observable<P> {}

/// An observable measuring geometric distance between ring elements under a specific metric.
pub trait MetricObservable<P: Primitives>: Observable<P> {}

/// An observable measuring properties of paths through the ring: path length, total variation, winding number.
pub trait PathObservable<P: Primitives>: Observable<P> {}

/// An observable measuring cascade properties: the length and count of operation sequences.
pub trait CascadeObservable<P: Primitives>: Observable<P> {}

/// An observable measuring catastrophe-theoretic properties: thresholds at which qualitative changes occur in the partition.
pub trait CatastropheObservable<P: Primitives>: Observable<P> {
    /// The ring dimension coordinate n in the (n, g) catastrophe phase diagram (PD_1 n-coordinate).
    fn phase_n(&self) -> P::PositiveInteger;
    /// The group-order coordinate g in the (n, g) catastrophe phase diagram (PD_1 g-coordinate).
    fn phase_g(&self) -> P::PositiveInteger;
    /// True when g divides 2^n − 1, placing this observable on a resonance line in the phase diagram (PD_4).
    fn on_resonance_line(&self) -> P::Boolean;
    /// The type of phase boundary at this point in the catastrophe diagram: PeriodBoundary or PowerOfTwoBoundary (PD_2).
    fn phase_boundary_type(&self) -> PhaseBoundaryType;
}

/// An observable measuring the curvature of the UOR geometry: the gap between ring-isometry and Hamming-isometry for a given transform.
pub trait CurvatureObservable<P: Primitives>: Observable<P> {}

/// An observable measuring holonomy: the accumulated transformation when traversing a closed path in the ring.
pub trait HolonomyObservable<P: Primitives>: Observable<P> {}

/// Distance between two ring elements under the ring metric: d_R(x, y) = |x - y| mod 2^n.
pub trait RingMetric<P: Primitives>: MetricObservable<P> {}

/// Distance between two ring elements under the Hamming metric: the number of bit positions where they differ.
pub trait HammingMetric<P: Primitives>: MetricObservable<P> {}

/// The metric incompatibility between two ring elements: the divergence between their ring-metric and Hamming-metric distances, measuring geometric curvature.
pub trait IncompatibilityMetric<P: Primitives>: MetricObservable<P> {}

/// The stratum index of a ring element.
pub trait StratumValue<P: Primitives>: StratumObservable<P> {}

/// The difference in stratum between two ring elements.
pub trait StratumDelta<P: Primitives>: StratumObservable<P> {}

/// The sequence of strata traversed by a path through the ring.
pub trait StratumTrajectory<P: Primitives>: StratumObservable<P> {}

/// The length of a path through the ring, measured in operation steps.
pub trait PathLength<P: Primitives>: PathObservable<P> {}

/// The total variation of a path: the sum of metric distances between consecutive elements.
pub trait TotalVariation<P: Primitives>: PathObservable<P> {}

/// The winding number of a closed path: the number of times the path wraps around the ring.
pub trait WindingNumber<P: Primitives>: PathObservable<P> {}

/// The number of operation applications in an operation cascade.
pub trait CascadeLength<P: Primitives>: CascadeObservable<P> {}

/// The number of distinct cascades in a computation.
pub trait CascadeCount<P: Primitives>: CascadeObservable<P> {}

/// A critical value at which a qualitative change occurs in the partition structure.
pub trait CatastropheThreshold<P: Primitives>: CatastropheObservable<P> {}

/// The number of catastrophe events (qualitative partition changes) in a computation.
pub trait CatastropheCount<P: Primitives>: CatastropheObservable<P> {}

/// The commutator \[f, g\](x) = f(g(x)) - g(f(x)) of two operations, measuring their non-commutativity.
pub trait Commutator<P: Primitives>: CurvatureObservable<P> {}

/// The integrated curvature over a region of type space: the total metric incompatibility accumulated.
pub trait CurvatureFlux<P: Primitives>: CurvatureObservable<P> {}

/// The monodromy of a closed path: the net transformation accumulated when traversing a loop in the type space.
pub trait Monodromy<P: Primitives>: HolonomyObservable<P> {
    /// Associated type for `ClosedConstraintPath`.
    type ClosedConstraintPath: ClosedConstraintPath<P>;
    /// The closed path that generates this monodromy value.
    fn monodromy_loop(&self) -> &Self::ClosedConstraintPath;
    /// Associated type for `DihedralElement`.
    type DihedralElement: DihedralElement<P>;
    /// The dihedral element g in D_{2^n} accumulated when traversing the loop. The monodromy is trivial iff this element is the group identity.
    fn monodromy_element(&self) -> &Self::DihedralElement;
    /// True iff the monodromyElement is the identity in D_{2^n}.
    fn is_trivial_monodromy(&self) -> P::Boolean;
}

/// The parallel transport of a vector along a path: the canonical lift of the path to the tangent bundle of the ring.
pub trait ParallelTransport<P: Primitives>: HolonomyObservable<P> {}

/// An element of the dihedral group D_{2^n} acting on the type space. Each dihedral element induces an isometry of 𝒯_n.
pub trait DihedralElement<P: Primitives>: HolonomyObservable<P> {
    /// Associated type for `Operation`.
    type Operation: crate::kernel::op::Operation<P>;
    /// Non-functional. One assertion per generator in the normal form of the element — the sequence of neg and/or bnot operations that realises this dihedral element when composed.
    fn dihedral_element_value(&self) -> &[Self::Operation];
    /// True iff this element is the group identity (the trivial monodromy value).
    fn is_identity_element(&self) -> P::Boolean;
    /// The order of this element in D_{2^n}: the smallest k >= 1 such that g^k = id. For neg and bnot: order 2.
    fn element_order(&self) -> P::PositiveInteger;
    /// The rotation exponent k ∈ \\[0, 2^n) of this dihedral element in the standard representation r^k s^s. Together with reflectionBit, uniquely identifies the element within D_\{2^n\}.
    fn rotation_exponent(&self) -> P::NonNegativeInteger;
    /// The reflection flag s ∈ \{0,1\} of this dihedral element. False = pure rotation (r^k), true = reflection (r^k·s). D_7 defines composition: (r^a s^p)(r^b s^q) = r^(a + (-1)^p b) s^(p XOR q).
    fn reflection_bit(&self) -> P::Boolean;
}

/// Fiber-by-fiber curvature decomposition. J_k measures the discrete derivative of the incompatibility metric at fiber position k: J_k = |d_R(x, succ(x)) - d_H(x, succ(x))| restricted to position k.
pub trait Jacobian<P: Primitives>: CurvatureObservable<P> {
    /// The fiber position k at which this Jacobian entry is measured.
    fn fiber_position(&self) -> P::NonNegativeInteger;
    /// The discrete derivative value at this fiber position.
    fn derivative_value(&self) -> P::Decimal;
}

/// An observable measuring a topological invariant of the resolution space. Topological observables are invariant under continuous deformations of the constraint configuration.
pub trait TopologicalObservable<P: Primitives>: Observable<P> {
    /// The dimension k of the topological observable (e.g., the degree of the Betti number or the dimension of the spectral gap).
    fn dimension(&self) -> P::NonNegativeInteger;
}

/// The rank of a homology group of the constraint nerve. β_k = rank(H_k(N(C))) counts the k-dimensional holes in the constraint configuration.
pub trait BettiNumber<P: Primitives>: TopologicalObservable<P> {}

/// The smallest positive eigenvalue of the constraint nerve Laplacian. Controls the convergence rate of iterative resolution: larger gap = faster convergence.
pub trait SpectralGap<P: Primitives>: TopologicalObservable<P> {}

/// An observable measuring thermodynamic properties of the resolution process: residual entropy, Landauer cost, and cascade distribution statistics.
pub trait ThermoObservable<P: Primitives>: Observable<P> {
    /// An estimated computational hardness for a ThermoObservable, connecting thermodynamic cost to complexity (TH_9 realisation).
    fn hardness_estimate(&self) -> P::Decimal;
}

/// S_residual: the residual Shannon entropy of the fiber distribution after partial resolution. Computed as S = (Σ κ_k − χ(N(C))) × ln 2 (IT_7b). Unit: Nats.
pub trait ResidualEntropy<P: Primitives>: ThermoObservable<P> {}

/// The minimum thermodynamic cost (in units of k_B T ln 2) of erasing one bit of fiber uncertainty. The UOR ring operates at β* = ln 2 — the Landauer temperature.
pub trait LandauerCost<P: Primitives>: ThermoObservable<P> {}

/// The Shannon entropy of the cascade distribution P(j) = 2^{−j}. At the Landauer temperature, this equals ln 2 per cascade step — each step erases exactly one bit of fiber uncertainty.
pub trait CascadeEntropy<P: Primitives>: ThermoObservable<P> {}

/// A named topological signature: a pair (realised Euler characteristic, realised Betti profile). Linked from TypeSynthesisResult. Allows comparison between the goal signature and the actually achieved signature.
pub trait SynthesisSignature<P: Primitives> {
    /// The Euler characteristic actually achieved by this synthesis signature.
    fn realised_euler(&self) -> P::Integer;
    /// Non-functional. Realised Betti number values, one assertion per homological degree.
    fn realised_betti(&self) -> &[P::NonNegativeInteger];
    /// The achievability classification of this observable's topological signature in the morphospace.
    fn achievability_status(&self) -> AchievabilityStatus;
    /// Whether this signature has been empirically verified as achievable at some quantum level.
    fn is_achievable(&self) -> P::Boolean;
    /// Whether this signature has been formally proven impossible by an ImpossibilityWitness.
    fn is_forbidden(&self) -> P::Boolean;
    /// Associated type for `Proof`.
    type Proof: crate::bridge::proof::Proof<P>;
    /// The proof individual (ImpossibilityWitness or EmpiricalVerification) that grounds this signature's achievability classification.
    fn achievability_witness(&self) -> &Self::Proof;
}

/// A single page E_r of the quantum level spectral sequence. Carries the page index r and the differential d_r. The sequence converges when all differentials vanish — typically by E_3 for simple constraint configurations.
pub trait SpectralSequencePage<P: Primitives> {
    /// The page r of this spectral sequence page. r=1 is the initial page; convergence is declared when all d_r are zero.
    fn page_index(&self) -> P::NonNegativeInteger;
    /// True iff d_r = 0 on this page — no further corrections to the lifted homology.
    fn differential_is_zero(&self) -> P::Boolean;
    /// The page index r at which the spectral sequence converged (all subsequent differentials zero).
    fn converged_at(&self) -> P::NonNegativeInteger;
    /// Associated type for `PostnikovTruncation`.
    type PostnikovTruncation: crate::bridge::homology::PostnikovTruncation<P>;
    /// The Postnikov truncation associated with this spectral sequence page.
    fn postnikov_truncation(&self) -> &Self::PostnikovTruncation;
}

/// The cohomology class in H^2(N(C(T))) representing the LiftObstruction for a specific QuantumLift. The class is zero iff the obstruction is trivial. When non-zero, it indexes the specific fiber pair at Q_{n+1} that cannot be closed by the lifted constraint set alone.
pub trait LiftObstructionClass<P: Primitives> {
    /// Associated type for `CohomologyGroup`.
    type CohomologyGroup: crate::bridge::cohomology::CohomologyGroup<P>;
    /// The cohomology class in H^2(N(C(T))) representing this obstruction.
    fn obstruction_class(&self) -> &Self::CohomologyGroup;
}

/// A classification of a type's holonomy: the subgroup of D_{2^n} generated by all Monodromy observables computed over closed paths in the type's constraint nerve. Trivial iff every closed constraint path returns to its starting fiber assignment without net dihedral transformation.
pub trait MonodromyClass<P: Primitives> {}

/// The holonomy group of a ConstrainedType: the group of all Monodromy elements achievable by closed paths in the constraint nerve. Always a subgroup of D_{2^n}. Trivial iff the type has trivial monodromy everywhere; equals D_{2^n} iff paths involving both neg and bnot involutions are present.
pub trait HolonomyGroup<P: Primitives> {
    /// Associated type for `DihedralElement`.
    type DihedralElement: DihedralElement<P>;
    /// Non-functional. The generators of the holonomy group: one DihedralElement per generating monodromy.
    fn holonomy_group(&self) -> &[Self::DihedralElement];
    /// The order of the holonomy group as a subgroup of D_{2^n}. For a FlatType: 1. For full dihedral holonomy: 2^{n+1}.
    fn holonomy_group_order(&self) -> P::PositiveInteger;
}

/// A sequence of constraint applications forming a closed loop in the constraint nerve — beginning and ending at the same fiber assignment. The Monodromy of the loop is the net DihedralElement accumulated when traversing it.
pub trait ClosedConstraintPath<P: Primitives> {
    /// The number of constraint application steps in this closed path.
    fn path_length(&self) -> P::NonNegativeInteger;
    /// Associated type for `Constraint`.
    type Constraint: crate::user::type_::Constraint<P>;
    /// Non-functional. The ordered sequence of constraints traversed. One assertion per step.
    fn path_constraints(&self) -> &[Self::Constraint];
}

/// The k-th homotopy group πk(N(C), v) of the constraint nerve based at vertex v.
pub trait HomotopyGroup<P: Primitives> {
    /// The dimension k of this homotopy group πk.
    fn homotopy_dimension(&self) -> P::NonNegativeInteger;
    /// The rank of this homotopy group (number of free generators).
    fn homotopy_rank(&self) -> P::NonNegativeInteger;
    /// Associated type for `Constraint`.
    type Constraint: crate::user::type_::Constraint<P>;
    /// The basepoint vertex v at which this homotopy group is computed.
    fn homotopy_basepoint(&self) -> &Self::Constraint;
}

/// The image of πk(N(C)) → Aut(fiberk) for k > 1. Generalises the MN_6 monodromy homomorphism.
pub trait HigherMonodromy<P: Primitives> {
    /// The dimension k > 1 at which this higher monodromy acts.
    fn higher_monodromy_dimension(&self) -> P::NonNegativeInteger;
}

/// The Whitehead product \[α, β\] ∈ πp+q−1 for α ∈ πp, β ∈ πq.
pub trait WhiteheadProduct<P: Primitives> {
    /// True iff this Whitehead product is trivial (zero in πp+q−1).
    fn whitehead_trivial(&self) -> P::Boolean;
}

/// A record of the holonomy stratification of the moduli space at a given quantum level: the list of HolonomyStrata, their codimensions, and their relationship to the MorphospaceBoundary.
pub trait StratificationRecord<P: Primitives> {
    /// The quantum level at which this stratification is computed.
    fn stratification_level(&self) -> QuantumLevel;
    /// Associated type for `HolonomyStratum`.
    type HolonomyStratum: crate::user::type_::HolonomyStratum<P>;
    /// A HolonomyStratum in this stratification record.
    fn stratification_stratum(&self) -> &[Self::HolonomyStratum];
}

/// Superclass for the six universal measurements. Every computation on the ring produces these six quantities: d_Δ, σ, J_k, β_k, χ, r.
pub trait BaseMetric<P: Primitives>: Observable<P> {
    /// The mathematical domain of this base metric.
    fn metric_domain(&self) -> &P::String;
    /// The mathematical range (codomain) of this base metric.
    fn metric_range(&self) -> &P::String;
    /// How this metric composes with others in the measurement tower.
    fn metric_composition(&self) -> &P::String;
    /// The existing observable class that this base metric references.
    fn references_class(&self) -> &P::String;
    /// The existing identity that defines this base metric.
    fn references_identity(&self) -> &P::String;
    /// The unit of measurement for this base metric.
    fn metric_unit(&self) -> &P::String;
    /// The precision or resolution of this base metric.
    fn metric_precision(&self) -> &P::String;
    /// Monotonicity property of this metric (e.g., non-decreasing).
    fn metric_monotonicity(&self) -> &P::String;
    /// The decomposition rule for this metric into sub-metrics.
    fn metric_decomposition(&self) -> &P::String;
    /// The position of this metric in the metric tower.
    fn metric_tower_position(&self) -> P::NonNegativeInteger;
    /// The computational cost of evaluating this metric.
    fn metric_computation_cost(&self) -> &P::String;
    /// Upper or lower bound on the metric value.
    fn metric_bound(&self) -> &P::String;
}

/// The saturation metric σ = pinned fibers / total fibers. Ranges from 0 (no fibers pinned) to 1 (fully saturated).
pub trait SaturationObservable<P: Primitives>: Observable<P> {
    /// The count of pinned fibers (numerator of σ).
    fn saturation_numerator(&self) -> P::NonNegativeInteger;
    /// The total fiber count (denominator of σ).
    fn saturation_denominator(&self) -> P::PositiveInteger;
}

/// The Euler characteristic χ = Σ(−1)^k β_k of the constraint nerve. An integer-valued topological invariant.
pub trait EulerCharacteristicObservable<P: Primitives>: Observable<P> {
    /// The alternating sum formula for Euler characteristic.
    fn alternating_sum(&self) -> &P::String;
}

/// Information-theoretic unit: the measurement is in bits (e.g., Hamming weight, entropy).
pub mod bits {}

/// Ring-arithmetic unit: the measurement is in ring distance steps (|x - y| mod 2^n).
pub mod ring_steps {}

/// Dimensionless unit: the measurement is a pure number (e.g., winding number, Betti number, spectral gap).
pub mod dimensionless {}

/// Natural information unit: entropy measured in nats (using natural logarithm). S_residual is expressed in nats when computed as (Σ κ_k − χ) × ln 2.
pub mod nats {}

/// A phase boundary where g divides 2^n − 1, meaning g is a period of the multiplicative structure of R_n.
pub mod period_boundary {}

/// A phase boundary where g = 2^k, meaning g aligns with the binary stratification of R_n.
pub mod power_of_two_boundary {}

/// The signature has been empirically verified as achievable at some quantum level by an EmpiricalVerification record.
pub mod achievable {}

/// The signature has been formally proven impossible by an ImpossibilityWitness deriving from MS_1, MS_2, or other impossibility theorems.
pub mod forbidden {}

/// d_Δ: the incompatibility metric |d_R − d_H| per fiber pair.
pub mod d_delta_metric {
    /// `metricDomain`
    pub const METRIC_DOMAIN: &str = "pair of ring elements";
    /// `metricRange`
    pub const METRIC_RANGE: &str = "non-negative integer";
    /// `referencesClass`
    pub const REFERENCES_CLASS: &str = "IncompatibilityMetric";
}

/// σ: the saturation metric, pinned fibers / total fibers.
pub mod sigma_metric {
    /// `metricDomain`
    pub const METRIC_DOMAIN: &str = "computation state";
    /// `metricRange`
    pub const METRIC_RANGE: &str = "decimal in [0, 1]";
    /// `referencesIdentity`
    pub const REFERENCES_IDENTITY: &str = "SC_2";
}

/// J_k: per-fiber curvature, ∂_R f_k.
pub mod jacobian_metric {
    /// `metricDomain`
    pub const METRIC_DOMAIN: &str = "computation state × fiber index";
    /// `metricRange`
    pub const METRIC_RANGE: &str = "decimal";
    /// `referencesClass`
    pub const REFERENCES_CLASS: &str = "Jacobian";
    /// `referencesIdentity`
    pub const REFERENCES_IDENTITY: &str = "DC_6";
}

/// β_k: per-dimension Betti number of the constraint nerve.
pub mod betti_metric {
    /// `metricDomain`
    pub const METRIC_DOMAIN: &str = "simplicial complex × dimension";
    /// `metricRange`
    pub const METRIC_RANGE: &str = "non-negative integer";
    /// `referencesClass`
    pub const REFERENCES_CLASS: &str = "BettiNumber";
}

/// χ: Euler characteristic, Σ(−1)^k β_k.
pub mod euler_metric {
    /// `metricDomain`
    pub const METRIC_DOMAIN: &str = "simplicial complex";
    /// `metricRange`
    pub const METRIC_RANGE: &str = "integer";
    /// `referencesIdentity`
    pub const REFERENCES_IDENTITY: &str = "IT_2";
}

/// r: count of free (unpinned) fibers, the residual entropy.
pub mod residual_metric {
    /// `metricDomain`
    pub const METRIC_DOMAIN: &str = "computation state";
    /// `metricRange`
    pub const METRIC_RANGE: &str = "non-negative integer";
    /// `referencesClass`
    pub const REFERENCES_CLASS: &str = "ResidualEntropy";
}