File: Mathlib/Data/Nat/Digits.lean

full_name: Nat.digitsAux0
code: /-- (Impl.) An auxiliary definition for `digits`, to help get the desired definitional unfolding. -/
def digitsAux0 : ℕ → List ℕ
  
goal: ℕ → List ℕ

full_name: Nat.digitsAux1
code: /-- (Impl.) An auxiliary definition for `digits`, to help get the desired definitional unfolding. -/
def digitsAux1 (n : ℕ) : List ℕ 
goal: List ℕ

full_name: Nat.digitsAux
code: /-- (Impl.) An auxiliary definition for `digits`, to help get the desired definitional unfolding. -/
def digitsAux (b : ℕ) (h : 2 ≤ b) : ℕ → List ℕ
  
goal: ℕ → List ℕ

full_name: Nat.digitsAux_zero
code: @[simp]
theorem digitsAux_zero (b : ℕ) (h : 2 ≤ b) : digitsAux b h 0 = [] 
goal: b.digitsAux h 0 = []

full_name: Nat.digitsAux_def
code: theorem digitsAux_def (b : ℕ) (h : 2 ≤ b) (n : ℕ) (w : 0 < n) :
    digitsAux b h n = (n % b) :: digitsAux b h (n / b) 
goal: b.digitsAux h n = n % b :: b.digitsAux h (n / b)

full_name: Nat.digits
code: /-- `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 = []`.
-/
def digits : ℕ → ℕ → List ℕ
  
goal: ℕ → ℕ → List ℕ

full_name: Nat.digits_zero
code: @[simp]
theorem digits_zero (b : ℕ) : digits b 0 = [] 
goal: b.digits 0 = []

full_name: Nat.digits_zero_zero
code: theorem digits_zero_zero : digits 0 0 = [] 
goal: Nat.digits 0 0 = []

full_name: Nat.digits_zero_succ
code: @[simp]
theorem digits_zero_succ (n : ℕ) : digits 0 n.succ = [n + 1] 
goal: Nat.digits 0 n.succ = [n + 1]

full_name: Nat.digits_zero_succ'
code: theorem digits_zero_succ' : ∀ {n : ℕ}, n ≠ 0 → digits 0 n = [n]
  
goal: n ≠ 0 → Nat.digits 0 n = [n]

full_name: Nat.digits_one
code: @[simp]
theorem digits_one (n : ℕ) : digits 1 n = List.replicate n 1 
goal: Nat.digits 1 n = List.replicate n 1

full_name: Nat.digits_one_succ
code: theorem digits_one_succ (n : ℕ) : digits 1 (n + 1) = 1 :: digits 1 n 
goal: Nat.digits 1 (n + 1) = 1 :: Nat.digits 1 n

full_name: Nat.digits_add_two_add_one
code: theorem digits_add_two_add_one (b n : ℕ) :
    digits (b + 2) (n + 1) = ((n + 1) % (b + 2)) :: digits (b + 2) ((n + 1) / (b + 2)) 
goal: (b + 2).digits (n + 1) = (n + 1) % (b + 2) :: (b + 2).digits ((n + 1) / (b + 2))

full_name: Nat.digits_of_two_le_of_pos
code: @[simp]
lemma digits_of_two_le_of_pos {b : ℕ} (hb : 2 ≤ b) (hn : 0 < n) :
    Nat.digits b n = n % b :: Nat.digits b (n / b) 
goal: b.digits n = n % b :: b.digits (n / b)

full_name: Nat.digits_def'
code: theorem digits_def' :
    ∀ {b : ℕ} (_ : 1 < b) {n : ℕ} (_ : 0 < n), digits b n = (n % b) :: digits b (n / b)
  
goal: 1 < b → ∀ {n : ℕ}, 0 < n → b.digits n = n % b :: b.digits (n / b)

full_name: Nat.digits_of_lt
code: @[simp]
theorem digits_of_lt (b x : ℕ) (hx : x ≠ 0) (hxb : x < b) : digits b x = [x] 
goal: b.digits x = [x]

full_name: Nat.digits_add
code: theorem digits_add (b : ℕ) (h : 1 < b) (x y : ℕ) (hxb : x < b) (hxy : x ≠ 0 ∨ y ≠ 0) :
    digits b (x + b * y) = x :: digits b y 
