-- Mathlib/Algebra/Module/PID.lean
theorem _root_.Ideal.torsionOf_eq_span_pow_pOrder (x : M) :
    torsionOf R M x = span {p ^ pOrder hM x}

Proof state:
case h.a
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
n : ℕ
⊢ p ^ n • x = 0 ↔ p ^ n ∈ torsionOf R M x

Tactic:
rfl

Result:
no goals

Proof state:
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
⊢ (fun n => p ^ n • x = 0) = fun n => Associates.mk (generator (torsionOf R M x)) ∣ Associates.mk p ^ n

Tactic:
ext n

Result:
case h.a
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
n : ℕ
⊢ p ^ n • x = 0 ↔ Associates.mk (generator (torsionOf R M x)) ∣ Associates.mk p ^ n

Proof state:
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
⊢ torsionOf R M x = Ideal.span {p ^ Nat.find ⋯}

Tactic:
rw [← (torsionOf R M x).span_singleton_generator, Ideal.span_singleton_eq_span_singleton, ←
  Associates.mk_eq_mk_iff_associated, Associates.mk_pow]

Result:
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
⊢ Associates.mk (generator (torsionOf R M x)) = Associates.mk p ^ Nat.find ⋯

Proof state:
case h.a
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
n : ℕ
⊢ p ^ n • x = 0 ↔ Associates.mk (generator (torsionOf R M x)) ∣ Associates.mk p ^ n

Tactic:
rw [← Associates.mk_pow, Associates.mk_dvd_mk, ← mem_iff_generator_dvd]

Result:
case h.a
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
n : ℕ
⊢ p ^ n • x = 0 ↔ p ^ n ∈ torsionOf R M x

Proof state:
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
prop : (fun n => p ^ n • x = 0) = fun n => Associates.mk (generator (torsionOf R M x)) ∣ Associates.mk p ^ n
⊢ Associates.mk (generator (torsionOf R M x)) = Associates.mk p ^ Nat.find ⋯

Tactic:
have := (isTorsion'_powers_iff p).mp hM x

Result:
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
prop : (fun n => p ^ n • x = 0) = fun n => Associates.mk (generator (torsionOf R M x)) ∣ Associates.mk p ^ n
this : ∃ n, p ^ n • x = 0
⊢ Associates.mk (generator (torsionOf R M x)) = Associates.mk p ^ Nat.find ⋯

Proof state:
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
⊢ Associates.mk (generator (torsionOf R M x)) = Associates.mk p ^ Nat.find ⋯

Tactic:
have prop :
  (fun n : ℕ => p ^ n • x = 0) = fun n : ℕ =>
    (Associates.mk <| generator <| torsionOf R M x) ∣ Associates.mk p ^ n := by
  ext n; rw [← Associates.mk_pow, Associates.mk_dvd_mk, ← mem_iff_generator_dvd]; rfl

Result:
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
prop : (fun n => p ^ n • x = 0) = fun n => Associates.mk (generator (torsionOf R M x)) ∣ Associates.mk p ^ n
⊢ Associates.mk (generator (torsionOf R M x)) = Associates.mk p ^ Nat.find ⋯

Proof state:
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
⊢ torsionOf R M x = Ideal.span {p ^ pOrder hM x}

Tactic:
classical
dsimp only [pOrder]
rw [← (torsionOf R M x).span_singleton_generator, Ideal.span_singleton_eq_span_singleton, ←
  Associates.mk_eq_mk_iff_associated, Associates.mk_pow]
have prop :
  (fun n : ℕ => p ^ n • x = 0) = fun n : ℕ =>
    (Associates.mk <| generator <| torsionOf R M x) ∣ Associates.mk p ^ n := by
  ext n; rw [← Associates.mk_pow, Associates.mk_dvd_mk, ← mem_iff_generator_dvd]; rfl
have := (isTorsion'_powers_iff p).mp hM x; rw [prop] at this
convert Associates.eq_pow_find_of_dvd_irreducible_pow (Associates.irreducible_mk.mpr hp)
  this.choose_spec

Result:
no goals

Proof state:
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
prop : (fun n => p ^ n • x = 0) = fun n => Associates.mk (generator (torsionOf R M x)) ∣ Associates.mk p ^ n
this : ∃ n, p ^ n • x = 0
⊢ Associates.mk (generator (torsionOf R M x)) = Associates.mk p ^ Nat.find ⋯

Tactic:
rw [prop] at this

Result:
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
prop : (fun n => p ^ n • x = 0) = fun n => Associates.mk (generator (torsionOf R M x)) ∣ Associates.mk p ^ n
this : ∃ n, Associates.mk (generator (torsionOf R M x)) ∣ Associates.mk p ^ n
⊢ Associates.mk (generator (torsionOf R M x)) = Associates.mk p ^ Nat.find ⋯

Proof state:
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
prop : (fun n => p ^ n • x = 0) = fun n => Associates.mk (generator (torsionOf R M x)) ∣ Associates.mk p ^ n
this : ∃ n, Associates.mk (generator (torsionOf R M x)) ∣ Associates.mk p ^ n
⊢ Associates.mk (generator (torsionOf R M x)) = Associates.mk p ^ Nat.find ⋯

Tactic:
convert Associates.eq_pow_find_of_dvd_irreducible_pow (Associates.irreducible_mk.mpr hp)
  this.choose_spec

Result:
no goals

Proof state:
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
⊢ torsionOf R M x = Ideal.span {p ^ pOrder hM x}

Tactic:
dsimp only [pOrder]

Result:
R : Type u
inst✝⁴ : CommRing R
inst✝³ : IsPrincipalIdealRing R
M : Type v
inst✝² : AddCommGroup M
inst✝¹ : Module R M
inst✝ : IsDomain R
p : R
hp : Irreducible p
hM : IsTorsion' M ↥(Submonoid.powers p)
dec : (x : M) → Decidable (x = 0)
x : M
⊢ torsionOf R M x = Ideal.span {p ^ Nat.find ⋯}