Contents


{-# OPTIONS --without-K --safe #-}

module structures where 

open import mltt
open import twocatconstructions
open import sets-logic
open import basichomotopy

open ≡-Reasoning
open ◾-lemmas
open ~-lemmas

We start a module to hold the Magma axioms. Recall that (in ordinary Mathematics) a magma is a set with a binary operation satisfying no conditions.

module Magmas where

  record Magma ( : Level) : Set (lsuc ) where
    constructor magma
    field
      -- Unicode with '\|', not a '|' which causes a syntax error
      ∣_∣ : Set 
      is  : isSet ∣_∣
      _•_ : ∣_∣  ∣_∣  ∣_∣
--      m   : ∣_∣ → ∣_∣ → ∣_∣
--    syntax m M x y = x •[ M ] y

  open Magma 

The reason for the above ‘syntax’ declaration is that without it, M occurs before the terms x y, which are of type ∣ M ∣. We also open the record (inside the module, though) to avoid prepending with Magma. to qualify the field names.

We define Magma homomorphisms, which are the obvious thing, and we state that the identity function of the underlying type id {A = ∣ X ∣} is a homomorphism. Note the condition that the carrier be a set does not enter into the definition of homomorphism.

  record Magma-Hom { ℓ' : Level} (X : Magma ) (Y : Magma ℓ') : Set (  ℓ') where
    private
      module X = Magma X
      module Y = Magma Y
    field
      f :  X    Y 
      c : (x y :  X )  f ( x X.• y )  f x Y.• f y
--      c : (x y : ∣ X ∣) → f ( x •[ X ] y ) ≡ f x  •[ Y ] f y

  id-Magma-Hom :  {} (X : Magma )  Magma-Hom X X
  Magma-Hom.f (id-Magma-Hom X) = id {A =  X }
  Magma-Hom.c (id-Magma-Hom X) = λ x y  refl

We define isomorphisms in the obvious way: if φ : X → Y is a magma homomorphism, it is an iso if there is a homomorphims ψ : Y → X such that the two compositions of the underlying set maps are the identity.

  record Magma-Iso { ℓ' : Level} (X : Magma ) (Y : Magma ℓ') : Set (  ℓ') where
    open Magma-Hom
    field
      φ : Magma-Hom X Y
      ψ : Magma-Hom Y X
      ε : (f φ) ∘′ (f ψ) ~ id
      η : (f ψ) ∘′ (f φ) ~ id

Of course, the identity is a magma isomorphism:

  id-Magma-Iso :  {} (X : Magma )  Magma-Iso  X X
  Magma-Iso.φ (id-Magma-Iso X) = id-Magma-Hom X
  Magma-Iso.ψ (id-Magma-Iso X) = id-Magma-Hom X
  Magma-Iso.ε (id-Magma-Iso X) = λ x  refl
  Magma-Iso.η (id-Magma-Iso X) = λ x  refl

Identification between magmas (at the same level) give isomorphisms, by path induction and using that the identity is an isomorphism.

  Id-Magma→Magda-Iso :  {} {X Y : Magma }  X  Y  Magma-Iso X Y
  Id-Magma→Magda-Iso refl = id-Magma-Iso _

Note that in an isomorphism the underlying function is a weak equivalence. Thus in the presence of univalence the types X ≡ Y and Magma-Iso X Y would be in bijection, but this requires a careful preliminary analysis of the identity type X ≡ Y.

  Magma→Σ :  {}  Magma   Σ[ M  Set  ] ((isSet M) × (M  M  M))
  Magma→Σ {} X =  X  , (is X , _•_ X)

  Σ→Magma :  {}  Σ[ M  Set  ] ((isSet M) × (M  M  M))  Magma 
  Σ→Magma {} (M , is , m) = record { ∣_∣ = M ; is = is ; _•_ = m }

  ≡-η-equality :  {} (X Y : Magma ) ( p :  X    Y  )  
                                       ( transport  A  isSet A) p (is X)   is Y )  
                                       ( transport  A  A  A  A) p (_•_ X)  _•_ Y)  
                                       X  Y
  ≡-η-equality (magma A₁ is₁ _•_₁) (magma .A₁ is₂ _•_₂) refl γ δ = magma A₁ is₁ _•_₁ ≡⟨ ap  v  magma A₁ v _•_₁) γ 
                                                                   magma A₁ is₂ _•_₁ ≡⟨ ap  v  magma A₁ is₂ v) δ 
                                                                   magma A₁ is₂ _•_₂ 

  magma-transport :  {} (X : Magma ) (B : Set ) (is : isSet B) (p :  X   B)  Magma 
  magma-transport X B is p = magma B is (transport  Z  Z  Z  Z) p (_•_ X))
  

top ⇑