[GOAL]
n m : ℕ
⊢ succ n * m = 0 → succ n = 0 ∨ m = 0
[PROOFSTEP]
rw [succ_mul]
[GOAL]
n m : ℕ
⊢ n * m + m = 0 → succ n = 0 ∨ m = 0
[PROOFSTEP]
intro h
[GOAL]
n m : ℕ
h : n * m + m = 0
⊢ succ n = 0 ∨ m = 0
[PROOFSTEP]
exact Or.inr (Nat.eq_zero_of_add_eq_zero_left h)
[GOAL]
m : ℕ
h : bit0 0 = bit0 (m + 1)
⊢ 0 = m + 1
[PROOFSTEP]
contradiction
[GOAL]
n : ℕ
h : bit0 (n + 1) = bit0 0
⊢ n + 1 = 0
[PROOFSTEP]
contradiction
[GOAL]
n m : ℕ
h : bit0 (n + 1) = bit0 (m + 1)
⊢ n + 1 = m + 1
[PROOFSTEP]
have : succ (succ (n + n)) = succ (succ (m + m)) :=
  by
  unfold bit0 at h ; simp [add_one, add_succ, succ_add] at h
  have aux : n + n = m + m := h; rw [aux]
[GOAL]
n m : ℕ
h : bit0 (n + 1) = bit0 (m + 1)
⊢ succ (succ (n + n)) = succ (succ (m + m))
[PROOFSTEP]
unfold bit0 at h
[GOAL]
n m : ℕ
h : n + 1 + (n + 1) = m + 1 + (m + 1)
⊢ succ (succ (n + n)) = succ (succ (m + m))
[PROOFSTEP]
simp [add_one, add_succ, succ_add] at h
[GOAL]
n m : ℕ
h : n + n = m + m
⊢ succ (succ (n + n)) = succ (succ (m + m))
[PROOFSTEP]
have aux : n + n = m + m := h
[GOAL]
n m : ℕ
h aux : n + n = m + m
⊢ succ (succ (n + n)) = succ (succ (m + m))
[PROOFSTEP]
rw [aux]
[GOAL]
n m : ℕ
h : bit0 (n + 1) = bit0 (m + 1)
this : succ (succ (n + n)) = succ (succ (m + m))
⊢ n + 1 = m + 1
[PROOFSTEP]
have : n + n = m + m := by repeat injection this with this
[GOAL]
n m : ℕ
h : bit0 (n + 1) = bit0 (m + 1)
this : succ (succ (n + n)) = succ (succ (m + m))
⊢ n + n = m + m
[PROOFSTEP]
repeat injection this with this
[GOAL]
n m : ℕ
h : bit0 (n + 1) = bit0 (m + 1)
this : succ (succ (n + n)) = succ (succ (m + m))
⊢ n + n = m + m
[PROOFSTEP]
injection this with this
[GOAL]
n m : ℕ
h : bit0 (n + 1) = bit0 (m + 1)
this : succ (n + n) = succ (m + m)
⊢ n + n = m + m
[PROOFSTEP]
injection this with this
[GOAL]

[PROOFSTEP]
injection this with this
[GOAL]
n m : ℕ
h : bit0 (n + 1) = bit0 (m + 1)
this✝ : succ (succ (n + n)) = succ (succ (m + m))
this : n + n = m + m
⊢ n + 1 = m + 1
[PROOFSTEP]
have : n = m := Nat.bit0_inj this
[GOAL]
n m : ℕ
h : bit0 (n + 1) = bit0 (m + 1)
this✝¹ : succ (succ (n + n)) = succ (succ (m + m))
this✝ : n + n = m + m
this : n = m
⊢ n + 1 = m + 1
[PROOFSTEP]
rw [this]
[GOAL]
n m : ℕ
h : bit1 n = bit1 m
⊢ succ (bit0 n) = succ (bit0 m)
[PROOFSTEP]
simp [Nat.bit1_eq_succ_bit0] at h
[GOAL]
n m : ℕ
h : bit0 n = bit0 m
⊢ succ (bit0 n) = succ (bit0 m)
[PROOFSTEP]
rw [h]
[GOAL]
n m : ℕ
h : bit1 n = bit1 m
this : succ (bit0 n) = succ (bit0 m)
⊢ bit0 n = bit0 m
[PROOFSTEP]
injection this
[GOAL]
h : 0 ≠ 0
⊢ 1 < bit1 0
[PROOFSTEP]
contradiction
[GOAL]
n : ℕ
_h : succ n ≠ 0
⊢ 1 < bit1 (succ n)
[PROOFSTEP]
rw [Nat.bit1_succ_eq]
[GOAL]
n : ℕ
_h : succ n ≠ 0
⊢ 1 < succ (succ (bit1 n))
[PROOFSTEP]
apply succ_lt_succ
[GOAL]
case a
n : ℕ
_h : succ n ≠ 0
⊢ 0 < bit1 n + 1
[PROOFSTEP]
apply zero_lt_succ
[GOAL]
h : 0 ≠ 0
⊢ 1 < bit0 0
[PROOFSTEP]
contradiction
[GOAL]
n : ℕ
_h : succ n ≠ 0
⊢ 1 < bit0 (succ n)
[PROOFSTEP]
rw [Nat.bit0_succ_eq]
[GOAL]
n : ℕ
_h : succ n ≠ 0
⊢ 1 < succ (succ (bit0 n))
[PROOFSTEP]
apply succ_lt_succ
[GOAL]
case a
n : ℕ
_h : succ n ≠ 0
⊢ 0 < bit0 n + 1
[PROOFSTEP]
apply zero_lt_succ
[GOAL]
n m : ℕ
h : n < succ m
this✝ : n ≤ m
this : succ (n + n) ≤ succ (m + m)
⊢ succ (n + n) ≤ succ m + m
[PROOFSTEP]
rw [succ_add]
[GOAL]
n m : ℕ
h : n < succ m
this✝ : n ≤ m
this : succ (n + n) ≤ succ (m + m)
⊢ succ (n + n) ≤ succ (m + m)
[PROOFSTEP]
assumption
[GOAL]
B : Sort u
n : ℕ
H1 : n = 0 → B
H2 : (m : ℕ) → n = succ m → B
⊢ B
[PROOFSTEP]
induction' h : n
[GOAL]
case zero
B : Sort u
n : ℕ
H1 : n = 0 → B
H2 : (m : ℕ) → n = succ m → B
x✝ : ℕ
h✝ : n = x✝
h : n = zero
⊢ B
[PROOFSTEP]
exact H1 h
[GOAL]
case succ
B : Sort u
n : ℕ
H1 : n = 0 → B
H2 : (m : ℕ) → n = succ m → B
x✝ : ℕ
h✝ : n = x✝
n✝ : ℕ
n_ih✝ : n = n✝ → B
h : n = succ n✝
⊢ B
[PROOFSTEP]
exact H2 _ h
[GOAL]
x y k : ℕ
h : k ≤ y
⊢ x ≤ y - k ↔ x + k ≤ y
[PROOFSTEP]
rw [← Nat.add_sub_cancel x k, Nat.sub_le_sub_iff_right h, Nat.add_sub_cancel]
[GOAL]
m n k : ℕ
⊢ m - n - k = m - k - n
[PROOFSTEP]
rw [Nat.sub_sub, Nat.sub_sub, Nat.add_comm]
[GOAL]
x : ℕ
d : Decidable (x % 2 = 1)
⊢ (bif decide (x % 2 = 1) then 1 else 0) = x % 2
[PROOFSTEP]
by_cases h : x % 2 = 1
[GOAL]
case pos
x : ℕ
d : Decidable (x % 2 = 1)
h : x % 2 = 1
⊢ (bif decide (x % 2 = 1) then 1 else 0) = x % 2
[PROOFSTEP]
simp! [*]
[GOAL]
case neg
x : ℕ
d : Decidable (x % 2 = 1)
h : ¬x % 2 = 1
⊢ (bif decide (x % 2 = 1) then 1 else 0) = x % 2
[PROOFSTEP]
cases mod_two_eq_zero_or_one x
[GOAL]
case neg.inl
x : ℕ
d : Decidable (x % 2 = 1)
h : ¬x % 2 = 1
h✝ : x % 2 = 0
⊢ (bif decide (x % 2 = 1) then 1 else 0) = x % 2
[PROOFSTEP]
simp! [*, Nat.zero_ne_one]
[GOAL]
case neg.inr
x : ℕ
d : Decidable (x % 2 = 1)
h : ¬x % 2 = 1
h✝ : x % 2 = 1
⊢ (bif decide (x % 2 = 1) then 1 else 0) = x % 2
[PROOFSTEP]
simp! [*, Nat.zero_ne_one]
[GOAL]
m n k : ℕ
H : 0 < m
⊢ m * n / (m * k) = n / k
[PROOFSTEP]
rw [← Nat.div_div_eq_div_mul, Nat.mul_div_cancel_left _ H]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
n : ℕ
pn : p n
m✝ m : ℕ
IH : ∀ (k : ℕ), n ≤ k + m → Acc Nat.lbp k
k : ℕ
kn : n ≤ k + succ m
y : ℕ
r : Nat.lbp y k
_a : ∀ (k_1 : ℕ), k_1 ≤ k → ¬p k_1
⊢ n ≤ k + 1 + m
[PROOFSTEP]
rw [Nat.add_right_comm]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
n : ℕ
pn : p n
m✝ m : ℕ
IH : ∀ (k : ℕ), n ≤ k + m → Acc Nat.lbp k
k : ℕ
kn : n ≤ k + succ m
y : ℕ
r : Nat.lbp y k
_a : ∀ (k_1 : ℕ), k_1 ≤ k → ¬p k_1
⊢ n ≤ k + m + 1
[PROOFSTEP]
exact kn
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
m : ℕ
IH : (y : ℕ) → Nat.lbp y m → (fun k => (∀ (n : ℕ), n < k → ¬p n) → { n // p n ∧ ∀ (m : ℕ), m < n → ¬p m }) y
al : ∀ (n : ℕ), n < m → ¬p n
pm : ¬p m
n : ℕ
h : n ≤ m
e : n = m
⊢ ¬p n
[PROOFSTEP]
rw [e]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
m : ℕ
IH : (y : ℕ) → Nat.lbp y m → (fun k => (∀ (n : ℕ), n < k → ¬p n) → { n // p n ∧ ∀ (m : ℕ), m < n → ¬p m }) y
al : ∀ (n : ℕ), n < m → ¬p n
pm : ¬p m
n : ℕ
h : n ≤ m
e : n = m
⊢ ¬p m
[PROOFSTEP]
exact pm
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
⊢ ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b f n l1) = List.length (toDigitsCore b f n l2)
[PROOFSTEP]
induction f with (simp only [Nat.toDigitsCore, List.length]; intro n l1 l2 hlen)
| zero => assumption
| succ f ih =>
  by_cases hx : n / b = 0
  case pos => simp only [hx, if_true, List.length, congrArg (fun l ↦ l + 1) hlen]
  case neg =>
    simp only [hx, if_false]
    specialize ih (n / b) (Nat.digitChar (n % b) :: l1) (Nat.digitChar (n % b) :: l2)
    simp only [List.length, congrArg (fun l ↦ l + 1) hlen] at ih
    exact ih trivial
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
⊢ ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b f n l1) = List.length (toDigitsCore b f n l2)
[PROOFSTEP]
induction f with (simp only [Nat.toDigitsCore, List.length]; intro n l1 l2 hlen)
| zero => assumption
| succ f ih =>
  by_cases hx : n / b = 0
  case pos => simp only [hx, if_true, List.length, congrArg (fun l ↦ l + 1) hlen]
  case neg =>
    simp only [hx, if_false]
    specialize ih (n / b) (Nat.digitChar (n % b) :: l1) (Nat.digitChar (n % b) :: l2)
    simp only [List.length, congrArg (fun l ↦ l + 1) hlen] at ih
    exact ih trivial
[GOAL]
case zero
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
⊢ ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b zero n l1) = List.length (toDigitsCore b zero n l2)
[PROOFSTEP]
simp only [Nat.toDigitsCore, List.length]
[GOAL]
case zero
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
⊢ ℕ → ∀ (l1 l2 : List Char), List.length l1 = List.length l2 → List.length l1 = List.length l2
[PROOFSTEP]
intro n l1 l2 hlen
[GOAL]
case zero
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b n : ℕ
l1 l2 : List Char
hlen : List.length l1 = List.length l2
⊢ List.length l1 = List.length l2
[PROOFSTEP]

| zero => assumption
[GOAL]
case zero
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b n : ℕ
l1 l2 : List Char
hlen : List.length l1 = List.length l2
⊢ List.length l1 = List.length l2
[PROOFSTEP]
assumption
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b f n l1) = List.length (toDigitsCore b f n l2)
⊢ ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 →
      List.length (toDigitsCore b (succ f) n l1) = List.length (toDigitsCore b (succ f) n l2)
