Skip to content

Commit df62ebe

Browse files
committed
Add Monoid (and related) for Construct.Add.Point (agda#845)
1 parent 6a0baaa commit df62ebe

File tree

2 files changed

+129
-1
lines changed

2 files changed

+129
-1
lines changed

CHANGELOG.md

+26-1
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,11 @@ Deprecated names
772772
New modules
773773
-----------
774774

775+
* Algebraic structures when freely adding an identity element:
776+
```
777+
Algebra.Construct.Add.Identity
778+
```
779+
775780
* Operations for module-like algebraic structures:
776781
```
777782
Algebra.Module.Core
@@ -942,6 +947,26 @@ New modules
942947
Other minor changes
943948
-------------------
944949

950+
* Added new proofs to `Algebra.Construct.Add.Identity`
951+
```agda
952+
lift-op : Op₂ A → Op₂ (Pointed A)
953+
cong₂ : Congruent₂ _≈_ op → Congruent₂ _≈∙_ (lift-op op)
954+
assoc : Associative _≈_ op → Associative _≈∙_ (lift-op op)
955+
identityˡ : LeftIdentity _≈∙_ ∙ (lift-op op)
956+
identityʳ : RightIdentity _≈∙_ ∙ (lift-op op)
957+
identity : Identity _≈∙_ ∙ (lift-op op)
958+
isMagma : IsMagma _≈_ op → IsMagma _≈∙_ (lift-op op)
959+
isSemigroup : IsSemigroup _≈_ op → IsSemigroup _≈∙_ (lift-op op)
960+
isMonoid : IsSemigroup _≈_ op → IsMonoid _≈∙_ (lift-op op) ∙
961+
semigroup : Semigroup a (a ⊔ ℓ) → Semigroup a (a ⊔ ℓ)
962+
monoid : Semigroup a (a ⊔ ℓ) → Monoid a (a ⊔ ℓ)
963+
```
964+
965+
* Added new proof to `Data.Maybe.Properties`
966+
```agda
967+
<∣>-idem : Idempotent _<∣>_
968+
```
969+
945970
* The module `Algebra` now publicly re-exports the contents of
946971
`Algebra.Structures.Biased`.
947972

@@ -1939,4 +1964,4 @@ This is a full list of proofs that have changed form to use irrelevant instance
19391964
```agda
19401965
Inverse⇒Injection : Inverse S T → Injection S T
19411966
↔⇒↣ : A ↔ B → A ↣ B
1942-
```
1967+
```
+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
------------------------------------------------------------------------
2+
-- The Agda standard library
3+
--
4+
-- Definition of algebraic structures we get from freely adding an
5+
-- identity element
6+
------------------------------------------------------------------------
7+
8+
{-# OPTIONS --without-K --safe #-}
9+
10+
module Algebra.Construct.Add.Identity where
11+
12+
open import Algebra.Bundles
13+
open import Algebra.Core using (Op₂)
14+
open import Algebra.Definitions
15+
open import Algebra.Structures
16+
open import Data.Maybe.Relation.Binary.Pointwise
17+
open import Data.Product using (_,_)
18+
open import Level using (Level; _⊔_)
19+
open import Relation.Binary.Core
20+
open import Relation.Binary.Definitions
21+
open import Relation.Binary.Structures
22+
open import Relation.Nullary.Construct.Add.Point
23+
24+
private
25+
variable
26+
a ℓ : Level
27+
A : Set a
28+
29+
lift-op : Op₂ A Op₂ (Pointed A)
30+
lift-op op [ p ] [ q ] = [ op p q ]
31+
lift-op _ [ p ] ∙ = [ p ]
32+
lift-op _ ∙ [ q ] = [ q ]
33+
lift-op _ ∙ ∙ =
34+
35+
module _ {_≈_ : Rel A ℓ} {op : Op₂ A} (refl-≈ : Reflexive _≈_) where
36+
private
37+
_≈∙_ = Pointwise _≈_
38+
39+
lift-≈ : {x y : A} x ≈ y Pointwise _≈_ [ x ] [ y ]
40+
lift-≈ = just
41+
42+
cong₂ : Congruent₂ _≈_ op Congruent₂ _≈∙_ (lift-op op)
43+
cong₂ R-cong (just eq-l) (just eq-r) = lift-≈ (R-cong eq-l eq-r)
44+
cong₂ R-cong (just eq) nothing = lift-≈ eq
45+
cong₂ R-cong nothing (just eq) = lift-≈ eq
46+
cong₂ R-cong nothing nothing = refl refl-≈
47+
48+
assoc : Associative _≈_ op Associative _≈∙_ (lift-op op)
49+
assoc assoc [ p ] [ q ] [ r ] = lift-≈ (assoc p q r)
50+
assoc _ [ p ] [ q ] ∙ = refl refl-≈
51+
assoc _ [ p ] ∙ [ r ] = refl refl-≈
52+
assoc _ [ p ] ∙ ∙ = refl refl-≈
53+
assoc _ ∙ [ r ] [ q ] = refl refl-≈
54+
assoc _ ∙ [ q ] ∙ = refl refl-≈
55+
assoc _ ∙ ∙ [ r ] = refl refl-≈
56+
assoc _ ∙ ∙ ∙ = refl refl-≈
57+
58+
identityˡ : LeftIdentity _≈∙_ ∙ (lift-op op)
59+
identityˡ [ p ] = refl refl-≈
60+
identityˡ ∙ = refl refl-≈
61+
62+
identityʳ : RightIdentity _≈∙_ ∙ (lift-op op)
63+
identityʳ [ p ] = refl refl-≈
64+
identityʳ ∙ = refl refl-≈
65+
66+
identity : Identity _≈∙_ ∙ (lift-op op)
67+
identity = identityˡ , identityʳ
68+
69+
module _ {_≈_ : Rel A ℓ} {op : Op₂ A} where
70+
private
71+
_≈∙_ = Pointwise _≈_
72+
op∙ = lift-op op
73+
74+
isMagma : IsMagma _≈_ op IsMagma _≈∙_ op∙
75+
isMagma M =
76+
record
77+
{ isEquivalence = isEquivalence M.isEquivalence
78+
; ∙-cong = cong₂ M.refl M.∙-cong
79+
} where module M = IsMagma M
80+
81+
isSemigroup : IsSemigroup _≈_ op IsSemigroup _≈∙_ op∙
82+
isSemigroup S = record
83+
{ isMagma = isMagma S.isMagma
84+
; assoc = assoc S.refl S.assoc
85+
} where module S = IsSemigroup S
86+
87+
isMonoid : IsSemigroup _≈_ op IsMonoid _≈∙_ op∙ ∙
88+
isMonoid S = record
89+
{ isSemigroup = isSemigroup S
90+
; identity = identity S.refl
91+
} where module S = IsSemigroup S
92+
93+
semigroup : Semigroup a (a ⊔ ℓ) Semigroup a (a ⊔ ℓ)
94+
semigroup S = record
95+
{ Carrier = Pointed S.Carrier
96+
; isSemigroup = isSemigroup S.isSemigroup
97+
} where module S = Semigroup S
98+
99+
monoid : Semigroup a (a ⊔ ℓ) Monoid a (a ⊔ ℓ)
100+
monoid S = record
101+
{ isMonoid = isMonoid S.isSemigroup
102+
} where module S = Semigroup S
103+

0 commit comments

Comments
 (0)