goal: b.digits (x + b * y) = x :: b.digits y

full_name: Nat.ofDigits
code: /-- `ofDigits b L` takes a list `L` of natural numbers, and interprets them
as a number in semiring, as the little-endian digits in base `b`.
-/
def ofDigits {α : Type*} [Semiring α] (b : α) : List ℕ → α
  
goal: List ℕ → α

full_name: Nat.ofDigits_eq_foldr
code: theorem ofDigits_eq_foldr {α : Type*} [Semiring α] (b : α) (L : List ℕ) :
    ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L 
goal: Nat.ofDigits b L = List.foldr (fun x y => ↑x + b * y) 0 L

full_name: Nat.ofDigits_eq_sum_map_with_index_aux
code: theorem ofDigits_eq_sum_map_with_index_aux (b : ℕ) (l : List ℕ) :
    ((List.range l.length).zipWith ((fun i a : ℕ => a * b ^ (i + 1))) l).sum =
      b * ((List.range l.length).zipWith (fun i a => a * b ^ i) l).sum 
goal: (List.zipWith (fun i a => a * b ^ (i + 1)) (List.range l.length) l).sum =
  b * (List.zipWith (fun i a => a * b ^ i) (List.range l.length) l).sum

full_name: Nat.ofDigits_eq_sum_mapIdx
code: theorem ofDigits_eq_sum_mapIdx (b : ℕ) (L : List ℕ) :
    ofDigits b L = (L.mapIdx fun i a => a * b ^ i).sum 
goal: Nat.ofDigits b L = (List.mapIdx (fun i a => a * b ^ i) L).sum

full_name: Nat.ofDigits_nil
code: @[simp]
theorem ofDigits_nil {b : ℕ} : ofDigits b [] = 0 
goal: Nat.ofDigits b [] = 0

full_name: Nat.ofDigits_singleton
code: @[simp]
theorem ofDigits_singleton {b n : ℕ} : ofDigits b [n] = n 
goal: Nat.ofDigits b [n] = n

full_name: Nat.ofDigits_one_cons
code: @[simp]
theorem ofDigits_one_cons {α : Type*} [Semiring α] (h : ℕ) (L : List ℕ) :
    ofDigits (1 : α) (h :: L) = h + ofDigits 1 L 
goal: Nat.ofDigits 1 (h :: L) = ↑h + Nat.ofDigits 1 L

full_name: Nat.ofDigits_cons
code: theorem ofDigits_cons {b hd} {tl : List ℕ} :
    ofDigits b (hd :: tl) = hd + b * ofDigits b tl 
goal: Nat.ofDigits b (hd :: tl) = hd + b * Nat.ofDigits b tl

full_name: Nat.ofDigits_append
code: theorem ofDigits_append {b : ℕ} {l1 l2 : List ℕ} :
    ofDigits b (l1 ++ l2) = ofDigits b l1 + b ^ l1.length * ofDigits b l2 
goal: Nat.ofDigits b (l1 ++ l2) = Nat.ofDigits b l1 + b ^ l1.length * Nat.ofDigits b l2

full_name: Nat.coe_ofDigits
code: @[norm_cast]
theorem coe_ofDigits (α : Type*) [Semiring α] (b : ℕ) (L : List ℕ) :
    ((ofDigits b L : ℕ) : α) = ofDigits (b : α) L 
goal: ↑(Nat.ofDigits b L) = Nat.ofDigits (↑b) L

full_name: Nat.coe_int_ofDigits
code: @[norm_cast]
theorem coe_int_ofDigits (b : ℕ) (L : List ℕ) : ((ofDigits b L : ℕ) : ℤ) = ofDigits (b : ℤ) L 
goal: ↑(Nat.ofDigits b L) = Nat.ofDigits (↑b) L

full_name: Nat.digits_zero_of_eq_zero
code: theorem digits_zero_of_eq_zero {b : ℕ} (h : b ≠ 0) :
    ∀ {L : List ℕ} (_ : ofDigits b L = 0), ∀ l ∈ L, l = 0
  
goal: Nat.ofDigits b L = 0 → ∀ l ∈ L, l = 0

