Debian Codegraph @

src/Algebra/Construct/NaturalChoice/Base.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Basic definition of an operator that computes the min/max value
5 -- with respect to a total preorder.
6 ------------------------------------------------------------------------
7
8 {-# OPTIONS --cubical-compatible --safe #-}
9
10 open import Algebra.Core using (Op₂)
11 open import Level as L hiding (_⊔_)
12 open import Function.Base using (flip)
13 open import Relation.Binary.Bundles using (TotalPreorder)
14 open import Relation.Binary.Construct.Flip.EqAndOrd using ()
15 renaming (totalPreorder to flipOrder)
16 import Relation.Binary.Properties.TotalOrder as TotalOrderProperties
17
18 module Algebra.Construct.NaturalChoice.Base where
19
20 private
21 variable
22 a ℓ₁ ℓ₂ : Level
23 O : TotalPreorder a ℓ₁ ℓ₂
24
25 ------------------------------------------------------------------------
26 -- Definition
27
28 module _ (O : TotalPreorder a ℓ₁ ℓ₂) where
29 open TotalPreorder O renaming (_≲_ to _≤_)
30 private _≥_ = flip _≤_
31
32 record MinOperator : Set (a L.⊔ ℓ₁ L.⊔ ℓ₂) where
33 infixl 7 _⊓_
34 field
35 _⊓_ : Op₂ Carrier
36 x≤y⇒x⊓y≈x : ∀ {x y} → x ≤ y → x ⊓ y ≈ x
37 x≥y⇒x⊓y≈y : ∀ {x y} → x ≥ y → x ⊓ y ≈ y
38
39 record MaxOperator : Set (a L.⊔ ℓ₁ L.⊔ ℓ₂) where
40 infixl 6 _⊔_
41 field
42 _⊔_ : Op₂ Carrier
43 x≤y⇒x⊔y≈y : ∀ {x y} → x ≤ y → x ⊔ y ≈ y
44 x≥y⇒x⊔y≈x : ∀ {x y} → x ≥ y → x ⊔ y ≈ x
45
46 ------------------------------------------------------------------------
47 -- Properties
48
49 MinOp⇒MaxOp : MinOperator O → MaxOperator (flipOrder O)
50 MinOp⇒MaxOp minOp = record
51 { _⊔_ = _⊓_
52 ; x≤y⇒x⊔y≈y = x≥y⇒x⊓y≈y
53 ; x≥y⇒x⊔y≈x = x≤y⇒x⊓y≈x
54 } where open MinOperator minOp
55
56 MaxOp⇒MinOp : MaxOperator O → MinOperator (flipOrder O)
57 MaxOp⇒MinOp maxOp = record
58 { _⊓_ = _⊔_
59 ; x≤y⇒x⊓y≈x = x≥y⇒x⊔y≈x
60 ; x≥y⇒x⊓y≈y = x≤y⇒x⊔y≈y
61 } where open MaxOperator maxOp