| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- This module is DEPRECATED. |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
open import Relation.Binary.Core using (_Preserves_⟶_) |
| 10 |
open import Relation.Binary.Bundles using (Setoid) |
| 11 |
|
| 12 |
module Function.Endomorphism.Setoid {c e} (S : Setoid c e) where |
| 13 |
|
| 14 |
{-# WARNING_ON_IMPORT |
| 15 |
"Function.Endomorphism.Setoid was deprecated in v2.1. |
| 16 |
Use Function.Endo.Setoid instead." |
| 17 |
#-} |
| 18 |
|
| 19 |
open import Agda.Builtin.Equality |
| 20 |
|
| 21 |
open import Algebra |
| 22 |
open import Algebra.Structures |
| 23 |
open import Algebra.Morphism; open Definitions |
| 24 |
open import Function.Equality using (setoid; _⟶_; id; _∘_; cong) |
| 25 |
open import Data.Nat.Base using (ℕ; _+_); open ℕ |
| 26 |
open import Data.Nat.Properties |
| 27 |
open import Data.Product.Base using (_,_) |
| 28 |
|
| 29 |
import Relation.Binary.Indexed.Heterogeneous.Construct.Trivial as Trivial |
| 30 |
|
| 31 |
private |
| 32 |
module E = Setoid (setoid S (Trivial.indexedSetoid S)) |
| 33 |
open E hiding (refl) |
| 34 |
|
| 35 |
------------------------------------------------------------------------ |
| 36 |
-- Basic type and functions |
| 37 |
|
| 38 |
Endo : Set _ |
| 39 |
Endo = S ⟶ S |
| 40 |
|
| 41 |
infixr 8 _^_ |
| 42 |
|
| 43 |
_^_ : Endo → ℕ → Endo |
| 44 |
f ^ zero = id |
| 45 |
f ^ suc n = f ∘ (f ^ n) |
| 46 |
|
| 47 |
^-cong₂ : ∀ f → (f ^_) Preserves _≡_ ⟶ _≈_ |
| 48 |
^-cong₂ f {n} refl = cong (f ^ n) |
| 49 |
|
| 50 |
^-homo : ∀ f → Homomorphic₂ ℕ Endo _≈_ (f ^_) _+_ _∘_ |
| 51 |
^-homo f zero n x≈y = cong (f ^ n) x≈y |
| 52 |
^-homo f (suc m) n x≈y = cong f (^-homo f m n x≈y) |
| 53 |
|
| 54 |
------------------------------------------------------------------------ |
| 55 |
-- Structures |
| 56 |
|
| 57 |
∘-isMagma : IsMagma _≈_ _∘_ |
| 58 |
∘-isMagma = record |
| 59 |
{ isEquivalence = isEquivalence |
| 60 |
; ∙-cong = λ g f x → g (f x) |
| 61 |
} |
| 62 |
|
| 63 |
∘-magma : Magma _ _ |
| 64 |
∘-magma = record { isMagma = ∘-isMagma } |
| 65 |
|
| 66 |
∘-isSemigroup : IsSemigroup _≈_ _∘_ |
| 67 |
∘-isSemigroup = record |
| 68 |
{ isMagma = ∘-isMagma |
| 69 |
; assoc = λ h g f x≈y → cong h (cong g (cong f x≈y)) |
| 70 |
} |
| 71 |
|
| 72 |
∘-semigroup : Semigroup _ _ |
| 73 |
∘-semigroup = record { isSemigroup = ∘-isSemigroup } |
| 74 |
|
| 75 |
∘-id-isMonoid : IsMonoid _≈_ _∘_ id |
| 76 |
∘-id-isMonoid = record |
| 77 |
{ isSemigroup = ∘-isSemigroup |
| 78 |
; identity = cong , cong |
| 79 |
} |
| 80 |
|
| 81 |
∘-id-monoid : Monoid _ _ |
| 82 |
∘-id-monoid = record { isMonoid = ∘-id-isMonoid } |
| 83 |
|
| 84 |
------------------------------------------------------------------------ |
| 85 |
-- Homomorphism |
| 86 |
|
| 87 |
^-isSemigroupMorphism : ∀ f → IsSemigroupMorphism +-semigroup ∘-semigroup (f ^_) |
| 88 |
^-isSemigroupMorphism f = record |
| 89 |
{ ⟦⟧-cong = ^-cong₂ f |
| 90 |
; ∙-homo = ^-homo f |
| 91 |
} |
| 92 |
|
| 93 |
^-isMonoidMorphism : ∀ f → IsMonoidMorphism +-0-monoid ∘-id-monoid (f ^_) |
| 94 |
^-isMonoidMorphism f = record |
| 95 |
{ sm-homo = ^-isSemigroupMorphism f |
| 96 |
; ε-homo = λ x≈y → x≈y |
| 97 |
} |