l3lab/ntp-mathlib huggingface dataset:
/--
Consider direct limits `lim G` and `lim G'` with direct system `f` and `f'` respectively, any
family of equivalences `eᵢ : Gᵢ ≅ G'ᵢ` such that `e ∘ f = f' ∘ e` induces an equivalence
`lim G ⟶ lim G'`.
-/
def congr [IsDirected ι (· ≤ ·)]
    (e : (i : ι) → G i ≃+* G' i)
    (he : ∀ i j h, (e j).toRingHom.comp (f i j h) = (f' i j h).comp (e i)) :
    DirectLimit G (fun _ _ h ↦ f _ _ h) ≃+* DirectLimit G' fun _ _ h ↦ f' _ _ h :=
  RingEquiv.ofHomInv
    (map (e ·) he)
    (map (fun i ↦ (e i).symm) fun i j h ↦ FunLike.ext _ _ fun x ↦ by
      have eq1 := FunLike.congr_fun (he i j h) ((e i).symm x)
      simp only [RingEquiv.toRingHom_eq_coe, RingHom.coe_comp, RingHom.coe_coe, Function.comp_apply,
        RingEquiv.apply_symm_apply] at eq1 ⊢
      simp [← eq1, of_f])
    (FunLike.ext _ _ fun x ↦ x.induction_on <| by simp)
    (FunLike.ext _ _ fun x ↦ x.induction_on <| by 

Proof state:
R : Type u
inst✝⁷ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁶ : Preorder ι
G : ι → Type w
inst✝⁵ : (i : ι) → CommRing (G i)
f✝ : (i j : ι) → i ≤ j → G i → G j
f'✝ : (i j : ι) → i ≤ j → G i →+* G j
P : Type u₁
inst✝⁴ : CommRing P
g : (i : ι) → G i →+* P
Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), (g j) (f✝ i j hij x) = (g i) x
f : (i j : ι) → i ≤ j → G i →+* G j
G' : ι → Type v'
inst✝³ : (i : ι) → CommRing (G' i)
f' : (i j : ι) → i ≤ j → G' i →+* G' j
G'' : ι → Type v''
inst✝² : (i : ι) → CommRing (G'' i)
f'' : (i j : ι) → i ≤ j → G'' i →+* G'' j
inst✝¹ : Nonempty ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
e : (i : ι) → G i ≃+* G' i
he : ∀ (i j : ι) (h : i ≤ j), RingHom.comp (RingEquiv.toRingHom (e j)) (f i j h) = RingHom.comp (f' i j h) ↑(e i)
x : DirectLimit G' fun x x_1 h => ⇑(f' x x_1 h)
⊢ ∀ (i : ι) (x : G' i),
    (RingHom.comp ↑(map (fun x => ↑(e x)) he)
          ↑(map (fun i => ↑(RingEquiv.symm (e i)))
              (_ :
                ∀ (i j : ι) (h : i ≤ j),
                  RingHom.comp ((fun i => ↑(RingEquiv.symm (e i))) j) (f' i j h) =
                    RingHom.comp (f i j h) ((fun i => ↑(RingEquiv.symm (e i))) i))))
        ((of G' (fun x x_1 h => ⇑(f' x x_1 h)) i) x) =
      (RingHom.id (DirectLimit G' fun x x_1 h => ⇑(f' x x_1 h))) ((of G' (fun x x_1 h => ⇑(f' x x_1 h)) i) x)

Next tactic:
simp
lemma congr_symm_apply_of [IsDirected ι (· ≤ ·)]
    (e : (i : ι) → G i ≃+* G' i)
    (he : ∀ i j h, (e j).toRingHom.comp (f i j h) = (f' i j h).comp (e i))
    {i : ι} (g : G' i) :
    (congr e he).symm (of G' _ i g) = of G (fun _ _ h ↦ f _ _ h) i ((e i).symm g) := by
  

Proof state:
R : Type u
inst✝⁷ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁶ : Preorder ι
G : ι → Type w
inst✝⁵ : (i : ι) → CommRing (G i)
f✝ : (i j : ι) → i ≤ j → G i → G j
f'✝ : (i j : ι) → i ≤ j → G i →+* G j
P : Type u₁
inst✝⁴ : CommRing P
g✝ : (i : ι) → G i →+* P
Hg : ∀ (i j : ι) (hij : i ≤ j) (x : G i), (g✝ j) (f✝ i j hij x) = (g✝ i) x
f : (i j : ι) → i ≤ j → G i →+* G j
G' : ι → Type v'
inst✝³ : (i : ι) → CommRing (G' i)
f' : (i j : ι) → i ≤ j → G' i →+* G' j
G'' : ι → Type v''
inst✝² : (i : ι) → CommRing (G'' i)
f'' : (i j : ι) → i ≤ j → G'' i →+* G'' j
inst✝¹ : Nonempty ι
inst✝ : IsDirected ι fun x x_1 => x ≤ x_1
e : (i : ι) → G i ≃+* G' i
he : ∀ (i j : ι) (h : i ≤ j), RingHom.comp (RingEquiv.toRingHom (e j)) (f i j h) = RingHom.comp (f' i j h) ↑(e i)
i : ι
g : G' i
⊢ (RingEquiv.symm (congr e he)) ((of G' (fun x x_1 h => ⇑(f' x x_1 h)) i) g) =
    (of G (fun x x_1 h => ⇑(f x x_1 h)) i) ((RingEquiv.symm (e i)) g)

Next tactic:
simp only [congr, RingEquiv.ofHomInv_symm_apply, map_apply_of, RingHom.coe_coe]
instance nontrivial [DirectedSystem G fun i j h => f' i j h] :
    Nontrivial (Ring.DirectLimit G fun i j h => f' i j h) :=
  ⟨⟨0, 1,
      Nonempty.elim (by 

Proof state:
R : Type u
inst✝⁵ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁴ : Preorder ι
G : ι → Type w
inst✝³ : Nonempty ι
inst✝² : IsDirected ι fun x x_1 => x ≤ x_1
inst✝¹ : (i : ι) → Field (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
⊢ Nonempty ι

Next tactic:
infer_instance
instance nontrivial [DirectedSystem G fun i j h => f' i j h] :
    Nontrivial (Ring.DirectLimit G fun i j h => f' i j h) :=
  ⟨⟨0, 1,
      Nonempty.elim (by infer_instance) fun i : ι => by
        

Proof state:
R : Type u
inst✝⁵ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁴ : Preorder ι
G : ι → Type w
inst✝³ : Nonempty ι
inst✝² : IsDirected ι fun x x_1 => x ≤ x_1
inst✝¹ : (i : ι) → Field (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
i : ι
⊢ 0 ≠ 1

Next tactic:
change (0 : Ring.DirectLimit G fun i j h => f' i j h) ≠ 1
instance nontrivial [DirectedSystem G fun i j h => f' i j h] :
    Nontrivial (Ring.DirectLimit G fun i j h => f' i j h) :=
  ⟨⟨0, 1,
      Nonempty.elim (by infer_instance) fun i : ι => by
        change (0 : Ring.DirectLimit G fun i j h => f' i j h) ≠ 1
        

Proof state:
R : Type u
inst✝⁵ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁴ : Preorder ι
G : ι → Type w
inst✝³ : Nonempty ι
inst✝² : IsDirected ι fun x x_1 => x ≤ x_1
inst✝¹ : (i : ι) → Field (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
i : ι
⊢ 0 ≠ 1

Next tactic:
rw [← (Ring.DirectLimit.of _ _ _).map_one]
instance nontrivial [DirectedSystem G fun i j h => f' i j h] :
    Nontrivial (Ring.DirectLimit G fun i j h => f' i j h) :=
  ⟨⟨0, 1,
      Nonempty.elim (by infer_instance) fun i : ι => by
        change (0 : Ring.DirectLimit G fun i j h => f' i j h) ≠ 1
        rw [← (Ring.DirectLimit.of _ _ _).map_one]
        

Proof state:
R : Type u
inst✝⁵ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁴ : Preorder ι
G : ι → Type w
inst✝³ : Nonempty ι
inst✝² : IsDirected ι fun x x_1 => x ≤ x_1
inst✝¹ : (i : ι) → Field (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
i : ι
⊢ 0 ≠ (Ring.DirectLimit.of G (fun i j h => ⇑(f' i j h)) ?m.5959528) 1
R : Type u
inst✝⁵ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁴ : Preorder ι
G : ι → Type w
inst✝³ : Nonempty ι
inst✝² : IsDirected ι fun x x_1 => x ≤ x_1
inst✝¹ : (i : ι) → Field (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
i : ι
⊢ ι

Next tactic:
intro H
instance nontrivial [DirectedSystem G fun i j h => f' i j h] :
    Nontrivial (Ring.DirectLimit G fun i j h => f' i j h) :=
  ⟨⟨0, 1,
      Nonempty.elim (by infer_instance) fun i : ι => by
        change (0 : Ring.DirectLimit G fun i j h => f' i j h) ≠ 1
        rw [← (Ring.DirectLimit.of _ _ _).map_one]
        intro H; 

Proof state:
R : Type u
inst✝⁵ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁴ : Preorder ι
G : ι → Type w
inst✝³ : Nonempty ι
inst✝² : IsDirected ι fun x x_1 => x ≤ x_1
inst✝¹ : (i : ι) → Field (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
i : ι
H : 0 = (Ring.DirectLimit.of G (fun i j h => ⇑(f' i j h)) ?m.5959528) 1
⊢ False
R : Type u
inst✝⁵ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁴ : Preorder ι
G : ι → Type w
inst✝³ : Nonempty ι
inst✝² : IsDirected ι fun x x_1 => x ≤ x_1
inst✝¹ : (i : ι) → Field (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
i : ι
⊢ ι

Next tactic:
rcases Ring.DirectLimit.of.zero_exact H.symm with ⟨j, hij, hf⟩
instance nontrivial [DirectedSystem G fun i j h => f' i j h] :
    Nontrivial (Ring.DirectLimit G fun i j h => f' i j h) :=
  ⟨⟨0, 1,
      Nonempty.elim (by infer_instance) fun i : ι => by
        change (0 : Ring.DirectLimit G fun i j h => f' i j h) ≠ 1
        rw [← (Ring.DirectLimit.of _ _ _).map_one]
        intro H; rcases Ring.DirectLimit.of.zero_exact H.symm with ⟨j, hij, hf⟩
        

Proof state:
case intro.intro
R : Type u
inst✝⁵ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁴ : Preorder ι
G : ι → Type w
inst✝³ : Nonempty ι
inst✝² : IsDirected ι fun x x_1 => x ≤ x_1
inst✝¹ : (i : ι) → Field (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
i : ι
H : 0 = (Ring.DirectLimit.of G (fun i j h => ⇑(f' i j h)) ?m.5959528) 1
j : ι
hij : ?m.5959528 ≤ j
hf : (f' ?m.5959528 j hij) 1 = 0
⊢ False
R : Type u
inst✝⁵ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁴ : Preorder ι
G : ι → Type w
inst✝³ : Nonempty ι
inst✝² : IsDirected ι fun x x_1 => x ≤ x_1
inst✝¹ : (i : ι) → Field (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
i : ι
⊢ ι

Next tactic:
rw [(f' i j hij).map_one] at hf
instance nontrivial [DirectedSystem G fun i j h => f' i j h] :
    Nontrivial (Ring.DirectLimit G fun i j h => f' i j h) :=
  ⟨⟨0, 1,
      Nonempty.elim (by infer_instance) fun i : ι => by
        change (0 : Ring.DirectLimit G fun i j h => f' i j h) ≠ 1
        rw [← (Ring.DirectLimit.of _ _ _).map_one]
        intro H; rcases Ring.DirectLimit.of.zero_exact H.symm with ⟨j, hij, hf⟩
        rw [(f' i j hij).map_one] at hf
        

Proof state:
case intro.intro
R : Type u
inst✝⁵ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝⁴ : Preorder ι
G : ι → Type w
inst✝³ : Nonempty ι
inst✝² : IsDirected ι fun x x_1 => x ≤ x_1
inst✝¹ : (i : ι) → Field (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
inst✝ : DirectedSystem G fun i j h => ⇑(f' i j h)
i : ι
H : 0 = (Ring.DirectLimit.of G (fun i j h => ⇑(f' i j h)) i) 1
j : ι
hij : i ≤ j
hf : 1 = 0
⊢ False

Next tactic:
exact one_ne_zero hf
theorem exists_inv {p : Ring.DirectLimit G f} : p ≠ 0 → ∃ y, p * y = 1 :=
  Ring.DirectLimit.induction_on p fun i x H =>
    ⟨Ring.DirectLimit.of G f i x⁻¹, by
      

Proof state:
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : Nonempty ι
inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1
inst✝ : (i : ι) → Field (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
p : Ring.DirectLimit G f
i : ι
x : G i
H : (Ring.DirectLimit.of G f i) x ≠ 0
⊢ (Ring.DirectLimit.of G f i) x * (Ring.DirectLimit.of G f i) x⁻¹ = 1

Next tactic:
erw [← (Ring.DirectLimit.of _ _ _).map_mul,
        mul_inv_cancel fun h : x = 0 => H <| by rw [h, (Ring.DirectLimit.of _ _ _).map_zero],
        (Ring.DirectLimit.of _ _ _).map_one]
theorem exists_inv {p : Ring.DirectLimit G f} : p ≠ 0 → ∃ y, p * y = 1 :=
  Ring.DirectLimit.induction_on p fun i x H =>
    ⟨Ring.DirectLimit.of G f i x⁻¹, by
      erw [← (Ring.DirectLimit.of _ _ _).map_mul,
        mul_inv_cancel fun h : x = 0 => H <| by 

Proof state:
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : Nonempty ι
inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1
inst✝ : (i : ι) → Field (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
p : Ring.DirectLimit G f
i : ι
x : G i
H : (Ring.DirectLimit.of G f i) x ≠ 0
h : x = 0
⊢ (Ring.DirectLimit.of G f i) x = 0

Next tactic:
rw [h, (Ring.DirectLimit.of _ _ _).map_zero]
protected theorem mul_inv_cancel {p : Ring.DirectLimit G f} (hp : p ≠ 0) : p * inv G f p = 1 := by
  

Proof state:
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : Nonempty ι
inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1
inst✝ : (i : ι) → Field (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
p : Ring.DirectLimit G f
hp : p ≠ 0
⊢ p * inv G f p = 1

Next tactic:
rw [inv, dif_neg hp, Classical.choose_spec (DirectLimit.exists_inv G f hp)]
protected theorem inv_mul_cancel {p : Ring.DirectLimit G f} (hp : p ≠ 0) : inv G f p * p = 1 := by
  

Proof state:
R : Type u
inst✝⁴ : Ring R
ι : Type v
dec_ι : DecidableEq ι
inst✝³ : Preorder ι
G : ι → Type w
inst✝² : Nonempty ι
inst✝¹ : IsDirected ι fun x x_1 => x ≤ x_1
inst✝ : (i : ι) → Field (G i)
f : (i j : ι) → i ≤ j → G i → G j
f' : (i j : ι) → i ≤ j → G i →+* G j
p : Ring.DirectLimit G f
hp : p ≠ 0
⊢ inv G f p * p = 1

Next tactic:
rw [_root_.mul_comm, DirectLimit.mul_inv_cancel G f hp]
theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R]
    (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by
  

Proof state:
R✝ : Type u
inst✝⁵ : CommRing R✝
inst✝⁴ : IsDomain R✝
inst✝³ : DiscreteValuationRing R✝
R : Type u_1
inst✝² : CommRing R
inst✝¹ : LocalRing R
inst✝ : IsDomain R
ϖ : R
hϖ : ϖ ≠ 0
h : maximalIdeal R = span {ϖ}
⊢ Irreducible ϖ

Next tactic:
have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ
theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R]
    (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by
  have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ
  

Proof state:
R✝ : Type u
inst✝⁵ : CommRing R✝
inst✝⁴ : IsDomain R✝
inst✝³ : DiscreteValuationRing R✝
R : Type u_1
inst✝² : CommRing R
inst✝¹ : LocalRing R
inst✝ : IsDomain R
ϖ : R
hϖ : ϖ ≠ 0
h : maximalIdeal R = span {ϖ}
h2 : ¬IsUnit ϖ
⊢ Irreducible ϖ

Next tactic:
refine' ⟨h2, _⟩
theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R]
    (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by
  have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ
  refine' ⟨h2, _⟩
  

Proof state:
R✝ : Type u
inst✝⁵ : CommRing R✝
inst✝⁴ : IsDomain R✝
inst✝³ : DiscreteValuationRing R✝
R : Type u_1
inst✝² : CommRing R
inst✝¹ : LocalRing R
inst✝ : IsDomain R
ϖ : R
hϖ : ϖ ≠ 0
h : maximalIdeal R = span {ϖ}
h2 : ¬IsUnit ϖ
⊢ ∀ (a b : R), ϖ = a * b → IsUnit a ∨ IsUnit b

Next tactic:
intro a b hab
theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R]
    (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by
  have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ
  refine' ⟨h2, _⟩
  intro a b hab
  

Proof state:
R✝ : Type u
inst✝⁵ : CommRing R✝
inst✝⁴ : IsDomain R✝
inst✝³ : DiscreteValuationRing R✝
R : Type u_1
inst✝² : CommRing R
inst✝¹ : LocalRing R
inst✝ : IsDomain R
ϖ : R
hϖ : ϖ ≠ 0
h : maximalIdeal R = span {ϖ}
h2 : ¬IsUnit ϖ
a b : R
hab : ϖ = a * b
⊢ IsUnit a ∨ IsUnit b

Next tactic:
by_contra! h
theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R]
    (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by
  have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ
  refine' ⟨h2, _⟩
  intro a b hab
  by_contra! h
  

Proof state:
R✝ : Type u
inst✝⁵ : CommRing R✝
inst✝⁴ : IsDomain R✝
inst✝³ : DiscreteValuationRing R✝
R : Type u_1
inst✝² : CommRing R
inst✝¹ : LocalRing R
inst✝ : IsDomain R
ϖ : R
hϖ : ϖ ≠ 0
h✝ : maximalIdeal R = span {ϖ}
h2 : ¬IsUnit ϖ
a b : R
hab : ϖ = a * b
h : ¬IsUnit a ∧ ¬IsUnit b
⊢ False

Next tactic:
obtain ⟨ha : a ∈ maximalIdeal R, hb : b ∈ maximalIdeal R⟩ := h
theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R]
    (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by
  have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ
  refine' ⟨h2, _⟩
  intro a b hab
  by_contra! h
  obtain ⟨ha : a ∈ maximalIdeal R, hb : b ∈ maximalIdeal R⟩ := h
  

Proof state:
case intro
R✝ : Type u
inst✝⁵ : CommRing R✝
inst✝⁴ : IsDomain R✝
inst✝³ : DiscreteValuationRing R✝
R : Type u_1
inst✝² : CommRing R
inst✝¹ : LocalRing R
inst✝ : IsDomain R
ϖ : R
hϖ : ϖ ≠ 0
h : maximalIdeal R = span {ϖ}
h2 : ¬IsUnit ϖ
a b : R
hab : ϖ = a * b
ha : a ∈ maximalIdeal R
hb : b ∈ maximalIdeal R
⊢ False

Next tactic:
rw [h, mem_span_singleton'] at ha hb
theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R]
    (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by
  have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ
  refine' ⟨h2, _⟩
  intro a b hab
  by_contra! h
  obtain ⟨ha : a ∈ maximalIdeal R, hb : b ∈ maximalIdeal R⟩ := h
  rw [h, mem_span_singleton'] at ha hb
  

Proof state:
case intro
R✝ : Type u
inst✝⁵ : CommRing R✝
inst✝⁴ : IsDomain R✝
inst✝³ : DiscreteValuationRing R✝
R : Type u_1
inst✝² : CommRing R
inst✝¹ : LocalRing R
inst✝ : IsDomain R
ϖ : R
hϖ : ϖ ≠ 0
h : maximalIdeal R = span {ϖ}
h2 : ¬IsUnit ϖ
a b : R
hab : ϖ = a * b
ha : ∃ a_1, a_1 * ϖ = a
hb : ∃ a, a * ϖ = b
⊢ False

Next tactic:
rcases ha with ⟨a, rfl⟩
theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R]
    (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by
  have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ
  refine' ⟨h2, _⟩
  intro a b hab
  by_contra! h
  obtain ⟨ha : a ∈ maximalIdeal R, hb : b ∈ maximalIdeal R⟩ := h
  rw [h, mem_span_singleton'] at ha hb
  rcases ha with ⟨a, rfl⟩
  

Proof state:
case intro.intro
R✝ : Type u
inst✝⁵ : CommRing R✝
inst✝⁴ : IsDomain R✝
inst✝³ : DiscreteValuationRing R✝
R : Type u_1
inst✝² : CommRing R
inst✝¹ : LocalRing R
inst✝ : IsDomain R
ϖ : R
hϖ : ϖ ≠ 0
h : maximalIdeal R = span {ϖ}
h2 : ¬IsUnit ϖ
b : R
hb : ∃ a, a * ϖ = b
a : R
hab : ϖ = a * ϖ * b
⊢ False

Next tactic:
rcases hb with ⟨b, rfl⟩
theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R]
    (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by
  have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ
  refine' ⟨h2, _⟩
  intro a b hab
  by_contra! h
  obtain ⟨ha : a ∈ maximalIdeal R, hb : b ∈ maximalIdeal R⟩ := h
  rw [h, mem_span_singleton'] at ha hb
  rcases ha with ⟨a, rfl⟩
  rcases hb with ⟨b, rfl⟩
  

Proof state:
case intro.intro.intro
R✝ : Type u
inst✝⁵ : CommRing R✝
inst✝⁴ : IsDomain R✝
inst✝³ : DiscreteValuationRing R✝
R : Type u_1
inst✝² : CommRing R
inst✝¹ : LocalRing R
inst✝ : IsDomain R
ϖ : R
hϖ : ϖ ≠ 0
h : maximalIdeal R = span {ϖ}
h2 : ¬IsUnit ϖ
a b : R
hab : ϖ = a * ϖ * (b * ϖ)
⊢ False

Next tactic:
rw [show a * ϖ * (b * ϖ) = ϖ * (ϖ * (a * b)) by ring] at hab
theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R]
    (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by
  have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ
  refine' ⟨h2, _⟩
  intro a b hab
  by_contra! h
  obtain ⟨ha : a ∈ maximalIdeal R, hb : b ∈ maximalIdeal R⟩ := h
  rw [h, mem_span_singleton'] at ha hb
  rcases ha with ⟨a, rfl⟩
  rcases hb with ⟨b, rfl⟩
  rw [show a * ϖ * (b * ϖ) = ϖ * (ϖ * (a * b)) by 

Proof state:
R✝ : Type u
inst✝⁵ : CommRing R✝
inst✝⁴ : IsDomain R✝
inst✝³ : DiscreteValuationRing R✝
R : Type u_1
inst✝² : CommRing R
inst✝¹ : LocalRing R
inst✝ : IsDomain R
ϖ : R
hϖ : ϖ ≠ 0
h : maximalIdeal R = span {ϖ}
h2 : ¬IsUnit ϖ
a b : R
hab : ϖ = a * ϖ * (b * ϖ)
⊢ a * ϖ * (b * ϖ) = ϖ * (ϖ * (a * b))

Next tactic:
ring
theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R]
    (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by
  have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ
  refine' ⟨h2, _⟩
  intro a b hab
  by_contra! h
  obtain ⟨ha : a ∈ maximalIdeal R, hb : b ∈ maximalIdeal R⟩ := h
  rw [h, mem_span_singleton'] at ha hb
  rcases ha with ⟨a, rfl⟩
  rcases hb with ⟨b, rfl⟩
  rw [show a * ϖ * (b * ϖ) = ϖ * (ϖ * (a * b)) by ring] at hab
  

Proof state:
case intro.intro.intro
R✝ : Type u
inst✝⁵ : CommRing R✝
inst✝⁴ : IsDomain R✝
inst✝³ : DiscreteValuationRing R✝
R : Type u_1
inst✝² : CommRing R
inst✝¹ : LocalRing R
inst✝ : IsDomain R
ϖ : R
hϖ : ϖ ≠ 0
h : maximalIdeal R = span {ϖ}
h2 : ¬IsUnit ϖ
a b : R
hab : ϖ = ϖ * (ϖ * (a * b))
⊢ False

Next tactic:
apply hϖ
theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R]
    (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by
  have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ
  refine' ⟨h2, _⟩
  intro a b hab
  by_contra! h
  obtain ⟨ha : a ∈ maximalIdeal R, hb : b ∈ maximalIdeal R⟩ := h
  rw [h, mem_span_singleton'] at ha hb
  rcases ha with ⟨a, rfl⟩
  rcases hb with ⟨b, rfl⟩
  rw [show a * ϖ * (b * ϖ) = ϖ * (ϖ * (a * b)) by ring] at hab
  apply hϖ
  

Proof state:
case intro.intro.intro
R✝ : Type u
inst✝⁵ : CommRing R✝
inst✝⁴ : IsDomain R✝
inst✝³ : DiscreteValuationRing R✝
R : Type u_1
inst✝² : CommRing R
inst✝¹ : LocalRing R
inst✝ : IsDomain R
ϖ : R
hϖ : ϖ ≠ 0
h : maximalIdeal R = span {ϖ}
h2 : ¬IsUnit ϖ
a b : R
hab : ϖ = ϖ * (ϖ * (a * b))
⊢ ϖ = 0

Next tactic:
apply eq_zero_of_mul_eq_self_right _ hab.symm
theorem irreducible_of_span_eq_maximalIdeal {R : Type*} [CommRing R] [LocalRing R] [IsDomain R]
    (ϖ : R) (hϖ : ϖ ≠ 0) (h : maximalIdeal R = Ideal.span {ϖ}) : Irreducible ϖ := by
  have h2 : ¬IsUnit ϖ := show ϖ ∈ maximalIdeal R from h.symm ▸ Submodule.mem_span_singleton_self ϖ
  refine' ⟨h2, _⟩
  intro a b hab
  by_contra! h
  obtain ⟨ha : a ∈ maximalIdeal R, hb : b ∈ maximalIdeal R⟩ := h
  rw [h, mem_span_singleton'] at ha hb
  rcases ha with ⟨a, rfl⟩
  rcases hb with ⟨b, rfl⟩
  rw [show a * ϖ * (b * ϖ) = ϖ * (ϖ * (a * b)) by ring] at hab
  apply hϖ
  apply eq_zero_of_mul_eq_self_right _ hab.symm
  

Proof state:
R✝ : Type u
inst✝⁵ : CommRing R✝
inst✝⁴ : IsDomain R✝
inst✝³ : DiscreteValuationRing R✝
R : Type u_1
inst✝² : CommRing R
inst✝¹ : LocalRing R
inst✝ : IsDomain R
ϖ : R
hϖ : ϖ ≠ 0
h : maximalIdeal R = span {ϖ}
h2 : ¬IsUnit ϖ
a b : R
hab : ϖ = ϖ * (ϖ * (a * b))
⊢ ϖ * (a * b) ≠ 1

Next tactic:
exact fun hh => h2 (isUnit_of_dvd_one ⟨_, hh.symm⟩)
/-- An element of a DVR is irreducible iff it is a uniformizer, that is, generates the
  maximal ideal of `R`. -/
theorem irreducible_iff_uniformizer (ϖ : R) : Irreducible ϖ ↔ maximalIdeal R = Ideal.span {ϖ} :=
  ⟨fun hϖ => (eq_maximalIdeal (isMaximal_of_irreducible hϖ)).symm,
    fun h => irreducible_of_span_eq_maximalIdeal ϖ
      (fun e => not_a_field R <| by 

Proof state:
R : Type u
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : DiscreteValuationRing R
ϖ : R
h : maximalIdeal R = span {ϖ}
e : ϖ = 0
⊢ maximalIdeal R = ⊥

Next tactic:
rwa [h, span_singleton_eq_bot]
/-- Uniformizers exist in a DVR. -/
theorem exists_irreducible : ∃ ϖ : R, Irreducible ϖ := by
  

Proof state:
R : Type u
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : DiscreteValuationRing R
⊢ ∃ ϖ, Irreducible ϖ

Next tactic:
simp_rw [irreducible_iff_uniformizer]
/-- Uniformizers exist in a DVR. -/
theorem exists_irreducible : ∃ ϖ : R, Irreducible ϖ := by
  simp_rw [irreducible_iff_uniformizer]
  

Proof state:
R : Type u
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : DiscreteValuationRing R
⊢ ∃ ϖ, maximalIdeal R = span {ϖ}

Next tactic:
exact (IsPrincipalIdealRing.principal <| maximalIdeal R).principal
/-- An integral domain is a DVR iff it's a PID with a unique non-zero prime ideal. -/
theorem iff_pid_with_one_nonzero_prime (R : Type u) [CommRing R] [IsDomain R] :
    DiscreteValuationRing R ↔ IsPrincipalIdealRing R ∧ ∃! P : Ideal R, P ≠ ⊥ ∧ IsPrime P := by
  

Proof state:
R✝ : Type u
inst✝⁴ : CommRing R✝
inst✝³ : IsDomain R✝
inst✝² : DiscreteValuationRing R✝
R : Type u
inst✝¹ : CommRing R
inst✝ : IsDomain R
⊢ DiscreteValuationRing R ↔ IsPrincipalIdealRing R ∧ ∃! P, P ≠ ⊥ ∧ IsPrime P

Next tactic:
constructor
/-- An integral domain is a DVR iff it's a PID with a unique non-zero prime ideal. -/
theorem iff_pid_with_one_nonzero_prime (R : Type u) [CommRing R] [IsDomain R] :
    DiscreteValuationRing R ↔ IsPrincipalIdealRing R ∧ ∃! P : Ideal R, P ≠ ⊥ ∧ IsPrime P := by
  constructor
  · 

Proof state:
case mp
R✝ : Type u
inst✝⁴ : CommRing R✝
inst✝³ : IsDomain R✝
inst✝² : DiscreteValuationRing R✝
R : Type u
inst✝¹ : CommRing R
inst✝ : IsDomain R
⊢ DiscreteValuationRing R → IsPrincipalIdealRing R ∧ ∃! P, P ≠ ⊥ ∧ IsPrime P

Next tactic:
intro RDVR