| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Consequences of a monomorphism between monoid-like structures |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
-- See Data.Nat.Binary.Properties for examples of how this and similar |
| 8 |
-- modules can be used to easily translate properties between types. |
| 9 |
|
| 10 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 11 |
|
| 12 |
open import Algebra.Bundles using (RawMonoid) |
| 13 |
open import Algebra.Morphism.Structures using (IsMonoidMonomorphism) |
| 14 |
|
| 15 |
module Algebra.Morphism.MonoidMonomorphism |
| 16 |
{a b ℓ₁ ℓ₂} {M₁ : RawMonoid a ℓ₁} {M₂ : RawMonoid b ℓ₂} {⟦_⟧} |
| 17 |
(isMonoidMonomorphism : IsMonoidMonomorphism M₁ M₂ ⟦_⟧) |
| 18 |
where |
| 19 |
|
| 20 |
open IsMonoidMonomorphism isMonoidMonomorphism |
| 21 |
open RawMonoid M₁ renaming (Carrier to A; _≈_ to _≈₁_; _∙_ to _∙_; ε to ε₁) |
| 22 |
open RawMonoid M₂ renaming (Carrier to B; _≈_ to _≈₂_; _∙_ to _◦_; ε to ε₂) |
| 23 |
|
| 24 |
open import Algebra.Definitions |
| 25 |
using (Identity; Zero; LeftIdentity; RightIdentity; LeftZero; RightZero) |
| 26 |
open import Algebra.Structures |
| 27 |
using (IsMagma; IsMonoid; IsCommutativeMonoid) |
| 28 |
open import Data.Product.Base using (map) |
| 29 |
open import Relation.Binary.Core using (Rel) |
| 30 |
import Relation.Binary.Reasoning.Setoid as ≈-Reasoning |
| 31 |
|
| 32 |
------------------------------------------------------------------------ |
| 33 |
-- Re-export all properties of magma monomorphisms |
| 34 |
|
| 35 |
open import Algebra.Morphism.MagmaMonomorphism |
| 36 |
isMagmaMonomorphism public |
| 37 |
|
| 38 |
------------------------------------------------------------------------ |
| 39 |
-- Properties |
| 40 |
|
| 41 |
module _ (◦-isMagma : IsMagma _≈₂_ _◦_) where |
| 42 |
|
| 43 |
open IsMagma ◦-isMagma renaming (∙-cong to ◦-cong) |
| 44 |
open ≈-Reasoning setoid |
| 45 |
|
| 46 |
identityˡ : LeftIdentity _≈₂_ ε₂ _◦_ → LeftIdentity _≈₁_ ε₁ _∙_ |
| 47 |
identityˡ idˡ x = injective (begin |
| 48 |
⟦ ε₁ ∙ x ⟧ ≈⟨ homo ε₁ x ⟩ |
| 49 |
⟦ ε₁ ⟧ ◦ ⟦ x ⟧ ≈⟨ ◦-cong ε-homo refl ⟩ |
| 50 |
ε₂ ◦ ⟦ x ⟧ ≈⟨ idˡ ⟦ x ⟧ ⟩ |
| 51 |
⟦ x ⟧ ∎) |
| 52 |
|
| 53 |
identityʳ : RightIdentity _≈₂_ ε₂ _◦_ → RightIdentity _≈₁_ ε₁ _∙_ |
| 54 |
identityʳ idʳ x = injective (begin |
| 55 |
⟦ x ∙ ε₁ ⟧ ≈⟨ homo x ε₁ ⟩ |
| 56 |
⟦ x ⟧ ◦ ⟦ ε₁ ⟧ ≈⟨ ◦-cong refl ε-homo ⟩ |
| 57 |
⟦ x ⟧ ◦ ε₂ ≈⟨ idʳ ⟦ x ⟧ ⟩ |
| 58 |
⟦ x ⟧ ∎) |
| 59 |
|
| 60 |
identity : Identity _≈₂_ ε₂ _◦_ → Identity _≈₁_ ε₁ _∙_ |
| 61 |
identity = map identityˡ identityʳ |
| 62 |
|
| 63 |
zeroˡ : LeftZero _≈₂_ ε₂ _◦_ → LeftZero _≈₁_ ε₁ _∙_ |
| 64 |
zeroˡ zeˡ x = injective (begin |
| 65 |
⟦ ε₁ ∙ x ⟧ ≈⟨ homo ε₁ x ⟩ |
| 66 |
⟦ ε₁ ⟧ ◦ ⟦ x ⟧ ≈⟨ ◦-cong ε-homo refl ⟩ |
| 67 |
ε₂ ◦ ⟦ x ⟧ ≈⟨ zeˡ ⟦ x ⟧ ⟩ |
| 68 |
ε₂ ≈⟨ ε-homo ⟨ |
| 69 |
⟦ ε₁ ⟧ ∎) |
| 70 |
|
| 71 |
zeroʳ : RightZero _≈₂_ ε₂ _◦_ → RightZero _≈₁_ ε₁ _∙_ |
| 72 |
zeroʳ zeʳ x = injective (begin |
| 73 |
⟦ x ∙ ε₁ ⟧ ≈⟨ homo x ε₁ ⟩ |
| 74 |
⟦ x ⟧ ◦ ⟦ ε₁ ⟧ ≈⟨ ◦-cong refl ε-homo ⟩ |
| 75 |
⟦ x ⟧ ◦ ε₂ ≈⟨ zeʳ ⟦ x ⟧ ⟩ |
| 76 |
ε₂ ≈⟨ ε-homo ⟨ |
| 77 |
⟦ ε₁ ⟧ ∎) |
| 78 |
|
| 79 |
zero : Zero _≈₂_ ε₂ _◦_ → Zero _≈₁_ ε₁ _∙_ |
| 80 |
zero = map zeroˡ zeroʳ |
| 81 |
|
| 82 |
------------------------------------------------------------------------ |
| 83 |
-- Structures |
| 84 |
|
| 85 |
isMonoid : IsMonoid _≈₂_ _◦_ ε₂ → IsMonoid _≈₁_ _∙_ ε₁ |
| 86 |
isMonoid isMonoid = record |
| 87 |
{ isSemigroup = isSemigroup M.isSemigroup |
| 88 |
; identity = identity M.isMagma M.identity |
| 89 |
} where module M = IsMonoid isMonoid |
| 90 |
|
| 91 |
isCommutativeMonoid : IsCommutativeMonoid _≈₂_ _◦_ ε₂ → |
| 92 |
IsCommutativeMonoid _≈₁_ _∙_ ε₁ |
| 93 |
isCommutativeMonoid isCommMonoid = record |
| 94 |
{ isMonoid = isMonoid C.isMonoid |
| 95 |
; comm = comm C.isMagma C.comm |
| 96 |
} where module C = IsCommutativeMonoid isCommMonoid |