Skip to main content

Symbol

Enum Symbol 

Source
#[repr(u8)]
pub enum Symbol {
Show 67 variants One = 49, Two = 50, Three = 51, Four = 52, Five = 53, Six = 54, Seven = 55, Eight = 56, Nine = 57, Pi = 112, E = 101, Phi = 102, Gamma = 103, Plastic = 80, Apery = 122, Catalan = 71, X = 120, UserConstant0 = 128, UserConstant1 = 129, UserConstant2 = 130, UserConstant3 = 131, UserConstant4 = 132, UserConstant5 = 133, UserConstant6 = 134, UserConstant7 = 135, UserConstant8 = 136, UserConstant9 = 137, UserConstant10 = 138, UserConstant11 = 139, UserConstant12 = 140, UserConstant13 = 141, UserConstant14 = 142, UserConstant15 = 143, UserFunction0 = 144, UserFunction1 = 145, UserFunction2 = 146, UserFunction3 = 147, UserFunction4 = 148, UserFunction5 = 149, UserFunction6 = 150, UserFunction7 = 151, UserFunction8 = 152, UserFunction9 = 153, UserFunction10 = 154, UserFunction11 = 155, UserFunction12 = 156, UserFunction13 = 157, UserFunction14 = 158, UserFunction15 = 159, Neg = 110, Recip = 114, Sqrt = 113, Square = 115, Ln = 108, Exp = 69, SinPi = 83, CosPi = 67, TanPi = 84, LambertW = 87, Add = 43, Sub = 45, Mul = 42, Div = 47, Pow = 94, Root = 118, Log = 76, Atan2 = 65,
}
Expand description

A symbol in a RIES expression

Variants§

§

One = 49

§

Two = 50

§

Three = 51

§

Four = 52

§

Five = 53

§

Six = 54

§

Seven = 55

§

Eight = 56

§

Nine = 57

§

Pi = 112

§

E = 101

§

Phi = 102

§

Gamma = 103

Euler-Mascheroni constant γ ≈ 0.5772156649

§

Plastic = 80

Plastic constant ρ ≈ 1.3247179572

§

Apery = 122

Apéry’s constant ζ(3) ≈ 1.2020569032

§

Catalan = 71

Catalan’s constant G ≈ 0.9159655942

§

X = 120

§

UserConstant0 = 128

§

UserConstant1 = 129

§

UserConstant2 = 130

§

UserConstant3 = 131

§

UserConstant4 = 132

§

UserConstant5 = 133

§

UserConstant6 = 134

§

UserConstant7 = 135

§

UserConstant8 = 136

§

UserConstant9 = 137

§

UserConstant10 = 138

§

UserConstant11 = 139

§

UserConstant12 = 140

§

UserConstant13 = 141

§

UserConstant14 = 142

§

UserConstant15 = 143

§

UserFunction0 = 144

§

UserFunction1 = 145

§

UserFunction2 = 146

§

UserFunction3 = 147

§

UserFunction4 = 148

§

UserFunction5 = 149

§

UserFunction6 = 150

§

UserFunction7 = 151

§

UserFunction8 = 152

§

UserFunction9 = 153

§

UserFunction10 = 154

§

UserFunction11 = 155

§

UserFunction12 = 156

§

UserFunction13 = 157

§

UserFunction14 = 158

§

UserFunction15 = 159

§

Neg = 110

§

Recip = 114

§

Sqrt = 113

§

Square = 115

§

Ln = 108

§

Exp = 69

§

SinPi = 83

§

CosPi = 67

§

TanPi = 84

§

LambertW = 87

§

Add = 43

§

Sub = 45

§

Mul = 42

§

Div = 47

§

Pow = 94

§

Root = 118

§

Log = 76

§

Atan2 = 65

Implementations§

Source§

impl Symbol

Source

pub const fn seft(self) -> Seft

Get the stack effect type of this symbol

Source

pub fn weight(self) -> u32

Get the default complexity weight of this symbol

Complexity weights determine how “simple” an expression is, affecting which equations RIES presents first. Lower complexity = simpler expression.

§Calibration Methodology

Weights are calibrated to match original RIES behavior while ensuring intuitive simplicity ordering:

