uor_foundation/enums.rs
1// @generated by uor-crate from uor-ontology — do not edit manually
2
3//! Shared enumerations derived from the UOR Foundation ontology.
4
5use core::fmt;
6
7/// Kernel/user/bridge classification for each namespace module.
8#[repr(u8)]
9#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
10pub enum Space {
11 /// Immutable kernel-space: compiled into ROM.
12 #[default]
13 Kernel,
14 /// Parameterizable user-space: runtime declarations.
15 User,
16 /// Bridge: kernel-computed, user-consumed.
17 Bridge,
18}
19
20impl fmt::Display for Space {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 match self {
23 Self::Kernel => f.write_str("kernel"),
24 Self::User => f.write_str("user"),
25 Self::Bridge => f.write_str("bridge"),
26 }
27 }
28}
29
30/// The 18 primitive operations defined in the UOR Foundation. 10 original (Neg/Bnot/Succ/Pred/Add/Sub/Mul/Xor/And/Or), 5 ADR-013/TR-08 substrate amendments (Le/Lt/Ge/Gt/Concat), 3 ADR-053 ring-axis completion (Div/Mod/Pow).
31#[repr(u8)]
32#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
33pub enum PrimitiveOp {
34 /// Ring reflection: neg(x) = (-x) mod 2^n. One of the two generators of the dihedral group D_{2^n}. neg(neg(x)) = x (involution property).
35 #[default]
36 Neg,
37 /// Hypercube reflection: bnot(x) = (2^n - 1) ⊕ x (bitwise complement). The second generator of D_{2^n}. bnot(bnot(x)) = x.
38 Bnot,
39 /// Successor: succ(x) = neg(bnot(x)) = (x + 1) mod 2^n. The critical identity: succ is the composition neg ∘ bnot.
40 Succ,
41 /// Predecessor: pred(x) = bnot(neg(x)) = (x - 1) mod 2^n. The inverse of succ. pred is the composition bnot ∘ neg.
42 Pred,
43 /// Ring addition: add(x, y) = (x + y) mod 2^n. Commutative, associative; identity element is 0.
44 Add,
45 /// Ring subtraction: sub(x, y) = (x - y) mod 2^n. Not commutative, not associative.
46 Sub,
47 /// Ring multiplication: mul(x, y) = (x × y) mod 2^n. Commutative, associative; identity element is 1.
48 Mul,
49 /// Bitwise exclusive or: xor(x, y) = x ⊕ y. Commutative, associative; identity element is 0.
50 Xor,
51 /// Bitwise and: and(x, y) = x ∧ y. Commutative, associative.
52 And,
53 /// Bitwise or: or(x, y) = x ∨ y. Commutative, associative.
54 Or,
55 /// Byte-level less-than-or-equal: le(x, y) = 1 if x ≤ y else 0. Operands compared as big-endian unsigned byte sequences. The catamorphism fold-rule emits Literal(1) on true, Literal(0) on false.
56 Le,
57 /// Byte-level less-than: lt(x, y) = 1 if x < y else 0. Operands compared as big-endian unsigned byte sequences.
58 Lt,
59 /// Byte-level greater-than-or-equal: ge(x, y) = 1 if x ≥ y else 0. Operands compared as big-endian unsigned byte sequences.
60 Ge,
61 /// Byte-level greater-than: gt(x, y) = 1 if x > y else 0. Operands compared as big-endian unsigned byte sequences.
62 Gt,
63 /// Byte-sequence concatenation: concat(x, y) = x ⧺ y. The substrate's byte-packing primitive — admits header serialization and other byte-array construction patterns. Result length is len(x) + len(y), bounded by the foundation's TERM_VALUE_MAX_BYTES ceiling.
64 Concat,
65 /// Euclidean quotient: div(a, b) = q where a = q·b + r, 0 ⇐ r < b. Total on the ring for b > 0; b = 0 emits a ShapeViolation. Operands read as unsigned big-endian integers at the operand width.
66 Div,
67 /// Euclidean remainder: mod(a, b) = r where a = q·b + r, 0 ⇐ r < b. Total on the ring for b > 0; b = 0 emits a ShapeViolation. Operands read as unsigned big-endian integers at the operand width.
68 Mod,
69 /// Modular exponentiation: pow(base, exp) = base^exp mod 2^n. Fold-rule: square-and-multiply over exp bits. pow(_, 0) = 1; pow(0, b > 0) = 0.
70 Pow,
71}
72
73impl fmt::Display for PrimitiveOp {
74 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
75 match self {
76 Self::Neg => f.write_str("neg"),
77 Self::Bnot => f.write_str("bnot"),
78 Self::Succ => f.write_str("succ"),
79 Self::Pred => f.write_str("pred"),
80 Self::Add => f.write_str("add"),
81 Self::Sub => f.write_str("sub"),
82 Self::Mul => f.write_str("mul"),
83 Self::Xor => f.write_str("xor"),
84 Self::And => f.write_str("and"),
85 Self::Or => f.write_str("or"),
86 Self::Le => f.write_str("le"),
87 Self::Lt => f.write_str("lt"),
88 Self::Ge => f.write_str("ge"),
89 Self::Gt => f.write_str("gt"),
90 Self::Concat => f.write_str("concat"),
91 Self::Div => f.write_str("div"),
92 Self::Mod => f.write_str("mod_"),
93 Self::Pow => f.write_str("pow"),
94 }
95 }
96}
97
98/// The three metric axes in the UOR tri-metric classification.
99#[repr(u8)]
100#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
101pub enum MetricAxis {
102 /// The vertical (ring/additive) metric axis. Constraints on this axis operate through ring arithmetic: residue classes, divisibility, and additive structure.
103 #[default]
104 Vertical,
105 /// The horizontal (Hamming/bitwise) metric axis. Constraints on this axis operate through bitwise structure: carry patterns, bit positions, and Hamming distance.
106 Horizontal,
107 /// The diagonal (incompatibility) metric axis. Constraints on this axis measure the gap between ring and Hamming metrics — the curvature of UOR geometry.
108 Diagonal,
109}
110
111impl fmt::Display for MetricAxis {
112 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
113 match self {
114 Self::Vertical => f.write_str("vertical"),
115 Self::Horizontal => f.write_str("horizontal"),
116 Self::Diagonal => f.write_str("diagonal"),
117 }
118 }
119}
120
121/// The state of a site: pinned or free.
122#[repr(u8)]
123#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
124pub enum SiteState {
125 /// Site is determined by a constraint.
126 #[default]
127 Pinned,
128 /// Site is still available for refinement.
129 Free,
130}
131
132impl fmt::Display for SiteState {
133 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
134 match self {
135 Self::Pinned => f.write_str("pinned"),
136 Self::Free => f.write_str("free"),
137 }
138 }
139}
140
141/// The geometric role of a ring operation in the UOR dual-geometry (ring + hypercube). Every op:Operation individual references exactly one GeometricCharacter via op:hasGeometricCharacter. The nine canonical individuals correspond to the action types of the dihedral group D_{2^n}.
142#[repr(u8)]
143#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
144pub enum GeometricCharacter {
145 /// Reflection through the origin of the additive ring: neg(x) = -x mod 2^n. One of the two generators of D_{2^n}.
146 #[default]
147 RingReflection,
148 /// Reflection through the centre of the hypercube: bnot(x) = (2^n-1) ⊕ x. The second generator of D_{2^n}.
149 HypercubeReflection,
150 /// Rotation by one step: succ(x) = (x+1) mod 2^n. The composition of the two reflections.
151 Rotation,
152 /// Rotation by one step in the reverse direction: pred(x) = (x-1) mod 2^n.
153 RotationInverse,
154 /// Translation along the ring axis: add(x,y), sub(x,y). Preserves Hamming distance locally.
155 Translation,
156 /// Scaling along the ring axis: mul(x,y) = (x×y) mod 2^n.
157 Scaling,
158 /// Translation along the hypercube axis: xor(x,y) = x ⊕ y. Preserves ring distance locally.
159 HypercubeTranslation,
160 /// Projection onto a hypercube face: and(x,y) = x ∧ y. Idempotent; collapses dimensions.
161 HypercubeProjection,
162 /// Join on the hypercube lattice: or(x,y) = x ∨ y. Idempotent; dual to projection.
163 HypercubeJoin,
164 /// Euclidean quotient along the ring axis: div(a,b) — the structural dual of Scaling. Geometric character of `op:div` per ADR-053.
165 Quotient,
166 /// Euclidean remainder along the ring axis: mod(a,b). Complement of Quotient — together they realize the divmod fold-rule. Geometric character of `op:mod` per ADR-053.
167 Remainder,
168 /// Iterated multiplicative scaling along the ring axis: pow(base, exp) = base^exp mod 2^n. Extends the multiplicative Scaling axis via square-and-multiply iteration. Geometric character of `op:pow` per ADR-053.
169 IteratedScaling,
170 /// Geometric character of dispatch: constraint-guided selection over the resolver registry lattice.
171 ConstraintSelection,
172 /// Geometric character of inference: traversal through the φ-pipeline resolution graph P ∘ Π ∘ G.
173 ResolutionTraversal,
174 /// Geometric character of accumulation: progressive pinning of site states in the context lattice.
175 SiteBinding,
176 /// Geometric character of lease partition: splitting a shared context into disjoint site-set leases.
177 SitePartition,
178 /// Geometric character of session composition: merging disjoint lease sessions into a unified resolution context.
179 SessionMerge,
180}
181
182impl fmt::Display for GeometricCharacter {
183 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
184 match self {
185 Self::RingReflection => f.write_str("ring_reflection"),
186 Self::HypercubeReflection => f.write_str("hypercube_reflection"),
187 Self::Rotation => f.write_str("rotation"),
188 Self::RotationInverse => f.write_str("rotation_inverse"),
189 Self::Translation => f.write_str("translation"),
190 Self::Scaling => f.write_str("scaling"),
191 Self::HypercubeTranslation => f.write_str("hypercube_translation"),
192 Self::HypercubeProjection => f.write_str("hypercube_projection"),
193 Self::HypercubeJoin => f.write_str("hypercube_join"),
194 Self::Quotient => f.write_str("quotient"),
195 Self::Remainder => f.write_str("remainder"),
196 Self::IteratedScaling => f.write_str("iterated_scaling"),
197 Self::ConstraintSelection => f.write_str("constraint_selection"),
198 Self::ResolutionTraversal => f.write_str("resolution_traversal"),
199 Self::SiteBinding => f.write_str("site_binding"),
200 Self::SitePartition => f.write_str("site_partition"),
201 Self::SessionMerge => f.write_str("session_merge"),
202 }
203 }
204}
205
206/// A named mathematical discipline through which an algebraic identity is established and grounded. Every op:Identity individual references at least one VerificationDomain via op:verificationDomain. The nine canonical domain individuals are kernel-level constants defined in op/.
207#[repr(u8)]
208#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
209pub enum VerificationDomain {
210 /// Established by exhaustive traversal of R_n. Valid for all identities where the ring is finite.
211 #[default]
212 Enumerative,
213 /// Established by equational reasoning from ring or group axioms. Covers derivations via associativity, commutativity, inverse laws, and group presentations.
214 Algebraic,
215 /// Established by isometry, symmetry, or GeometricCharacter arguments. Covers dihedral actions, fixed-point analysis, automorphism groups, and affine embeddings.
216 Geometric,
217 /// Established via discrete differential calculus or metric analysis. Covers ring/Hamming derivatives (DC_), metric divergence (AM_), and adiabatic scheduling (AR_).
218 Analytical,
219 /// Established via entropy, Landauer bounds, or Boltzmann distributions. Covers site entropy (TH_), reversible computation (RC_), and phase transitions.
220 Thermodynamic,
221 /// Established via simplicial homology, cohomology, or constraint nerve analysis. Covers homological algebra (HA_) and the ψ-pipeline base chain ψ_1..ψ_6 (constraint nerve construction, chain functor, homology, Betti extraction, dualization, cohomology).
222 Topological,
223 /// Established by the inter-algebra map structure of the resolution pipeline. Covers φ-maps (phi_1–phi_6) and the ψ-pipeline tower ψ_7..ψ_9 (Postnikov truncation, homotopy group extraction, k-invariant computation). The earlier ψ_1..ψ_6 chain (constraint nerve → simplicial homology) is established under op:Topological.
224 Pipeline,
225 /// Established by the composition of Analytical and Topological reasoning. The only domain requiring multiple op:verificationDomain assertions. Covers the UOR Index Theorem (IT_7a–IT_7d).
226 IndexTheoretic,
227 /// Established by superposition analysis of site states. Covers identities involving superposed (non-classical) site assignments where sites carry complex amplitudes.
228 SuperpositionDomain,
229 /// Established by the intersection of quantum superposition analysis and classical thermodynamic reasoning. Covers identities relating von Neumann entropy of superposed states to Landauer costs of projective collapse (QM_).
230 QuantumThermodynamic,
231 /// Established by number-theoretic valuation arguments including p-adic absolute values, the Ostrowski product formula, and the arithmetic of global fields. Covers identities grounded in the product formula |x|_p · |x|_∞ = 1 and the Witt–Ostrowski derivation chain.
232 ArithmeticValuation,
233 /// Verification domain for composed operation identities — algebraic properties of operator compositions including dispatch, inference, accumulation, lease, and session composition operations.
234 ComposedAlgebraic,
235}
236
237impl fmt::Display for VerificationDomain {
238 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
239 match self {
240 Self::Enumerative => f.write_str("enumerative"),
241 Self::Algebraic => f.write_str("algebraic"),
242 Self::Geometric => f.write_str("geometric"),
243 Self::Analytical => f.write_str("analytical"),
244 Self::Thermodynamic => f.write_str("thermodynamic"),
245 Self::Topological => f.write_str("topological"),
246 Self::Pipeline => f.write_str("pipeline"),
247 Self::IndexTheoretic => f.write_str("index_theoretic"),
248 Self::SuperpositionDomain => f.write_str("superposition_domain"),
249 Self::QuantumThermodynamic => f.write_str("quantum_thermodynamic"),
250 Self::ArithmeticValuation => f.write_str("arithmetic_valuation"),
251 Self::ComposedAlgebraic => f.write_str("composed_algebraic"),
252 }
253 }
254}
255
256/// A computational complexity classification for resolvers. Each resolver's asymptotic runtime is typed as a named ComplexityClass individual rather than a free string.
257#[repr(u8)]
258#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
259pub enum ComplexityClass {
260 /// O(1) complexity — the resolver runs in constant time regardless of ring size.
261 #[default]
262 Constant,
263 /// O(log n) complexity — the resolver runs in logarithmic time in the quantum level.
264 Logarithmic,
265 /// O(n) complexity — the resolver runs in time linear in the quantum level.
266 Linear,
267 /// O(2^n) complexity — the resolver runs in time exponential in the quantum level.
268 Exponential,
269}
270
271impl fmt::Display for ComplexityClass {
272 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
273 match self {
274 Self::Constant => f.write_str("constant"),
275 Self::Logarithmic => f.write_str("logarithmic"),
276 Self::Linear => f.write_str("linear"),
277 Self::Exponential => f.write_str("exponential"),
278 }
279 }
280}
281
282/// A named rewrite rule that can be applied in a derivation step. Each RewriteRule individual represents a specific algebraic law or normalization strategy used during term rewriting.
283#[repr(u8)]
284#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
285pub enum RewriteRule {
286 /// The rewrite rule applying the critical identity: neg(bnot(x)) → succ(x). Grounded in op:criticalIdentity.
287 #[default]
288 CriticalIdentity,
289 /// The rewrite rule applying involution cancellation: f(f(x)) → x for any involution f.
290 Involution,
291 /// The rewrite rule applying associativity to re-bracket nested binary operations.
292 Associativity,
293 /// The rewrite rule applying commutativity to reorder operands of commutative operations.
294 Commutativity,
295 /// The rewrite rule eliminating identity elements: add(x, 0) → x, mul(x, 1) → x, xor(x, 0) → x.
296 IdentityElement,
297 /// The rewrite rule normalizing compound expressions to canonical ordering (e.g., sorting operands by address).
298 Normalization,
299}
300
301impl fmt::Display for RewriteRule {
302 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
303 match self {
304 Self::CriticalIdentity => f.write_str("critical_identity"),
305 Self::Involution => f.write_str("involution"),
306 Self::Associativity => f.write_str("associativity"),
307 Self::Commutativity => f.write_str("commutativity"),
308 Self::IdentityElement => f.write_str("identity_element"),
309 Self::Normalization => f.write_str("normalization"),
310 }
311 }
312}
313
314/// A unit of measurement for observable quantities. Each MeasurementUnit individual names a specific unit (bits, ring steps, dimensionless) replacing the string-valued observable:unit property.
315#[repr(u8)]
316#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
317pub enum MeasurementUnit {
318 /// Information-theoretic unit: the measurement is in bits (e.g., Hamming weight, entropy).
319 #[default]
320 Bits,
321 /// Ring-arithmetic unit: the measurement is in ring distance steps (|x - y| mod 2^n).
322 RingSteps,
323 /// Dimensionless unit: the measurement is a pure number (e.g., winding number, Betti number, spectral gap).
324 Dimensionless,
325 /// Natural information unit: entropy measured in nats (using natural logarithm). S_residual is expressed in nats when computed as (Σ κ_k − χ) × ln 2.
326 Nats,
327}
328
329impl fmt::Display for MeasurementUnit {
330 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
331 match self {
332 Self::Bits => f.write_str("bits"),
333 Self::RingSteps => f.write_str("ring_steps"),
334 Self::Dimensionless => f.write_str("dimensionless"),
335 Self::Nats => f.write_str("nats"),
336 }
337 }
338}
339
340/// A classification of coordinate types that a CoordinateQuery can extract. Each TriadProjection individual names a specific coordinate system (stratum, spectrum, address) replacing the string-valued query:coordinate property.
341#[repr(u8)]
342#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
343pub enum TriadProjection {
344 /// The stratum coordinate: the layer position of a datum within the ring's stratification.
345 #[default]
346 TwoAdicValuation,
347 /// The spectrum coordinate: the spectral decomposition of a datum under the ring's Fourier analysis.
348 WalshHadamardImage,
349 /// The address coordinate: the content-addressable position of a datum in the Braille glyph encoding. Renamed from RingElement in v0.2.2 W8 to unify vocabulary with the schema:Triad bundling properties.
350 Address,
351}
352
353impl fmt::Display for TriadProjection {
354 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
355 match self {
356 Self::TwoAdicValuation => f.write_str("two_adic_valuation"),
357 Self::WalshHadamardImage => f.write_str("walsh_hadamard_image"),
358 Self::Address => f.write_str("address"),
359 }
360 }
361}
362
363/// A typed controlled vocabulary for session boundary reasons. Each individual names a specific reason a context-reset boundary was triggered during a multi-turn session.
364#[repr(u8)]
365#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
366pub enum SessionBoundaryType {
367 /// The caller explicitly requested a context reset. All accumulated bindings are discarded.
368 #[default]
369 ExplicitReset,
370 /// The session resolver determined that no further queries can reduce the aggregate site deficit.
371 ConvergenceBoundary,
372 /// A new query produced a type contradiction with an accumulated binding. Context must reset before resolution can continue.
373 ContradictionBoundary,
374}
375
376impl fmt::Display for SessionBoundaryType {
377 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
378 match self {
379 Self::ExplicitReset => f.write_str("explicit_reset"),
380 Self::ConvergenceBoundary => f.write_str("convergence_boundary"),
381 Self::ContradictionBoundary => f.write_str("contradiction_boundary"),
382 }
383 }
384}
385
386/// A classification of phase boundary in the catastrophe diagram: period boundary (g divides 2^n − 1) or power-of-two boundary (g = 2^k).
387#[repr(u8)]
388#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
389pub enum PhaseBoundaryType {
390 /// A phase boundary where g divides 2^n − 1, meaning g is a period of the multiplicative structure of R_n.
391 #[default]
392 Period,
393 /// A phase boundary where g = 2^k, meaning g aligns with the binary stratification of R_n.
394 PowerOfTwo,
395}
396
397impl fmt::Display for PhaseBoundaryType {
398 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
399 match self {
400 Self::Period => f.write_str("period"),
401 Self::PowerOfTwo => f.write_str("power_of_two"),
402 }
403 }
404}
405
406/// A typed controlled vocabulary for the three phases of context saturation: Open (σ = 0), PartialGrounding (0 < σ < 1), and FullGrounding (σ = 1).
407#[repr(u8)]
408#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
409pub enum GroundingPhase {
410 /// The context has σ = 0: no bindings accumulated, all sites are free. The initial phase of every session.
411 #[default]
412 Open,
413 /// The context has 0 < σ < 1: some sites are pinned by accumulated bindings, but free sites remain. The accumulation phase.
414 PartialGrounding,
415 /// The context has σ = 1: all sites are pinned, freeRank = 0. The ground state. All subsequent queries resolve in O(1) via SC_5.
416 FullGrounding,
417}
418
419impl fmt::Display for GroundingPhase {
420 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
421 match self {
422 Self::Open => f.write_str("open"),
423 Self::PartialGrounding => f.write_str("partial_grounding"),
424 Self::FullGrounding => f.write_str("full_grounding"),
425 }
426 }
427}
428
429/// The achievability classification of a topological signature in the morphospace. Either Achievable or Forbidden (witnessed by ImpossibilityWitness).
430#[repr(u8)]
431#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
432pub enum AchievabilityStatus {
433 /// The signature has been verified as achievable at some quantum level by an AxiomaticDerivation proof.
434 #[default]
435 Achievable,
436 /// The signature has been formally proven impossible by an ImpossibilityWitness deriving from MS_1, MS_2, or other impossibility theorems.
437 Forbidden,
438}
439
440impl fmt::Display for AchievabilityStatus {
441 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
442 match self {
443 Self::Achievable => f.write_str("achievable"),
444 Self::Forbidden => f.write_str("forbidden"),
445 }
446 }
447}
448
449/// Root class for validity scope individuals. Instances are the four named scope kinds: Universal, ParametricLower, ParametricRange, and LevelSpecific.
450#[repr(u8)]
451#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
452pub enum ValidityScopeKind {
453 /// Holds for all k in N. No minimum k constraint.
454 #[default]
455 Universal,
456 /// Holds for all k >= k_min, where k_min is given by validKMin.
457 ParametricLower,
458 /// Holds for k_min <= k <= k_max. Both validKMin and validKMax required.
459 ParametricRange,
460 /// Holds only at exactly one level, given by a WittLevelBinding.
461 LevelSpecific,
462}
463
464impl fmt::Display for ValidityScopeKind {
465 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
466 match self {
467 Self::Universal => f.write_str("universal"),
468 Self::ParametricLower => f.write_str("parametric_lower"),
469 Self::ParametricRange => f.write_str("parametric_range"),
470 Self::LevelSpecific => f.write_str("level_specific"),
471 }
472 }
473}
474
475/// A typed controlled vocabulary for ExecutionPolicy individuals. Follows the SessionBoundaryType pattern: a single class with named individuals rather than a subclass hierarchy.
476#[repr(u8)]
477#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
478pub enum ExecutionPolicyKind {
479 /// Process queries in arrival order. The implicit pre-Amendment 48 behavior.
480 #[default]
481 FifoPolicy,
482 /// Process the query with the smallest targetSite.freeRank first. Favors cheapest resolutions, accelerating early grounding gain.
483 MinFreeCountFirst,
484 /// Process the query with the largest targetSite.freeRank first. Favors hardest resolutions, maximizing information gain per step.
485 MaxFreeCountFirst,
486 /// Process queries whose targetSite is disjoint from all other pending queries' site sets first. Minimizes contention when operating against a SharedContext.
487 DisjointFirst,
488}
489
490impl fmt::Display for ExecutionPolicyKind {
491 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
492 match self {
493 Self::FifoPolicy => f.write_str("fifo_policy"),
494 Self::MinFreeCountFirst => f.write_str("min_free_count_first"),
495 Self::MaxFreeCountFirst => f.write_str("max_free_count_first"),
496 Self::DisjointFirst => f.write_str("disjoint_first"),
497 }
498 }
499}
500
501/// The variance of a structural type position under operad composition. One of Covariant, Contravariant, Invariant, or Bivariant.
502#[repr(u8)]
503#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
504pub enum VarianceAnnotation {
505 /// The structural position preserves TypeInclusion: if T₁ ≤ T₂, then F(T₁) ≤ F(T₂).
506 #[default]
507 Covariant,
508 /// The structural position reverses TypeInclusion: if T₁ ≤ T₂, then F(T₂) ≤ F(T₁).
509 Contravariant,
510 /// The structural position requires exact type equality: F(T₁) ≤ F(T₂) only if T₁ = T₂.
511 Invariant,
512 /// The structural position ignores the type parameter: F(T₁) ≤ F(T₂) for all T₁, T₂.
513 Bivariant,
514}
515
516impl fmt::Display for VarianceAnnotation {
517 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
518 match self {
519 Self::Covariant => f.write_str("covariant"),
520 Self::Contravariant => f.write_str("contravariant"),
521 Self::Invariant => f.write_str("invariant"),
522 Self::Bivariant => f.write_str("bivariant"),
523 }
524 }
525}
526
527/// The kind of quantifier: Universal (forall) or Existential (exists). Controlled vocabulary with exactly 2 individuals.
528#[repr(u8)]
529#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
530pub enum QuantifierKind {
531 /// Universal quantification (forall).
532 #[default]
533 Universal,
534 /// Existential quantification (exists).
535 Existential,
536}
537
538impl fmt::Display for QuantifierKind {
539 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
540 match self {
541 Self::Universal => f.write_str("universal"),
542 Self::Existential => f.write_str("existential"),
543 }
544 }
545}
546
547/// A controlled vocabulary of proof methods. Each proof individual carries exactly one strategy from this vocabulary, enabling compilation to verified theorem provers.
548#[repr(u8)]
549#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
550pub enum ProofStrategy {
551 /// Follows from ZMod ring axioms. Lean4 tactic: `by ring`.
552 #[default]
553 RingAxiom,
554 /// Decidable at Q0 by exhaustive evaluation. Lean4: `by native_decide`.
555 DecideQ0,
556 /// Induction on bit width n. Lean4: `by induction n`.
557 BitwiseInduction,
558 /// From dihedral group presentation. Lean4: `by group`.
559 GroupPresentation,
560 /// By simplification with cited lemmas. Lean4: `by simp \[lemmalist\]`.
561 Simplification,
562 /// By Chinese Remainder Theorem. Lean4: `by exact ZMod.chineseRemainder ...`.
563 ChineseRemainder,
564 /// By Euler-Poincare formula applied to the constraint nerve.
565 EulerPoincare,
566 /// By Ostrowski product formula or derived valuation arguments.
567 ProductFormula,
568 /// By composing proofs of sub-identities. Lean4: `by exact ...`.
569 Composition,
570 /// By deriving contradiction for impossibility witnesses. Lean4: `by contradiction`.
571 Contradiction,
572 /// By computation at a specified quantum level. Lean4: `by native_decide`.
573 Computation,
574}
575
576impl fmt::Display for ProofStrategy {
577 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
578 match self {
579 Self::RingAxiom => f.write_str("ring_axiom"),
580 Self::DecideQ0 => f.write_str("decide_q0"),
581 Self::BitwiseInduction => f.write_str("bitwise_induction"),
582 Self::GroupPresentation => f.write_str("group_presentation"),
583 Self::Simplification => f.write_str("simplification"),
584 Self::ChineseRemainder => f.write_str("chinese_remainder"),
585 Self::EulerPoincare => f.write_str("euler_poincare"),
586 Self::ProductFormula => f.write_str("product_formula"),
587 Self::Composition => f.write_str("composition"),
588 Self::Contradiction => f.write_str("contradiction"),
589 Self::Computation => f.write_str("computation"),
590 }
591 }
592}
593
594/// The kind of shape violation: Missing, TypeMismatch, CardinalityViolation, ValueCheck, or LevelMismatch.
595#[repr(u8)]
596#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
597pub enum ViolationKind {
598 /// Required property was not set on the builder.
599 #[default]
600 Missing,
601 /// Property was set but its value is not an instance of the constraintRange.
602 TypeMismatch,
603 /// Cardinality violated: too few or too many values provided.
604 CardinalityViolation,
605 /// Value-dependent check failed (Tier 2). For example, thermodynamic budget insufficient for Landauer bound.
606 ValueCheck,
607 /// A term's quantum level annotation exceeds the CompileUnit ceiling, or binary operation operands are at different levels without an intervening lift or project.
608 LevelMismatch,
609}
610
611impl fmt::Display for ViolationKind {
612 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
613 match self {
614 Self::Missing => f.write_str("missing"),
615 Self::TypeMismatch => f.write_str("type_mismatch"),
616 Self::CardinalityViolation => f.write_str("cardinality_violation"),
617 Self::ValueCheck => f.write_str("value_check"),
618 Self::LevelMismatch => f.write_str("level_mismatch"),
619 }
620 }
621}
622
623/// Closed enumeration of partition component kinds: Irreducible (non-factorizable), Reducible (factorizable into non-trivial parts), Units (invertible), Exterior (outside the factorization domain). Codegen treats this as an enum class with exactly 4 individuals.
624#[repr(u8)]
625#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
626pub enum PartitionComponent {
627 /// The irreducible component: elements that admit no non-trivial factorization within the ring.
628 #[default]
629 Irreducible,
630 /// The reducible component: elements that factor into non-trivial parts.
631 Reducible,
632 /// The unit component: invertible elements of the ring.
633 Units,
634 /// The exterior component: elements outside the factorization domain (e.g., zero or ring-boundary values).
635 Exterior,
636}
637
638impl fmt::Display for PartitionComponent {
639 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
640 match self {
641 Self::Irreducible => f.write_str("irreducible"),
642 Self::Reducible => f.write_str("reducible"),
643 Self::Units => f.write_str("units"),
644 Self::Exterior => f.write_str("exterior"),
645 }
646 }
647}
648
649/// The modality of a proof: computation (exhaustive verification at a specific quantum level) or axiomatic (derivation from ring axioms).
650#[repr(u8)]
651#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
652pub enum ProofModality {
653 /// A proof confirmed by exhaustive execution over R_n at a specific quantum level.
654 #[default]
655 Computation,
656 /// A proof derived from ring axioms that holds at all quantum levels.
657 Axiomatic,
658 /// A proof by structural induction on the quantum level parameter k.
659 Inductive,
660}
661
662impl fmt::Display for ProofModality {
663 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
664 match self {
665 Self::Computation => f.write_str("computation"),
666 Self::Axiomatic => f.write_str("axiomatic"),
667 Self::Inductive => f.write_str("inductive"),
668 }
669 }
670}
671
672/// A Witt level W_n at which the UOR ring R_n = Z/2^n Z operates.
673/// Corresponds to `schema:WittLevel` in the uor.foundation ontology.
674/// The class is open: any positive multiple of 8 identifies a valid level.
675/// Named levels W8 through W32 are provided as associated constants.
676/// Arbitrary levels can be constructed with `WittLevel::new(n)`.
677/// # Examples
678/// ```rust
679/// use uor_foundation::WittLevel;
680///
681/// // Named reference levels (W8-W32 are spec-defined):
682/// let w8 = WittLevel::W8;
683/// assert_eq!(w8.witt_length(), 8);
684/// assert_eq!(w8.bits_width(), 8); // Witt length IS bit width
685/// assert_eq!(w8.cycle_size(), Some(256)); // 2^8 = 256 ring elements
686///
687/// let w32 = WittLevel::W32;
688/// assert_eq!(w32.bits_width(), 32); // 32 bits
689///
690/// // Arbitrary levels beyond W32 (Prism-declared):
691/// let w64 = WittLevel::new(64);
692/// assert_eq!(w64.bits_width(), 64); // 64 bits — native u64
693///
694/// // The chain is unbounded:
695/// let w88 = WittLevel::new(88);
696/// assert_eq!(w88.bits_width(), 88);
697/// assert_eq!(w88.next_witt_level().witt_length(), 96);
698///
699/// // Ordering follows the Witt length:
700/// assert!(WittLevel::W8 < WittLevel::W32);
701/// ```
702#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
703pub struct WittLevel {
704 /// The Witt length n in W_n. Maps to `schema:wittLength`.
705 witt_length: u32,
706}
707
708impl WittLevel {
709 /// Witt level 8: 8-bit ring Z/256Z, 256 states. The reference level for all ComputationCertificate proofs in the spec.
710 pub const W8: Self = Self { witt_length: 8 };
711 /// Witt level 16: 16-bit ring Z/65536Z, 65,536 states.
712 pub const W16: Self = Self { witt_length: 16 };
713 /// Witt level 24: 24-bit ring Z/16777216Z, 16,777,216 states.
714 pub const W24: Self = Self { witt_length: 24 };
715 /// Witt level 32: 32-bit ring Z/4294967296Z, 4,294,967,296 states. The highest named level in the spec.
716 pub const W32: Self = Self { witt_length: 32 };
717
718 /// Construct an arbitrary Witt level W_n. `n` need not be one of the spec-named individuals; Prism implementations may use any level.
719 #[inline]
720 pub const fn new(witt_length: u32) -> Self {
721 Self { witt_length }
722 }
723
724 /// The Witt length n. Maps to `schema:wittLength`.
725 #[inline]
726 pub const fn witt_length(self) -> u32 {
727 self.witt_length
728 }
729
730 /// Bit width of the ring at this level: equal to the Witt length. Maps to `schema:bitsWidth`. This is an identity — the Witt length IS the bit width.
731 #[inline]
732 pub const fn bits_width(self) -> u32 {
733 self.witt_length
734 }
735
736 /// Number of distinct ring states at this level: 2^n. Maps to `schema:cycleSize`. Returns `None` if the result exceeds `u128` (i.e. for n > 128).
737 #[inline]
738 pub const fn cycle_size(self) -> Option<u128> {
739 1u128.checked_shl(self.bits_width())
740 }
741
742 /// The next Witt level in the chain: W_n -> W_{n+8}. Maps to `schema:nextWittLevel`. Always well-defined; the chain is unbounded.
743 #[inline]
744 pub const fn next_witt_level(self) -> Self {
745 Self {
746 witt_length: self.witt_length + 8,
747 }
748 }
749}
750
751impl Default for WittLevel {
752 /// `W8` is the spec-defined minimum Witt level and the canonical base referenced by `schema:WittLevel` individuals.
753 #[inline]
754 fn default() -> Self {
755 Self::W8
756 }
757}
758
759impl fmt::Display for WittLevel {
760 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
761 write!(f, "w{}", self.witt_length)
762 }
763}