Digits of a natural number #
This provides lemma about the digits of natural numbers.
Properties #
This section contains various lemmas of properties relating to digits and ofDigits.
Binary #
Modular Arithmetic #
Bijection #
The list of digits of n in base b with some 0's appended so that its length is equal to l
if it is < l. This is an inverse function of Nat.ofDigits for n < b ^ l,
see Nat.setInvOn_digitsAppend_ofDigits.
If n ≥ b ^ l, then the list of digits of n in base b is of length at least l and
this function just return b.digits n.
Equations
- b.digitsAppend l n = b.digits n ++ List.replicate (l - (b.digits n).length) 0
Instances For
The map L ↦ Nat.ofDigits b L is bijection between the set of lists of natural integers of
length l with coefficients < b to the set of natural integers < b ^ l.
The map n ↦ Nat.digitsAppend b L is bijection between the set of natural integers < b ^ l
to the set of lists of natural integers of length l with coefficients < b to .
The bijection Nat.bijOn_ofDigits stated as a bijection between Finset.
This spelling can be helpful for some proofs.
The bijection Nat.bijOn_digitsAppend stated as a bijection between Finset.
This spelling can be helpful for some proofs.
The Finset of lists whose head is a fixed integer d and tail is a list
in List.fixedLengthDigits b l.
Equations
- List.consFixedLengthDigits hb l d = Finset.image (fun (L : List ℕ) => d :: L) (List.fixedLengthDigits hb l)
Instances For
If L is a list in List.fixedLengthDigits b l and d is an integer < b, then
d :: L is a list in List.fixedLengthDigits b (l + 1).
The set List.fixedLengthDigits b (l + 1) is the disjoint union of the sets
List.consFixedLengthDigits b l d where d ranges through the natural integers < d.