§Constants
  • Small integers (1-9): Range from 3-6, with smaller digits cheaper

    • Rationale: Single digits are fundamental building blocks
    • 1 and 2 are cheapest (3) as they appear in most simple equations
    • Larger digits cost more as they’re less “fundamental”
  • Transcendental constants (π, e): Weight 8

    • Higher than integers as they require special notation
    • Same weight as they’re equally “fundamental” in mathematics
  • Algebraic constants (φ, ρ): Weight 10

    • Higher than π/e as they’re less commonly used
    • Plastic constant (ρ) is algebraic (root of x³ = x + 1)
  • Special constants (γ, ζ(3), G): Weight 10-12

    • Euler-Mascheroni γ and Catalan’s G: 10
    • Apéry’s constant ζ(3): 12 (higher due to obscurity)
§Unary Operators
  • Negation (-): Weight 4 - simplest unary operation
  • Reciprocal (1/x): Weight 5 - slightly more complex
  • Square (x²): Weight 5 - very common, moderate cost
  • Square root (√): Weight 6 - inverse of square
  • Logarithm (ln): Weight 8 - transcendental operation
  • Exponential (e^x): Weight 8 - inverse of ln, transcendental
  • Trigonometric (sin(πx), cos(πx)): Weight 9-10 - periodic complexity
  • Lambert W: Weight 12 - most complex, rarely used
§Binary Operators
  • Addition/Subtraction (+, -): Weight 3 - simplest operations
  • Multiplication (*): Weight 3 - fundamental arithmetic
  • Division (/): Weight 4 - slightly more complex than multiply
  • Power (^): Weight 5 - exponentiation
  • Root (ᵃ√b): Weight 6 - inverse of power, more notation
  • Logarithm base (log_a b): Weight 7 - two transcendental ops
  • Atan2: Weight 7 - two-argument inverse trig
§Example Weight Calculations
Expression    Postfix    Weight Calculation          Total
x = 2         x2=        6(x) + 3(2)                 9
x² = 4        xs4=       6(x) + 5(s) + 4(4)          15
2x = 5        2x*5=      3(2) + 6(x) + 3(*) + 5(5)   17
e^x = π       xEep       6(x) + 8(E) + 8(p)          22
x^x = π²      xx^ps      6+6+5+8+5                   30
§Design Philosophy

The weight system follows these principles:

  1. Pedagogical value: Simpler concepts have lower weights
  2. Historical consistency: Weights approximate original RIES behavior
  3. Practical usage: Commonly-used operations are cheaper
  4. Composability: Complex expressions = sum of symbol weights
§See Also

For a detailed explanation of the calibration process and rationale, see docs/COMPLEXITY.md in the source repository.

Source

pub const fn default_weight(self) -> u32

Get the default complexity weight (without overrides)

This is used by SymbolTable to build per-run weight configurations.

Source

pub fn legacy_parity_weight(self) -> i32

Legacy (original RIES) per-symbol weight delta used for parity ranking.

Original RIES uses a base symbol cost plus a signed per-symbol delta where many binary operators have negative deltas. This function exposes the signed delta component for output-ranking parity mode.

Source

pub fn result_type(self, arg_types: &[NumType]) -> NumType

Get the result type when this operation is applied

Source

pub const fn inherent_type(self) -> NumType

Get the inherent numeric type of this symbol (for constants) Returns Transcendental for operators (since they can produce any type)

Source

pub const fn name(self) -> &'static str

Get the infix name for display

Source

pub fn display_name(self) -> String

Get the display name for this symbol.

Note: For per-run name overrides, use SymbolTable::name() instead.

Source

pub fn from_byte(b: u8) -> Option<Self>

Parse a symbol from its byte representation

Source

pub fn user_constant_index(self) -> Option<u8>

Get user constant index (0-15) if this is a user constant symbol

Source

pub fn user_function_index(self) -> Option<u8>

Get user function index (0-15) if this is a user function symbol

Source

pub fn constants() -> &'static [Symbol]

Get all constant symbols (Seft::A)

Source

pub fn unary_ops() -> &'static [Symbol]

Get all unary operators (Seft::B)

Source

pub fn binary_ops() -> &'static [Symbol]

Get all binary operators (Seft::C)

Trait Implementations§

Source§

impl Clone for Symbol

Source§

fn clone(&self) -> Symbol

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Symbol

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Symbol

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Symbol> for u8

Source§

fn from(s: Symbol) -> u8

Converts to this type from the input type.
Source§

impl Hash for Symbol

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Symbol

Source§

fn cmp(&self, other: &Symbol) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Symbol

Source§

fn eq(&self, other: &Symbol) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Symbol

Source§

fn partial_cmp(&self, other: &Symbol) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Symbol

Source§

impl Eq for Symbol

Source§

impl StructuralPartialEq for Symbol

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.