[PROOFSTEP]
simp only [Nat.toDigitsCore, List.length]
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b f n l1) = List.length (toDigitsCore b f n l2)
⊢ ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 →
      List.length (if n / b = 0 then digitChar (n % b) :: l1 else toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
        List.length (if n / b = 0 then digitChar (n % b) :: l2 else toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
[PROOFSTEP]
intro n l1 l2 hlen
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b f n l1) = List.length (toDigitsCore b f n l2)
n : ℕ
l1 l2 : List Char
hlen : List.length l1 = List.length l2
⊢ List.length (if n / b = 0 then digitChar (n % b) :: l1 else toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
    List.length (if n / b = 0 then digitChar (n % b) :: l2 else toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
[PROOFSTEP]

| succ f ih =>
  by_cases hx : n / b = 0
  case pos => simp only [hx, if_true, List.length, congrArg (fun l ↦ l + 1) hlen]
  case neg =>
    simp only [hx, if_false]
    specialize ih (n / b) (Nat.digitChar (n % b) :: l1) (Nat.digitChar (n % b) :: l2)
    simp only [List.length, congrArg (fun l ↦ l + 1) hlen] at ih
    exact ih trivial
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b f n l1) = List.length (toDigitsCore b f n l2)
n : ℕ
l1 l2 : List Char
hlen : List.length l1 = List.length l2
⊢ List.length (if n / b = 0 then digitChar (n % b) :: l1 else toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
    List.length (if n / b = 0 then digitChar (n % b) :: l2 else toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
[PROOFSTEP]
by_cases hx : n / b = 0
[GOAL]
case pos
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b f n l1) = List.length (toDigitsCore b f n l2)
n : ℕ
l1 l2 : List Char
hlen : List.length l1 = List.length l2
hx : n / b = 0
⊢ List.length (if n / b = 0 then digitChar (n % b) :: l1 else toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
    List.length (if n / b = 0 then digitChar (n % b) :: l2 else toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
case neg
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b f n l1) = List.length (toDigitsCore b f n l2)
n : ℕ
l1 l2 : List Char
hlen : List.length l1 = List.length l2
hx : ¬n / b = 0
⊢ List.length (if n / b = 0 then digitChar (n % b) :: l1 else toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
    List.length (if n / b = 0 then digitChar (n % b) :: l2 else toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
[PROOFSTEP]
case pos => simp only [hx, if_true, List.length, congrArg (fun l ↦ l + 1) hlen]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b f n l1) = List.length (toDigitsCore b f n l2)
n : ℕ
l1 l2 : List Char
hlen : List.length l1 = List.length l2
hx : n / b = 0
⊢ List.length (if n / b = 0 then digitChar (n % b) :: l1 else toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
    List.length (if n / b = 0 then digitChar (n % b) :: l2 else toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
[PROOFSTEP]
case pos => simp only [hx, if_true, List.length, congrArg (fun l ↦ l + 1) hlen]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b f n l1) = List.length (toDigitsCore b f n l2)
n : ℕ
l1 l2 : List Char
hlen : List.length l1 = List.length l2
hx : n / b = 0
⊢ List.length (if n / b = 0 then digitChar (n % b) :: l1 else toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
    List.length (if n / b = 0 then digitChar (n % b) :: l2 else toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
[PROOFSTEP]
simp only [hx, if_true, List.length, congrArg (fun l ↦ l + 1) hlen]
[GOAL]
case neg
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b f n l1) = List.length (toDigitsCore b f n l2)
n : ℕ
l1 l2 : List Char
hlen : List.length l1 = List.length l2
hx : ¬n / b = 0
⊢ List.length (if n / b = 0 then digitChar (n % b) :: l1 else toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
    List.length (if n / b = 0 then digitChar (n % b) :: l2 else toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
[PROOFSTEP]
case neg =>
  simp only [hx, if_false]
  specialize ih (n / b) (Nat.digitChar (n % b) :: l1) (Nat.digitChar (n % b) :: l2)
  simp only [List.length, congrArg (fun l ↦ l + 1) hlen] at ih
  exact ih trivial
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b f n l1) = List.length (toDigitsCore b f n l2)
n : ℕ
l1 l2 : List Char
hlen : List.length l1 = List.length l2
hx : ¬n / b = 0
⊢ List.length (if n / b = 0 then digitChar (n % b) :: l1 else toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
    List.length (if n / b = 0 then digitChar (n % b) :: l2 else toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
[PROOFSTEP]
case neg =>
  simp only [hx, if_false]
  specialize ih (n / b) (Nat.digitChar (n % b) :: l1) (Nat.digitChar (n % b) :: l2)
  simp only [List.length, congrArg (fun l ↦ l + 1) hlen] at ih
  exact ih trivial
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b f n l1) = List.length (toDigitsCore b f n l2)
n : ℕ
l1 l2 : List Char
hlen : List.length l1 = List.length l2
hx : ¬n / b = 0
⊢ List.length (if n / b = 0 then digitChar (n % b) :: l1 else toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
    List.length (if n / b = 0 then digitChar (n % b) :: l2 else toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
[PROOFSTEP]
simp only [hx, if_false]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (l1 l2 : List Char),
    List.length l1 = List.length l2 → List.length (toDigitsCore b f n l1) = List.length (toDigitsCore b f n l2)
n : ℕ
l1 l2 : List Char
hlen : List.length l1 = List.length l2
hx : ¬n / b = 0
⊢ List.length (toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
    List.length (toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
[PROOFSTEP]
specialize ih (n / b) (Nat.digitChar (n % b) :: l1) (Nat.digitChar (n % b) :: l2)
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f n : ℕ
l1 l2 : List Char
hlen : List.length l1 = List.length l2
hx : ¬n / b = 0
ih :
  List.length (digitChar (n % b) :: l1) = List.length (digitChar (n % b) :: l2) →
    List.length (toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
      List.length (toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
⊢ List.length (toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
    List.length (toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
[PROOFSTEP]
simp only [List.length, congrArg (fun l ↦ l + 1) hlen] at ih
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f n : ℕ
l1 l2 : List Char
hlen : List.length l1 = List.length l2
hx : ¬n / b = 0
ih :
  True →
    List.length (toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
      List.length (toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
⊢ List.length (toDigitsCore b f (n / b) (digitChar (n % b) :: l1)) =
    List.length (toDigitsCore b f (n / b) (digitChar (n % b) :: l2))
[PROOFSTEP]
exact ih trivial
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
⊢ ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
[PROOFSTEP]
induction f with (intro n c tl; simp only [Nat.toDigitsCore, List.length])
| succ f ih =>
  by_cases hnb : (n / b) = 0
  case pos => simp only [hnb, if_true, List.length]
  case neg =>
    generalize hx : Nat.digitChar (n % b) = x
    simp only [hx, hnb, if_false] at ih
    simp only [hnb, if_false]
    specialize ih (n / b) c (x :: tl)
    rw [← ih]
    have lens_eq : (x :: (c :: tl)).length = (c :: x :: tl).length := by simp
    apply to_digits_core_lens_eq_aux
    exact lens_eq
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
⊢ ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
[PROOFSTEP]
induction f with (intro n c tl; simp only [Nat.toDigitsCore, List.length])
| succ f ih =>
  by_cases hnb : (n / b) = 0
  case pos => simp only [hnb, if_true, List.length]
  case neg =>
    generalize hx : Nat.digitChar (n % b) = x
    simp only [hx, hnb, if_false] at ih
    simp only [hnb, if_false]
    specialize ih (n / b) c (x :: tl)
    rw [← ih]
    have lens_eq : (x :: (c :: tl)).length = (c :: x :: tl).length := by simp
    apply to_digits_core_lens_eq_aux
    exact lens_eq
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
⊢ ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b (succ f) n (c :: tl)) = List.length (toDigitsCore b (succ f) n tl) + 1
[PROOFSTEP]
intro n c tl
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
n : ℕ
c : Char
tl : List Char
⊢ List.length (toDigitsCore b (succ f) n (c :: tl)) = List.length (toDigitsCore b (succ f) n tl) + 1
[PROOFSTEP]
simp only [Nat.toDigitsCore, List.length]
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
n : ℕ
c : Char
tl : List Char
⊢ List.length
      (if n / b = 0 then digitChar (n % b) :: c :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: c :: tl)) =
    List.length (if n / b = 0 then digitChar (n % b) :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: tl)) + 1
[PROOFSTEP]

| succ f ih =>
  by_cases hnb : (n / b) = 0
  case pos => simp only [hnb, if_true, List.length]
  case neg =>
    generalize hx : Nat.digitChar (n % b) = x
    simp only [hx, hnb, if_false] at ih
    simp only [hnb, if_false]
    specialize ih (n / b) c (x :: tl)
    rw [← ih]
    have lens_eq : (x :: (c :: tl)).length = (c :: x :: tl).length := by simp
    apply to_digits_core_lens_eq_aux
    exact lens_eq
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
n : ℕ
c : Char
tl : List Char
⊢ List.length
      (if n / b = 0 then digitChar (n % b) :: c :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: c :: tl)) =
    List.length (if n / b = 0 then digitChar (n % b) :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: tl)) + 1
[PROOFSTEP]
by_cases hnb : (n / b) = 0
[GOAL]
case pos
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
n : ℕ
c : Char
tl : List Char
hnb : n / b = 0
⊢ List.length
      (if n / b = 0 then digitChar (n % b) :: c :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: c :: tl)) =
    List.length (if n / b = 0 then digitChar (n % b) :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: tl)) + 1
case neg
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
⊢ List.length
      (if n / b = 0 then digitChar (n % b) :: c :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: c :: tl)) =
    List.length (if n / b = 0 then digitChar (n % b) :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: tl)) + 1
[PROOFSTEP]
case pos => simp only [hnb, if_true, List.length]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
n : ℕ
c : Char
tl : List Char
hnb : n / b = 0
⊢ List.length
      (if n / b = 0 then digitChar (n % b) :: c :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: c :: tl)) =
    List.length (if n / b = 0 then digitChar (n % b) :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: tl)) + 1
[PROOFSTEP]
case pos => simp only [hnb, if_true, List.length]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
n : ℕ
c : Char
tl : List Char
hnb : n / b = 0
⊢ List.length
      (if n / b = 0 then digitChar (n % b) :: c :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: c :: tl)) =
    List.length (if n / b = 0 then digitChar (n % b) :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: tl)) + 1
[PROOFSTEP]
simp only [hnb, if_true, List.length]
[GOAL]
case neg
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
⊢ List.length
      (if n / b = 0 then digitChar (n % b) :: c :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: c :: tl)) =
    List.length (if n / b = 0 then digitChar (n % b) :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: tl)) + 1
[PROOFSTEP]
case neg =>
  generalize hx : Nat.digitChar (n % b) = x
  simp only [hx, hnb, if_false] at ih
  simp only [hnb, if_false]
  specialize ih (n / b) c (x :: tl)
  rw [← ih]
  have lens_eq : (x :: (c :: tl)).length = (c :: x :: tl).length := by simp
  apply to_digits_core_lens_eq_aux
  exact lens_eq
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
⊢ List.length
      (if n / b = 0 then digitChar (n % b) :: c :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: c :: tl)) =
    List.length (if n / b = 0 then digitChar (n % b) :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: tl)) + 1
[PROOFSTEP]
case neg =>
  generalize hx : Nat.digitChar (n % b) = x
  simp only [hx, hnb, if_false] at ih
  simp only [hnb, if_false]
  specialize ih (n / b) c (x :: tl)
  rw [← ih]
  have lens_eq : (x :: (c :: tl)).length = (c :: x :: tl).length := by simp
  apply to_digits_core_lens_eq_aux
  exact lens_eq
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
⊢ List.length
      (if n / b = 0 then digitChar (n % b) :: c :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: c :: tl)) =
    List.length (if n / b = 0 then digitChar (n % b) :: tl else toDigitsCore b f (n / b) (digitChar (n % b) :: tl)) + 1
[PROOFSTEP]
generalize hx : Nat.digitChar (n % b) = x
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : digitChar (n % b) = x
⊢ List.length (if n / b = 0 then x :: c :: tl else toDigitsCore b f (n / b) (x :: c :: tl)) =
    List.length (if n / b = 0 then x :: tl else toDigitsCore b f (n / b) (x :: tl)) + 1
[PROOFSTEP]
simp only [hx, hnb, if_false] at ih
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : digitChar (n % b) = x
⊢ List.length (if n / b = 0 then x :: c :: tl else toDigitsCore b f (n / b) (x :: c :: tl)) =
    List.length (if n / b = 0 then x :: tl else toDigitsCore b f (n / b) (x :: tl)) + 1
[PROOFSTEP]
simp only [hnb, if_false]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f : ℕ
ih :
  ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b f n (c :: tl)) = List.length (toDigitsCore b f n tl) + 1
