Theorem: padicValRat.le_padicValRat_add_of_le
File: Mathlib/NumberTheory/Padics/PadicVal.lean

tactic: simpa [hq] using h
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h : padicValRat p q ≤ padicValRat p r
hq : q = 0
⊢ padicValRat p q ≤ padicValRat p (q + r)

tactic: simp [hr]
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h : padicValRat p q ≤ padicValRat p r
hq : ¬q = 0
hr : r = 0
⊢ padicValRat p q ≤ padicValRat p (q + r)

tactic: have hqn : q.num ≠ 0 := Rat.num_ne_zero_of_ne_zero hq
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h : padicValRat p q ≤ padicValRat p r
hq : ¬q = 0
hr : ¬r = 0
⊢ padicValRat p q ≤ padicValRat p (q + r)

tactic: have hqd : (q.den : ℤ) ≠ 0 := by exact_mod_cast Rat.den_nz _
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h : padicValRat p q ≤ padicValRat p r
hq : ¬q = 0
hr : ¬r = 0
hqn : q.num ≠ 0
⊢ padicValRat p q ≤ padicValRat p (q + r)

tactic: have hrn : r.num ≠ 0 := Rat.num_ne_zero_of_ne_zero hr
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h : padicValRat p q ≤ padicValRat p r
hq : ¬q = 0
hr : ¬r = 0
hqn : q.num ≠ 0
hqd : ↑q.den ≠ 0
⊢ padicValRat p q ≤ padicValRat p (q + r)

tactic: have hrd : (r.den : ℤ) ≠ 0 := by exact_mod_cast Rat.den_nz _
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h : padicValRat p q ≤ padicValRat p r
hq : ¬q = 0
hr : ¬r = 0
hqn : q.num ≠ 0
hqd : ↑q.den ≠ 0
hrn : r.num ≠ 0
⊢ padicValRat p q ≤ padicValRat p (q + r)

tactic: have hqreq : q + r = (q.num * r.den + q.den * r.num) /. (q.den * r.den) := Rat.add_num_den _ _
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h : padicValRat p q ≤ padicValRat p r
hq : ¬q = 0
hr : ¬r = 0
hqn : q.num ≠ 0
hqd : ↑q.den ≠ 0
hrn : r.num ≠ 0
hrd : ↑r.den ≠ 0
⊢ padicValRat p q ≤ padicValRat p (q + r)

tactic: have hqrd : q.num * r.den + q.den * r.num ≠ 0 := Rat.mk_num_ne_zero_of_ne_zero hqr hqreq
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h : padicValRat p q ≤ padicValRat p r
hq : ¬q = 0
hr : ¬r = 0
hqn : q.num ≠ 0
hqd : ↑q.den ≠ 0
hrn : r.num ≠ 0
hrd : ↑r.den ≠ 0
hqreq : q + r = (q.num * ↑r.den + ↑q.den * r.num) /. (↑q.den * ↑r.den)
⊢ padicValRat p q ≤ padicValRat p (q + r)

tactic: conv_lhs => rw [← @Rat.num_den q]
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h : padicValRat p q ≤ padicValRat p r
hq : ¬q = 0
hr : ¬r = 0
hqn : q.num ≠ 0
hqd : ↑q.den ≠ 0
hrn : r.num ≠ 0
hrd : ↑r.den ≠ 0
hqreq : q + r = (q.num * ↑r.den + ↑q.den * r.num) /. (↑q.den * ↑r.den)
hqrd : q.num * ↑r.den + ↑q.den * r.num ≠ 0
⊢ padicValRat p q ≤ padicValRat p (q + r)

tactic: rw [hqreq, padicValRat_le_padicValRat_iff hqn hqrd hqd (mul_ne_zero hqd hrd), ←
  multiplicity_le_multiplicity_iff, mul_left_comm,
  multiplicity.mul (Nat.prime_iff_prime_int.1 hp.1), add_mul]
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h : padicValRat p q ≤ padicValRat p r
hq : ¬q = 0
hr : ¬r = 0
hqn : q.num ≠ 0
hqd : ↑q.den ≠ 0
hrn : r.num ≠ 0
hrd : ↑r.den ≠ 0
hqreq : q + r = (q.num * ↑r.den + ↑q.den * r.num) /. (↑q.den * ↑r.den)
hqrd : q.num * ↑r.den + ↑q.den * r.num ≠ 0
⊢ padicValRat p (q.num /. ↑q.den) ≤ padicValRat p (q + r)

tactic: rw [← @Rat.num_den q, ← @Rat.num_den r, padicValRat_le_padicValRat_iff hqn hrn hqd hrd, ←
  multiplicity_le_multiplicity_iff] at h
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h : padicValRat p q ≤ padicValRat p r
hq : ¬q = 0
hr : ¬r = 0
hqn : q.num ≠ 0
hqd : ↑q.den ≠ 0
hrn : r.num ≠ 0
hrd : ↑r.den ≠ 0
hqreq : q + r = (q.num * ↑r.den + ↑q.den * r.num) /. (↑q.den * ↑r.den)
hqrd : q.num * ↑r.den + ↑q.den * r.num ≠ 0
⊢ multiplicity ↑p ↑q.den + multiplicity (↑p) (q.num * ↑r.den) ≤
    multiplicity (↑p) (q.num * ↑r.den * ↑q.den + ↑q.den * r.num * ↑q.den)

