Skip to content

Classical.Bundles.CommutativeSemigroup

Bundle bridge for commutative semigroups

This is the Classical.Bundles.CommutativeSemigroup module of the Agda Universal Algebra Library.

Mirror of the Semigroup bridge with the added comm field; over Sig-Magma.

{-# OPTIONS --cubical-compatible --exact-split --safe #-}

module Classical.Bundles.CommutativeSemigroup where

-- Imports from the Agda Standard Library -----------------------------------------
open import Algebra.Bundles     using () renaming (  CommutativeSemigroup
                                                     to stdlib-CommutativeSemigroup )
open import Data.Fin.Patterns   using ( 0F ; 1F ; 2F )
open import Data.Product        using ( _,_ ; proj₁ )
open import Function            using ( Func )
open import Level               using ( Level )
open import Relation.Binary     using ( Setoid )
import Relation.Binary.PropositionalEquality as ≑
open Func renaming ( to to _⟨$⟩_ )

-- Imports from the Agda Universal Algebra Library --------------------------------
open import Classical.Signatures.Magma                 using  ( βˆ™-Op ; Sig-Magma )
open import Classical.Structures.CommutativeSemigroup  using  ( CommutativeSemigroup
                                                              ; module CommutativeSemigroup-Op )
open import Classical.Theories.CommutativeSemigroup    using  ( assoc ; comm )
open import Setoid.Algebras.Basic {𝑆 = Sig-Magma}      using  ( Algebra ; π•Œ[_] ; 𝔻[_] )
open import Setoid.Signatures                          using ( ⟨_⟩ )

private variable α ρ : Level
⟨_⟩ᢜ˒ᡍ : CommutativeSemigroup Ξ± ρ β†’ stdlib-CommutativeSemigroup Ξ± ρ
⟨ π‘ͺ ⟩ᢜ˒ᡍ = record
  { Carrier = π•Œ[ proj₁ π‘ͺ ]
  ; _β‰ˆ_     = _β‰ˆ_
  ; _βˆ™_     = _βˆ™_
  ; isCommutativeSemigroup = record
      { isSemigroup = record
          { isMagma = record { isEquivalence = isEquivalence ; βˆ™-cong = βˆ™-cong }
          ; assoc   = assoc-law
          }
      ; comm = comm-law
      }
  }
  where
  open CommutativeSemigroup-Op π‘ͺ
  open Setoid 𝔻[ proj₁ π‘ͺ ]

βŸͺ_⟫ᢜ˒ᡍ : stdlib-CommutativeSemigroup Ξ± ρ β†’ CommutativeSemigroup Ξ± ρ
βŸͺ S ⟫ᢜ˒ᡍ = 𝑨 , Ξ» { assoc ρ β†’ S-assoc (ρ 0F) (ρ 1F) (ρ 2F)
                ; comm  ρ β†’ S-comm  (ρ 0F) (ρ 1F) }
  where
  open stdlib-CommutativeSemigroup S
      using ( setoid ; βˆ™-cong )
      renaming ( _βˆ™_ to _Β·_ ; assoc to S-assoc ; comm to S-comm )

  𝑨 : Algebra _ _
  𝑨 = record { Domain = setoid ; Interp = interp }
    where
    interp : Func (⟨ Sig-Magma ⟩ setoid) setoid
    interp ⟨$⟩ (βˆ™-Op , args)                            = args 0F Β· args 1F
    cong interp {βˆ™-Op , _} {.βˆ™-Op , _} (≑.refl , argsβ‰ˆ) = βˆ™-cong (argsβ‰ˆ 0F) (argsβ‰ˆ 1F)

module _ {π‘ͺ : CommutativeSemigroup Ξ± ρ} where
  open CommutativeSemigroup-Op π‘ͺ
  open Setoid 𝔻[ proj₁ π‘ͺ ]
  open CommutativeSemigroup-Op βŸͺ ⟨ π‘ͺ ⟩ᢜ˒ᡍ ⟫ᢜ˒ᡍ renaming ( _βˆ™_ to _βˆ™'_ )

  roundtrip-cbc-cs : (a b : π•Œ[ proj₁ π‘ͺ ]) β†’ (a βˆ™' b) β‰ˆ (a βˆ™ b)
  roundtrip-cbc-cs a b = refl

module _ {S : stdlib-CommutativeSemigroup α ρ} where
  open stdlib-CommutativeSemigroup S using ( _β‰ˆ_ ; _βˆ™_ ; refl ) renaming ( Carrier to A )
  open stdlib-CommutativeSemigroup ⟨ βŸͺ S ⟫ᢜ˒ᡍ ⟩ᢜ˒ᡍ using () renaming ( _βˆ™_ to _βˆ™'_ )

  roundtrip-bcb-cs : (a b : A) β†’ (a βˆ™ b) β‰ˆ (a βˆ™' b)
  roundtrip-bcb-cs a b = refl