n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : digitChar (n % b) = x
⊢ List.length (toDigitsCore b f (n / b) (x :: c :: tl)) = List.length (toDigitsCore b f (n / b) (x :: tl)) + 1
[PROOFSTEP]
specialize ih (n / b) c (x :: tl)
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : digitChar (n % b) = x
ih : List.length (toDigitsCore b f (n / b) (c :: x :: tl)) = List.length (toDigitsCore b f (n / b) (x :: tl)) + 1
⊢ List.length (toDigitsCore b f (n / b) (x :: c :: tl)) = List.length (toDigitsCore b f (n / b) (x :: tl)) + 1
[PROOFSTEP]
rw [← ih]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : digitChar (n % b) = x
ih : List.length (toDigitsCore b f (n / b) (c :: x :: tl)) = List.length (toDigitsCore b f (n / b) (x :: tl)) + 1
⊢ List.length (toDigitsCore b f (n / b) (x :: c :: tl)) = List.length (toDigitsCore b f (n / b) (c :: x :: tl))
[PROOFSTEP]
have lens_eq : (x :: (c :: tl)).length = (c :: x :: tl).length := by simp
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : digitChar (n % b) = x
ih : List.length (toDigitsCore b f (n / b) (c :: x :: tl)) = List.length (toDigitsCore b f (n / b) (x :: tl)) + 1
⊢ List.length (x :: c :: tl) = List.length (c :: x :: tl)
[PROOFSTEP]
simp
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : digitChar (n % b) = x
ih : List.length (toDigitsCore b f (n / b) (c :: x :: tl)) = List.length (toDigitsCore b f (n / b) (x :: tl)) + 1
lens_eq : List.length (x :: c :: tl) = List.length (c :: x :: tl)
⊢ List.length (toDigitsCore b f (n / b) (x :: c :: tl)) = List.length (toDigitsCore b f (n / b) (c :: x :: tl))
[PROOFSTEP]
apply to_digits_core_lens_eq_aux
[GOAL]
case a
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b f n : ℕ
c : Char
tl : List Char
hnb : ¬n / b = 0
x : Char
hx : digitChar (n % b) = x
ih : List.length (toDigitsCore b f (n / b) (c :: x :: tl)) = List.length (toDigitsCore b f (n / b) (x :: tl)) + 1
lens_eq : List.length (x :: c :: tl) = List.length (c :: x :: tl)
⊢ List.length (x :: c :: tl) = List.length (c :: x :: tl)
[PROOFSTEP]
exact lens_eq
[GOAL]
case zero
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
⊢ ∀ (n : ℕ) (c : Char) (tl : List Char),
    List.length (toDigitsCore b zero n (c :: tl)) = List.length (toDigitsCore b zero n tl) + 1
[PROOFSTEP]
intro n c tl
[GOAL]
case zero
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b n : ℕ
c : Char
tl : List Char
⊢ List.length (toDigitsCore b zero n (c :: tl)) = List.length (toDigitsCore b zero n tl) + 1
[PROOFSTEP]
simp only [Nat.toDigitsCore, List.length]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
n b e : ℕ
h_b_pos : 0 < b
⊢ n < b ^ succ e → n / b < b ^ e
[PROOFSTEP]
simp only [Nat.pow_succ]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
n b e : ℕ
h_b_pos : 0 < b
⊢ n < b ^ e * b → n / b < b ^ e
[PROOFSTEP]
exact (@Nat.div_lt_iff_lt_mul b n (b ^ e) h_b_pos).mpr
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f n e : ℕ
hlt : n < b ^ e
h_e_pos : 0 < e
⊢ List.length (toDigitsCore b f n []) ≤ e
[PROOFSTEP]
induction f generalizing n e hlt h_e_pos with simp only [Nat.toDigitsCore, List.length, Nat.zero_le]
| succ f ih =>
  cases e with
  | zero => exact False.elim (Nat.lt_irrefl 0 h_e_pos)
  | succ e =>
    by_cases h_pred_pos : 0 < e
    case pos =>
      have _ : 0 < b := Nat.lt_trans (by decide) h
      specialize ih (n / b) e (nat_repr_len_aux n b e ‹0 < b› hlt) h_pred_pos
      by_cases hdiv_ten : n / b = 0
      case pos => simp only [hdiv_ten]; exact Nat.le.step h_pred_pos
      case neg =>
        simp only [hdiv_ten, to_digits_core_lens_eq b f (n / b) (Nat.digitChar $ n % b), if_false]
        exact Nat.succ_le_succ ih
    case neg =>
      have _ : e = 0 := Nat.eq_zero_of_nonpos e h_pred_pos
      rw [‹e = 0›]
      have _ : b ^ 1 = b := by simp only [pow_succ, pow_zero, Nat.one_mul]
      have _ : n < b := ‹b ^ 1 = b› ▸ (‹e = 0› ▸ hlt : n < b ^ Nat.succ 0)
      simp only [(@Nat.div_eq_of_lt n b ‹n < b› : n / b = 0), if_true, List.length]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f n e : ℕ
hlt : n < b ^ e
h_e_pos : 0 < e
⊢ List.length (toDigitsCore b f n []) ≤ e
[PROOFSTEP]
induction f generalizing n e hlt h_e_pos with simp only [Nat.toDigitsCore, List.length, Nat.zero_le]
| succ f ih =>
  cases e with
  | zero => exact False.elim (Nat.lt_irrefl 0 h_e_pos)
  | succ e =>
    by_cases h_pred_pos : 0 < e
    case pos =>
      have _ : 0 < b := Nat.lt_trans (by decide) h
      specialize ih (n / b) e (nat_repr_len_aux n b e ‹0 < b› hlt) h_pred_pos
      by_cases hdiv_ten : n / b = 0
      case pos => simp only [hdiv_ten]; exact Nat.le.step h_pred_pos
      case neg =>
        simp only [hdiv_ten, to_digits_core_lens_eq b f (n / b) (Nat.digitChar $ n % b), if_false]
        exact Nat.succ_le_succ ih
    case neg =>
      have _ : e = 0 := Nat.eq_zero_of_nonpos e h_pred_pos
      rw [‹e = 0›]
      have _ : b ^ 1 = b := by simp only [pow_succ, pow_zero, Nat.one_mul]
      have _ : n < b := ‹b ^ 1 = b› ▸ (‹e = 0› ▸ hlt : n < b ^ Nat.succ 0)
      simp only [(@Nat.div_eq_of_lt n b ‹n < b› : n / b = 0), if_true, List.length]
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ e
h_e_pos : 0 < e
⊢ List.length (toDigitsCore b (succ f) n []) ≤ e
[PROOFSTEP]
simp only [Nat.toDigitsCore, List.length, Nat.zero_le]
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ e
h_e_pos : 0 < e
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ e
[PROOFSTEP]

| succ f ih =>
  cases e with
  | zero => exact False.elim (Nat.lt_irrefl 0 h_e_pos)
  | succ e =>
    by_cases h_pred_pos : 0 < e
    case pos =>
      have _ : 0 < b := Nat.lt_trans (by decide) h
      specialize ih (n / b) e (nat_repr_len_aux n b e ‹0 < b› hlt) h_pred_pos
      by_cases hdiv_ten : n / b = 0
      case pos => simp only [hdiv_ten]; exact Nat.le.step h_pred_pos
      case neg =>
        simp only [hdiv_ten, to_digits_core_lens_eq b f (n / b) (Nat.digitChar $ n % b), if_false]
        exact Nat.succ_le_succ ih
    case neg =>
      have _ : e = 0 := Nat.eq_zero_of_nonpos e h_pred_pos
      rw [‹e = 0›]
      have _ : b ^ 1 = b := by simp only [pow_succ, pow_zero, Nat.one_mul]
      have _ : n < b := ‹b ^ 1 = b› ▸ (‹e = 0› ▸ hlt : n < b ^ Nat.succ 0)
      simp only [(@Nat.div_eq_of_lt n b ‹n < b› : n / b = 0), if_true, List.length]
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ e
h_e_pos : 0 < e
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ e
[PROOFSTEP]
cases e with
| zero => exact False.elim (Nat.lt_irrefl 0 h_e_pos)
| succ e =>
  by_cases h_pred_pos : 0 < e
  case pos =>
    have _ : 0 < b := Nat.lt_trans (by decide) h
    specialize ih (n / b) e (nat_repr_len_aux n b e ‹0 < b› hlt) h_pred_pos
    by_cases hdiv_ten : n / b = 0
    case pos => simp only [hdiv_ten]; exact Nat.le.step h_pred_pos
    case neg =>
      simp only [hdiv_ten, to_digits_core_lens_eq b f (n / b) (Nat.digitChar $ n % b), if_false]
      exact Nat.succ_le_succ ih
  case neg =>
    have _ : e = 0 := Nat.eq_zero_of_nonpos e h_pred_pos
    rw [‹e = 0›]
    have _ : b ^ 1 = b := by simp only [pow_succ, pow_zero, Nat.one_mul]
    have _ : n < b := ‹b ^ 1 = b› ▸ (‹e = 0› ▸ hlt : n < b ^ Nat.succ 0)
    simp only [(@Nat.div_eq_of_lt n b ‹n < b› : n / b = 0), if_true, List.length]
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ e
h_e_pos : 0 < e
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ e
[PROOFSTEP]
cases e with
| zero => exact False.elim (Nat.lt_irrefl 0 h_e_pos)
| succ e =>
  by_cases h_pred_pos : 0 < e
  case pos =>
    have _ : 0 < b := Nat.lt_trans (by decide) h
    specialize ih (n / b) e (nat_repr_len_aux n b e ‹0 < b› hlt) h_pred_pos
    by_cases hdiv_ten : n / b = 0
    case pos => simp only [hdiv_ten]; exact Nat.le.step h_pred_pos
    case neg =>
      simp only [hdiv_ten, to_digits_core_lens_eq b f (n / b) (Nat.digitChar $ n % b), if_false]
      exact Nat.succ_le_succ ih
  case neg =>
    have _ : e = 0 := Nat.eq_zero_of_nonpos e h_pred_pos
    rw [‹e = 0›]
    have _ : b ^ 1 = b := by simp only [pow_succ, pow_zero, Nat.one_mul]
    have _ : n < b := ‹b ^ 1 = b› ▸ (‹e = 0› ▸ hlt : n < b ^ Nat.succ 0)
    simp only [(@Nat.div_eq_of_lt n b ‹n < b› : n / b = 0), if_true, List.length]
[GOAL]
case succ.zero
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n : ℕ
hlt : n < b ^ zero
h_e_pos : 0 < zero
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ zero
[PROOFSTEP]

| zero => exact False.elim (Nat.lt_irrefl 0 h_e_pos)
[GOAL]
case succ.zero
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n : ℕ
hlt : n < b ^ zero
h_e_pos : 0 < zero
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ zero
[PROOFSTEP]
exact False.elim (Nat.lt_irrefl 0 h_e_pos)
[GOAL]
case succ.succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]

| succ e =>
  by_cases h_pred_pos : 0 < e
  case pos =>
    have _ : 0 < b := Nat.lt_trans (by decide) h
    specialize ih (n / b) e (nat_repr_len_aux n b e ‹0 < b› hlt) h_pred_pos
    by_cases hdiv_ten : n / b = 0
    case pos => simp only [hdiv_ten]; exact Nat.le.step h_pred_pos
    case neg =>
      simp only [hdiv_ten, to_digits_core_lens_eq b f (n / b) (Nat.digitChar $ n % b), if_false]
      exact Nat.succ_le_succ ih
  case neg =>
    have _ : e = 0 := Nat.eq_zero_of_nonpos e h_pred_pos
    rw [‹e = 0›]
    have _ : b ^ 1 = b := by simp only [pow_succ, pow_zero, Nat.one_mul]
    have _ : n < b := ‹b ^ 1 = b› ▸ (‹e = 0› ▸ hlt : n < b ^ Nat.succ 0)
    simp only [(@Nat.div_eq_of_lt n b ‹n < b› : n / b = 0), if_true, List.length]
