| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Bundles for morphisms between binary relations |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Relation.Binary.Morphism.Bundles where |
| 10 |
|
| 11 |
open import Level using (Level; _⊔_) |
| 12 |
open import Relation.Binary.Core using (_Preserves_⟶_) |
| 13 |
open import Relation.Binary.Bundles using (Setoid; Preorder; Poset) |
| 14 |
open import Relation.Binary.Morphism.Structures |
| 15 |
using (IsRelHomomorphism; IsRelMonomorphism; IsRelIsomorphism |
| 16 |
; IsOrderHomomorphism; IsOrderMonomorphism; IsOrderIsomorphism) |
| 17 |
open import Relation.Binary.Consequences using (mono⇒cong) |
| 18 |
|
| 19 |
private |
| 20 |
variable |
| 21 |
ℓ₁ ℓ₂ ℓ₃ ℓ₄ ℓ₅ ℓ₆ : Level |
| 22 |
|
| 23 |
------------------------------------------------------------------------ |
| 24 |
-- Setoids |
| 25 |
------------------------------------------------------------------------ |
| 26 |
|
| 27 |
module _ (S₁ : Setoid ℓ₁ ℓ₂) (S₂ : Setoid ℓ₃ ℓ₄) where |
| 28 |
|
| 29 |
record SetoidHomomorphism : Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) where |
| 30 |
open Setoid |
| 31 |
field |
| 32 |
⟦_⟧ : Carrier S₁ → Carrier S₂ |
| 33 |
isRelHomomorphism : IsRelHomomorphism (_≈_ S₁) (_≈_ S₂) ⟦_⟧ |
| 34 |
|
| 35 |
open IsRelHomomorphism isRelHomomorphism public |
| 36 |
|
| 37 |
|
| 38 |
record SetoidMonomorphism : Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) where |
| 39 |
open Setoid |
| 40 |
field |
| 41 |
⟦_⟧ : Carrier S₁ → Carrier S₂ |
| 42 |
isRelMonomorphism : IsRelMonomorphism (_≈_ S₁) (_≈_ S₂) ⟦_⟧ |
| 43 |
|
| 44 |
open IsRelMonomorphism isRelMonomorphism public |
| 45 |
|
| 46 |
homomorphism : SetoidHomomorphism |
| 47 |
homomorphism = record { isRelHomomorphism = isHomomorphism } |
| 48 |
|
| 49 |
|
| 50 |
record SetoidIsomorphism : Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄) where |
| 51 |
open Setoid |
| 52 |
field |
| 53 |
⟦_⟧ : Carrier S₁ → Carrier S₂ |
| 54 |
isRelIsomorphism : IsRelIsomorphism (_≈_ S₁) (_≈_ S₂) ⟦_⟧ |
| 55 |
|
| 56 |
open IsRelIsomorphism isRelIsomorphism public |
| 57 |
|
| 58 |
monomorphism : SetoidMonomorphism |
| 59 |
monomorphism = record { isRelMonomorphism = isMonomorphism } |
| 60 |
|
| 61 |
open SetoidMonomorphism monomorphism public |
| 62 |
using (homomorphism) |
| 63 |
|
| 64 |
|
| 65 |
------------------------------------------------------------------------ |
| 66 |
-- Preorders |
| 67 |
------------------------------------------------------------------------ |
| 68 |
|
| 69 |
record PreorderHomomorphism (S₁ : Preorder ℓ₁ ℓ₂ ℓ₃) |
| 70 |
(S₂ : Preorder ℓ₄ ℓ₅ ℓ₆) |
| 71 |
: Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄ ⊔ ℓ₅ ⊔ ℓ₆) where |
| 72 |
open Preorder |
| 73 |
field |
| 74 |
⟦_⟧ : Carrier S₁ → Carrier S₂ |
| 75 |
isOrderHomomorphism : IsOrderHomomorphism (_≈_ S₁) (_≈_ S₂) (_≲_ S₁) (_≲_ S₂) ⟦_⟧ |
| 76 |
|
| 77 |
open IsOrderHomomorphism isOrderHomomorphism public |
| 78 |
|
| 79 |
------------------------------------------------------------------------ |
| 80 |
-- Posets |
| 81 |
------------------------------------------------------------------------ |
| 82 |
|
| 83 |
module _ (P : Poset ℓ₁ ℓ₂ ℓ₃) (Q : Poset ℓ₄ ℓ₅ ℓ₆) where |
| 84 |
|
| 85 |
private |
| 86 |
module P = Poset P |
| 87 |
module Q = Poset Q |
| 88 |
|
| 89 |
record PosetHomomorphism : Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃ ⊔ ℓ₄ ⊔ ℓ₅ ⊔ ℓ₆) where |
| 90 |
field |
| 91 |
⟦_⟧ : P.Carrier → Q.Carrier |
| 92 |
isOrderHomomorphism : IsOrderHomomorphism P._≈_ Q._≈_ P._≤_ Q._≤_ ⟦_⟧ |
| 93 |
|
| 94 |
open IsOrderHomomorphism isOrderHomomorphism public |
| 95 |
|
| 96 |
|
| 97 |
-- Smart constructor that automatically constructs the congruence |
| 98 |
-- proof from the monotonicity proof |
| 99 |
mkPosetHomo : ∀ f → f Preserves P._≤_ ⟶ Q._≤_ → PosetHomomorphism |
| 100 |
mkPosetHomo f mono = record |
| 101 |
{ ⟦_⟧ = f |
| 102 |
; isOrderHomomorphism = record |
| 103 |
{ cong = mono⇒cong P._≈_ Q._≈_ P.Eq.sym P.reflexive Q.antisym mono |
| 104 |
; mono = mono |
| 105 |
} |
| 106 |
} |