Theorem: PadicInt.norm_sub_modPart
File: Mathlib/NumberTheory/Padics/RingHoms.lean

tactic: let n := modPart p r
state_before: p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
⊢ ‖⟨↑r, h⟩ - ↑(modPart p r)‖ < 1
state_after: p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
⊢ ‖⟨↑r, h⟩ - ↑(modPart p r)‖ < 1

tactic: rw [norm_lt_one_iff_dvd, ← (isUnit_den r h).dvd_mul_right]
state_before: p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
⊢ ‖⟨↑r, h⟩ - ↑(modPart p r)‖ < 1
state_after: p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
⊢ ↑p ∣ (⟨↑r, h⟩ - ↑(modPart p r)) * ↑r.den

tactic: suffices ↑p ∣ r.num - n * r.den by
  convert (Int.castRingHom ℤ_[p]).map_dvd this
  simp only [sub_mul, Int.cast_natCast, eq_intCast, Int.cast_mul, sub_left_inj, Int.cast_sub]
  apply Subtype.coe_injective
  simp only [coe_mul, Subtype.coe_mk, coe_natCast]
  rw_mod_cast [@Rat.mul_den_eq_num r]
  rfl
state_before: p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
⊢ ↑p ∣ (⟨↑r, h⟩ - ↑(modPart p r)) * ↑r.den
state_after: p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
⊢ ↑p ∣ r.num - n * ↑r.den

tactic: exact norm_sub_modPart_aux r h
state_before: p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
⊢ ↑p ∣ r.num - n * ↑r.den
state_after: no goals

tactic: convert (Int.castRingHom ℤ_[p]).map_dvd this
state_before: p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
this : ↑p ∣ r.num - n * ↑r.den
⊢ ↑p ∣ (⟨↑r, h⟩ - ↑(modPart p r)) * ↑r.den
state_after: case h.e'_4
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
this : ↑p ∣ r.num - n * ↑r.den
⊢ (⟨↑r, h⟩ - ↑(modPart p r)) * ↑r.den = (Int.castRingHom ℤ_[p]) (r.num - n * ↑r.den)

tactic: simp only [sub_mul, Int.cast_natCast, eq_intCast, Int.cast_mul, sub_left_inj, Int.cast_sub]
state_before: case h.e'_4
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
this : ↑p ∣ r.num - n * ↑r.den
⊢ (⟨↑r, h⟩ - ↑(modPart p r)) * ↑r.den = (Int.castRingHom ℤ_[p]) (r.num - n * ↑r.den)
state_after: case h.e'_4
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
this : ↑p ∣ r.num - n * ↑r.den
⊢ ⟨↑r, h⟩ * ↑r.den = ↑r.num

tactic: apply Subtype.coe_injective
state_before: case h.e'_4
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
this : ↑p ∣ r.num - n * ↑r.den
⊢ ⟨↑r, h⟩ * ↑r.den = ↑r.num
state_after: case h.e'_4.a
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
this : ↑p ∣ r.num - n * ↑r.den
⊢ (fun a => ↑a) (⟨↑r, h⟩ * ↑r.den) = (fun a => ↑a) ↑r.num

tactic: simp only [coe_mul, Subtype.coe_mk, coe_natCast]
state_before: case h.e'_4.a
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
this : ↑p ∣ r.num - n * ↑r.den
⊢ (fun a => ↑a) (⟨↑r, h⟩ * ↑r.den) = (fun a => ↑a) ↑r.num
state_after: case h.e'_4.a
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
this : ↑p ∣ r.num - n * ↑r.den
⊢ ↑r * ↑r.den = ↑↑r.num

tactic: rw_mod_cast [@Rat.mul_den_eq_num r]
state_before: case h.e'_4.a
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
h : ‖↑r‖ ≤ 1
n : ℤ := modPart p r
this : ↑p ∣ r.num - n * ↑r.den
⊢ ↑r * ↑r.den = ↑↑r.num
state_after: case h.e'_4.a
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
n : ℤ := modPart p r
this : ↑p ∣ r.num - n * ↑r.den
h : ‖↑r‖ ≤ 1
⊢ ↑↑r.num = ↑r.num

tactic: rfl
state_before: case h.e'_4.a
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
n : ℤ := modPart p r
this : ↑p ∣ r.num - n * ↑r.den
h : ‖↑r‖ ≤ 1
⊢ ↑↑r.num = ↑r.num
state_after: no goals