#[repr(u8)]pub enum PrimitiveOp {
Show 18 variants
Neg = 0,
Bnot = 1,
Succ = 2,
Pred = 3,
Add = 4,
Sub = 5,
Mul = 6,
Xor = 7,
And = 8,
Or = 9,
Le = 10,
Lt = 11,
Ge = 12,
Gt = 13,
Concat = 14,
Div = 15,
Mod = 16,
Pow = 17,
}Expand description
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).
Variants§
Neg = 0
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).
Bnot = 1
Hypercube reflection: bnot(x) = (2^n - 1) ⊕ x (bitwise complement). The second generator of D_{2^n}. bnot(bnot(x)) = x.
Succ = 2
Successor: succ(x) = neg(bnot(x)) = (x + 1) mod 2^n. The critical identity: succ is the composition neg ∘ bnot.
Pred = 3
Predecessor: pred(x) = bnot(neg(x)) = (x - 1) mod 2^n. The inverse of succ. pred is the composition bnot ∘ neg.
Add = 4
Ring addition: add(x, y) = (x + y) mod 2^n. Commutative, associative; identity element is 0.
Sub = 5
Ring subtraction: sub(x, y) = (x - y) mod 2^n. Not commutative, not associative.
Mul = 6
Ring multiplication: mul(x, y) = (x × y) mod 2^n. Commutative, associative; identity element is 1.
Xor = 7
Bitwise exclusive or: xor(x, y) = x ⊕ y. Commutative, associative; identity element is 0.
And = 8
Bitwise and: and(x, y) = x ∧ y. Commutative, associative.
Or = 9
Bitwise or: or(x, y) = x ∨ y. Commutative, associative.
Le = 10
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.
Lt = 11
Byte-level less-than: lt(x, y) = 1 if x < y else 0. Operands compared as big-endian unsigned byte sequences.
Ge = 12
Byte-level greater-than-or-equal: ge(x, y) = 1 if x ≥ y else 0. Operands compared as big-endian unsigned byte sequences.
Gt = 13
Byte-level greater-than: gt(x, y) = 1 if x > y else 0. Operands compared as big-endian unsigned byte sequences.
Concat = 14
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.
Div = 15
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.
Mod = 16
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.
Pow = 17
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.
Implementations§
Source§impl PrimitiveOp
impl PrimitiveOp
Sourcepub const fn arity(self) -> i64
pub const fn arity(self) -> i64
Returns the arity of this operation (1 for unary, 2 for binary).
Sourcepub const fn is_commutative(self) -> bool
pub const fn is_commutative(self) -> bool
Returns whether this operation is commutative.
Sourcepub const fn is_involution(self) -> bool
pub const fn is_involution(self) -> bool
Returns whether this operation is an involution (self-inverse).
Sourcepub const fn has_geometric_character(self) -> GeometricCharacter
pub const fn has_geometric_character(self) -> GeometricCharacter
Returns the geometric character of this operation.
Trait Implementations§
Source§impl Clone for PrimitiveOp
impl Clone for PrimitiveOp
Source§fn clone(&self) -> PrimitiveOp
fn clone(&self) -> PrimitiveOp
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PrimitiveOp
impl Debug for PrimitiveOp
Source§impl Default for PrimitiveOp
impl Default for PrimitiveOp
Source§fn default() -> PrimitiveOp
fn default() -> PrimitiveOp
Source§impl Display for PrimitiveOp
impl Display for PrimitiveOp
Source§impl Hash for PrimitiveOp
impl Hash for PrimitiveOp
Source§impl Ord for PrimitiveOp
impl Ord for PrimitiveOp
Source§fn cmp(&self, other: &PrimitiveOp) -> Ordering
fn cmp(&self, other: &PrimitiveOp) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PrimitiveOp
impl PartialEq for PrimitiveOp
Source§fn eq(&self, other: &PrimitiveOp) -> bool
fn eq(&self, other: &PrimitiveOp) -> bool
self and other values to be equal, and is used by ==.