[GOAL]
case succ.succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
by_cases h_pred_pos : 0 < e
[GOAL]
case pos
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
case neg
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : ¬0 < e
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
case pos =>
  have _ : 0 < b := Nat.lt_trans (by decide) h
  specialize ih (n / b) e (nat_repr_len_aux n b e ‹0 < b› hlt) h_pred_pos
  by_cases hdiv_ten : n / b = 0
  case pos => simp only [hdiv_ten]; exact Nat.le.step h_pred_pos
  case neg =>
    simp only [hdiv_ten, to_digits_core_lens_eq b f (n / b) (Nat.digitChar $ n % b), if_false]
    exact Nat.succ_le_succ ih
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
case pos =>
  have _ : 0 < b := Nat.lt_trans (by decide) h
  specialize ih (n / b) e (nat_repr_len_aux n b e ‹0 < b› hlt) h_pred_pos
  by_cases hdiv_ten : n / b = 0
  case pos => simp only [hdiv_ten]; exact Nat.le.step h_pred_pos
  case neg =>
    simp only [hdiv_ten, to_digits_core_lens_eq b f (n / b) (Nat.digitChar $ n % b), if_false]
    exact Nat.succ_le_succ ih
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
have _ : 0 < b := Nat.lt_trans (by decide) h
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
⊢ 0 < 1
[PROOFSTEP]
decide
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
x✝ : 0 < b
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
specialize ih (n / b) e (nat_repr_len_aux n b e ‹0 < b› hlt) h_pred_pos
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
x✝ : 0 < b
ih : List.length (toDigitsCore b f (n / b) []) ≤ e
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
by_cases hdiv_ten : n / b = 0
[GOAL]
case pos
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
x✝ : 0 < b
ih : List.length (toDigitsCore b f (n / b) []) ≤ e
hdiv_ten : n / b = 0
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
case neg
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
x✝ : 0 < b
ih : List.length (toDigitsCore b f (n / b) []) ≤ e
hdiv_ten : ¬n / b = 0
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
case pos => simp only [hdiv_ten]; exact Nat.le.step h_pred_pos
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
x✝ : 0 < b
ih : List.length (toDigitsCore b f (n / b) []) ≤ e
hdiv_ten : n / b = 0
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
case pos => simp only [hdiv_ten]; exact Nat.le.step h_pred_pos
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
x✝ : 0 < b
ih : List.length (toDigitsCore b f (n / b) []) ≤ e
hdiv_ten : n / b = 0
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
simp only [hdiv_ten]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
x✝ : 0 < b
ih : List.length (toDigitsCore b f (n / b) []) ≤ e
hdiv_ten : n / b = 0
⊢ List.length (if True then [digitChar (n % b)] else toDigitsCore b f 0 [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
exact Nat.le.step h_pred_pos
[GOAL]
case neg
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
x✝ : 0 < b
ih : List.length (toDigitsCore b f (n / b) []) ≤ e
hdiv_ten : ¬n / b = 0
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
case neg =>
  simp only [hdiv_ten, to_digits_core_lens_eq b f (n / b) (Nat.digitChar $ n % b), if_false]
  exact Nat.succ_le_succ ih
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
x✝ : 0 < b
ih : List.length (toDigitsCore b f (n / b) []) ≤ e
hdiv_ten : ¬n / b = 0
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
case neg =>
  simp only [hdiv_ten, to_digits_core_lens_eq b f (n / b) (Nat.digitChar $ n % b), if_false]
  exact Nat.succ_le_succ ih
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
x✝ : 0 < b
ih : List.length (toDigitsCore b f (n / b) []) ≤ e
hdiv_ten : ¬n / b = 0
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
simp only [hdiv_ten, to_digits_core_lens_eq b f (n / b) (Nat.digitChar $ n % b), if_false]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : 0 < e
x✝ : 0 < b
ih : List.length (toDigitsCore b f (n / b) []) ≤ e
hdiv_ten : ¬n / b = 0
⊢ List.length (toDigitsCore b f (n / b) []) + 1 ≤ succ e
[PROOFSTEP]
exact Nat.succ_le_succ ih
[GOAL]
case neg
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : ¬0 < e
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
case neg =>
  have _ : e = 0 := Nat.eq_zero_of_nonpos e h_pred_pos
  rw [‹e = 0›]
  have _ : b ^ 1 = b := by simp only [pow_succ, pow_zero, Nat.one_mul]
  have _ : n < b := ‹b ^ 1 = b› ▸ (‹e = 0› ▸ hlt : n < b ^ Nat.succ 0)
  simp only [(@Nat.div_eq_of_lt n b ‹n < b› : n / b = 0), if_true, List.length]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : ¬0 < e
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
case neg =>
  have _ : e = 0 := Nat.eq_zero_of_nonpos e h_pred_pos
  rw [‹e = 0›]
  have _ : b ^ 1 = b := by simp only [pow_succ, pow_zero, Nat.one_mul]
  have _ : n < b := ‹b ^ 1 = b› ▸ (‹e = 0› ▸ hlt : n < b ^ Nat.succ 0)
  simp only [(@Nat.div_eq_of_lt n b ‹n < b› : n / b = 0), if_true, List.length]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : ¬0 < e
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
have _ : e = 0 := Nat.eq_zero_of_nonpos e h_pred_pos
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : ¬0 < e
x✝ : e = 0
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ e
[PROOFSTEP]
rw [‹e = 0›]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : ¬0 < e
x✝ : e = 0
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ 0
[PROOFSTEP]
have _ : b ^ 1 = b := by simp only [pow_succ, pow_zero, Nat.one_mul]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : ¬0 < e
x✝ : e = 0
⊢ b ^ 1 = b
[PROOFSTEP]
simp only [pow_succ, pow_zero, Nat.one_mul]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : ¬0 < e
x✝¹ : e = 0
x✝ : b ^ 1 = b
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ 0
[PROOFSTEP]
have _ : n < b := ‹b ^ 1 = b› ▸ (‹e = 0› ▸ hlt : n < b ^ Nat.succ 0)
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
f : ℕ
ih : ∀ (n e : ℕ), n < b ^ e → 0 < e → List.length (toDigitsCore b f n []) ≤ e
n e : ℕ
hlt : n < b ^ succ e
h_e_pos : 0 < succ e
h_pred_pos : ¬0 < e
x✝² : e = 0
x✝¹ : b ^ 1 = b
x✝ : n < b
⊢ List.length (if n / b = 0 then [digitChar (n % b)] else toDigitsCore b f (n / b) [digitChar (n % b)]) ≤ succ 0
[PROOFSTEP]
simp only [(@Nat.div_eq_of_lt n b ‹n < b› : n / b = 0), if_true, List.length]
[GOAL]
case zero
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
b : ℕ
h : 2 ≤ b
n e : ℕ
hlt : n < b ^ e
h_e_pos : 0 < e
⊢ List.length (toDigitsCore b zero n []) ≤ e
[PROOFSTEP]
simp only [Nat.toDigitsCore, List.length, Nat.zero_le]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
n e : ℕ
⊢ 0 < e → n < 10 ^ e → String.length (Nat.repr n) ≤ e
[PROOFSTEP]
cases n with (intro e0 he; simp only [Nat.repr, Nat.toDigits, String.length, List.asString])
| zero => assumption
| succ n =>
  by_cases hterm : n.succ / 10 = 0
  case pos => simp only [hterm, Nat.toDigitsCore]; assumption
  case neg => exact to_digits_core_length 10 (by decide) (Nat.succ n + 1) (Nat.succ n) e he e0
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
n e : ℕ
⊢ 0 < e → n < 10 ^ e → String.length (Nat.repr n) ≤ e
[PROOFSTEP]
cases n with (intro e0 he; simp only [Nat.repr, Nat.toDigits, String.length, List.asString])
| zero => assumption
| succ n =>
  by_cases hterm : n.succ / 10 = 0
  case pos => simp only [hterm, Nat.toDigitsCore]; assumption
  case neg => exact to_digits_core_length 10 (by decide) (Nat.succ n + 1) (Nat.succ n) e he e0
[GOAL]
case zero
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e : ℕ
⊢ 0 < e → zero < 10 ^ e → String.length (Nat.repr zero) ≤ e
[PROOFSTEP]
intro e0 he
[GOAL]
case zero
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e : ℕ
e0 : 0 < e
he : zero < 10 ^ e
⊢ String.length (Nat.repr zero) ≤ e
[PROOFSTEP]
simp only [Nat.repr, Nat.toDigits, String.length, List.asString]
[GOAL]
case zero
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e : ℕ
e0 : 0 < e
he : zero < 10 ^ e
⊢ List.length (toDigitsCore 10 (zero + 1) zero []) ≤ e
[PROOFSTEP]

| zero => assumption
[GOAL]
case zero
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e : ℕ
e0 : 0 < e
he : zero < 10 ^ e
⊢ List.length (toDigitsCore 10 (zero + 1) zero []) ≤ e
[PROOFSTEP]
assumption
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e n : ℕ
⊢ 0 < e → succ n < 10 ^ e → String.length (Nat.repr (succ n)) ≤ e
[PROOFSTEP]
intro e0 he
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e n : ℕ
e0 : 0 < e
he : succ n < 10 ^ e
⊢ String.length (Nat.repr (succ n)) ≤ e
[PROOFSTEP]
simp only [Nat.repr, Nat.toDigits, String.length, List.asString]
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e n : ℕ
e0 : 0 < e
he : succ n < 10 ^ e
⊢ List.length (toDigitsCore 10 (succ n + 1) (succ n) []) ≤ e
[PROOFSTEP]

| succ n =>
  by_cases hterm : n.succ / 10 = 0
  case pos => simp only [hterm, Nat.toDigitsCore]; assumption
  case neg => exact to_digits_core_length 10 (by decide) (Nat.succ n + 1) (Nat.succ n) e he e0
[GOAL]
case succ
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e n : ℕ
e0 : 0 < e
he : succ n < 10 ^ e
⊢ List.length (toDigitsCore 10 (succ n + 1) (succ n) []) ≤ e
[PROOFSTEP]
by_cases hterm : n.succ / 10 = 0
[GOAL]
case pos
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e n : ℕ
e0 : 0 < e
he : succ n < 10 ^ e
hterm : succ n / 10 = 0
⊢ List.length (toDigitsCore 10 (succ n + 1) (succ n) []) ≤ e
case neg
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e n : ℕ
e0 : 0 < e
he : succ n < 10 ^ e
hterm : ¬succ n / 10 = 0
⊢ List.length (toDigitsCore 10 (succ n + 1) (succ n) []) ≤ e
[PROOFSTEP]
case pos => simp only [hterm, Nat.toDigitsCore]; assumption
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e n : ℕ
e0 : 0 < e
he : succ n < 10 ^ e
hterm : succ n / 10 = 0
⊢ List.length (toDigitsCore 10 (succ n + 1) (succ n) []) ≤ e
[PROOFSTEP]
case pos => simp only [hterm, Nat.toDigitsCore]; assumption
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e n : ℕ
e0 : 0 < e
he : succ n < 10 ^ e
hterm : succ n / 10 = 0
⊢ List.length (toDigitsCore 10 (succ n + 1) (succ n) []) ≤ e
[PROOFSTEP]
simp only [hterm, Nat.toDigitsCore]
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e n : ℕ
e0 : 0 < e
he : succ n < 10 ^ e
hterm : succ n / 10 = 0
⊢ List.length
      (if True then [digitChar (succ n % 10)]
      else
        if True then [digitChar (0 % 10), digitChar (succ n % 10)]
        else toDigitsCore 10 n (0 / 10) [digitChar (0 % 10), digitChar (succ n % 10)]) ≤
    e
[PROOFSTEP]
assumption
[GOAL]
case neg
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e n : ℕ
e0 : 0 < e
he : succ n < 10 ^ e
hterm : ¬succ n / 10 = 0
⊢ List.length (toDigitsCore 10 (succ n + 1) (succ n) []) ≤ e
[PROOFSTEP]
case neg => exact to_digits_core_length 10 (by decide) (Nat.succ n + 1) (Nat.succ n) e he e0
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e n : ℕ
e0 : 0 < e
he : succ n < 10 ^ e
hterm : ¬succ n / 10 = 0
⊢ List.length (toDigitsCore 10 (succ n + 1) (succ n) []) ≤ e
[PROOFSTEP]
case neg => exact to_digits_core_length 10 (by decide) (Nat.succ n + 1) (Nat.succ n) e he e0
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e n : ℕ
e0 : 0 < e
he : succ n < 10 ^ e
hterm : ¬succ n / 10 = 0
⊢ List.length (toDigitsCore 10 (succ n + 1) (succ n) []) ≤ e
[PROOFSTEP]
exact to_digits_core_length 10 (by decide) (Nat.succ n + 1) (Nat.succ n) e he e0
[GOAL]
p : ℕ → Prop
inst✝ : DecidablePred p
H : ∃ n, p n
e n : ℕ
e0 : 0 < e
he : succ n < 10 ^ e
hterm : ¬succ n / 10 = 0
⊢ 2 ≤ 10
[PROOFSTEP]
decide


[GOAL]
α : Type u_1
inst✝ : NonUnitalNonAssocRing α
k : α
h : ∀ (x : α), k * x = 0 → x = 0
⊢ IsLeftRegular k
[PROOFSTEP]
refine' fun x y (h' : k * x = k * y) => sub_eq_zero.mp (h _ _)
[GOAL]
α : Type u_1
inst✝ : NonUnitalNonAssocRing α
k : α
h : ∀ (x : α), k * x = 0 → x = 0
x y : α
h' : k * x = k * y
⊢ k * (x - y) = 0
[PROOFSTEP]
rw [mul_sub, sub_eq_zero, h']
[GOAL]
α : Type u_1
inst✝ : NonUnitalNonAssocRing α
k : α
h : ∀ (x : α), x * k = 0 → x = 0
⊢ IsRightRegular k
[PROOFSTEP]
refine' fun x y (h' : x * k = y * k) => sub_eq_zero.mp (h _ _)
[GOAL]
α : Type u_1
inst✝ : NonUnitalNonAssocRing α
k : α
h : ∀ (x : α), x * k = 0 → x = 0
x y : α
h' : x * k = y * k
⊢ (x - y) * k = 0
[PROOFSTEP]
rw [sub_mul, sub_eq_zero, h']
[GOAL]
α : Type u_1
inst✝² : Nontrivial α
inst✝¹ : NonUnitalNonAssocRing α
inst✝ : NoZeroDivisors α
k : α
h : IsRegular k
⊢ k ≠ 0
[PROOFSTEP]
rintro rfl
[GOAL]
α : Type u_1
inst✝² : Nontrivial α
inst✝¹ : NonUnitalNonAssocRing α
inst✝ : NoZeroDivisors α
h : IsRegular 0
⊢ False
[PROOFSTEP]
exact not_not.mpr h.left not_isLeftRegular_zero
[GOAL]
α : Type u_1
inst✝¹ : Ring α
inst✝ : NoZeroDivisors α
⊢ MonoidWithZero α
[PROOFSTEP]
infer_instance


[GOAL]
R : Type u_1
inst✝¹ : CommRing R
p : ℕ
inst✝ : CharP R p
I : Ideal R
h : ∀ (x : ℕ), ↑x ∈ I → ↑x = 0
x : ℕ
⊢ ↑x = 0 ↔ p ∣ x
[PROOFSTEP]
rw [← cast_eq_zero_iff R p x, ← map_natCast (Ideal.Quotient.mk I)]
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
p : ℕ
inst✝ : CharP R p
I : Ideal R
h : ∀ (x : ℕ), ↑x ∈ I → ↑x = 0
x : ℕ
⊢ ↑(Ideal.Quotient.mk I) ↑x = 0 ↔ ↑x = 0
[PROOFSTEP]
refine' Ideal.Quotient.eq.trans (_ : ↑x - 0 ∈ I ↔ _)
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
p : ℕ
inst✝ : CharP R p
I : Ideal R
h : ∀ (x : ℕ), ↑x ∈ I → ↑x = 0
x : ℕ
⊢ ↑x - 0 ∈ I ↔ ↑x = 0
[PROOFSTEP]
rw [sub_zero]
[GOAL]
R : Type u_1
inst✝¹ : CommRing R
p : ℕ
inst✝ : CharP R p
I : Ideal R
h : ∀ (x : ℕ), ↑x ∈ I → ↑x = 0
x : ℕ
⊢ ↑x ∈ I ↔ ↑x = 0
[PROOFSTEP]
exact ⟨h x, fun h' => h'.symm ▸ I.zero_mem⟩
[GOAL]
R : Type u_1
inst✝ : CommRing R
I : Ideal R
⊢ ↑(AddSubgroup.index (Submodule.toAddSubgroup I)) = 0
[PROOFSTEP]
rw [AddSubgroup.index, Nat.card_eq]
[GOAL]
R : Type u_1
inst✝ : CommRing R
I : Ideal R
⊢ ↑(if h : Finite (R ⧸ Submodule.toAddSubgroup I) then Fintype.card (R ⧸ Submodule.toAddSubgroup I) else 0) = 0
[PROOFSTEP]
split_ifs with hq
[GOAL]
case pos
R : Type u_1
inst✝ : CommRing R
I : Ideal R
hq : Finite (R ⧸ Submodule.toAddSubgroup I)
⊢ ↑(Fintype.card (R ⧸ Submodule.toAddSubgroup I)) = 0
case neg R : Type u_1 inst✝ : CommRing R I : Ideal R hq : ¬Finite (R ⧸ Submodule.toAddSubgroup I) ⊢ ↑0 = 0
[PROOFSTEP]
swap
[GOAL]
case neg
R : Type u_1
inst✝ : CommRing R
I : Ideal R
hq : ¬Finite (R ⧸ Submodule.toAddSubgroup I)
⊢ ↑0 = 0
case pos
R : Type u_1
inst✝ : CommRing R
I : Ideal R
hq : Finite (R ⧸ Submodule.toAddSubgroup I)
⊢ ↑(Fintype.card (R ⧸ Submodule.toAddSubgroup I)) = 0
[PROOFSTEP]
simp
[GOAL]
case pos
R : Type u_1
inst✝ : CommRing R
I : Ideal R
hq : Finite (R ⧸ Submodule.toAddSubgroup I)
⊢ ↑(Fintype.card (R ⧸ Submodule.toAddSubgroup I)) = 0
[PROOFSTEP]
by_contra h
[GOAL]
case pos
R : Type u_1
inst✝ : CommRing R
I : Ideal R
hq : Finite (R ⧸ Submodule.toAddSubgroup I)
h : ¬↑(Fintype.card (R ⧸ Submodule.toAddSubgroup I)) = 0
⊢ False
[PROOFSTEP]
letI : Fintype (R ⧸ I) := @Fintype.ofFinite _ hq
[GOAL]
case pos
R : Type u_1
inst✝ : CommRing R
I : Ideal R
hq : Finite (R ⧸ Submodule.toAddSubgroup I)
h : ¬↑(Fintype.card (R ⧸ Submodule.toAddSubgroup I)) = 0
this : Fintype (R ⧸ I) := Fintype.ofFinite (R ⧸ I)
⊢ False
[PROOFSTEP]
have h : (Fintype.card (R ⧸ I) : R ⧸ I) ≠ 0 := h
[GOAL]
case pos
R : Type u_1
inst✝ : CommRing R
I : Ideal R
hq : Finite (R ⧸ Submodule.toAddSubgroup I)
h✝ : ¬↑(Fintype.card (R ⧸ Submodule.toAddSubgroup I)) = 0
this : Fintype (R ⧸ I) := Fintype.ofFinite (R ⧸ I)
h : ↑(Fintype.card (R ⧸ I)) ≠ 0
⊢ False
[PROOFSTEP]
simp at h


[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝³ : Zero R
inst✝² : One R
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
a : α
e : Sym2 α
⊢ incMatrix R G a e = if e ∈ incidenceSet G a then 1 else 0
[PROOFSTEP]
unfold incMatrix Set.indicator
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝³ : Zero R
inst✝² : One R
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
a : α
e : Sym2 α
⊢ (if e ∈ incidenceSet G a then OfNat.ofNat 1 e else 0) = if e ∈ incidenceSet G a then 1 else 0
[PROOFSTEP]
simp only [Pi.one_apply]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝ : MulZeroOneClass R
a b : α
e : Sym2 α
⊢ incMatrix R G a e * incMatrix R G b e = Set.indicator (incidenceSet G a ∩ incidenceSet G b) 1 e
[PROOFSTEP]
classical simp only [incMatrix, Set.indicator_apply, ← ite_and_mul_zero, Pi.one_apply, mul_one, Set.mem_inter_iff]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝ : MulZeroOneClass R
a b : α
e : Sym2 α
⊢ incMatrix R G a e * incMatrix R G b e = Set.indicator (incidenceSet G a ∩ incidenceSet G b) 1 e
[PROOFSTEP]
simp only [incMatrix, Set.indicator_apply, ← ite_and_mul_zero, Pi.one_apply, mul_one, Set.mem_inter_iff]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝ : MulZeroOneClass R
a b : α
e : Sym2 α
hab : a ≠ b
h : ¬Adj G a b
⊢ incMatrix R G a e * incMatrix R G b e = 0
[PROOFSTEP]
rw [incMatrix_apply_mul_incMatrix_apply, Set.indicator_of_not_mem]
[GOAL]
case h
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝ : MulZeroOneClass R
a b : α
e : Sym2 α
hab : a ≠ b
h : ¬Adj G a b
⊢ ¬e ∈ incidenceSet G a ∩ incidenceSet G b
[PROOFSTEP]
rw [G.incidenceSet_inter_incidenceSet_of_not_adj h hab]
[GOAL]
case h
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝ : MulZeroOneClass R
a b : α
e : Sym2 α
hab : a ≠ b
h : ¬Adj G a b
⊢ ¬e ∈ ∅
[PROOFSTEP]
exact Set.not_mem_empty e
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝ : MulZeroOneClass R
a b : α
e : Sym2 α
h : ¬e ∈ incidenceSet G a
⊢ incMatrix R G a e = 0
[PROOFSTEP]
rw [incMatrix_apply, Set.indicator_of_not_mem h]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝ : MulZeroOneClass R
a b : α
e : Sym2 α
h : e ∈ incidenceSet G a
⊢ incMatrix R G a e = 1
[PROOFSTEP]
rw [incMatrix_apply, Set.indicator_of_mem h, Pi.one_apply]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
⊢ incMatrix R G a e = 0 ↔ ¬e ∈ incidenceSet G a
[PROOFSTEP]
simp only [incMatrix_apply, Set.indicator_apply_eq_zero, Pi.one_apply, one_ne_zero]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
⊢ incMatrix R G a e = 1 ↔ e ∈ incidenceSet G a
[PROOFSTEP]
unfold incMatrix Set.indicator
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
⊢ (if e ∈ incidenceSet G a then OfNat.ofNat 1 e else 0) = 1 ↔ e ∈ incidenceSet G a
[PROOFSTEP]
simp only [Pi.one_apply]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
⊢ (if e ∈ incidenceSet G a then 1 else 0) = 1 ↔ e ∈ incidenceSet G a
[PROOFSTEP]
apply Iff.intro
[GOAL]
case mp
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
⊢ (if e ∈ incidenceSet G a then 1 else 0) = 1 → e ∈ incidenceSet G a
[PROOFSTEP]
intro h
[GOAL]
case mpr
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
⊢ e ∈ incidenceSet G a → (if e ∈ incidenceSet G a then 1 else 0) = 1
[PROOFSTEP]
intro h
[GOAL]
case mp
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
h : (if e ∈ incidenceSet G a then 1 else 0) = 1
⊢ e ∈ incidenceSet G a
[PROOFSTEP]
split at h
[GOAL]
case mp.inl
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
h✝ : e ∈ incidenceSet G a
h : 1 = 1
⊢ e ∈ incidenceSet G a
[PROOFSTEP]
simp_all only [zero_ne_one]
[GOAL]
case mp.inr
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
h✝ : ¬e ∈ incidenceSet G a
h : 0 = 1
⊢ e ∈ incidenceSet G a
[PROOFSTEP]
simp_all only [zero_ne_one]
[GOAL]
case mpr
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : MulZeroOneClass R
a b : α
e : Sym2 α
inst✝ : Nontrivial R
h : e ∈ incidenceSet G a
⊢ (if e ∈ incidenceSet G a then 1 else 0) = 1
[PROOFSTEP]
simp_all only [ite_true]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝³ : Fintype α
inst✝² : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
⊢ ∑ e : Sym2 α, incMatrix R G a e = ↑(degree G a)
[PROOFSTEP]
simp [incMatrix_apply', sum_boole, Set.filter_mem_univ_eq_toFinset]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝³ : Fintype α
inst✝² : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
⊢ (incMatrix R G * (incMatrix R G)ᵀ) a a = ↑(degree G a)
[PROOFSTEP]
rw [← sum_incMatrix_apply]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝³ : Fintype α
inst✝² : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
⊢ (incMatrix R G * (incMatrix R G)ᵀ) a a = ∑ e : Sym2 α, incMatrix R G a e
[PROOFSTEP]
simp only [mul_apply, incMatrix_apply', transpose_apply, mul_ite, mul_one, mul_zero]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝³ : Fintype α
inst✝² : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
⊢ (∑ x : Sym2 α, if x ∈ incidenceSet G a then if x ∈ incidenceSet G a then 1 else 0 else 0) =
    ∑ x : Sym2 α, if x ∈ incidenceSet G a then 1 else 0
[PROOFSTEP]
simp_all only [ite_true, sum_boole]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a b : α
e : Sym2 α
⊢ e ∈ edgeSet G → ∑ a : α, incMatrix R G a e = 2
[PROOFSTEP]
classical
refine' e.ind _
intro a b h
rw [mem_edgeSet] at h
rw [← Nat.cast_two, ← card_doubleton h.ne]
simp only [incMatrix_apply', sum_boole, mk'_mem_incidenceSet_iff, h, true_and_iff]
congr 2
ext e
simp only [mem_filter, mem_univ, true_and_iff, mem_insert, mem_singleton]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a b : α
e : Sym2 α
⊢ e ∈ edgeSet G → ∑ a : α, incMatrix R G a e = 2
[PROOFSTEP]
refine' e.ind _
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a b : α
e : Sym2 α
⊢ ∀ (x y : α),
    Quotient.mk (Rel.setoid α) (x, y) ∈ edgeSet G → ∑ a : α, incMatrix R G a (Quotient.mk (Rel.setoid α) (x, y)) = 2
[PROOFSTEP]
intro a b h
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a✝ b✝ : α
e : Sym2 α
a b : α
h : Quotient.mk (Rel.setoid α) (a, b) ∈ edgeSet G
⊢ ∑ a_1 : α, incMatrix R G a_1 (Quotient.mk (Rel.setoid α) (a, b)) = 2
[PROOFSTEP]
rw [mem_edgeSet] at h
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a✝ b✝ : α
e : Sym2 α
a b : α
h : Adj G a b
⊢ ∑ a_1 : α, incMatrix R G a_1 (Quotient.mk (Rel.setoid α) (a, b)) = 2
[PROOFSTEP]
rw [← Nat.cast_two, ← card_doubleton h.ne]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a✝ b✝ : α
e : Sym2 α
a b : α
h : Adj G a b
⊢ ∑ a_1 : α, incMatrix R G a_1 (Quotient.mk (Rel.setoid α) (a, b)) = ↑(card {a, b})
[PROOFSTEP]
simp only [incMatrix_apply', sum_boole, mk'_mem_incidenceSet_iff, h, true_and_iff]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a✝ b✝ : α
e : Sym2 α
a b : α
h : Adj G a b
⊢ ↑(card (filter (fun x => x = a ∨ x = b) univ)) = ↑(card {a, b})
[PROOFSTEP]
congr 2
[GOAL]
case e_a.e_s
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a✝ b✝ : α
e : Sym2 α
a b : α
h : Adj G a b
⊢ filter (fun x => x = a ∨ x = b) univ = {a, b}
[PROOFSTEP]
ext e
[GOAL]
case e_a.e_s.a
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype α
inst✝ : NonAssocSemiring R
a✝ b✝ : α
e✝ : Sym2 α
a b : α
h : Adj G a b
e : α
⊢ e ∈ filter (fun x => x = a ∨ x = b) univ ↔ e ∈ {a, b}
[PROOFSTEP]
simp only [mem_filter, mem_univ, true_and_iff, mem_insert, mem_singleton]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
⊢ ((incMatrix R G)ᵀ * incMatrix R G) e e = if e ∈ edgeSet G then 2 else 0
[PROOFSTEP]
classical
simp only [Matrix.mul_apply, incMatrix_apply', transpose_apply, ← ite_and_mul_zero, one_mul, sum_boole, and_self_iff]
split_ifs with h
· revert h
  refine' e.ind _
  intro v w h
  rw [← Nat.cast_two, ← card_doubleton (G.ne_of_adj h)]
  simp [mk'_mem_incidenceSet_iff, G.mem_edgeSet.mp h]
  congr 2
  ext u
  simp
· revert h
  refine' e.ind _
  intro v w h
  simp [mk'_mem_incidenceSet_iff, G.mem_edgeSet.not.mp h]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
⊢ ((incMatrix R G)ᵀ * incMatrix R G) e e = if e ∈ edgeSet G then 2 else 0
[PROOFSTEP]
simp only [Matrix.mul_apply, incMatrix_apply', transpose_apply, ← ite_and_mul_zero, one_mul, sum_boole, and_self_iff]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
⊢ ↑(card (filter (fun x => e ∈ incidenceSet G x) univ)) = if e ∈ edgeSet G then 2 else 0
[PROOFSTEP]
split_ifs with h
[GOAL]
case pos
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
h : e ∈ edgeSet G
⊢ ↑(card (filter (fun x => e ∈ incidenceSet G x) univ)) = 2
[PROOFSTEP]
revert h
[GOAL]
case pos
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
⊢ e ∈ edgeSet G → ↑(card (filter (fun x => e ∈ incidenceSet G x) univ)) = 2
[PROOFSTEP]
refine' e.ind _
[GOAL]
case pos
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
⊢ ∀ (x y : α),
    Quotient.mk (Rel.setoid α) (x, y) ∈ edgeSet G →
      ↑(card (filter (fun x_1 => Quotient.mk (Rel.setoid α) (x, y) ∈ incidenceSet G x_1) univ)) = 2
[PROOFSTEP]
intro v w h
[GOAL]
case pos
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
v w : α
h : Quotient.mk (Rel.setoid α) (v, w) ∈ edgeSet G
⊢ ↑(card (filter (fun x => Quotient.mk (Rel.setoid α) (v, w) ∈ incidenceSet G x) univ)) = 2
[PROOFSTEP]
rw [← Nat.cast_two, ← card_doubleton (G.ne_of_adj h)]
[GOAL]
case pos
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
v w : α
h : Quotient.mk (Rel.setoid α) (v, w) ∈ edgeSet G
⊢ ↑(card (filter (fun x => Quotient.mk (Rel.setoid α) (v, w) ∈ incidenceSet G x) univ)) =
    ↑(card {(v, w).fst, (v, w).snd})
[PROOFSTEP]
simp [mk'_mem_incidenceSet_iff, G.mem_edgeSet.mp h]
[GOAL]
case pos
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
v w : α
h : Quotient.mk (Rel.setoid α) (v, w) ∈ edgeSet G
⊢ ↑(card (filter (fun x => x = v ∨ x = w) univ)) = ↑(card {v, w})
[PROOFSTEP]
congr 2
[GOAL]
case pos.e_a.e_s
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
v w : α
h : Quotient.mk (Rel.setoid α) (v, w) ∈ edgeSet G
⊢ filter (fun x => x = v ∨ x = w) univ = {v, w}
[PROOFSTEP]
ext u
[GOAL]
case pos.e_a.e_s.a
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
v w : α
h : Quotient.mk (Rel.setoid α) (v, w) ∈ edgeSet G
u : α
⊢ u ∈ filter (fun x => x = v ∨ x = w) univ ↔ u ∈ {v, w}
[PROOFSTEP]
simp
[GOAL]
case neg
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
h : ¬e ∈ edgeSet G
⊢ ↑(card (filter (fun x => e ∈ incidenceSet G x) univ)) = 0
[PROOFSTEP]
revert h
[GOAL]
case neg
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
⊢ ¬e ∈ edgeSet G → ↑(card (filter (fun x => e ∈ incidenceSet G x) univ)) = 0
[PROOFSTEP]
refine' e.ind _
[GOAL]
case neg
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
⊢ ∀ (x y : α),
    ¬Quotient.mk (Rel.setoid α) (x, y) ∈ edgeSet G →
      ↑(card (filter (fun x_1 => Quotient.mk (Rel.setoid α) (x, y) ∈ incidenceSet G x_1) univ)) = 0
[PROOFSTEP]
intro v w h
[GOAL]
case neg
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝² : Fintype α
inst✝¹ : NonAssocSemiring R
a b : α
e : Sym2 α
inst✝ : DecidableRel G.Adj
v w : α
h : ¬Quotient.mk (Rel.setoid α) (v, w) ∈ edgeSet G
⊢ ↑(card (filter (fun x => Quotient.mk (Rel.setoid α) (v, w) ∈ incidenceSet G x) univ)) = 0
[PROOFSTEP]
simp [mk'_mem_incidenceSet_iff, G.mem_edgeSet.not.mp h]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype (Sym2 α)
inst✝ : Semiring R
a b : α
e : Sym2 α
h : Adj G a b
⊢ (incMatrix R G * (incMatrix R G)ᵀ) a b = 1
[PROOFSTEP]
classical
simp_rw [Matrix.mul_apply, Matrix.transpose_apply, incMatrix_apply_mul_incMatrix_apply, Set.indicator_apply,
  Pi.one_apply, sum_boole]
convert @Nat.cast_one R _
convert card_singleton ⟦(a, b)⟧
rw [← coe_eq_singleton, coe_filter_univ]
exact G.incidenceSet_inter_incidenceSet_of_adj h
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype (Sym2 α)
inst✝ : Semiring R
a b : α
e : Sym2 α
h : Adj G a b
⊢ (incMatrix R G * (incMatrix R G)ᵀ) a b = 1
[PROOFSTEP]
simp_rw [Matrix.mul_apply, Matrix.transpose_apply, incMatrix_apply_mul_incMatrix_apply, Set.indicator_apply,
  Pi.one_apply, sum_boole]
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype (Sym2 α)
inst✝ : Semiring R
a b : α
e : Sym2 α
h : Adj G a b
⊢ ↑(card (filter (fun x => x ∈ incidenceSet G a ∩ incidenceSet G b) univ)) = 1
[PROOFSTEP]
convert @Nat.cast_one R _
[GOAL]
case h.e'_2.h.e'_3
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype (Sym2 α)
inst✝ : Semiring R
a b : α
e : Sym2 α
h : Adj G a b
⊢ card (filter (fun x => x ∈ incidenceSet G a ∩ incidenceSet G b) univ) = 1
[PROOFSTEP]
convert card_singleton ⟦(a, b)⟧
[GOAL]
case h.e'_2.h.e'_2.h
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype (Sym2 α)
inst✝ : Semiring R
a b : α
e : Sym2 α
h : Adj G a b
e_1✝ : Sym2 α = Quotient (Rel.setoid α)
⊢ filter (fun x => x ∈ incidenceSet G a ∩ incidenceSet G b) univ = {Quotient.mk (Rel.setoid α) (a, b)}
[PROOFSTEP]
rw [← coe_eq_singleton, coe_filter_univ]
[GOAL]
case h.e'_2.h.e'_2.h
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝¹ : Fintype (Sym2 α)
inst✝ : Semiring R
a b : α
e : Sym2 α
h : Adj G a b
e_1✝ : Sym2 α = Quotient (Rel.setoid α)
⊢ {x | x ∈ incidenceSet G a ∩ incidenceSet G b} = {Quotient.mk (Rel.setoid α) (a, b)}
[PROOFSTEP]
exact G.incidenceSet_inter_incidenceSet_of_adj h
[GOAL]
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝⁴ : Fintype (Sym2 α)
inst✝³ : Semiring R
a b : α
e : Sym2 α
inst✝² : Fintype α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
⊢ incMatrix R G * (incMatrix R G)ᵀ = fun a b => if a = b then ↑(degree G a) else if Adj G a b then 1 else 0
[PROOFSTEP]
ext a b
[GOAL]
case a.h
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝⁴ : Fintype (Sym2 α)
inst✝³ : Semiring R
a✝ b✝ : α
e : Sym2 α
inst✝² : Fintype α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
a b : α
⊢ (incMatrix R G * (incMatrix R G)ᵀ) a b = if a = b then ↑(degree G a) else if Adj G a b then 1 else 0
[PROOFSTEP]
split_ifs with h h'
[GOAL]
case pos
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝⁴ : Fintype (Sym2 α)
inst✝³ : Semiring R
a✝ b✝ : α
e : Sym2 α
inst✝² : Fintype α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
a b : α
h : a = b
⊢ (incMatrix R G * (incMatrix R G)ᵀ) a b = ↑(degree G a)
[PROOFSTEP]
subst b
[GOAL]
case pos
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝⁴ : Fintype (Sym2 α)
inst✝³ : Semiring R
a✝ b : α
e : Sym2 α
inst✝² : Fintype α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
a : α
⊢ (incMatrix R G * (incMatrix R G)ᵀ) a a = ↑(degree G a)
[PROOFSTEP]
rename Semiring R => sr
[GOAL]
case pos
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝³ : Fintype (Sym2 α)
sr : Semiring R
a✝ b : α
e : Sym2 α
inst✝² : Fintype α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
a : α
⊢ (incMatrix R G * (incMatrix R G)ᵀ) a a = ↑(degree G a)
[PROOFSTEP]
convert @incMatrix_mul_transpose_diag _ _ _ _ sr.toNonAssocSemiring _ _ _
[GOAL]
case pos
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝⁴ : Fintype (Sym2 α)
inst✝³ : Semiring R
a✝ b✝ : α
e : Sym2 α
inst✝² : Fintype α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
a b : α
h : ¬a = b
h' : Adj G a b
⊢ (incMatrix R G * (incMatrix R G)ᵀ) a b = 1
[PROOFSTEP]
exact G.incMatrix_mul_transpose_apply_of_adj h'
[GOAL]
case neg
R : Type u_1
α : Type u_2
G : SimpleGraph α
inst✝⁴ : Fintype (Sym2 α)
inst✝³ : Semiring R
a✝ b✝ : α
e : Sym2 α
inst✝² : Fintype α
inst✝¹ : DecidableEq α
inst✝ : DecidableRel G.Adj
a b : α
h : ¬a = b
h' : ¬Adj G a b
⊢ (incMatrix R G * (incMatrix R G)ᵀ) a b = 0
[PROOFSTEP]
simp only [Matrix.mul_apply, Matrix.transpose_apply, G.incMatrix_apply_mul_incMatrix_apply_of_not_adj h h',
  sum_const_zero]


[GOAL]
α : Type u
β : Type v
γ : Type w
ε : ℝ
ε0 : ε > 0
a✝ b✝ : ℝ
h : dist a✝ b✝ < ε
⊢ dist (-a✝) (-b✝) < ε
[PROOFSTEP]
rw [dist_comm] at h
[GOAL]
α : Type u
β : Type v
γ : Type w
ε : ℝ
ε0 : ε > 0
a✝ b✝ : ℝ
h : dist b✝ a✝ < ε
⊢ dist (-a✝) (-b✝) < ε
[PROOFSTEP]
simpa only [Real.dist_eq, neg_sub_neg] using h
[GOAL]
α : Type u
β : Type v
γ : Type w
⊢ TopologicalAddGroup ℝ
[PROOFSTEP]
infer_instance
[GOAL]
α : Type u
β : Type v
γ : Type w
x r : ℝ
⊢ IsCompact (closedBall x r)
[PROOFSTEP]
rw [Real.closedBall_eq_Icc]
[GOAL]
α : Type u
β : Type v
γ : Type w
x r : ℝ
⊢ IsCompact (Icc (x - r) (x + r))
[PROOFSTEP]
apply isCompact_Icc
[GOAL]
α : Type u
β : Type v
γ : Type w
⊢ ∀ (u : Set ℝ), u ∈ ⋃ (a : ℚ) (b : ℚ) (_ : a < b), {Ioo ↑a ↑b} → IsOpen u
[PROOFSTEP]
simp (config := { contextual := true }) [isOpen_Ioo]
[GOAL]
α : Type u
β : Type v
γ : Type w
a : ℝ
v : Set ℝ
hav : a ∈ v
hv : IsOpen v
l u : ℝ
hl : l < a
hu : a < u
h : Ioo l u ⊆ v
q : ℚ
hlq : l < ↑q
hqa : ↑q < a
p : ℚ
hap : a < ↑p
hpu : ↑p < u
⊢ Ioo ↑q ↑p ∈ ⋃ (a : ℚ) (b : ℚ) (_ : a < b), {Ioo ↑a ↑b}
[PROOFSTEP]
simp only [mem_iUnion]
[GOAL]
α : Type u
β : Type v
γ : Type w
a : ℝ
v : Set ℝ
hav : a ∈ v
hv : IsOpen v
l u : ℝ
hl : l < a
hu : a < u
h : Ioo l u ⊆ v
q : ℚ
hlq : l < ↑q
hqa : ↑q < a
p : ℚ
hap : a < ↑p
hpu : ↑p < u
⊢ ∃ i i_1 i_2, Ioo ↑q ↑p ∈ {Ioo ↑i ↑i_1}
[PROOFSTEP]
exact ⟨q, p, Rat.cast_lt.1 <| hqa.trans hap, rfl⟩
[GOAL]
α : Type u
β : Type v
γ : Type w
⊢ cocompact ℝ = atBot ⊔ atTop
[PROOFSTEP]
simp only [← comap_dist_right_atTop_eq_cocompact (0 : ℝ), Real.dist_eq, sub_zero, comap_abs_atTop]
[GOAL]
α : Type u
β : Type v
γ : Type w
s : Set ℝ
x : ℝ
⊢ x ∈ closure s ↔ ∀ (ε : ℝ), ε > 0 → ∃ y, y ∈ s ∧ |y - x| < ε
[PROOFSTEP]
simp [mem_closure_iff_nhds_basis nhds_basis_ball, Real.dist_eq]
[GOAL]
α : Type u
β : Type v
γ : Type w
⊢ CompleteSpace ℝ
[PROOFSTEP]
apply complete_of_cauchySeq_tendsto
[GOAL]
case a
α : Type u
β : Type v
γ : Type w
⊢ ∀ (u : ℕ → ℝ), CauchySeq u → ∃ a, Tendsto u atTop (𝓝 a)
[PROOFSTEP]
intro u hu
[GOAL]
case a
α : Type u
β : Type v
γ : Type w
u : ℕ → ℝ
hu : CauchySeq u
⊢ ∃ a, Tendsto u atTop (𝓝 a)
[PROOFSTEP]
let c : CauSeq ℝ abs := ⟨u, Metric.cauchySeq_iff'.1 hu⟩
[GOAL]
case a
α : Type u
β : Type v
γ : Type w
u : ℕ → ℝ
hu : CauchySeq u
c : CauSeq ℝ abs := { val := u, property := (_ : ∀ (ε : ℝ), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → dist (u n) (u N) < ε) }
⊢ ∃ a, Tendsto u atTop (𝓝 a)
[PROOFSTEP]
refine' ⟨c.lim, fun s h => _⟩
[GOAL]
case a
α : Type u
β : Type v
γ : Type w
u : ℕ → ℝ
hu : CauchySeq u
c : CauSeq ℝ abs := { val := u, property := (_ : ∀ (ε : ℝ), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → dist (u n) (u N) < ε) }
s : Set ℝ
h : s ∈ 𝓝 (CauSeq.lim c)
⊢ s ∈ map u atTop
[PROOFSTEP]
rcases Metric.mem_nhds_iff.1 h with ⟨ε, ε0, hε⟩
[GOAL]
case a.intro.intro
α : Type u
β : Type v
γ : Type w
u : ℕ → ℝ
hu : CauchySeq u
c : CauSeq ℝ abs := { val := u, property := (_ : ∀ (ε : ℝ), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → dist (u n) (u N) < ε) }
s : Set ℝ
h : s ∈ 𝓝 (CauSeq.lim c)
ε : ℝ
ε0 : ε > 0
hε : ball (CauSeq.lim c) ε ⊆ s
⊢ s ∈ map u atTop
[PROOFSTEP]
have := c.equiv_lim ε ε0
[GOAL]
case a.intro.intro
α : Type u
β : Type v
γ : Type w
u : ℕ → ℝ
hu : CauchySeq u
c : CauSeq ℝ abs := { val := u, property := (_ : ∀ (ε : ℝ), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → dist (u n) (u N) < ε) }
s : Set ℝ
h : s ∈ 𝓝 (CauSeq.lim c)
ε : ℝ
ε0 : ε > 0
hε : ball (CauSeq.lim c) ε ⊆ s
this : ∃ i, ∀ (j : ℕ), j ≥ i → |↑(c - CauSeq.const abs (CauSeq.lim c)) j| < ε
⊢ s ∈ map u atTop
[PROOFSTEP]
simp only [mem_map, mem_atTop_sets, mem_setOf_eq]
[GOAL]
case a.intro.intro
α : Type u
β : Type v
γ : Type w
u : ℕ → ℝ
hu : CauchySeq u
c : CauSeq ℝ abs := { val := u, property := (_ : ∀ (ε : ℝ), ε > 0 → ∃ N, ∀ (n : ℕ), n ≥ N → dist (u n) (u N) < ε) }
s : Set ℝ
h : s ∈ 𝓝 (CauSeq.lim c)
ε : ℝ
ε0 : ε > 0
hε : ball (CauSeq.lim c) ε ⊆ s
this : ∃ i, ∀ (j : ℕ), j ≥ i → |↑(c - CauSeq.const abs (CauSeq.lim c)) j| < ε
⊢ ∃ a, ∀ (b : ℕ), b ≥ a → b ∈ u ⁻¹' s
[PROOFSTEP]
refine' this.imp fun N hN n hn => hε (hN n hn)
[GOAL]
α : Type u
β : Type v
γ : Type w
x ε : ℝ
⊢ TotallyBounded (ball x ε)
[PROOFSTEP]
rw [Real.ball_eq_Ioo]
[GOAL]
α : Type u
β : Type v
γ : Type w
x ε : ℝ
⊢ TotallyBounded (Ioo (x - ε) (x + ε))
[PROOFSTEP]
apply totallyBounded_Ioo
[GOAL]
α : Type u
β : Type v
γ : Type w
q : ℚ
x : ℝ
hx : x ∈ {r | ↑q ≤ r}
t : Set ℝ
ht : t ∈ 𝓝 x
ε : ℝ
ε0 : ε > 0
hε : ball x ε ⊆ t
p : ℚ
h₁ : x < ↑p
h₂ : ↑p < x + ε
⊢ ↑p ∈ ball x ε
[PROOFSTEP]
rwa [mem_ball, Real.dist_eq, abs_of_pos (sub_pos.2 h₁), sub_lt_iff_lt_add']
[GOAL]
α : Type u
β : Type v
γ : Type w
s : Set ℝ
⊢ Metric.Bounded s → BddBelow s ∧ BddAbove s
[PROOFSTEP]
intro bdd
[GOAL]
α : Type u
β : Type v
γ : Type w
s : Set ℝ
bdd : Metric.Bounded s
⊢ BddBelow s ∧ BddAbove s
[PROOFSTEP]
rcases(bounded_iff_subset_ball 0).1 bdd with
  ⟨r, hr⟩
    -- hr : s ⊆ closed_ball 0 r
[GOAL]
case intro
α : Type u
β : Type v
γ : Type w
s : Set ℝ
bdd : Metric.Bounded s
r : ℝ
hr : s ⊆ closedBall 0 r
⊢ BddBelow s ∧ BddAbove s
[PROOFSTEP]
rw [Real.closedBall_eq_Icc] at hr
[GOAL]
case intro
α : Type u
β : Type v
γ : Type w
s : Set ℝ
bdd : Metric.Bounded s
r : ℝ
hr : s ⊆ Icc (0 - r) (0 + r)
⊢ BddBelow s ∧ BddAbove s
[PROOFSTEP]
exact ⟨bddBelow_Icc.mono hr, bddAbove_Icc.mono hr⟩
[GOAL]
α : Type u
β : Type v
γ : Type w
inst✝ : TopologicalSpace α
f : ℝ → α
c : ℝ
hp : Periodic f c
hc : c ≠ 0
hf : Continuous f
⊢ IsCompact (range f)
[PROOFSTEP]
rw [← hp.image_uIcc hc 0]
[GOAL]
α : Type u
β : Type v
γ : Type w
inst✝ : TopologicalSpace α
f : ℝ → α
c : ℝ
hp : Periodic f c
hc : c ≠ 0
hf : Continuous f
⊢ IsCompact (f '' [[0, 0 + c]])
[PROOFSTEP]
exact isCompact_uIcc.image hf
[GOAL]
α : Type u
β : Type v
γ : Type w
a : ℝ
⊢ DiscreteTopology { x // x ∈ AddSubgroup.zmultiples a }
[PROOFSTEP]
rcases eq_or_ne a 0 with (rfl | ha)
[GOAL]
case inl
α : Type u
β : Type v
γ : Type w
⊢ DiscreteTopology { x // x ∈ AddSubgroup.zmultiples 0 }
[PROOFSTEP]
rw [AddSubgroup.zmultiples_zero_eq_bot]
[GOAL]
case inl
α : Type u
β : Type v
γ : Type w
⊢ DiscreteTopology { x // x ∈ ⊥ }
[PROOFSTEP]
exact Subsingleton.discreteTopology (α := (⊥ : Submodule ℤ ℝ))
[GOAL]
case inr
α : Type u
β : Type v
γ : Type w
a : ℝ
ha : a ≠ 0
⊢ DiscreteTopology { x // x ∈ AddSubgroup.zmultiples a }
[PROOFSTEP]
rw [discreteTopology_iff_open_singleton_zero, isOpen_induced_iff]
[GOAL]
case inr
α : Type u
β : Type v
γ : Type w
a : ℝ
ha : a ≠ 0
⊢ ∃ t, IsOpen t ∧ Subtype.val ⁻¹' t = {0}
[PROOFSTEP]
refine' ⟨ball 0 |a|, isOpen_ball, _⟩
[GOAL]
case inr
α : Type u
β : Type v
γ : Type w
a : ℝ
ha : a ≠ 0
⊢ Subtype.val ⁻¹' ball 0 |a| = {0}
[PROOFSTEP]
ext ⟨x, hx⟩
[GOAL]
case inr.h.mk
α : Type u
β : Type v
γ : Type w
a : ℝ
ha : a ≠ 0
x : ℝ
hx : x ∈ AddSubgroup.zmultiples a
⊢ { val := x, property := hx } ∈ Subtype.val ⁻¹' ball 0 |a| ↔ { val := x, property := hx } ∈ {0}
[PROOFSTEP]
obtain ⟨k, rfl⟩ := AddSubgroup.mem_zmultiples_iff.mp hx
[GOAL]
case inr.h.mk.intro
α : Type u
β : Type v
γ : Type w
a : ℝ
ha : a ≠ 0
k : ℤ
hx : k • a ∈ AddSubgroup.zmultiples a
⊢ { val := k • a, property := hx } ∈ Subtype.val ⁻¹' ball 0 |a| ↔ { val := k • a, property := hx } ∈ {0}
[PROOFSTEP]
simp [ha, Real.dist_eq, abs_mul, (by norm_cast : |(k : ℝ)| < 1 ↔ |k| < 1)]
[GOAL]
α : Type u
β : Type v
γ : Type w
a : ℝ
ha : a ≠ 0
k : ℤ
hx : k • a ∈ AddSubgroup.zmultiples a
⊢ |↑k| < 1 ↔ |k| < 1
[PROOFSTEP]
norm_cast
[GOAL]
α : Type u
β : Type v
γ : Type w
⊢ Tendsto Int.cast cofinite (cocompact ℝ)
[PROOFSTEP]
apply (castAddHom ℝ).tendsto_coe_cofinite_of_discrete cast_injective
[GOAL]
α : Type u
β : Type v
γ : Type w
⊢ DiscreteTopology { x // x ∈ AddMonoidHom.range (castAddHom ℝ) }
[PROOFSTEP]
rw [range_castAddHom]
[GOAL]
α : Type u
β : Type v
γ : Type w
⊢ DiscreteTopology { x // x ∈ AddSubgroup.zmultiples 1 }
[PROOFSTEP]
infer_instance
[GOAL]
α : Type u
β : Type v
γ : Type w
a : ℝ
ha : a ≠ 0
⊢ Tendsto (↑(↑(zmultiplesHom ℝ) a)) cofinite (cocompact ℝ)
[PROOFSTEP]
apply (zmultiplesHom ℝ a).tendsto_coe_cofinite_of_discrete $ smul_left_injective ℤ ha
[GOAL]
α : Type u
β : Type v
γ : Type w
a : ℝ
ha : a ≠ 0
⊢ DiscreteTopology { x // x ∈ AddMonoidHom.range (↑(zmultiplesHom ℝ) a) }
[PROOFSTEP]
rw [AddSubgroup.range_zmultiplesHom]
[GOAL]
α : Type u
β : Type v
γ : Type w
a : ℝ
ha : a ≠ 0
⊢ DiscreteTopology { x // x ∈ AddSubgroup.zmultiples a }
[PROOFSTEP]
infer_instance


[GOAL]
α : Type u_1
x : ℤˣ
⊢ x ∈ {1, -1}
[PROOFSTEP]
cases Int.units_eq_one_or x
[GOAL]
case inl
α : Type u_1
x : ℤˣ
h✝ : x = 1
⊢ x ∈ {1, -1}
[PROOFSTEP]
simp [*]
[GOAL]
case inr
α : Type u_1
x : ℤˣ
h✝ : x = -1
⊢ x ∈ {1, -1}
[PROOFSTEP]
simp [*]
[GOAL]
α : Type u_1
inst✝² : GroupWithZero α
inst✝¹ : Fintype α
inst✝ : DecidableEq α
⊢ card α = card αˣ + 1
[PROOFSTEP]
rw [eq_comm, Fintype.card_congr (unitsEquivNeZero α)]
[GOAL]
α : Type u_1
inst✝² : GroupWithZero α
inst✝¹ : Fintype α
inst✝ : DecidableEq α
⊢ card { a // a ≠ 0 } + 1 = card α
[PROOFSTEP]
have := Fintype.card_congr (Equiv.sumCompl (· = (0 : α)))
[GOAL]
α : Type u_1
inst✝² : GroupWithZero α
inst✝¹ : Fintype α
inst✝ : DecidableEq α
this : card ({ a // a = 0 } ⊕ { a // ¬a = 0 }) = card α
⊢ card { a // a ≠ 0 } + 1 = card α
[PROOFSTEP]
rwa [Fintype.card_sum, add_comm, Fintype.card_subtype_eq] at this
[GOAL]
α : Type u_1
inst✝¹ : GroupWithZero α
inst✝ : Finite α
⊢ Nat.card α = Nat.card αˣ + 1
[PROOFSTEP]
have : Fintype α := Fintype.ofFinite α
[GOAL]
α : Type u_1
inst✝¹ : GroupWithZero α
inst✝ : Finite α
this : Fintype α
⊢ Nat.card α = Nat.card αˣ + 1
[PROOFSTEP]
classical rw [Nat.card_eq_fintype_card, Nat.card_eq_fintype_card, Fintype.card_eq_card_units_add_one]
[GOAL]
α : Type u_1
inst✝¹ : GroupWithZero α
inst✝ : Finite α
this : Fintype α
⊢ Nat.card α = Nat.card αˣ + 1
[PROOFSTEP]
rw [Nat.card_eq_fintype_card, Nat.card_eq_fintype_card, Fintype.card_eq_card_units_add_one]
[GOAL]
α : Type u_1
inst✝² : GroupWithZero α
inst✝¹ : Fintype α
inst✝ : DecidableEq α
⊢ card αˣ = card α - 1
[PROOFSTEP]
rw [@Fintype.card_eq_card_units_add_one α, Nat.add_sub_cancel]


[GOAL]
α : Type u
β : Type v
f : α → α
n✝ n : ℕ
ihn : id^[n] = id
⊢ id^[Nat.succ n] = id
[PROOFSTEP]
rw [iterate_succ, ihn, comp.left_id]
[GOAL]
α : Type u
β : Type v
f : α → α
m n : ℕ
⊢ f^[m + Nat.succ n] = f^[m] ∘ f^[Nat.succ n]
[PROOFSTEP]
rw [Nat.add_succ, iterate_succ, iterate_succ, iterate_add m n]
[GOAL]
α : Type u
β : Type v
f : α → α
m n : ℕ
⊢ (f^[m] ∘ f^[n]) ∘ f = f^[m] ∘ f^[n] ∘ f
[PROOFSTEP]
rfl
[GOAL]
α : Type u
β : Type v
f : α → α
m n : ℕ
x : α
⊢ f^[m + n] x = f^[m] (f^[n] x)
[PROOFSTEP]
rw [iterate_add f m n]
[GOAL]
α : Type u
β : Type v
f : α → α
m n : ℕ
x : α
⊢ (f^[m] ∘ f^[n]) x = f^[m] (f^[n] x)
[PROOFSTEP]
rfl
[GOAL]
α : Type u
β : Type v
f : α → α
m : ℕ
⊢ f^[m * 0] = f^[m]^[0]
[PROOFSTEP]
simp only [Nat.mul_zero, iterate_zero]
[GOAL]
α : Type u
β : Type v
f : α → α
m n : ℕ
⊢ f^[m * (n + 1)] = f^[m]^[n + 1]
[PROOFSTEP]
simp only [Nat.mul_succ, Nat.mul_one, iterate_one, iterate_add, iterate_mul m n]
[GOAL]
α : Type u
β : Type v
f : α → α
x : α
h : f x = x
n✝ n : ℕ
ihn : f^[n] x = x
⊢ f^[Nat.succ n] x = x
[PROOFSTEP]
rw [iterate_succ_apply, h, ihn]
[GOAL]
α : Type u
β : Type v
f : α → α
g : ℕ → α → α
H : ∀ (n : ℕ), Semiconj f (g n) (g (n + 1))
n k : ℕ
⊢ Semiconj f^[n] (g k) (g (n + k))
[PROOFSTEP]
induction' n with n ihn generalizing k
[GOAL]
case zero
α : Type u
β : Type v
f : α → α
g : ℕ → α → α
H : ∀ (n : ℕ), Semiconj f (g n) (g (n + 1))
k✝ k : ℕ
⊢ Semiconj f^[Nat.zero] (g k) (g (Nat.zero + k))
[PROOFSTEP]
rw [Nat.zero_add]
[GOAL]
case zero
α : Type u
β : Type v
f : α → α
g : ℕ → α → α
H : ∀ (n : ℕ), Semiconj f (g n) (g (n + 1))
k✝ k : ℕ
⊢ Semiconj f^[Nat.zero] (g k) (g k)
[PROOFSTEP]
exact id_left
[GOAL]
case succ
α : Type u
β : Type v
f : α → α
g : ℕ → α → α
H : ∀ (n : ℕ), Semiconj f (g n) (g (n + 1))
k✝ n : ℕ
ihn : ∀ (k : ℕ), Semiconj f^[n] (g k) (g (n + k))
k : ℕ
⊢ Semiconj f^[Nat.succ n] (g k) (g (Nat.succ n + k))
[PROOFSTEP]
rw [Nat.succ_eq_add_one, Nat.add_right_comm, Nat.add_assoc]
[GOAL]
case succ
α : Type u
β : Type v
f : α → α
g : ℕ → α → α
H : ∀ (n : ℕ), Semiconj f (g n) (g (n + 1))
k✝ n : ℕ
ihn : ∀ (k : ℕ), Semiconj f^[n] (g k) (g (n + k))
k : ℕ
⊢ Semiconj f^[n + 1] (g k) (g (n + (k + 1)))
[PROOFSTEP]
exact (H k).comp_left (ihn (k + 1))
[GOAL]
α : Type u
β : Type v
f g : α → α
h : Commute f g
n✝ : ℕ
x : α
hx : f x = g x
n : ℕ
ihn : f^[n] x = g^[n] x
⊢ f^[Nat.succ n] x = g^[Nat.succ n] x
[PROOFSTEP]
simp only [iterate_succ_apply, hx, (h.iterate_left n).eq, ihn, ((refl g).iterate_right n).eq]
[GOAL]
α : Type u
β : Type v
f g : α → α
h : Commute f g
n : ℕ
⊢ (f ∘ g)^[n] = f^[n] ∘ g^[n]
[PROOFSTEP]
induction' n with n ihn
[GOAL]
case zero
α : Type u
β : Type v
f g : α → α
h : Commute f g
⊢ (f ∘ g)^[Nat.zero] = f^[Nat.zero] ∘ g^[Nat.zero]
[PROOFSTEP]
rfl
[GOAL]
case succ
α : Type u
β : Type v
f g : α → α
h : Commute f g
n : ℕ
ihn : (f ∘ g)^[n] = f^[n] ∘ g^[n]
⊢ (f ∘ g)^[Nat.succ n] = f^[Nat.succ n] ∘ g^[Nat.succ n]
[PROOFSTEP]
funext x
[GOAL]
case succ.h
α : Type u
β : Type v
f g : α → α
h : Commute f g
n : ℕ
ihn : (f ∘ g)^[n] = f^[n] ∘ g^[n]
x : α
⊢ (f ∘ g)^[Nat.succ n] x = (f^[Nat.succ n] ∘ g^[Nat.succ n]) x
[PROOFSTEP]
simp only [ihn, (h.iterate_right n).eq, iterate_succ, comp_apply]
[GOAL]
α : Type u
β : Type v
f : α → α
n : ℕ
⊢ f^[Nat.succ n] = f ∘ f^[n]
[PROOFSTEP]
rw [iterate_succ, (Commute.self_iterate f n).comp_eq]
[GOAL]
α : Type u
β : Type v
f : α → α
n : ℕ
x : α
⊢ f^[Nat.succ n] x = f (f^[n] x)
[PROOFSTEP]
rw [iterate_succ']
[GOAL]
α : Type u
β : Type v
f : α → α
n : ℕ
x : α
⊢ (f ∘ f^[n]) x = f (f^[n] x)
[PROOFSTEP]
rfl
[GOAL]
α : Type u
β : Type v
f : α → α
n : ℕ
hn : 0 < n
⊢ f^[Nat.pred n] ∘ f = f^[n]
[PROOFSTEP]
rw [← iterate_succ, Nat.succ_pred_eq_of_pos hn]
[GOAL]
α : Type u
β : Type v
f : α → α
n : ℕ
hn : 0 < n
⊢ f ∘ f^[Nat.pred n] = f^[n]
[PROOFSTEP]
rw [← iterate_succ', Nat.succ_pred_eq_of_pos hn]
[GOAL]
α : Type u
β : Type v
f : α → α
m n✝¹ : ℕ
a : α
g : α → α
hg : LeftInverse g f
n✝ n : ℕ
ihn : LeftInverse g^[n] f^[n]
⊢ LeftInverse g^[Nat.succ n] f^[Nat.succ n]
[PROOFSTEP]
rw [iterate_succ', iterate_succ]
[GOAL]
α : Type u
β : Type v
f : α → α
m n✝¹ : ℕ
a : α
g : α → α
hg : LeftInverse g f
n✝ n : ℕ
ihn : LeftInverse g^[n] f^[n]
⊢ LeftInverse (g ∘ g^[n]) (f^[n] ∘ f)
[PROOFSTEP]
exact ihn.comp hg
[GOAL]
α : Type u
β : Type v
f✝ : α → α
m✝ n✝ : ℕ
a : α
f : α → α
m n : ℕ
⊢ f^[n * m] = f^[m * n]
[PROOFSTEP]
rw [Nat.mul_comm]
[GOAL]
α : Type u
β : Type v
f : α → α
m n : ℕ
a : α
hf : Injective f
⊢ f^[m + n] a = f^[n] a ↔ f^[n] (f^[m] a) = f^[n] a
[PROOFSTEP]
rw [← iterate_add_apply, Nat.add_comm]
[GOAL]
α : Type u
β : Type v
f : α → α
m n : ℕ
a : α
hf : Injective f
ha : f^[m] a = f^[n] a
⊢ f^[m - n] a = a
[PROOFSTEP]
obtain h | h := le_total m n
[GOAL]
case inl
α : Type u
β : Type v
f : α → α
m n : ℕ
a : α
hf : Injective f
ha : f^[m] a = f^[n] a
h : m ≤ n
⊢ f^[m - n] a = a
case inr
α : Type u
β : Type v
f : α → α
m n : ℕ
a : α
hf : Injective f
ha : f^[m] a = f^[n] a
h : n ≤ m
⊢ f^[m - n] a = a
[PROOFSTEP]
{simp [Nat.sub_eq_zero_of_le h]
}
[GOAL]
case inl
α : Type u
β : Type v
f : α → α
m n : ℕ
a : α
hf : Injective f
ha : f^[m] a = f^[n] a
h : m ≤ n
⊢ f^[m - n] a = a
[PROOFSTEP]
simp [Nat.sub_eq_zero_of_le h]
[GOAL]
case inr
α : Type u
β : Type v
f : α → α
m n : ℕ
a : α
hf : Injective f
ha : f^[m] a = f^[n] a
h : n ≤ m
⊢ f^[m - n] a = a
[PROOFSTEP]
{exact iterate_cancel_of_add hf (by rwa [Nat.sub_add_cancel h])
}
[GOAL]
case inr
α : Type u
β : Type v
f : α → α
m n : ℕ
a : α
hf : Injective f
ha : f^[m] a = f^[n] a
h : n ≤ m
⊢ f^[m - n] a = a
[PROOFSTEP]
exact iterate_cancel_of_add hf (by rwa [Nat.sub_add_cancel h])
[GOAL]
α : Type u
β : Type v
f : α → α
m n : ℕ
a : α
hf : Injective f
ha : f^[m] a = f^[n] a
h : n ≤ m
⊢ f^[m - n + ?m.6123] a = f^[?m.6123] a
[PROOFSTEP]
rwa [Nat.sub_add_cancel h]
[GOAL]
α : Type u
β : Type v
f : α → α
a : α
l : List β
⊢ foldl (fun b x => f b) a l = f^[length l] a
[PROOFSTEP]
induction' l with b l H generalizing a
[GOAL]
case nil
α : Type u
β : Type v
f : α → α
a✝ a : α
⊢ foldl (fun b x => f b) a [] = f^[length []] a
[PROOFSTEP]
rfl
[GOAL]
case cons
α : Type u
β : Type v
f : α → α
a✝ : α
b : β
l : List β
H : ∀ (a : α), foldl (fun b x => f b) a l = f^[length l] a
a : α
⊢ foldl (fun b x => f b) a (b :: l) = f^[length (b :: l)] a
[PROOFSTEP]
rw [length_cons, foldl, iterate_succ_apply, H]
[GOAL]
α : Type u
β : Type v
f : β → β
b : β
a : α
l : List α
⊢ foldr (fun x => f) b (a :: l) = f^[length (a :: l)] b
[PROOFSTEP]
rw [length_cons, foldr, foldr_const f b l, iterate_succ_apply']