full_name: Nat.digits_ofDigits
code: theorem digits_ofDigits (b : ℕ) (h : 1 < b) (L : List ℕ) (w₁ : ∀ l ∈ L, l < b)
    (w₂ : ∀ h : L ≠ [], L.getLast h ≠ 0) : digits b (ofDigits b L) = L 
goal: b.digits (Nat.ofDigits b L) = L

full_name: Nat.ofDigits_digits
code: theorem ofDigits_digits (b n : ℕ) : ofDigits b (digits b n) = n 
goal: Nat.ofDigits b (b.digits n) = n

full_name: Nat.ofDigits_one
code: theorem ofDigits_one (L : List ℕ) : ofDigits 1 L = L.sum 
goal: Nat.ofDigits 1 L = L.sum

full_name: Nat.digits_eq_nil_iff_eq_zero
code: theorem digits_eq_nil_iff_eq_zero {b n : ℕ} : digits b n = [] ↔ n = 0 
goal: b.digits n = [] ↔ n = 0

full_name: Nat.digits_ne_nil_iff_ne_zero
code: theorem digits_ne_nil_iff_ne_zero {b n : ℕ} : digits b n ≠ [] ↔ n ≠ 0 
goal: b.digits n ≠ [] ↔ n ≠ 0

full_name: Nat.digits_eq_cons_digits_div
code: theorem digits_eq_cons_digits_div {b n : ℕ} (h : 1 < b) (w : n ≠ 0) :
    digits b n = (n % b) :: digits b (n / b) 
goal: b.digits n = n % b :: b.digits (n / b)

full_name: Nat.digits_getLast
code: theorem digits_getLast {b : ℕ} (m : ℕ) (h : 1 < b) (p q) :
    (digits b m).getLast p = (digits b (m / b)).getLast q 
goal: (b.digits m).getLast p = (b.digits (m / b)).getLast q

full_name: Nat.digits.injective
code: theorem digits.injective (b : ℕ) : Function.Injective b.digits 
goal: Function.Injective b.digits

full_name: Nat.digits_inj_iff
code: @[simp]
theorem digits_inj_iff {b n m : ℕ} : b.digits n = b.digits m ↔ n = m 
goal: b.digits n = b.digits m ↔ n = m

full_name: Nat.digits_len
code: theorem digits_len (b n : ℕ) (hb : 1 < b) (hn : n ≠ 0) : (b.digits n).length = b.log n + 1 
goal: (b.digits n).length = Nat.log b n + 1

