Theorems · Definition · number theory
Nat.digits
ℕ → ℕ → List ℕ
digits b n gives the digits, in little-endian order,
of a natural number n in a specified base b.
In any base, we have ofDigits b L = L.foldr (fun x y ↦ x + b * y) 0.
* For any 2 ≤ b, we have l < b for any l ∈ digits b n,
and the last digit is not zero.
This uniquely specifies the behaviour of digits b.
* For b = 1, we define digits 1 n = List.replicate n 1.
* For b = 0, we define digits 0 n = [n], except digits 0 0 = [].
Note this differs from the existing Nat.toDigits in core, which is used for printing numerals.
In particular, Nat.toDigits b 0 = ['0'], while digits b 0 = [].
- Defined in
- Mathlib.Data.Nat.Digits.Defs
- Cited by
- 70 results in Mathlib
- Foundations
- Depth 28 from the axioms · uses propext, Classical.choice, Quot.sound
Around this declaration
Dashed lines are statement dependencies; solid lines are citations in proofs.
Cites3
Mathlib declarations this one mentions in its statement or cites explicitly in its proof. Plumbing is filtered out.
- Nat.digitsAuxproof · cited by 6
- Nat.digitsAux0proof · cited by 0
- Nat.digitsAux1proof · cited by 0
Cited by71
Results whose statement or proof uses this declaration.
- Nat.ofDigits_digitsstatement and proof · cited by 15
- Nat.digits_zerostatement · cited by 15
- Nat.digits_lt_basestatement and proof · cited by 7
- Nat.digitsAppendproof · cited by 6
- Nat.length_digitsstatement and proof · cited by 5
- Nat.digits_ne_nil_iff_ne_zerostatement · cited by 5
- Nat.digits_add_two_add_onestatement · cited by 4
- Nat.getLast_digit_ne_zerostatement and proof · cited by 4
- Nat.setInvOn_digitsAppend_ofDigitsproof · cited by 3
- Nat.digits_def'statement and proof · cited by 3
- Nat.modEq_digits_sumstatement and proof · cited by 2
- Nat.lt_of_mem_digitsAppendproof · cited by 2