Theorem: Padic.exi_rat_seq_conv_cauchy
File: Mathlib/NumberTheory/Padics/PadicNumbers.lean

tactic: have hε3 : 0 < ε / 3 := div_pos hε (by norm_num)
state_before: p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
⊢ ∃ i, ∀ (j : ℕ), j ≥ i → padicNorm p (limSeq f j - limSeq f i) < ε

tactic: let ⟨N, hN⟩ := exi_rat_seq_conv f hε3
state_before: p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
⊢ ∃ i, ∀ (j : ℕ), j ≥ i → padicNorm p (limSeq f j - limSeq f i) < ε

tactic: let ⟨N2, hN2⟩ := f.cauchy₂ hε3
state_before: p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
⊢ ∃ i, ∀ (j : ℕ), j ≥ i → padicNorm p (limSeq f j - limSeq f i) < ε

tactic: exists max N N2
state_before: p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
⊢ ∃ i, ∀ (j : ℕ), j ≥ i → padicNorm p (limSeq f j - limSeq f i) < ε

tactic: intro j hj
state_before: p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
⊢ ∀ (j : ℕ), j ≥ max N N2 → padicNorm p (limSeq f j - limSeq f (max N N2)) < ε

tactic: suffices
  padicNormE (limSeq f j - f (max N N2) + (f (max N N2) - limSeq f (max N N2)) : ℚ_[p]) < ε by
  ring_nf at this ⊢
  rw [← padicNormE.eq_padic_norm']
  exact_mod_cast this
state_before: p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ padicNorm p (limSeq f j - limSeq f (max N N2)) < ε

tactic: norm_num
state_before: p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
⊢ 0 < 3

tactic: ring_nf at this ⊢
state_before: p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
this : ↑padicNormE (↑(limSeq f j) - ↑f (max N N2) + (↑f (max N N2) - ↑(limSeq f (max N N2)))) < ε
⊢ padicNorm p (limSeq f j - limSeq f (max N N2)) < ε

tactic: rw [← padicNormE.eq_padic_norm']
state_before: p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
this : ↑padicNormE (↑(limSeq f j) - ↑(limSeq f (max N N2))) < ε
⊢ padicNorm p (limSeq f j - limSeq f (max N N2)) < ε

tactic: exact_mod_cast this
state_before: p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
this : ↑padicNormE (↑(limSeq f j) - ↑(limSeq f (max N N2))) < ε
⊢ ↑padicNormE ↑(limSeq f j - limSeq f (max N N2)) < ε

tactic: apply lt_of_le_of_lt
state_before: p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ ↑padicNormE (↑(limSeq f j) - ↑f (max N N2) + (↑f (max N N2) - ↑(limSeq f (max N N2)))) < ε

tactic: apply padicNormE.add_le
state_before: case a
p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ ↑padicNormE (↑(limSeq f j) - ↑f (max N N2) + (↑f (max N N2) - ↑(limSeq f (max N N2)))) ≤ ?b

tactic: rw [←add_thirds ε]
state_before: case a
p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ ↑padicNormE (↑(limSeq f j) - ↑f (max N N2)) + ↑padicNormE (↑f (max N N2) - ↑(limSeq f (max N N2))) < ε

tactic: apply _root_.add_lt_add
state_before: case a
p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ ↑padicNormE (↑(limSeq f j) - ↑f (max N N2)) + ↑padicNormE (↑f (max N N2) - ↑(limSeq f (max N N2))) <
    ε / 3 + ε / 3 + ε / 3

tactic: suffices padicNormE (limSeq f j - f j + (f j - f (max N N2)) : ℚ_[p]) < ε / 3 + ε / 3 by
  simpa only [sub_add_sub_cancel]
state_before: case a.h₁
p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ ↑padicNormE (↑(limSeq f j) - ↑f (max N N2)) < ε / 3 + ε / 3

tactic: apply lt_of_le_of_lt
state_before: case a.h₁
p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ ↑padicNormE (↑(limSeq f j) - ↑f j + (↑f j - ↑f (max N N2))) < ε / 3 + ε / 3

tactic: simpa only [sub_add_sub_cancel]
state_before: p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
this : ↑padicNormE (↑(limSeq f j) - ↑f j + (↑f j - ↑f (max N N2))) < ε / 3 + ε / 3
⊢ ↑padicNormE (↑(limSeq f j) - ↑f (max N N2)) < ε / 3 + ε / 3

tactic: apply padicNormE.add_le
state_before: case a.h₁.a
p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ ↑padicNormE (↑(limSeq f j) - ↑f j + (↑f j - ↑f (max N N2))) ≤ ?a.h₁.b✝

tactic: apply _root_.add_lt_add
state_before: case a.h₁.a
p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ ↑padicNormE (↑(limSeq f j) - ↑f j) + ↑padicNormE (↑f j - ↑f (max N N2)) < ε / 3 + ε / 3

tactic: rw [padicNormE.map_sub]
state_before: case a.h₁.a.h₁
p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ ↑padicNormE (↑(limSeq f j) - ↑f j) < ε / 3

tactic: apply_mod_cast hN j
state_before: case a.h₁.a.h₁
p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ ↑padicNormE (↑f j - ↑(limSeq f j)) < ε / 3

tactic: exact le_of_max_le_left hj
state_before: case a.h₁.a.h₁
p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ j ≥ N

tactic: exact hN2 _ (le_of_max_le_right hj) _ (le_max_right _ _)
state_before: case a.h₁.a.h₂
p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ ↑padicNormE (↑f j - ↑f (max N N2)) < ε / 3

tactic: apply_mod_cast hN (max N N2)
state_before: case a.h₂
p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ ↑padicNormE (↑f (max N N2) - ↑(limSeq f (max N N2))) < ε / 3

tactic: apply le_max_left
state_before: case a.h₂
p : ℕ
inst✝ : Fact (Nat.Prime p)
f : CauSeq ℚ_[p] ↑padicNormE
ε : ℚ
hε : ε > 0
hε3 : 0 < ε / 3
N : ℕ
hN : ∀ (i : ℕ), i ≥ N → ↑padicNormE (↑f i - ↑(limSeq f i)) < ε / 3
N2 : ℕ
hN2 : ∀ (j : ℕ), j ≥ N2 → ∀ (k : ℕ), k ≥ N2 → ↑padicNormE (↑f j - ↑f k) < ε / 3
j : ℕ
hj : j ≥ max N N2
⊢ max N N2 ≥ N