Theorem: DiscreteValuationRing.HasUnitMulPowIrreducibleFactorization.toUniqueFactorizationMonoid
File: Mathlib/RingTheory/DiscreteValuationRing/Basic.lean

tactic: use Multiset.replicate (Classical.choose (spec.2 hx)) p
state_before: R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
⊢ ∃ f, (∀ (b : R), b ∈ f → Prime b) ∧ Associated (Multiset.prod f) x

tactic: constructor
state_before: R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
⊢ (∀ (b : R), b ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p → Prime b) ∧
    Associated (Multiset.prod (Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p)) x

tactic: intro q hq
state_before: case left
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
⊢ ∀ (b : R), b ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p → Prime b

tactic: have hpq := Multiset.eq_of_mem_replicate hq
state_before: case left
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
⊢ Prime q

tactic: rw [hpq]
state_before: case left
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
⊢ Prime q

tactic: refine' ⟨spec.1.ne_zero, spec.1.not_unit, _⟩
state_before: case left
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
⊢ Prime p

tactic: intro a b h
state_before: case left
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
⊢ ∀ (a b : R), p ∣ a * b → p ∣ a ∨ p ∣ b

tactic: by_cases ha : a = 0
state_before: case left
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
a b : R
h : p ∣ a * b
⊢ p ∣ a ∨ p ∣ b

tactic: obtain ⟨m, u, rfl⟩ := spec.2 ha
state_before: case neg
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
a b : R
h : p ∣ a * b
ha : ¬a = 0
⊢ p ∣ a ∨ p ∣ b

tactic: rw [mul_assoc, mul_left_comm, IsUnit.dvd_mul_left _ _ _ (Units.isUnit _)] at h
state_before: case neg.intro.intro
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
b : R
m : ℕ
u : Rˣ
h : p ∣ choose hR ^ m * ↑u * b
ha : ¬choose hR ^ m * ↑u = 0
⊢ p ∣ choose hR ^ m * ↑u ∨ p ∣ b

tactic: rw [IsUnit.dvd_mul_right (Units.isUnit _)]
state_before: case neg.intro.intro
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
b : R
m : ℕ
u : Rˣ
h : p ∣ choose hR ^ m * b
ha : ¬choose hR ^ m * ↑u = 0
⊢ p ∣ choose hR ^ m * ↑u ∨ p ∣ b

tactic: by_cases hm : m = 0
state_before: case neg.intro.intro
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
b : R
m : ℕ
u : Rˣ
h : p ∣ choose hR ^ m * b
ha : ¬choose hR ^ m * ↑u = 0
⊢ p ∣ choose hR ^ m ∨ p ∣ b

tactic: left
state_before: case neg
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
b : R
m : ℕ
u : Rˣ
h : p ∣ choose hR ^ m * b
ha : ¬choose hR ^ m * ↑u = 0
hm : ¬m = 0
⊢ p ∣ choose hR ^ m ∨ p ∣ b

tactic: obtain ⟨m, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hm
state_before: case neg.h
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
b : R
m : ℕ
u : Rˣ
h : p ∣ choose hR ^ m * b
ha : ¬choose hR ^ m * ↑u = 0
hm : ¬m = 0
⊢ p ∣ choose hR ^ m

tactic: rw [pow_succ]
state_before: case neg.h.intro
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
b : R
u : Rˣ
m : ℕ
h : p ∣ choose hR ^ Nat.succ m * b
ha : ¬choose hR ^ Nat.succ m * ↑u = 0
hm : ¬Nat.succ m = 0
⊢ p ∣ choose hR ^ Nat.succ m

tactic: apply dvd_mul_of_dvd_left dvd_rfl _
state_before: case neg.h.intro
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
b : R
u : Rˣ
m : ℕ
h : p ∣ choose hR ^ Nat.succ m * b
ha : ¬choose hR ^ Nat.succ m * ↑u = 0
hm : ¬Nat.succ m = 0
⊢ p ∣ choose hR * choose hR ^ m

tactic: rw [ha]
state_before: case pos
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
a b : R
h : p ∣ a * b
ha : a = 0
⊢ p ∣ a ∨ p ∣ b

tactic: simp only [true_or_iff, dvd_zero]
state_before: case pos
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
a b : R
h : p ∣ a * b
ha : a = 0
⊢ p ∣ 0 ∨ p ∣ b

tactic: simp only [hm, one_mul, pow_zero] at h⊢
state_before: case pos
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
b : R
m : ℕ
u : Rˣ
h : p ∣ choose hR ^ m * b
ha : ¬choose hR ^ m * ↑u = 0
hm : m = 0
⊢ p ∣ choose hR ^ m ∨ p ∣ b

tactic: right
state_before: case pos
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
b : R
m : ℕ
u : Rˣ
ha : ¬choose hR ^ m * ↑u = 0
hm : m = 0
h : choose hR ∣ b
⊢ choose hR ∣ 1 ∨ choose hR ∣ b

tactic: exact h
state_before: case pos.h
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
q : R
hq : q ∈ Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p
hpq : q = p
b : R
m : ℕ
u : Rˣ
ha : ¬choose hR ^ m * ↑u = 0
hm : m = 0
h : choose hR ∣ b
⊢ choose hR ∣ b

tactic: rw [Multiset.prod_replicate]
state_before: case right
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
⊢ Associated (Multiset.prod (Multiset.replicate (choose (_ : ∃ n, Associated (choose hR ^ n) x)) p)) x

tactic: exact Classical.choose_spec (spec.2 hx)
state_before: case right
R : Type u_1
inst✝¹ : CommRing R
hR : HasUnitMulPowIrreducibleFactorization R
inst✝ : IsDomain R
p : R := choose hR
spec : Irreducible (choose hR) ∧ ∀ {x : R}, x ≠ 0 → ∃ n, Associated (choose hR ^ n) x := choose_spec hR
x : R
hx : x ≠ 0
⊢ Associated (p ^ choose (_ : ∃ n, Associated (choose hR ^ n) x)) x