| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Definitions of the lexicographic product of two operators. |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
open import Algebra.Bundles using (Magma) |
| 10 |
open import Algebra.Definitions |
| 11 |
open import Data.Bool.Base using (true; false) |
| 12 |
open import Data.Product.Base using (_×_; _,_) |
| 13 |
open import Data.Product.Relation.Binary.Pointwise.NonDependent using (Pointwise) |
| 14 |
open import Data.Sum.Base using (inj₁; inj₂; map) |
| 15 |
open import Function.Base using (_∘_) |
| 16 |
open import Relation.Binary.Core using (Rel) |
| 17 |
open import Relation.Binary.Definitions using (Decidable) |
| 18 |
open import Relation.Nullary.Decidable.Core using (does; yes; no) |
| 19 |
open import Relation.Nullary.Negation.Core using (¬_; contradiction; contradiction₂) |
| 20 |
import Relation.Binary.Reasoning.Setoid as ≈-Reasoning |
| 21 |
|
| 22 |
module Algebra.Construct.LexProduct |
| 23 |
{ℓ₁ ℓ₂ ℓ₃ ℓ₄} (M : Magma ℓ₁ ℓ₂) (N : Magma ℓ₃ ℓ₄) |
| 24 |
(_≟₁_ : Decidable (Magma._≈_ M)) |
| 25 |
where |
| 26 |
|
| 27 |
open Magma M using (_∙_ ; ∙-cong) |
| 28 |
renaming |
| 29 |
( Carrier to A |
| 30 |
; _≈_ to _≈₁_ |
| 31 |
; _≉_ to _≉₁_ |
| 32 |
) |
| 33 |
|
| 34 |
open Magma N using () |
| 35 |
renaming |
| 36 |
( Carrier to B |
| 37 |
; _∙_ to _◦_ |
| 38 |
; _≈_ to _≈₂_ |
| 39 |
; refl to ≈₂-refl |
| 40 |
) |
| 41 |
|
| 42 |
import Algebra.Construct.LexProduct.Inner M N _≟₁_ as InnerLex |
| 43 |
|
| 44 |
private |
| 45 |
infix 4 _≋_ |
| 46 |
_≋_ : Rel (A × B) _ |
| 47 |
_≋_ = Pointwise _≈₁_ _≈₂_ |
| 48 |
|
| 49 |
variable |
| 50 |
a b : A |
| 51 |
|
| 52 |
------------------------------------------------------------------------ |
| 53 |
-- Definition |
| 54 |
------------------------------------------------------------------------ |
| 55 |
|
| 56 |
open import Algebra.Construct.LexProduct.Base _∙_ _◦_ _≟₁_ public |
| 57 |
renaming (lex to _⊕_) |
| 58 |
|
| 59 |
------------------------------------------------------------------------ |
| 60 |
-- Properties |
| 61 |
------------------------------------------------------------------------ |
| 62 |
-- Basic cases |
| 63 |
|
| 64 |
case₁ : ∀ {a b} → (a ∙ b) ≈₁ a → (a ∙ b) ≉₁ b → |
| 65 |
∀ x y → (a , x) ⊕ (b , y) ≋ (a , x) |
| 66 |
case₁ ab≈a ab≉b _ _ = ab≈a , InnerLex.case₁ ab≈a ab≉b |
| 67 |
|
| 68 |
case₂ : ∀ {a b} → (a ∙ b) ≉₁ a → (a ∙ b) ≈₁ b → |
| 69 |
∀ x y → (a , x) ⊕ (b , y) ≋ (b , y) |
| 70 |
case₂ ab≉a ab≈b _ _ = ab≈b , InnerLex.case₂ ab≉a ab≈b |
| 71 |
|
| 72 |
case₃ : ∀ {a b} → (a ∙ b) ≈₁ a → (a ∙ b) ≈₁ b → |
| 73 |
∀ x y → (a , x) ⊕ (b , y) ≋ (a , x ◦ y) |
| 74 |
case₃ ab≈a ab≈b _ _ = ab≈a , InnerLex.case₃ ab≈a ab≈b |
| 75 |
|
| 76 |
------------------------------------------------------------------------ |
| 77 |
-- Algebraic properties |
| 78 |
|
| 79 |
cong : Congruent₂ _≋_ _⊕_ |
| 80 |
cong (a≈b , w≈x) (c≈d , y≈z) = |
| 81 |
∙-cong a≈b c≈d , |
| 82 |
InnerLex.cong a≈b c≈d w≈x y≈z |
| 83 |
|
| 84 |
assoc : Associative _≈₁_ _∙_ → Commutative _≈₁_ _∙_ → |
| 85 |
Selective _≈₁_ _∙_ → Associative _≈₂_ _◦_ → |
| 86 |
Associative _≋_ _⊕_ |
| 87 |
assoc ∙-assoc ∙-comm ∙-sel ◦-assoc (a , x) (b , y) (c , z) = |
| 88 |
∙-assoc a b c , |
| 89 |
InnerLex.assoc ∙-assoc ∙-comm ∙-sel ◦-assoc a b c x y z |
| 90 |
|
| 91 |
comm : Commutative _≈₁_ _∙_ → Commutative _≈₂_ _◦_ → |
| 92 |
Commutative _≋_ _⊕_ |
| 93 |
comm ∙-comm ◦-comm (a , x) (b , y) = |
| 94 |
∙-comm a b , |
| 95 |
InnerLex.comm ∙-comm ◦-comm a b x y |
| 96 |
|
| 97 |
zeroʳ : ∀ {e f} → RightZero _≈₁_ e _∙_ → RightZero _≈₂_ f _◦_ → |
| 98 |
RightZero _≋_ (e , f) _⊕_ |
| 99 |
zeroʳ ze₁ ze₂ (x , a) = ze₁ x , InnerLex.zeroʳ ze₁ ze₂ |
| 100 |
|
| 101 |
identityʳ : ∀ {e f} → RightIdentity _≈₁_ e _∙_ → RightIdentity _≈₂_ f _◦_ → |
| 102 |
RightIdentity _≋_ (e , f) _⊕_ |
| 103 |
identityʳ id₁ id₂ (x , a) = id₁ x , InnerLex.identityʳ id₁ id₂ |
| 104 |
|
| 105 |
sel : Selective _≈₁_ _∙_ → Selective _≈₂_ _◦_ → Selective _≋_ _⊕_ |
| 106 |
sel ∙-sel ◦-sel (a , x) (b , y) with (a ∙ b) ≟₁ a | (a ∙ b) ≟₁ b |
| 107 |
... | no ab≉a | no ab≉b = contradiction₂ (∙-sel a b) ab≉a ab≉b |
| 108 |
... | yes ab≈a | no _ = inj₁ (ab≈a , ≈₂-refl) |
| 109 |
... | no _ | yes ab≈b = inj₂ (ab≈b , ≈₂-refl) |
| 110 |
... | yes ab≈a | yes ab≈b = map (ab≈a ,_) (ab≈b ,_) (◦-sel x y) |