l3lab/ntp-mathlib huggingface dataset:
theorem ofDigits_modEq' (b b' : ℕ) (k : ℕ) (h : b ≡ b' [MOD k]) (L : List ℕ) :
    ofDigits b L ≡ ofDigits b' L [MOD k] := by
  induction' L with d L ih
  · rfl
  · dsimp [ofDigits]
    dsimp [Nat.ModEq] at *
    conv_lhs => rw [Nat.add_mod, Nat.mul_mod, h, ih]
    

Proof state:
case cons
n b b' k : ℕ
h : b % k = b' % k
d : ℕ
L : List ℕ
ih : ofDigits b L % k = ofDigits b' L % k
⊢ (d % k + b' % k * (ofDigits b' L % k) % k) % k = (d + b' * ofDigits b' L) % k

Next tactic:
conv_rhs => rw [Nat.add_mod, Nat.mul_mod]
theorem ofDigits_modEq' (b b' : ℕ) (k : ℕ) (h : b ≡ b' [MOD k]) (L : List ℕ) :
    ofDigits b L ≡ ofDigits b' L [MOD k] := by
  induction' L with d L ih
  · rfl
  · dsimp [ofDigits]
    dsimp [Nat.ModEq] at *
    conv_lhs => rw [Nat.add_mod, Nat.mul_mod, h, ih]
    conv_rhs => 

Proof state:
n b b' k : ℕ
h : b % k = b' % k
d : ℕ
L : List ℕ
ih : ofDigits b L % k = ofDigits b' L % k
| (d + b' * ofDigits b' L) % k

Next tactic:
rw [Nat.add_mod, Nat.mul_mod]
theorem ofDigits_zmodeq' (b b' : ℤ) (k : ℕ) (h : b ≡ b' [ZMOD k]) (L : List ℕ) :
    ofDigits b L ≡ ofDigits b' L [ZMOD k] := by
  

Proof state:
n : ℕ
b b' : ℤ
k : ℕ
h : b ≡ b' [ZMOD ↑k]
L : List ℕ
⊢ ofDigits b L ≡ ofDigits b' L [ZMOD ↑k]

Next tactic:
induction' L with d L ih
theorem ofDigits_zmodeq' (b b' : ℤ) (k : ℕ) (h : b ≡ b' [ZMOD k]) (L : List ℕ) :
    ofDigits b L ≡ ofDigits b' L [ZMOD k] := by
  induction' L with d L ih
  · 

Proof state:
case nil
n : ℕ
b b' : ℤ
k : ℕ
h : b ≡ b' [ZMOD ↑k]
⊢ ofDigits b [] ≡ ofDigits b' [] [ZMOD ↑k]

Next tactic:
rfl
theorem ofDigits_zmodeq' (b b' : ℤ) (k : ℕ) (h : b ≡ b' [ZMOD k]) (L : List ℕ) :
    ofDigits b L ≡ ofDigits b' L [ZMOD k] := by
  induction' L with d L ih
  · rfl
  · 

Proof state:
case cons
n : ℕ
b b' : ℤ
k : ℕ
h : b ≡ b' [ZMOD ↑k]
d : ℕ
L : List ℕ
ih : ofDigits b L ≡ ofDigits b' L [ZMOD ↑k]
⊢ ofDigits b (d :: L) ≡ ofDigits b' (d :: L) [ZMOD ↑k]

Next tactic:
dsimp [ofDigits]
theorem ofDigits_zmodeq' (b b' : ℤ) (k : ℕ) (h : b ≡ b' [ZMOD k]) (L : List ℕ) :
    ofDigits b L ≡ ofDigits b' L [ZMOD k] := by
  induction' L with d L ih
  · rfl
  · dsimp [ofDigits]
    

Proof state:
case cons
n : ℕ
b b' : ℤ
k : ℕ
h : b ≡ b' [ZMOD ↑k]
d : ℕ
L : List ℕ
ih : ofDigits b L ≡ ofDigits b' L [ZMOD ↑k]
⊢ ↑d + b * ofDigits b L ≡ ↑d + b' * ofDigits b' L [ZMOD ↑k]

Next tactic:
dsimp [Int.ModEq] at *
theorem ofDigits_zmodeq' (b b' : ℤ) (k : ℕ) (h : b ≡ b' [ZMOD k]) (L : List ℕ) :
    ofDigits b L ≡ ofDigits b' L [ZMOD k] := by
  induction' L with d L ih
  · rfl
  · dsimp [ofDigits]
    dsimp [Int.ModEq] at *
    

Proof state:
case cons
n : ℕ
b b' : ℤ
k : ℕ
h : b % ↑k = b' % ↑k
d : ℕ
L : List ℕ
ih : ofDigits b L % ↑k = ofDigits b' L % ↑k
⊢ (↑d + b * ofDigits b L) % ↑k = (↑d + b' * ofDigits b' L) % ↑k

Next tactic:
conv_lhs => rw [Int.add_emod, Int.mul_emod, h, ih]
theorem ofDigits_zmodeq' (b b' : ℤ) (k : ℕ) (h : b ≡ b' [ZMOD k]) (L : List ℕ) :
    ofDigits b L ≡ ofDigits b' L [ZMOD k] := by
  induction' L with d L ih
  · rfl
  · dsimp [ofDigits]
    dsimp [Int.ModEq] at *
    conv_lhs => 

Proof state:
n : ℕ
b b' : ℤ
k : ℕ
h : b % ↑k = b' % ↑k
d : ℕ
L : List ℕ
ih : ofDigits b L % ↑k = ofDigits b' L % ↑k
| (↑d + b * ofDigits b L) % ↑k

Next tactic:
rw [Int.add_emod, Int.mul_emod, h, ih]
theorem ofDigits_zmodeq' (b b' : ℤ) (k : ℕ) (h : b ≡ b' [ZMOD k]) (L : List ℕ) :
    ofDigits b L ≡ ofDigits b' L [ZMOD k] := by
  induction' L with d L ih
  · rfl
  · dsimp [ofDigits]
    dsimp [Int.ModEq] at *
    conv_lhs => rw [Int.add_emod, Int.mul_emod, h, ih]
    

Proof state:
case cons
n : ℕ
b b' : ℤ
k : ℕ
h : b % ↑k = b' % ↑k
d : ℕ
L : List ℕ
ih : ofDigits b L % ↑k = ofDigits b' L % ↑k
⊢ (↑d % ↑k + b' % ↑k * (ofDigits b' L % ↑k) % ↑k) % ↑k = (↑d + b' * ofDigits b' L) % ↑k

