Debian Codegraph @

src/Algebra/Morphism/MagmaMonomorphism.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Consequences of a monomorphism between magma-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 (RawMagma)
13 open import Algebra.Morphism.Structures using (IsMagmaMonomorphism)
14
15 module Algebra.Morphism.MagmaMonomorphism
16 {a b ℓ₁ ℓ₂} {M₁ : RawMagma a ℓ₁} {M₂ : RawMagma b ℓ₂} {⟦_⟧}
17 (isMagmaMonomorphism : IsMagmaMonomorphism M₁ M₂ ⟦_⟧)
18 where
19
20 open IsMagmaMonomorphism isMagmaMonomorphism
21 open RawMagma M₁ renaming (Carrier to A; _≈_ to _≈₁_; _∙_ to _∙_)
22 open RawMagma M₂ renaming (Carrier to B; _≈_ to _≈₂_; _∙_ to _◦_)
23
24 open import Algebra.Structures
25 using (IsMagma; IsSemigroup; IsBand; IsSelectiveMagma)
26 open import Algebra.Definitions
27 using (Congruent₂; Associative; Commutative; Idempotent ; Selective
28 ; LeftCancellative; RightCancellative; Cancellative)
29 open import Data.Product.Base using (map)
30 open import Data.Sum.Base using (inj₁; inj₂)
31 import Relation.Binary.Reasoning.Setoid as ≈-Reasoning
32 import Relation.Binary.Morphism.RelMonomorphism isRelMonomorphism as RelMorphism
33 open import Relation.Binary.Core using (Rel)
34
35 ------------------------------------------------------------------------
36 -- Properties
37
38 module _ (◦-isMagma : IsMagma _≈₂_ _◦_) where
39
40 open IsMagma ◦-isMagma renaming (∙-cong to ◦-cong)
41 open ≈-Reasoning setoid
42
43 cong : Congruent₂ _≈₁_ _∙_
44 cong {x} {y} {u} {v} x≈y u≈v = injective (begin
45 ⟦ x ∙ u ⟧ ≈⟨ homo x u ⟩
46 ⟦ x ⟧ ◦ ⟦ u ⟧ ≈⟨ ◦-cong (⟦⟧-cong x≈y) (⟦⟧-cong u≈v) ⟩
47 ⟦ y ⟧ ◦ ⟦ v ⟧ ≈⟨ homo y v ⟨
48 ⟦ y ∙ v ⟧ ∎)
49
50 assoc : Associative _≈₂_ _◦_ → Associative _≈₁_ _∙_
51 assoc assoc x y z = injective (begin
52 ⟦ (x ∙ y) ∙ z ⟧ ≈⟨ homo (x ∙ y) z ⟩
53 ⟦ x ∙ y ⟧ ◦ ⟦ z ⟧ ≈⟨ ◦-cong (homo x y) refl ⟩
54 (⟦ x ⟧ ◦ ⟦ y ⟧) ◦ ⟦ z ⟧ ≈⟨ assoc ⟦ x ⟧ ⟦ y ⟧ ⟦ z ⟧ ⟩
55 ⟦ x ⟧ ◦ (⟦ y ⟧ ◦ ⟦ z ⟧) ≈⟨ ◦-cong refl (homo y z) ⟨
56 ⟦ x ⟧ ◦ ⟦ y ∙ z ⟧ ≈⟨ homo x (y ∙ z) ⟨
57 ⟦ x ∙ (y ∙ z) ⟧ ∎)
58
59 comm : Commutative _≈₂_ _◦_ → Commutative _≈₁_ _∙_
60 comm comm x y = injective (begin
61 ⟦ x ∙ y ⟧ ≈⟨ homo x y ⟩
62 ⟦ x ⟧ ◦ ⟦ y ⟧ ≈⟨ comm ⟦ x ⟧ ⟦ y ⟧ ⟩
63 ⟦ y ⟧ ◦ ⟦ x ⟧ ≈⟨ homo y x ⟨
64 ⟦ y ∙ x ⟧ ∎)
65
66 idem : Idempotent _≈₂_ _◦_ → Idempotent _≈₁_ _∙_
67 idem idem x = injective (begin
68 ⟦ x ∙ x ⟧ ≈⟨ homo x x ⟩
69 ⟦ x ⟧ ◦ ⟦ x ⟧ ≈⟨ idem ⟦ x ⟧ ⟩
70 ⟦ x ⟧ ∎)
71
72 sel : Selective _≈₂_ _◦_ → Selective _≈₁_ _∙_
73 sel sel x y with sel ⟦ x ⟧ ⟦ y ⟧
74 ... | inj₁ x◦y≈x = inj₁ (injective (begin
75 ⟦ x ∙ y ⟧ ≈⟨ homo x y ⟩
76 ⟦ x ⟧ ◦ ⟦ y ⟧ ≈⟨ x◦y≈x ⟩
77 ⟦ x ⟧ ∎))
78 ... | inj₂ x◦y≈y = inj₂ (injective (begin
79 ⟦ x ∙ y ⟧ ≈⟨ homo x y ⟩
80 ⟦ x ⟧ ◦ ⟦ y ⟧ ≈⟨ x◦y≈y ⟩
81 ⟦ y ⟧ ∎))
82
83 cancelˡ : LeftCancellative _≈₂_ _◦_ → LeftCancellative _≈₁_ _∙_
84 cancelˡ cancelˡ x y z x∙y≈x∙z = injective (cancelˡ ⟦ x ⟧ ⟦ y ⟧ ⟦ z ⟧ (begin
85 ⟦ x ⟧ ◦ ⟦ y ⟧ ≈⟨ homo x y ⟨
86 ⟦ x ∙ y ⟧ ≈⟨ ⟦⟧-cong x∙y≈x∙z ⟩
87 ⟦ x ∙ z ⟧ ≈⟨ homo x z ⟩
88 ⟦ x ⟧ ◦ ⟦ z ⟧ ∎))
89
90 cancelʳ : RightCancellative _≈₂_ _◦_ → RightCancellative _≈₁_ _∙_
91 cancelʳ cancelʳ x y z y∙x≈z∙x = injective (cancelʳ ⟦ x ⟧ ⟦ y ⟧ ⟦ z ⟧ (begin
92 ⟦ y ⟧ ◦ ⟦ x ⟧ ≈⟨ homo y x ⟨
93 ⟦ y ∙ x ⟧ ≈⟨ ⟦⟧-cong y∙x≈z∙x ⟩
94 ⟦ z ∙ x ⟧ ≈⟨ homo z x ⟩
95 ⟦ z ⟧ ◦ ⟦ x ⟧ ∎))
96
97 cancel : Cancellative _≈₂_ _◦_ → Cancellative _≈₁_ _∙_
98 cancel = map cancelˡ cancelʳ
99
100 ------------------------------------------------------------------------
101 -- Structures
102
103 isMagma : IsMagma _≈₂_ _◦_ → IsMagma _≈₁_ _∙_
104 isMagma isMagma = record
105 { isEquivalence = RelMorphism.isEquivalence M.isEquivalence
106 ; ∙-cong = cong isMagma
107 } where module M = IsMagma isMagma
108
109 isSemigroup : IsSemigroup _≈₂_ _◦_ → IsSemigroup _≈₁_ _∙_
110 isSemigroup isSemigroup = record
111 { isMagma = isMagma S.isMagma
112 ; assoc = assoc S.isMagma S.assoc
113 } where module S = IsSemigroup isSemigroup
114
115 isBand : IsBand _≈₂_ _◦_ → IsBand _≈₁_ _∙_
116 isBand isBand = record
117 { isSemigroup = isSemigroup B.isSemigroup
118 ; idem = idem B.isMagma B.idem
119 } where module B = IsBand isBand
120
121 isSelectiveMagma : IsSelectiveMagma _≈₂_ _◦_ → IsSelectiveMagma _≈₁_ _∙_
122 isSelectiveMagma isSelMagma = record
123 { isMagma = isMagma S.isMagma
124 ; sel = sel S.isMagma S.sel
125 } where module S = IsSelectiveMagma isSelMagma