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

tactic: apply ZMod.ringHom_eq_of_ker_eq
state_before: p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x : ℤ_[p]
m n : ℕ
h : m ≤ n
⊢ RingHom.comp (ZMod.castHom (_ : p ^ m ∣ p ^ n) (ZMod (p ^ m))) (toZModPow n) = toZModPow m

tactic: ext x
state_before: case h
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x : ℤ_[p]
m n : ℕ
h : m ≤ n
⊢ RingHom.ker (RingHom.comp (ZMod.castHom (_ : p ^ m ∣ p ^ n) (ZMod (p ^ m))) (toZModPow n)) = RingHom.ker (toZModPow m)

tactic: rw [RingHom.mem_ker, RingHom.mem_ker]
state_before: case h.h
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
m n : ℕ
h : m ≤ n
x : ℤ_[p]
⊢ x ∈ RingHom.ker (RingHom.comp (ZMod.castHom (_ : p ^ m ∣ p ^ n) (ZMod (p ^ m))) (toZModPow n)) ↔
    x ∈ RingHom.ker (toZModPow m)

tactic: simp only [Function.comp_apply, ZMod.castHom_apply, RingHom.coe_comp]
state_before: case h.h
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
m n : ℕ
h : m ≤ n
x : ℤ_[p]
⊢ ↑(RingHom.comp (ZMod.castHom (_ : p ^ m ∣ p ^ n) (ZMod (p ^ m))) (toZModPow n)) x = 0 ↔ ↑(toZModPow m) x = 0

tactic: simp only [toZModPow, toZModHom, RingHom.coe_mk]
state_before: case h.h
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
m n : ℕ
h : m ≤ n
x : ℤ_[p]
⊢ ↑(↑(toZModPow n) x) = 0 ↔ ↑(toZModPow m) x = 0

tactic: dsimp
state_before: case h.h
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
m n : ℕ
h : m ≤ n
x : ℤ_[p]
⊢ ↑(↑{ toOneHom := { toFun := fun x => ↑(appr x n), map_one' := (_ : (fun x => ↑(appr x n)) 1 = 1) },
              map_mul' :=
                (_ :
                  ∀ (x y : ℤ_[p]),
                    OneHom.toFun { toFun := fun x => ↑(appr x n), map_one' := (_ : (fun x => ↑(appr x n)) 1 = 1) }
                        (x * y) =
                      OneHom.toFun { toFun := fun x => ↑(appr x n), map_one' := (_ : (fun x => ↑(appr x n)) 1 = 1) } x *
                        OneHom.toFun { toFun := fun x => ↑(appr x n), map_one' := (_ : (fun x => ↑(appr x n)) 1 = 1) }
                          y) }
          x) =
      0 ↔
    ↑{ toOneHom := { toFun := fun x => ↑(appr x m), map_one' := (_ : (fun x => ↑(appr x m)) 1 = 1) },
            map_mul' :=
              (_ :
                ∀ (x y : ℤ_[p]),
                  OneHom.toFun { toFun := fun x => ↑(appr x m), map_one' := (_ : (fun x => ↑(appr x m)) 1 = 1) }
                      (x * y) =
                    OneHom.toFun { toFun := fun x => ↑(appr x m), map_one' := (_ : (fun x => ↑(appr x m)) 1 = 1) } x *
                      OneHom.toFun { toFun := fun x => ↑(appr x m), map_one' := (_ : (fun x => ↑(appr x m)) 1 = 1) }
                        y) }
        x =
      0

tactic: rw [ZMod.cast_nat_cast (pow_dvd_pow p h),
  zmod_congr_of_sub_mem_span m (x.appr n) (x.appr n) (x.appr m)]
state_before: case h.h
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
m n : ℕ
h : m ≤ n
x : ℤ_[p]
⊢ ↑↑(appr x n) = 0 ↔ ↑(appr x m) = 0

tactic: rw [sub_self]
state_before: case h.h.ha
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
m n : ℕ
h : m ≤ n
x : ℤ_[p]
⊢ ↑(appr x n) - ↑(appr x n) ∈ Ideal.span {↑p ^ m}

tactic: apply Ideal.zero_mem _
state_before: case h.h.ha
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
m n : ℕ
h : m ≤ n
x : ℤ_[p]
⊢ 0 ∈ Ideal.span {↑p ^ m}

tactic: rw [Ideal.mem_span_singleton]
state_before: case h.h.hb
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
m n : ℕ
h : m ≤ n
x : ℤ_[p]
⊢ ↑(appr x n) - ↑(appr x m) ∈ Ideal.span {↑p ^ m}

tactic: rcases dvd_appr_sub_appr x m n h with ⟨c, hc⟩
state_before: case h.h.hb
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
m n : ℕ
h : m ≤ n
x : ℤ_[p]
⊢ ↑p ^ m ∣ ↑(appr x n) - ↑(appr x m)

tactic: use c
state_before: case h.h.hb.intro
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
m n : ℕ
h : m ≤ n
x : ℤ_[p]
c : ℕ
hc : appr x n - appr x m = p ^ m * c
⊢ ↑p ^ m ∣ ↑(appr x n) - ↑(appr x m)

tactic: rw [← Nat.cast_sub (appr_mono _ h), hc, Nat.cast_mul, Nat.cast_pow]
state_before: case h.h.hb.intro
p : ℕ
hp_prime : Fact (Nat.Prime p)
r : ℚ
x✝ : ℤ_[p]
m n : ℕ
h : m ≤ n
x : ℤ_[p]
c : ℕ
hc : appr x n - appr x m = p ^ m * c
⊢ ↑(appr x n) - ↑(appr x m) = ↑p ^ m * ↑c