Next tactic:
conv_rhs => rw [Int.add_emod, Int.mul_emod]
theorem ofDigits_zmodeq' (b b' : ℤ) (k : ℕ) (h : b ≡ b' [ZMOD k]) (L : List ℕ) :
    ofDigits b L ≡ ofDigits b' L [ZMOD k] := by
  induction' L with d L ih
  · rfl
  · dsimp [ofDigits]
    dsimp [Int.ModEq] at *
    conv_lhs => rw [Int.add_emod, Int.mul_emod, h, ih]
    conv_rhs => 

Proof state:
n : ℕ
b b' : ℤ
k : ℕ
h : b % ↑k = b' % ↑k
d : ℕ
L : List ℕ
ih : ofDigits b L % ↑k = ofDigits b' L % ↑k
| (↑d + b' * ofDigits b' L) % ↑k

Next tactic:
rw [Int.add_emod, Int.mul_emod]
theorem modEq_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) : n ≡ (digits b' n).sum [MOD b] := by
  

Proof state:
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
⊢ n ≡ List.sum (digits b' n) [MOD b]

Next tactic:
rw [← ofDigits_one]
theorem modEq_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) : n ≡ (digits b' n).sum [MOD b] := by
  rw [← ofDigits_one]
  

Proof state:
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
⊢ n ≡ ofDigits 1 (digits b' n) [MOD b]

Next tactic:
conv =>
    congr
    · skip
    · rw [← ofDigits_digits b' n]
theorem modEq_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) : n ≡ (digits b' n).sum [MOD b] := by
  rw [← ofDigits_one]
  conv =>
    

Proof state:
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
| n ≡ ofDigits 1 (digits b' n) [MOD b]

Next tactic:
congr
    · skip
    · rw [← ofDigits_digits b' n]
theorem modEq_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) : n ≡ (digits b' n).sum [MOD b] := by
  rw [← ofDigits_one]
  conv =>
    

Proof state:
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
| n ≡ ofDigits 1 (digits b' n) [MOD b]

Next tactic:
congr
theorem modEq_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) : n ≡ (digits b' n).sum [MOD b] := by
  rw [← ofDigits_one]
  conv =>
    congr
    

Proof state:
case n
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
| b
case a
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
| n
case b n✝ b b' : ℕ h : b' % b = 1 n : ℕ | ofDigits 1 (digits b' n)

Next tactic:
· skip
theorem modEq_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) : n ≡ (digits b' n).sum [MOD b] := by
  rw [← ofDigits_one]
  conv =>
    congr
    · 

Proof state:
case n
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
| b

Next tactic:
skip
theorem modEq_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) : n ≡ (digits b' n).sum [MOD b] := by
  rw [← ofDigits_one]
  conv =>
    congr
    · skip
    

Proof state:
case a
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
| n
case b n✝ b b' : ℕ h : b' % b = 1 n : ℕ | ofDigits 1 (digits b' n)

Next tactic:
· rw [← ofDigits_digits b' n]
theorem modEq_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) : n ≡ (digits b' n).sum [MOD b] := by
  rw [← ofDigits_one]
  conv =>
    congr
    · skip
    · 

Proof state:
case a
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
| n

Next tactic:
rw [← ofDigits_digits b' n]
theorem modEq_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) : n ≡ (digits b' n).sum [MOD b] := by
  rw [← ofDigits_one]
  conv =>
    congr
    · skip
    · rw [← ofDigits_digits b' n]
  

Proof state:
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
⊢ ofDigits b' (digits b' n) ≡ ofDigits 1 (digits b' n) [MOD b]

Next tactic:
convert ofDigits_modEq b' b (digits b' n)
theorem modEq_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) : n ≡ (digits b' n).sum [MOD b] := by
  rw [← ofDigits_one]
  conv =>
    congr
    · skip
    · rw [← ofDigits_digits b' n]
  convert ofDigits_modEq b' b (digits b' n)
  

Proof state:
case h.e'_3.h.e'_3
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
⊢ 1 = b' % b

Next tactic:
exact h.symm
theorem modEq_three_digits_sum (n : ℕ) : n ≡ (digits 10 n).sum [MOD 3] :=
  modEq_digits_sum 3 10 (by 

Proof state:
n✝ n : ℕ
⊢ 10 % 3 = 1

Next tactic:
norm_num
theorem modEq_nine_digits_sum (n : ℕ) : n ≡ (digits 10 n).sum [MOD 9] :=
  modEq_digits_sum 9 10 (by 

Proof state:
n✝ n : ℕ
⊢ 10 % 9 = 1

Next tactic:
norm_num
theorem zmodeq_ofDigits_digits (b b' : ℕ) (c : ℤ) (h : b' ≡ c [ZMOD b]) (n : ℕ) :
    n ≡ ofDigits c (digits b' n) [ZMOD b] := by
  

Proof state:
n✝ b b' : ℕ
c : ℤ
h : ↑b' ≡ c [ZMOD ↑b]
n : ℕ
⊢ ↑n ≡ ofDigits c (digits b' n) [ZMOD ↑b]

Next tactic:
conv =>
    congr
    · skip
    · rw [← ofDigits_digits b' n]
theorem zmodeq_ofDigits_digits (b b' : ℕ) (c : ℤ) (h : b' ≡ c [ZMOD b]) (n : ℕ) :
    n ≡ ofDigits c (digits b' n) [ZMOD b] := by
  conv =>
    

Proof state:
n✝ b b' : ℕ
c : ℤ
h : ↑b' ≡ c [ZMOD ↑b]
n : ℕ
| ↑n ≡ ofDigits c (digits b' n) [ZMOD ↑b]

Next tactic:
congr
    · skip
    · rw [← ofDigits_digits b' n]
theorem zmodeq_ofDigits_digits (b b' : ℕ) (c : ℤ) (h : b' ≡ c [ZMOD b]) (n : ℕ) :
    n ≡ ofDigits c (digits b' n) [ZMOD b] := by
  conv =>
    

Proof state:
n✝ b b' : ℕ
c : ℤ
h : ↑b' ≡ c [ZMOD ↑b]
n : ℕ
| ↑n ≡ ofDigits c (digits b' n) [ZMOD ↑b]

Next tactic:
congr
theorem zmodeq_ofDigits_digits (b b' : ℕ) (c : ℤ) (h : b' ≡ c [ZMOD b]) (n : ℕ) :
    n ≡ ofDigits c (digits b' n) [ZMOD b] := by
  conv =>
    congr
    

Proof state:
case n
n✝ b b' : ℕ
c : ℤ
h : ↑b' ≡ c [ZMOD ↑b]
n : ℕ
| ↑b
case a
n✝ b b' : ℕ
c : ℤ
h : ↑b' ≡ c [ZMOD ↑b]
n : ℕ
| ↑n
case b n✝ b b' : ℕ c : ℤ h : ↑b' ≡ c [ZMOD ↑b] n : ℕ | ofDigits c (digits b' n)

Next tactic:
· skip
theorem zmodeq_ofDigits_digits (b b' : ℕ) (c : ℤ) (h : b' ≡ c [ZMOD b]) (n : ℕ) :
    n ≡ ofDigits c (digits b' n) [ZMOD b] := by
  conv =>
    congr
    · 

Proof state:
case n
n✝ b b' : ℕ
c : ℤ
h : ↑b' ≡ c [ZMOD ↑b]
n : ℕ
| ↑b

Next tactic:
skip
theorem zmodeq_ofDigits_digits (b b' : ℕ) (c : ℤ) (h : b' ≡ c [ZMOD b]) (n : ℕ) :
    n ≡ ofDigits c (digits b' n) [ZMOD b] := by
  conv =>
    congr
    · skip
    

Proof state:
case a
n✝ b b' : ℕ
c : ℤ
h : ↑b' ≡ c [ZMOD ↑b]
n : ℕ
| ↑n
case b n✝ b b' : ℕ c : ℤ h : ↑b' ≡ c [ZMOD ↑b] n : ℕ | ofDigits c (digits b' n)

Next tactic:
· rw [← ofDigits_digits b' n]
theorem zmodeq_ofDigits_digits (b b' : ℕ) (c : ℤ) (h : b' ≡ c [ZMOD b]) (n : ℕ) :
    n ≡ ofDigits c (digits b' n) [ZMOD b] := by
  conv =>
    congr
    · skip
    · 

Proof state:
case a
n✝ b b' : ℕ
c : ℤ
h : ↑b' ≡ c [ZMOD ↑b]
n : ℕ
| ↑n

Next tactic:
rw [← ofDigits_digits b' n]
theorem zmodeq_ofDigits_digits (b b' : ℕ) (c : ℤ) (h : b' ≡ c [ZMOD b]) (n : ℕ) :
    n ≡ ofDigits c (digits b' n) [ZMOD b] := by
  conv =>
    congr
    · skip
    · rw [← ofDigits_digits b' n]
  

Proof state:
n✝ b b' : ℕ
c : ℤ
h : ↑b' ≡ c [ZMOD ↑b]
n : ℕ
⊢ ↑(ofDigits b' (digits b' n)) ≡ ofDigits c (digits b' n) [ZMOD ↑b]

Next tactic:
rw [coe_int_ofDigits]
theorem zmodeq_ofDigits_digits (b b' : ℕ) (c : ℤ) (h : b' ≡ c [ZMOD b]) (n : ℕ) :
    n ≡ ofDigits c (digits b' n) [ZMOD b] := by
  conv =>
    congr
    · skip
    · rw [← ofDigits_digits b' n]
  rw [coe_int_ofDigits]
  

Proof state:
n✝ b b' : ℕ
c : ℤ
h : ↑b' ≡ c [ZMOD ↑b]
n : ℕ
⊢ ofDigits (↑b') (digits b' n) ≡ ofDigits c (digits b' n) [ZMOD ↑b]

Next tactic:
apply ofDigits_zmodeq' _ _ _ h
theorem ofDigits_neg_one :
    ∀ L : List ℕ, ofDigits (-1 : ℤ) L = (L.map fun n : ℕ => (n : ℤ)).alternatingSum
  | [] => rfl
  | [n] => by 

Proof state:
n✝ n : ℕ
⊢ ofDigits (-1) [n] = List.alternatingSum (List.map (fun n => ↑n) [n])

Next tactic:
simp [ofDigits, List.alternatingSum]
theorem ofDigits_neg_one :
    ∀ L : List ℕ, ofDigits (-1 : ℤ) L = (L.map fun n : ℕ => (n : ℤ)).alternatingSum
  | [] => rfl
  | [n] => by simp [ofDigits, List.alternatingSum]
  | a :: b :: t => by
    

Proof state:
n a b : ℕ
t : List ℕ
⊢ ofDigits (-1) (a :: b :: t) = List.alternatingSum (List.map (fun n => ↑n) (a :: b :: t))

Next tactic:
simp only [ofDigits, List.alternatingSum, List.map_cons, ofDigits_neg_one t]
theorem ofDigits_neg_one :
    ∀ L : List ℕ, ofDigits (-1 : ℤ) L = (L.map fun n : ℕ => (n : ℤ)).alternatingSum
  | [] => rfl
  | [n] => by simp [ofDigits, List.alternatingSum]
  | a :: b :: t => by
    simp only [ofDigits, List.alternatingSum, List.map_cons, ofDigits_neg_one t]
    

Proof state:
n a b : ℕ
t : List ℕ
⊢ ↑a + -1 * (↑b + -1 * List.alternatingSum (List.map (fun n => ↑n) t)) =
    ↑a + -↑b + List.alternatingSum (List.map (fun n => ↑n) t)

Next tactic:
ring
theorem modEq_eleven_digits_sum (n : ℕ) :
    n ≡ ((digits 10 n).map fun n : ℕ => (n : ℤ)).alternatingSum [ZMOD 11] := by
  

Proof state:
n✝ n : ℕ
⊢ ↑n ≡ List.alternatingSum (List.map (fun n => ↑n) (digits 10 n)) [ZMOD 11]

Next tactic:
have t := zmodeq_ofDigits_digits 11 10 (-1 : ℤ) (by unfold Int.ModEq; rfl) n
theorem modEq_eleven_digits_sum (n : ℕ) :
    n ≡ ((digits 10 n).map fun n : ℕ => (n : ℤ)).alternatingSum [ZMOD 11] := by
  have t := zmodeq_ofDigits_digits 11 10 (-1 : ℤ) (by 

Proof state:
n✝ n : ℕ
⊢ ↑10 ≡ -1 [ZMOD ↑11]

Next tactic:
unfold Int.ModEq
theorem modEq_eleven_digits_sum (n : ℕ) :
    n ≡ ((digits 10 n).map fun n : ℕ => (n : ℤ)).alternatingSum [ZMOD 11] := by
  have t := zmodeq_ofDigits_digits 11 10 (-1 : ℤ) (by unfold Int.ModEq; 

Proof state:
n✝ n : ℕ
⊢ ↑10 % ↑11 = -1 % ↑11

Next tactic:
rfl
theorem modEq_eleven_digits_sum (n : ℕ) :
    n ≡ ((digits 10 n).map fun n : ℕ => (n : ℤ)).alternatingSum [ZMOD 11] := by
  have t := zmodeq_ofDigits_digits 11 10 (-1 : ℤ) (by unfold Int.ModEq; rfl) n
  

Proof state:
n✝ n : ℕ
t : ↑n ≡ ofDigits (-1) (digits 10 n) [ZMOD ↑11]
⊢ ↑n ≡ List.alternatingSum (List.map (fun n => ↑n) (digits 10 n)) [ZMOD 11]

Next tactic:
rwa [ofDigits_neg_one] at t
theorem dvd_iff_dvd_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) :
    b ∣ n ↔ b ∣ (digits b' n).sum := by
  

Proof state:
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
⊢ b ∣ n ↔ b ∣ List.sum (digits b' n)

Next tactic:
rw [← ofDigits_one]
theorem dvd_iff_dvd_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) :
    b ∣ n ↔ b ∣ (digits b' n).sum := by
  rw [← ofDigits_one]
  

Proof state:
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
⊢ b ∣ n ↔ b ∣ ofDigits 1 (digits b' n)

Next tactic:
conv_lhs => rw [← ofDigits_digits b' n]
theorem dvd_iff_dvd_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) :
    b ∣ n ↔ b ∣ (digits b' n).sum := by
  rw [← ofDigits_one]
  conv_lhs => 

Proof state:
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
| b ∣ n

Next tactic:
rw [← ofDigits_digits b' n]
theorem dvd_iff_dvd_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) :
    b ∣ n ↔ b ∣ (digits b' n).sum := by
  rw [← ofDigits_one]
  conv_lhs => rw [← ofDigits_digits b' n]
  

Proof state:
n✝ b b' : ℕ
h : b' % b = 1
n : ℕ
⊢ b ∣ ofDigits b' (digits b' n) ↔ b ∣ ofDigits 1 (digits b' n)

Next tactic:
rw [Nat.dvd_iff_mod_eq_zero, Nat.dvd_iff_mod_eq_zero, ofDigits_mod, h]
/-- **Divisibility by 3 Rule** -/
theorem three_dvd_iff (n : ℕ) : 3 ∣ n ↔ 3 ∣ (digits 10 n).sum :=
  dvd_iff_dvd_digits_sum 3 10 (by 

Proof state:
n✝ n : ℕ
⊢ 10 % 3 = 1

Next tactic:
norm_num
theorem nine_dvd_iff (n : ℕ) : 9 ∣ n ↔ 9 ∣ (digits 10 n).sum :=
  dvd_iff_dvd_digits_sum 9 10 (by 

Proof state:
n✝ n : ℕ
⊢ 10 % 9 = 1

Next tactic:
norm_num
theorem dvd_iff_dvd_ofDigits (b b' : ℕ) (c : ℤ) (h : (b : ℤ) ∣ (b' : ℤ) - c) (n : ℕ) :
    b ∣ n ↔ (b : ℤ) ∣ ofDigits c (digits b' n) := by
  

Proof state:
n✝ b b' : ℕ
c : ℤ
h : ↑b ∣ ↑b' - c
n : ℕ
⊢ b ∣ n ↔ ↑b ∣ ofDigits c (digits b' n)

Next tactic:
rw [← Int.coe_nat_dvd]
theorem dvd_iff_dvd_ofDigits (b b' : ℕ) (c : ℤ) (h : (b : ℤ) ∣ (b' : ℤ) - c) (n : ℕ) :
    b ∣ n ↔ (b : ℤ) ∣ ofDigits c (digits b' n) := by
  rw [← Int.coe_nat_dvd]
  

Proof state:
n✝ b b' : ℕ
c : ℤ
h : ↑b ∣ ↑b' - c
n : ℕ
⊢ ↑b ∣ ↑n ↔ ↑b ∣ ofDigits c (digits b' n)

Next tactic:
exact
    dvd_iff_dvd_of_dvd_sub (zmodeq_ofDigits_digits b b' c (Int.modEq_iff_dvd.2 h).symm _).symm.dvd
theorem eleven_dvd_iff :
    11 ∣ n ↔ (11 : ℤ) ∣ ((digits 10 n).map fun n : ℕ => (n : ℤ)).alternatingSum := by
  

Proof state:
n : ℕ
⊢ 11 ∣ n ↔ 11 ∣ List.alternatingSum (List.map (fun n => ↑n) (digits 10 n))

Next tactic:
have t := dvd_iff_dvd_ofDigits 11 10 (-1 : ℤ) (by norm_num) n
theorem eleven_dvd_iff :
    11 ∣ n ↔ (11 : ℤ) ∣ ((digits 10 n).map fun n : ℕ => (n : ℤ)).alternatingSum := by
  have t := dvd_iff_dvd_ofDigits 11 10 (-1 : ℤ) (by 

Proof state:
n : ℕ
⊢ ↑11 ∣ ↑10 - -1

Next tactic:
norm_num
theorem eleven_dvd_iff :
    11 ∣ n ↔ (11 : ℤ) ∣ ((digits 10 n).map fun n : ℕ => (n : ℤ)).alternatingSum := by
  have t := dvd_iff_dvd_ofDigits 11 10 (-1 : ℤ) (by norm_num) n
  

Proof state:
n : ℕ
t : 11 ∣ n ↔ ↑11 ∣ ofDigits (-1) (digits 10 n)
⊢ 11 ∣ n ↔ 11 ∣ List.alternatingSum (List.map (fun n => ↑n) (digits 10 n))

Next tactic:
rw [ofDigits_neg_one] at t
theorem eleven_dvd_iff :
    11 ∣ n ↔ (11 : ℤ) ∣ ((digits 10 n).map fun n : ℕ => (n : ℤ)).alternatingSum := by
  have t := dvd_iff_dvd_ofDigits 11 10 (-1 : ℤ) (by norm_num) n
  rw [ofDigits_neg_one] at t
  

Proof state:
n : ℕ
t : 11 ∣ n ↔ ↑11 ∣ List.alternatingSum (List.map (fun n => ↑n) (digits 10 n))
⊢ 11 ∣ n ↔ 11 ∣ List.alternatingSum (List.map (fun n => ↑n) (digits 10 n))

Next tactic:
exact t
theorem eleven_dvd_of_palindrome (p : (digits 10 n).Palindrome) (h : Even (digits 10 n).length) :
    11 ∣ n := by
  

Proof state:
n : ℕ
p : List.Palindrome (digits 10 n)
h : Even (List.length (digits 10 n))
⊢ 11 ∣ n

Next tactic:
let dig := (digits 10 n).map (Coe.coe : ℕ → ℤ)
theorem eleven_dvd_of_palindrome (p : (digits 10 n).Palindrome) (h : Even (digits 10 n).length) :
    11 ∣ n := by
  let dig := (digits 10 n).map (Coe.coe : ℕ → ℤ)
  

Proof state:
n : ℕ
p : List.Palindrome (digits 10 n)
h : Even (List.length (digits 10 n))
dig : List ℤ := List.map Coe.coe (digits 10 n)
⊢ 11 ∣ n

Next tactic:
replace h : Even dig.length := by rwa [List.length_map]
theorem eleven_dvd_of_palindrome (p : (digits 10 n).Palindrome) (h : Even (digits 10 n).length) :
    11 ∣ n := by
  let dig := (digits 10 n).map (Coe.coe : ℕ → ℤ)
  replace h : Even dig.length := by 

Proof state:
n : ℕ
p : List.Palindrome (digits 10 n)
h : Even (List.length (digits 10 n))
dig : List ℤ := List.map Coe.coe (digits 10 n)
⊢ Even (List.length dig)

Next tactic:
rwa [List.length_map]
theorem eleven_dvd_of_palindrome (p : (digits 10 n).Palindrome) (h : Even (digits 10 n).length) :
    11 ∣ n := by
  let dig := (digits 10 n).map (Coe.coe : ℕ → ℤ)
  replace h : Even dig.length := by rwa [List.length_map]
  

Proof state:
n : ℕ
p : List.Palindrome (digits 10 n)
dig : List ℤ := List.map Coe.coe (digits 10 n)
h : Even (List.length dig)
⊢ 11 ∣ n

Next tactic:
refine' eleven_dvd_iff.2 ⟨0, (_ : dig.alternatingSum = 0)⟩
theorem eleven_dvd_of_palindrome (p : (digits 10 n).Palindrome) (h : Even (digits 10 n).length) :
    11 ∣ n := by
  let dig := (digits 10 n).map (Coe.coe : ℕ → ℤ)
  replace h : Even dig.length := by rwa [List.length_map]
  refine' eleven_dvd_iff.2 ⟨0, (_ : dig.alternatingSum = 0)⟩
  

Proof state:
n : ℕ
p : List.Palindrome (digits 10 n)
dig : List ℤ := List.map Coe.coe (digits 10 n)
h : Even (List.length dig)
⊢ List.alternatingSum dig = 0

Next tactic:
have := dig.alternatingSum_reverse
theorem eleven_dvd_of_palindrome (p : (digits 10 n).Palindrome) (h : Even (digits 10 n).length) :
    11 ∣ n := by
  let dig := (digits 10 n).map (Coe.coe : ℕ → ℤ)
  replace h : Even dig.length := by rwa [List.length_map]
  refine' eleven_dvd_iff.2 ⟨0, (_ : dig.alternatingSum = 0)⟩
  have := dig.alternatingSum_reverse
  

Proof state:
n : ℕ
p : List.Palindrome (digits 10 n)
dig : List ℤ := List.map Coe.coe (digits 10 n)
h : Even (List.length dig)
this : List.alternatingSum (List.reverse dig) = (-1) ^ (List.length dig + 1) • List.alternatingSum dig
⊢ List.alternatingSum dig = 0

Next tactic:
rw [(p.map _).reverse_eq, _root_.pow_succ, h.neg_one_pow, mul_one, neg_one_zsmul] at this
theorem eleven_dvd_of_palindrome (p : (digits 10 n).Palindrome) (h : Even (digits 10 n).length) :
    11 ∣ n := by
  let dig := (digits 10 n).map (Coe.coe : ℕ → ℤ)
  replace h : Even dig.length := by rwa [List.length_map]
  refine' eleven_dvd_iff.2 ⟨0, (_ : dig.alternatingSum = 0)⟩
  have := dig.alternatingSum_reverse
  rw [(p.map _).reverse_eq, _root_.pow_succ, h.neg_one_pow, mul_one, neg_one_zsmul] at this
  

Proof state:
n : ℕ
p : List.Palindrome (digits 10 n)
dig : List ℤ := List.map Coe.coe (digits 10 n)
h : Even (List.length dig)
this : List.alternatingSum (List.map Coe.coe (digits 10 n)) = -List.alternatingSum dig
⊢ List.alternatingSum dig = 0

Next tactic:
exact eq_zero_of_neg_eq this.symm
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 := by
  

Proof state:
n✝ b n m r : ℕ
l : List ℕ
e : r + b * m = n
hr : r < b
h : digits b m = l ∧ 1 < b ∧ 0 < m
⊢ digits b n = r :: l ∧ 1 < b ∧ 0 < n

Next tactic:
rcases h with ⟨h, b2, m0⟩
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 := by
  rcases h with ⟨h, b2, m0⟩
  

Proof state:
case intro.intro
n✝ b n m r : ℕ
l : List ℕ
e : r + b * m = n
hr : r < b
h : digits b m = l
b2 : 1 < b
m0 : 0 < m
⊢ digits b n = r :: l ∧ 1 < b ∧ 0 < n

Next tactic:
have b0 : 0 < b := by linarith
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 := by
  rcases h with ⟨h, b2, m0⟩
  have b0 : 0 < b := by 

Proof state:
n✝ b n m r : ℕ
l : List ℕ
e : r + b * m = n
hr : r < b
h : digits b m = l
b2 : 1 < b
m0 : 0 < m
⊢ 0 < b

Next tactic:
linarith
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 := by
  rcases h with ⟨h, b2, m0⟩
  have b0 : 0 < b := by linarith
  

Proof state:
case intro.intro
n✝ b n m r : ℕ
l : List ℕ
e : r + b * m = n
hr : r < b
h : digits b m = l
b2 : 1 < b
m0 : 0 < m
b0 : 0 < b
⊢ digits b n = r :: l ∧ 1 < b ∧ 0 < n

Next tactic:
have n0 : 0 < n := by linarith [mul_pos b0 m0]
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 := by
  rcases h with ⟨h, b2, m0⟩
  have b0 : 0 < b := by linarith
  have n0 : 0 < n := by 

Proof state:
n✝ b n m r : ℕ
l : List ℕ
e : r + b * m = n
hr : r < b
h : digits b m = l
b2 : 1 < b
m0 : 0 < m
b0 : 0 < b
⊢ 0 < n

Next tactic:
linarith [mul_pos b0 m0]
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 := by
  rcases h with ⟨h, b2, m0⟩
  have b0 : 0 < b := by linarith
  have n0 : 0 < n := by linarith [mul_pos b0 m0]
  

Proof state:
case intro.intro
n✝ b n m r : ℕ
l : List ℕ
e : r + b * m = n
hr : r < b
h : digits b m = l
b2 : 1 < b
m0 : 0 < m
b0 : 0 < b
n0 : 0 < n
⊢ digits b n = r :: l ∧ 1 < b ∧ 0 < n

Next tactic:
refine' ⟨_, b2, n0⟩
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 := by
  rcases h with ⟨h, b2, m0⟩
  have b0 : 0 < b := by linarith
  have n0 : 0 < n := by linarith [mul_pos b0 m0]
  refine' ⟨_, b2, n0⟩
  

Proof state:
case intro.intro
n✝ b n m r : ℕ
l : List ℕ
e : r + b * m = n
hr : r < b
h : digits b m = l
b2 : 1 < b
m0 : 0 < m
b0 : 0 < b
n0 : 0 < n
⊢ digits b n = r :: l

Next tactic:
obtain ⟨rfl, rfl⟩ := (Nat.div_mod_unique b0).2 ⟨e, hr⟩
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 := by
  rcases h with ⟨h, b2, m0⟩
  have b0 : 0 < b := by linarith
  have n0 : 0 < n := by linarith [mul_pos b0 m0]
  refine' ⟨_, b2, n0⟩
  obtain ⟨rfl, rfl⟩ := (Nat.div_mod_unique b0).2 ⟨e, hr⟩
  

Proof state:
case intro.intro.intro
n✝ b n : ℕ
l : List ℕ
b2 : 1 < b
b0 : 0 < b
n0 : 0 < n
h : digits b (n / b) = l
m0 : 0 < n / b
hr : n % b < b
e : n % b + b * (n / b) = n
⊢ digits b n = n % b :: l

Next tactic:
subst h
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 := by
  rcases h with ⟨h, b2, m0⟩
  have b0 : 0 < b := by linarith
  have n0 : 0 < n := by linarith [mul_pos b0 m0]
  refine' ⟨_, b2, n0⟩
  obtain ⟨rfl, rfl⟩ := (Nat.div_mod_unique b0).2 ⟨e, hr⟩
  subst h; 

Proof state:
case intro.intro.intro
n✝ b n : ℕ
b2 : 1 < b
b0 : 0 < b
n0 : 0 < n
m0 : 0 < n / b
hr : n % b < b
e : n % b + b * (n / b) = n
⊢ digits b n = n % b :: digits b (n / b)

Next tactic:
exact Nat.digits_def' b2 n0
theorem digits_one (b n) (n0 : 0 < n) (nb : n < b) : Nat.digits b n = [n] ∧ 1 < b ∧ 0 < n := by
  

Proof state:
n✝ b n : ℕ
n0 : 0 < n
nb : n < b
⊢ digits b n = [n] ∧ 1 < b ∧ 0 < n

Next tactic:
have b2 : 1 < b :=
    lt_iff_add_one_le.mpr (le_trans (add_le_add_right (lt_iff_add_one_le.mp n0) 1) nb)
theorem digits_one (b n) (n0 : 0 < n) (nb : n < b) : Nat.digits b n = [n] ∧ 1 < b ∧ 0 < n := by
  have b2 : 1 < b :=
    lt_iff_add_one_le.mpr (le_trans (add_le_add_right (lt_iff_add_one_le.mp n0) 1) nb)
  

Proof state:
n✝ b n : ℕ
n0 : 0 < n
nb : n < b
b2 : 1 < b
⊢ digits b n = [n] ∧ 1 < b ∧ 0 < n

Next tactic:
refine' ⟨_, b2, n0⟩