{-# OPTIONS --safe --lossy-unification #-}
module Cubical.ZCohomology.Groups.Coproduct where

open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels

open import Cubical.Data.Nat
open import Cubical.Data.Sigma
open import Cubical.Data.Sum as Sum

open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.DirProd
open import Cubical.Algebra.Ring
open import Cubical.Algebra.Ring.DirectProd

open import Cubical.HITs.SetTruncation as ST

open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.GroupStructure

private variable
   ℓ' : Level

module _
  {X : Type }
  {Y : Type ℓ'}
  where

  open Iso
  open IsGroupHom
  open GroupStr

  Equiv-Coproduct-CoHom : {n : }  GroupIso (coHomGr n (X  Y)) (DirProd (coHomGr n X) (coHomGr n Y))
  Iso.fun (fst Equiv-Coproduct-CoHom)      = ST.rec (isSet× squash₂ squash₂)  f   f  inl ∣₂ ,  (f  inr) ∣₂)
  Iso.inv (fst Equiv-Coproduct-CoHom)      = uncurry
                           (ST.rec  u v p q i j y  squash₂ (u y) (v y)  X  p X y)  X  q X y) i j)
                            g  ST.rec squash₂  h   Sum.rec g h ∣₂)))
  Iso.rightInv (fst Equiv-Coproduct-CoHom) = uncurry
                           (ST.elim  x  isProp→isSet λ u v i y  isSet× squash₂ squash₂ _ _ (u y) (v y) i)
                            g  ST.elim  _  isProp→isSet (isSet× squash₂ squash₂ _ _))
                                    h  refl)))
  Iso.leftInv (fst Equiv-Coproduct-CoHom) = ST.elim  _  isProp→isSet (squash₂ _ _))
                          λ f  cong ∣_∣₂ (funExt (Sum.elim  x  refl)  x  refl)))
  snd Equiv-Coproduct-CoHom =               makeIsGroupHom
                          (ST.elim  x  isProp→isSet λ u v i y  isSet× squash₂ squash₂ _ _ (u y) (v y) i)
                           g  ST.elim  _  isProp→isSet (isSet× squash₂ squash₂ _ _))
                          λ h  refl))