tactic: calc
  _ ≤
      min (multiplicity (↑p) (q.num * r.den * q.den))
        (multiplicity (↑p) (↑q.den * r.num * ↑q.den)) :=
    le_min
      (by rw [@multiplicity.mul _ _ _ _ (_ * _) _ (Nat.prime_iff_prime_int.1 hp.1), add_comm])
      (by
        rw [mul_assoc,
            @multiplicity.mul _ _ _ _ (q.den : ℤ) (_ * _)
              (Nat.prime_iff_prime_int.1 hp.1)]
        exact add_le_add_left h _)
  _ ≤ _ := min_le_multiplicity_add
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h✝ : ∀ (n : ℕ), ↑p ^ n ∣ q.num * ↑r.den → ↑p ^ n ∣ r.num * ↑q.den
h : multiplicity (↑p) (q.num * ↑r.den) ≤ multiplicity (↑p) (r.num * ↑q.den)
hq : ¬q = 0
hr : ¬r = 0
hqn : q.num ≠ 0
hqd : ↑q.den ≠ 0
hrn : r.num ≠ 0
hrd : ↑r.den ≠ 0
hqreq : q + r = (q.num * ↑r.den + ↑q.den * r.num) /. (↑q.den * ↑r.den)
hqrd : q.num * ↑r.den + ↑q.den * r.num ≠ 0
⊢ multiplicity ↑p ↑q.den + multiplicity (↑p) (q.num * ↑r.den) ≤
    multiplicity (↑p) (q.num * ↑r.den * ↑q.den + ↑q.den * r.num * ↑q.den)

tactic: exact_mod_cast Rat.den_nz _
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h : padicValRat p q ≤ padicValRat p r
hq : ¬q = 0
hr : ¬r = 0
hqn : q.num ≠ 0
⊢ ↑q.den ≠ 0

tactic: exact_mod_cast Rat.den_nz _
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h : padicValRat p q ≤ padicValRat p r
hq : ¬q = 0
hr : ¬r = 0
hqn : q.num ≠ 0
hqd : ↑q.den ≠ 0
hrn : r.num ≠ 0
⊢ ↑r.den ≠ 0

tactic: rw [@multiplicity.mul _ _ _ _ (_ * _) _ (Nat.prime_iff_prime_int.1 hp.1), add_comm]
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h✝ : ∀ (n : ℕ), ↑p ^ n ∣ q.num * ↑r.den → ↑p ^ n ∣ r.num * ↑q.den
h : multiplicity (↑p) (q.num * ↑r.den) ≤ multiplicity (↑p) (r.num * ↑q.den)
hq : ¬q = 0
hr : ¬r = 0
hqn : q.num ≠ 0
hqd : ↑q.den ≠ 0
hrn : r.num ≠ 0
hrd : ↑r.den ≠ 0
hqreq : q + r = (q.num * ↑r.den + ↑q.den * r.num) /. (↑q.den * ↑r.den)
hqrd : q.num * ↑r.den + ↑q.den * r.num ≠ 0
⊢ multiplicity ↑p ↑q.den + multiplicity (↑p) (q.num * ↑r.den) ≤ multiplicity (↑p) (q.num * ↑r.den * ↑q.den)

tactic: rw [mul_assoc,
    @multiplicity.mul _ _ _ _ (q.den : ℤ) (_ * _)
      (Nat.prime_iff_prime_int.1 hp.1)]
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h✝ : ∀ (n : ℕ), ↑p ^ n ∣ q.num * ↑r.den → ↑p ^ n ∣ r.num * ↑q.den
h : multiplicity (↑p) (q.num * ↑r.den) ≤ multiplicity (↑p) (r.num * ↑q.den)
hq : ¬q = 0
hr : ¬r = 0
hqn : q.num ≠ 0
hqd : ↑q.den ≠ 0
hrn : r.num ≠ 0
hrd : ↑r.den ≠ 0
hqreq : q + r = (q.num * ↑r.den + ↑q.den * r.num) /. (↑q.den * ↑r.den)
hqrd : q.num * ↑r.den + ↑q.den * r.num ≠ 0
⊢ multiplicity ↑p ↑q.den + multiplicity (↑p) (q.num * ↑r.den) ≤ multiplicity (↑p) (↑q.den * r.num * ↑q.den)

tactic: exact add_le_add_left h _
state_before: p : ℕ
hp : Fact (Nat.Prime p)
q r : ℚ
hqr : q + r ≠ 0
h✝ : ∀ (n : ℕ), ↑p ^ n ∣ q.num * ↑r.den → ↑p ^ n ∣ r.num * ↑q.den
h : multiplicity (↑p) (q.num * ↑r.den) ≤ multiplicity (↑p) (r.num * ↑q.den)
hq : ¬q = 0
hr : ¬r = 0
hqn : q.num ≠ 0
hqd : ↑q.den ≠ 0
hrn : r.num ≠ 0
hrd : ↑r.den ≠ 0
hqreq : q + r = (q.num * ↑r.den + ↑q.den * r.num) /. (↑q.den * ↑r.den)
hqrd : q.num * ↑r.den + ↑q.den * r.num ≠ 0
⊢ multiplicity ↑p ↑q.den + multiplicity (↑p) (q.num * ↑r.den) ≤
    multiplicity ↑p ↑q.den + multiplicity (↑p) (r.num * ↑q.den)