full_name: Nat.getLast_digit_ne_zero
code: theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) :
    (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 
goal: (b.digits m).getLast ⋯ ≠ 0

full_name: Nat.mul_ofDigits
code: theorem mul_ofDigits (n : ℕ) {b : ℕ} {l : List ℕ} :
    n * ofDigits b l = ofDigits b (l.map (n * ·)) 
goal: n * Nat.ofDigits b l = Nat.ofDigits b (List.map (fun x => n * x) l)

full_name: Nat.ofDigits_add_ofDigits_eq_ofDigits_zipWith_of_length_eq
code: /-- The addition of ofDigits of two lists is equal to ofDigits of digit-wise addition of them-/
theorem ofDigits_add_ofDigits_eq_ofDigits_zipWith_of_length_eq {b : ℕ} {l1 l2 : List ℕ}
    (h : l1.length = l2.length) :
    ofDigits b l1 + ofDigits b l2 = ofDigits b (l1.zipWith (· + ·) l2) 
goal: Nat.ofDigits b l1 + Nat.ofDigits b l2 = Nat.ofDigits b (List.zipWith (fun x x_1 => x + x_1) l1 l2)

full_name: Nat.digits_lt_base'
code: /-- The digits in the base b+2 expansion of n are all less than b+2 -/
theorem digits_lt_base' {b m : ℕ} : ∀ {d}, d ∈ digits (b + 2) m → d < b + 2 
goal: d ∈ (b + 2).digits m → d < b + 2

full_name: Nat.digits_lt_base
code: /-- The digits in the base b expansion of n are all less than b, if b ≥ 2 -/
theorem digits_lt_base {b m d : ℕ} (hb : 1 < b) (hd : d ∈ digits b m) : d < b 
goal: d < b

full_name: Nat.ofDigits_lt_base_pow_length'
code: /-- an n-digit number in base b + 2 is less than (b + 2)^n -/
theorem ofDigits_lt_base_pow_length' {b : ℕ} {l : List ℕ} (hl : ∀ x ∈ l, x < b + 2) :
    ofDigits (b + 2) l < (b + 2) ^ l.length 
goal: Nat.ofDigits (b + 2) l < (b + 2) ^ l.length

full_name: Nat.ofDigits_lt_base_pow_length
code: /-- an n-digit number in base b is less than b^n if b > 1 -/
theorem ofDigits_lt_base_pow_length {b : ℕ} {l : List ℕ} (hb : 1 < b) (hl : ∀ x ∈ l, x < b) :
    ofDigits b l < b ^ l.length 
goal: Nat.ofDigits b l < b ^ l.length

full_name: Nat.lt_base_pow_length_digits'
code: /-- Any number m is less than (b+2)^(number of digits in the base b + 2 representation of m) -/
theorem lt_base_pow_length_digits' {b m : ℕ} : m < (b + 2) ^ (digits (b + 2) m).length 
goal: m < (b + 2) ^ ((b + 2).digits m).length

full_name: Nat.lt_base_pow_length_digits
code: /-- Any number m is less than b^(number of digits in the base b representation of m) -/
theorem lt_base_pow_length_digits {b m : ℕ} (hb : 1 < b) : m < b ^ (digits b m).length 
goal: m < b ^ (b.digits m).length

full_name: Nat.ofDigits_digits_append_digits
code: theorem ofDigits_digits_append_digits {b m n : ℕ} :
    ofDigits b (digits b n ++ digits b m) = n + b ^ (digits b n).length * m 
goal: Nat.ofDigits b (b.digits n ++ b.digits m) = n + b ^ (b.digits n).length * m

full_name: Nat.digits_append_digits
code: theorem digits_append_digits {b m n : ℕ} (hb : 0 < b) :
    digits b n ++ digits b m = digits b (n + b ^ (digits b n).length * m) 
goal: b.digits n ++ b.digits m = b.digits (n + b ^ (b.digits n).length * m)

full_name: Nat.digits_len_le_digits_len_succ
code: theorem digits_len_le_digits_len_succ (b n : ℕ) :
    (digits b n).length ≤ (digits b (n + 1)).length 
goal: (b.digits n).length ≤ (b.digits (n + 1)).length

full_name: Nat.le_digits_len_le
code: theorem le_digits_len_le (b n m : ℕ) (h : n ≤ m) : (digits b n).length ≤ (digits b m).length 
goal: (b.digits n).length ≤ (b.digits m).length

full_name: Nat.ofDigits_monotone
code: @[mono]
theorem ofDigits_monotone {p q : ℕ} (L : List ℕ) (h : p ≤ q) : ofDigits p L ≤ ofDigits q L 
goal: Nat.ofDigits p L ≤ Nat.ofDigits q L

full_name: Nat.sum_le_ofDigits
code: theorem sum_le_ofDigits {p : ℕ} (L : List ℕ) (h : 1 ≤ p) : L.sum ≤ ofDigits p L 
goal: L.sum ≤ Nat.ofDigits p L

full_name: Nat.digit_sum_le
code: theorem digit_sum_le (p n : ℕ) : List.sum (digits p n) ≤ n 
goal: (p.digits n).sum ≤ n

full_name: Nat.pow_length_le_mul_ofDigits
code: theorem pow_length_le_mul_ofDigits {b : ℕ} {l : List ℕ} (hl : l ≠ []) (hl2 : l.getLast hl ≠ 0) :
    (b + 2) ^ l.length ≤ (b + 2) * ofDigits (b + 2) l 
goal: (b + 2) ^ l.length ≤ (b + 2) * Nat.ofDigits (b + 2) l

full_name: Nat.base_pow_length_digits_le'
code: /-- Any non-zero natural number `m` is greater than
(b+2)^((number of digits in the base (b+2) representation of m) - 1)
-/
theorem base_pow_length_digits_le' (b m : ℕ) (hm : m ≠ 0) :
    (b + 2) ^ (digits (b + 2) m).length ≤ (b + 2) * m 
goal: (b + 2) ^ ((b + 2).digits m).length ≤ (b + 2) * m

full_name: Nat.base_pow_length_digits_le
code: /-- Any non-zero natural number `m` is greater than
b^((number of digits in the base b representation of m) - 1)
-/
theorem base_pow_length_digits_le (b m : ℕ) (hb : 1 < b) :
    m ≠ 0 → b ^ (digits b m).length ≤ b * m 
goal: m ≠ 0 → b ^ (b.digits m).length ≤ b * m

full_name: Nat.ofDigits_div_eq_ofDigits_tail
code: /-- Interpreting as a base `p` number and dividing by `p` is the same as interpreting the tail.
-/
lemma ofDigits_div_eq_ofDigits_tail {p : ℕ} (hpos : 0 < p) (digits : List ℕ)
    (w₁ : ∀ l ∈ digits, l < p) : ofDigits p digits / p = ofDigits p digits.tail 
goal: Nat.ofDigits p digits / p = Nat.ofDigits p digits.tail

full_name: Nat.ofDigits_div_pow_eq_ofDigits_drop
code: /-- Interpreting as a base `p` number and dividing by `p^i` is the same as dropping `i`.
-/
lemma ofDigits_div_pow_eq_ofDigits_drop
    {p : ℕ} (i : ℕ) (hpos : 0 < p) (digits : List ℕ) (w₁ : ∀ l ∈ digits, l < p) :
    ofDigits p digits / p ^ i = ofDigits p (digits.drop i) 
goal: Nat.ofDigits p digits / p ^ i = Nat.ofDigits p (List.drop i digits)

full_name: Nat.self_div_pow_eq_ofDigits_drop
code: /-- Dividing `n` by `p^i` is like truncating the first `i` digits of `n` in base `p`.
-/
lemma self_div_pow_eq_ofDigits_drop {p : ℕ} (i n : ℕ) (h : 2 ≤ p) :
    n / p ^ i = ofDigits p ((p.digits n).drop i) 
goal: n / p ^ i = Nat.ofDigits p (List.drop i (p.digits n))

full_name: Nat.sub_one_mul_sum_div_pow_eq_sub_sum_digits
code: theorem sub_one_mul_sum_div_pow_eq_sub_sum_digits {p : ℕ}
    (L : List ℕ) {h_nonempty} (h_ne_zero : L.getLast h_nonempty ≠ 0) (h_lt : ∀ l ∈ L, l < p) :
    (p - 1) * ∑ i ∈ range L.length, (ofDigits p L) / p ^ i.succ = (ofDigits p L) - L.sum 
goal: (p - 1) * ∑ i ∈ Finset.range L.length, Nat.ofDigits p L / p ^ i.succ = Nat.ofDigits p L - L.sum

full_name: Nat.sub_one_mul_sum_log_div_pow_eq_sub_sum_digits
code: theorem sub_one_mul_sum_log_div_pow_eq_sub_sum_digits {p : ℕ} (n : ℕ) :
    (p - 1) * ∑ i ∈ range (log p n).succ, n / p ^ i.succ = n - (p.digits n).sum 
goal: (p - 1) * ∑ i ∈ Finset.range (Nat.log p n).succ, n / p ^ i.succ = n - (p.digits n).sum

full_name: Nat.digits_two_eq_bits
code: theorem digits_two_eq_bits (n : ℕ) : digits 2 n = n.bits.map fun b => cond b 1 0 
goal: Nat.digits 2 n = List.map (fun b => bif b then 1 else 0) n.bits

full_name: Nat.dvd_ofDigits_sub_ofDigits
code: theorem dvd_ofDigits_sub_ofDigits {α : Type*} [CommRing α] {a b k : α} (h : k ∣ a - b)
    (L : List ℕ) : k ∣ ofDigits a L - ofDigits b L 
goal: k ∣ Nat.ofDigits a L - Nat.ofDigits b L

full_name: Nat.ofDigits_modEq'
code: theorem ofDigits_modEq' (b b' : ℕ) (k : ℕ) (h : b ≡ b' [MOD k]) (L : List ℕ) :
    ofDigits b L ≡ ofDigits b' L [MOD k] 
goal: Nat.ofDigits b L ≡ Nat.ofDigits b' L [MOD k]

full_name: Nat.ofDigits_modEq
code: theorem ofDigits_modEq (b k : ℕ) (L : List ℕ) : ofDigits b L ≡ ofDigits (b % k) L [MOD k] 
goal: Nat.ofDigits b L ≡ Nat.ofDigits (b % k) L [MOD k]

full_name: Nat.ofDigits_mod
code: theorem ofDigits_mod (b k : ℕ) (L : List ℕ) : ofDigits b L % k = ofDigits (b % k) L % k 
goal: Nat.ofDigits b L % k = Nat.ofDigits (b % k) L % k

full_name: Nat.ofDigits_mod_eq_head!
code: theorem ofDigits_mod_eq_head! (b : ℕ) (l : List ℕ) : ofDigits b l % b = l.head! % b 
goal: Nat.ofDigits b l % b = l.head! % b

full_name: Nat.head!_digits
code: theorem head!_digits {b n : ℕ} (h : b ≠ 1) : (Nat.digits b n).head! = n % b 
goal: (b.digits n).head! = n % b

full_name: Nat.ofDigits_zmodeq'
code: theorem ofDigits_zmodeq' (b b' : ℤ) (k : ℕ) (h : b ≡ b' [ZMOD k]) (L : List ℕ) :
    ofDigits b L ≡ ofDigits b' L [ZMOD k] 
goal: Nat.ofDigits b L ≡ Nat.ofDigits b' L [ZMOD ↑k]

full_name: Nat.ofDigits_zmodeq
code: theorem ofDigits_zmodeq (b : ℤ) (k : ℕ) (L : List ℕ) : ofDigits b L ≡ ofDigits (b % k) L [ZMOD k] 
goal: Nat.ofDigits b L ≡ Nat.ofDigits (b % ↑k) L [ZMOD ↑k]

full_name: Nat.ofDigits_zmod
code: theorem ofDigits_zmod (b : ℤ) (k : ℕ) (L : List ℕ) : ofDigits b L % k = ofDigits (b % k) L % k 
goal: Nat.ofDigits b L % ↑k = Nat.ofDigits (b % ↑k) L % ↑k

full_name: Nat.modEq_digits_sum
code: theorem modEq_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) : n ≡ (digits b' n).sum [MOD b] 
goal: n ≡ (b'.digits n).sum [MOD b]

full_name: Nat.modEq_three_digits_sum
code: theorem modEq_three_digits_sum (n : ℕ) : n ≡ (digits 10 n).sum [MOD 3] 
goal: n ≡ (Nat.digits 10 n).sum [MOD 3]

full_name: Nat.modEq_nine_digits_sum
code: theorem modEq_nine_digits_sum (n : ℕ) : n ≡ (digits 10 n).sum [MOD 9] 
goal: n ≡ (Nat.digits 10 n).sum [MOD 9]

full_name: Nat.zmodeq_ofDigits_digits
code: theorem zmodeq_ofDigits_digits (b b' : ℕ) (c : ℤ) (h : b' ≡ c [ZMOD b]) (n : ℕ) :
    n ≡ ofDigits c (digits b' n) [ZMOD b] 
goal: ↑n ≡ Nat.ofDigits c (b'.digits n) [ZMOD ↑b]

full_name: Nat.ofDigits_neg_one
code: theorem ofDigits_neg_one :
    ∀ L : List ℕ, ofDigits (-1 : ℤ) L = (L.map fun n : ℕ => (n : ℤ)).alternatingSum
  
goal: Nat.ofDigits (-1) L = (List.map (fun n => ↑n) L).alternatingSum

full_name: Nat.modEq_eleven_digits_sum
code: theorem modEq_eleven_digits_sum (n : ℕ) :
    n ≡ ((digits 10 n).map fun n : ℕ => (n : ℤ)).alternatingSum [ZMOD 11] 
goal: ↑n ≡ (List.map (fun n => ↑n) (Nat.digits 10 n)).alternatingSum [ZMOD 11]

full_name: Nat.dvd_iff_dvd_digits_sum
code: theorem dvd_iff_dvd_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) :
    b ∣ n ↔ b ∣ (digits b' n).sum 
goal: b ∣ n ↔ b ∣ (b'.digits n).sum

full_name: Nat.three_dvd_iff
code: /-- **Divisibility by 3 Rule** -/
theorem three_dvd_iff (n : ℕ) : 3 ∣ n ↔ 3 ∣ (digits 10 n).sum 
goal: 3 ∣ n ↔ 3 ∣ (Nat.digits 10 n).sum

full_name: Nat.nine_dvd_iff
code: theorem nine_dvd_iff (n : ℕ) : 9 ∣ n ↔ 9 ∣ (digits 10 n).sum 
goal: 9 ∣ n ↔ 9 ∣ (Nat.digits 10 n).sum

full_name: Nat.dvd_iff_dvd_ofDigits
code: theorem dvd_iff_dvd_ofDigits (b b' : ℕ) (c : ℤ) (h : (b : ℤ) ∣ (b' : ℤ) - c) (n : ℕ) :
    b ∣ n ↔ (b : ℤ) ∣ ofDigits c (digits b' n) 
goal: b ∣ n ↔ ↑b ∣ Nat.ofDigits c (b'.digits n)

full_name: Nat.eleven_dvd_iff
code: theorem eleven_dvd_iff :
    11 ∣ n ↔ (11 : ℤ) ∣ ((digits 10 n).map fun n : ℕ => (n : ℤ)).alternatingSum 
goal: 11 ∣ n ↔ 11 ∣ (List.map (fun n => ↑n) (Nat.digits 10 n)).alternatingSum

full_name: Nat.eleven_dvd_of_palindrome
code: theorem eleven_dvd_of_palindrome (p : (digits 10 n).Palindrome) (h : Even (digits 10 n).length) :
    11 ∣ n 
goal: 11 ∣ n

full_name: Nat.toDigitsCore_lens_eq_aux
code: lemma toDigitsCore_lens_eq_aux (b f : Nat) :
    ∀ (n : Nat) (l1 l2 : List Char), l1.length = l2.length →
    (Nat.toDigitsCore b f n l1).length = (Nat.toDigitsCore b f n l2).length 
goal: l1.length = l2.length → (b.toDigitsCore f n l1).length = (b.toDigitsCore f n l2).length

full_name: Nat.toDigitsCore_lens_eq
code: lemma toDigitsCore_lens_eq (b f : Nat) : ∀ (n : Nat) (c : Char) (tl : List Char),
    (Nat.toDigitsCore b f n (c :: tl)).length = (Nat.toDigitsCore b f n tl).length + 1 
goal: (b.toDigitsCore f n (c :: tl)).length = (b.toDigitsCore f n tl).length + 1

full_name: Nat.nat_repr_len_aux
code: lemma nat_repr_len_aux (n b e : Nat) (h_b_pos : 0 < b) :  n < b ^ e.succ → n / b < b ^ e 
goal: n < b ^ e.succ → n / b < b ^ e

full_name: Nat.toDigitsCore_length
code: /-- The String representation produced by toDigitsCore has the proper length relative to
the number of digits in `n < e` for some base `b`. Since this works with any base greater
than one, it can be used for binary, decimal, and hex. -/
lemma toDigitsCore_length (b : Nat) (h : 2 <= b) (f n e : Nat)
    (hlt : n < b ^ e) (h_e_pos : 0 < e) : (Nat.toDigitsCore b f n []).length <= e 
goal: (b.toDigitsCore f n []).length ≤ e

full_name: Nat.repr_length
code: /-- The core implementation of `Nat.repr` returns a String with length less than or equal to the
number of digits in the decimal number (represented by `e`). For example, the decimal string
representation of any number less than 1000 (10 ^ 3) has a length less than or equal to 3. -/
lemma repr_length (n e : Nat) : 0 < e → n < 10 ^ e → (Nat.repr n).length <= e 
goal: 0 < e → n < 10 ^ e → n.repr.length ≤ e

full_name: Nat.NormDigits.digits_succ
code: theorem digits_succ (b n m r l) (e : r + b * m = n) (hr : r < b)
    (h : Nat.digits b m = l ∧ 1 < b ∧ 0 < m) : (Nat.digits b n = r :: l) ∧ 1 < b ∧ 0 < n 
goal: b.digits n = r :: l ∧ 1 < b ∧ 0 < n

full_name: Nat.NormDigits.digits_one
code: theorem digits_one (b n) (n0 : 0 < n) (nb : n < b) : Nat.digits b n = [n] ∧ 1 < b ∧ 0 < n 
goal: b.digits n = [n] ∧ 1 < b ∧ 0 < n