Theorem: padicNorm.add_eq_max_of_ne
File: Mathlib/NumberTheory/Padics/PadicNorm.lean

tactic: wlog hlt : padicNorm p r < padicNorm p q
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
⊢ padicNorm p (q + r) = max (padicNorm p q) (padicNorm p r)

tactic: have : padicNorm p q ≤ max (padicNorm p (q + r)) (padicNorm p r) :=
  calc
    padicNorm p q = padicNorm p (q + r + (-r)) := by ring_nf
    _ ≤ max (padicNorm p (q + r)) (padicNorm p (-r)) := padicNorm.nonarchimedean
    _ = max (padicNorm p (q + r)) (padicNorm p r) := by simp
state_before: p✝ p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
hlt : padicNorm p r < padicNorm p q
⊢ padicNorm p (q + r) = max (padicNorm p q) (padicNorm p r)

tactic: have hnge : padicNorm p r ≤ padicNorm p (q + r) := by
  apply le_of_not_gt
  intro hgt
  rw [max_eq_right_of_lt hgt] at this
  exact not_lt_of_ge this hlt
state_before: p✝ p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
hlt : padicNorm p r < padicNorm p q
this : padicNorm p q ≤ max (padicNorm p (q + r)) (padicNorm p r)
⊢ padicNorm p (q + r) = max (padicNorm p q) (padicNorm p r)

tactic: have : padicNorm p q ≤ padicNorm p (q + r) := by rwa [max_eq_left hnge] at this
state_before: p✝ p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
hlt : padicNorm p r < padicNorm p q
this : padicNorm p q ≤ max (padicNorm p (q + r)) (padicNorm p r)
hnge : padicNorm p r ≤ padicNorm p (q + r)
⊢ padicNorm p (q + r) = max (padicNorm p q) (padicNorm p r)

tactic: apply _root_.le_antisymm
state_before: p✝ p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
hlt : padicNorm p r < padicNorm p q
this✝ : padicNorm p q ≤ max (padicNorm p (q + r)) (padicNorm p r)
hnge : padicNorm p r ≤ padicNorm p (q + r)
this : padicNorm p q ≤ padicNorm p (q + r)
⊢ padicNorm p (q + r) = max (padicNorm p q) (padicNorm p r)

tactic: rw [add_comm, max_comm]
state_before: case inr
p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
this :
  ∀ {p : ℕ} [hp : Fact (Nat.Prime p)] {q r : ℚ},
    padicNorm p q ≠ padicNorm p r →
      padicNorm p r < padicNorm p q → padicNorm p (q + r) = max (padicNorm p q) (padicNorm p r)
hlt : ¬padicNorm p r < padicNorm p q
⊢ padicNorm p (q + r) = max (padicNorm p q) (padicNorm p r)

tactic: exact this hne.symm (hne.lt_or_lt.resolve_right hlt)
state_before: case inr
p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
this :
  ∀ {p : ℕ} [hp : Fact (Nat.Prime p)] {q r : ℚ},
    padicNorm p q ≠ padicNorm p r →
      padicNorm p r < padicNorm p q → padicNorm p (q + r) = max (padicNorm p q) (padicNorm p r)
hlt : ¬padicNorm p r < padicNorm p q
⊢ padicNorm p (r + q) = max (padicNorm p r) (padicNorm p q)

tactic: ring_nf
state_before: p✝ p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
hlt : padicNorm p r < padicNorm p q
⊢ padicNorm p q = padicNorm p (q + r + -r)

tactic: simp
state_before: p✝ p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
hlt : padicNorm p r < padicNorm p q
⊢ max (padicNorm p (q + r)) (padicNorm p (-r)) = max (padicNorm p (q + r)) (padicNorm p r)

tactic: apply le_of_not_gt
state_before: p✝ p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
hlt : padicNorm p r < padicNorm p q
this : padicNorm p q ≤ max (padicNorm p (q + r)) (padicNorm p r)
⊢ padicNorm p r ≤ padicNorm p (q + r)

tactic: intro hgt
state_before: case a
p✝ p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
hlt : padicNorm p r < padicNorm p q
this : padicNorm p q ≤ max (padicNorm p (q + r)) (padicNorm p r)
⊢ ¬padicNorm p r > padicNorm p (q + r)

tactic: rw [max_eq_right_of_lt hgt] at this
state_before: case a
p✝ p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
hlt : padicNorm p r < padicNorm p q
this : padicNorm p q ≤ max (padicNorm p (q + r)) (padicNorm p r)
hgt : padicNorm p r > padicNorm p (q + r)
⊢ False

tactic: exact not_lt_of_ge this hlt
state_before: case a
p✝ p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
hlt : padicNorm p r < padicNorm p q
this : padicNorm p q ≤ padicNorm p r
hgt : padicNorm p r > padicNorm p (q + r)
⊢ False

tactic: rwa [max_eq_left hnge] at this
state_before: p✝ p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
hlt : padicNorm p r < padicNorm p q
this : padicNorm p q ≤ max (padicNorm p (q + r)) (padicNorm p r)
hnge : padicNorm p r ≤ padicNorm p (q + r)
⊢ padicNorm p q ≤ padicNorm p (q + r)

tactic: apply padicNorm.nonarchimedean
state_before: case a
p✝ p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
hlt : padicNorm p r < padicNorm p q
this✝ : padicNorm p q ≤ max (padicNorm p (q + r)) (padicNorm p r)
hnge : padicNorm p r ≤ padicNorm p (q + r)
this : padicNorm p q ≤ padicNorm p (q + r)
⊢ padicNorm p (q + r) ≤ max (padicNorm p q) (padicNorm p r)

tactic: rwa [max_eq_left_of_lt hlt]
state_before: case a
p✝ p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hne : padicNorm p q ≠ padicNorm p r
hlt : padicNorm p r < padicNorm p q
this✝ : padicNorm p q ≤ max (padicNorm p (q + r)) (padicNorm p r)
hnge : padicNorm p r ≤ padicNorm p (q + r)
this : padicNorm p q ≤ padicNorm p (q + r)
⊢ max (padicNorm p q) (padicNorm p r) ≤ padicNorm p (q + r)