Encode a string to ℕ Making sure the encoding is injective.
Equations
- Units.Dimension.PrimeScale.string_to_nat s = List.foldl (fun (h : ℕ) (c : Char) => h * (UInt32.size + 1) + (c.toNat + 1)) 0 s.toList
Instances For
@[irreducible]
Helper function to get the digits of a natural number in base 2^32.
Equations
- Units.Dimension.PrimeScale.digits n = if n = 0 then [] else Units.Dimension.PrimeScale.digits (n / (UInt32.size + 1)) ++ [n % (UInt32.size + 1)]
Instances For
Get the next Nat.Primes after n.
Equations
Instances For
Get the n-th Nat.Primes (0-indexed). For example, nth_prime 0 = 2, nth_prime 1 = 3, nth_prime 2 = 5, etc.
Equations
Instances For
Equations
Instances For
Get the n-th Nat prime number (0-indexed). For example, nth_prime 0 = 2, nth_prime 1 = 3, nth_prime 2 = 5, etc.
Instances For
Get the prime number associated to a string. This allows us to assign a unique prime number to each base dimension represented by a string. We use it to construct the PrimeScale of a dimension.
Equations
Instances For
Compute the prime expnentiation for a given string and rational number. It's used to compute the PrimeScale of a dimension.