Module docstring
{"# More lemmas about irreducible elements "}
{"# More lemmas about irreducible elements "}
not_irreducible_pow
      theorem
     : ∀ {n : ℕ}, n ≠ 1 → ¬Irreducible (x ^ n)
        @[to_additive]
lemma not_irreducible_pow : ∀ {n : ℕ}, n ≠ 1 → ¬ Irreducible (x ^ n)
  | 0, _ => by simp
  | n + 2, _ => by
    intro ⟨h₁, h₂⟩
    have := h₂ (pow_succ _ _)
    rw [isUnit_pow_iff n.succ_ne_zero, or_self] at this
    exact h₁ (this.pow _)
        irreducible_units_mul
      theorem
     (u : Mˣ) : Irreducible (u * y) ↔ Irreducible y
        @[to_additive]
lemma irreducible_units_mul (u : Mˣ) : IrreducibleIrreducible (u * y) ↔ Irreducible y := by
  simp only [irreducible_iff, Units.isUnit_units_mul, and_congr_right_iff]
  refine fun _ => ⟨fun h A B HAB => ?_, fun h A B HAB => ?_⟩
  · rw [← u.isUnit_units_mul]
    apply h
    rw [mul_assoc, ← HAB]
  · rw [← u⁻¹.isUnit_units_mul]
    apply h
    rw [mul_assoc, ← HAB, Units.inv_mul_cancel_left]
        irreducible_isUnit_mul
      theorem
     (h : IsUnit x) : Irreducible (x * y) ↔ Irreducible y
        @[to_additive]
lemma irreducible_isUnit_mul (h : IsUnit x) : IrreducibleIrreducible (x * y) ↔ Irreducible y :=
  let ⟨x, ha⟩ := h
  ha ▸ irreducible_units_mul x
        irreducible_mul_units
      theorem
     (u : Mˣ) : Irreducible (y * u) ↔ Irreducible y
        @[to_additive]
lemma irreducible_mul_units (u : Mˣ) : IrreducibleIrreducible (y * u) ↔ Irreducible y := by
  simp only [irreducible_iff, Units.isUnit_mul_units, and_congr_right_iff]
  refine fun _ => ⟨fun h A B HAB => ?_, fun h A B HAB => ?_⟩
  · rw [← u.isUnit_mul_units B]
    apply h
    rw [← mul_assoc, ← HAB]
  · rw [← u⁻¹.isUnit_mul_units B]
    apply h
    rw [← mul_assoc, ← HAB, Units.mul_inv_cancel_right]
        irreducible_mul_isUnit
      theorem
     (h : IsUnit x) : Irreducible (y * x) ↔ Irreducible y
        @[to_additive]
lemma irreducible_mul_isUnit (h : IsUnit x) : IrreducibleIrreducible (y * x) ↔ Irreducible y :=
  let ⟨x, hx⟩ := h
  hx ▸ irreducible_mul_units x
        irreducible_mul_iff
      theorem
     : Irreducible (x * y) ↔ Irreducible x ∧ IsUnit y ∨ Irreducible y ∧ IsUnit x
        @[to_additive]
lemma irreducible_mul_iff :
    IrreducibleIrreducible (x * y) ↔ Irreducible x ∧ IsUnit y ∨ Irreducible y ∧ IsUnit x := by
  constructor
  · refine fun h => Or.imp (fun h' => ⟨?_, h'⟩) (fun h' => ⟨?_, h'⟩) (h.isUnit_or_isUnit rfl).symm
    · rwa [irreducible_mul_isUnit h'] at h
    · rwa [irreducible_isUnit_mul h'] at h
  · rintro (⟨ha, hb⟩ | ⟨hb, ha⟩)
    · rwa [irreducible_mul_isUnit hb]
    · rwa [irreducible_isUnit_mul ha]
        MulEquiv.irreducible_iff
      theorem
     : Irreducible (f x) ↔ Irreducible x
        @[to_additive]
lemma MulEquiv.irreducible_iff : IrreducibleIrreducible (f x) ↔ Irreducible x := by
  simp [_root_.irreducible_iff, (EquivLike.surjective f).forall, ← map_mul, -isUnit_map_iff]
        Irreducible.of_map
      theorem
     [FunLike F M N] [MonoidHomClass F M N] [IsLocalHom f] (hfx : Irreducible (f x)) : Irreducible x
        lemma Irreducible.of_map [FunLike F M N] [MonoidHomClass F M N] [IsLocalHom f]
    (hfx : Irreducible (f x)) : Irreducible x where
  not_isUnit hu := hfx.not_isUnit <| hu.map f
  isUnit_or_isUnit := by
    rintro p q rfl; exact (hfx.isUnit_or_isUnit <| map_mul f p q).imp (.of_map f _) (.of_map f _)
        Irreducible.not_isSquare
      theorem
     (ha : Irreducible x) : ¬IsSquare x
        @[to_additive]
lemma Irreducible.not_isSquare (ha : Irreducible x) : ¬IsSquare x := by
  rw [isSquare_iff_exists_sq]
  rintro ⟨y, rfl⟩
  exact not_irreducible_pow (by decide) ha
        IsSquare.not_irreducible
      theorem
     (ha : IsSquare x) : ¬Irreducible x
        @[to_additive]
lemma IsSquare.not_irreducible (ha : IsSquare x) : ¬Irreducible x := fun h => h.not_isSquare ha