/-- Noncomputably defines a `normalizationMonoid` structure on a `UniqueFactorizationMonoid`. -/
protected noncomputable def normalizationMonoid : NormalizationMonoid α :=
  normalizationMonoidOfMonoidHomRightInverse
    { toFun := fun a : Associates α =>
        if a = 0 then 0
        else
          ((normalizedFactors a).map
              (Classical.choose mk_surjective.hasRightInverse : Associates α → α)).prod
      map_one' := by simp
      map_mul' := fun x y => by
        by_cases hx : x = 0
        · simp [hx]
        by_cases hy : y = 0
        · simp [hy]
        simp [hx, hy] }
    (by
      

Proof state:
α : Type u_1
inst✝² : CancelCommMonoidWithZero α
inst✝¹ : Nontrivial α
inst✝ : UniqueFactorizationMonoid α
⊢ Function.RightInverse
    (⇑{
        toOneHom :=
          {
            toFun := fun a =>
              if a = 0 then 0
              else prod (map (Classical.choose (_ : Function.HasRightInverse Associates.mk)) (normalizedFactors a)),
            map_one' :=
              (_ :
                (if 1 = 0 then 0
                  else
                    prod (map (Classical.choose (_ : Function.HasRightInverse Associates.mk)) (normalizedFactors 1))) =
                  1) },
        map_mul' :=
          (_ :
            ∀ (x y : Associates α),
              OneHom.toFun
                  {
                    toFun := fun a =>
                      if a = 0 then 0
                      else
                        prod
                          (map (Classical.choose (_ : Function.HasRightInverse Associates.mk)) (normalizedFactors a)),
                    map_one' :=
                      (_ :
                        (if 1 = 0 then 0
                          else
                            prod
                              (map (Classical.choose (_ : Function.HasRightInverse Associates.mk))
                                (normalizedFactors 1))) =
                          1) }
                  (x * y) =
                OneHom.toFun
                    {
                      toFun := fun a =>
                        if a = 0 then 0
                        else
                          prod
                            (map (Classical.choose (_ : Function.HasRightInverse Associates.mk)) (normalizedFactors a)),
                      map_one' :=
                        (_ :
                          (if 1 = 0 then 0
                            else
                              prod
                                (map (Classical.choose (_ : Function.HasRightInverse Associates.mk))
                                  (normalizedFactors 1))) =
                            1) }
                    x *
                  OneHom.toFun
                    {
                      toFun := fun a =>
                        if a = 0 then 0
                        else
                          prod
                            (map (Classical.choose (_ : Function.HasRightInverse Associates.mk)) (normalizedFactors a)),
                      map_one' :=
                        (_ :
                          (if 1 = 0 then 0
                            else
                              prod
                                (map (Classical.choose (_ : Function.HasRightInverse Associates.mk))
                                  (normalizedFactors 1))) =
                            1) }
                    y) })
    Associates.mk

Next tactic:
intro x