| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- The min operator derived from an arbitrary total preorder. |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
open import Relation.Binary.Bundles using (TotalOrder) |
| 10 |
|
| 11 |
module Algebra.Construct.NaturalChoice.Min |
| 12 |
{a ℓ₁ ℓ₂} (O : TotalOrder a ℓ₁ ℓ₂) |
| 13 |
where |
| 14 |
|
| 15 |
open import Algebra.Core using (Op₂) |
| 16 |
open import Algebra.Construct.NaturalChoice.Base |
| 17 |
import Algebra.Construct.NaturalChoice.MinOp as MinOp |
| 18 |
open import Data.Sum.Base using (inj₁; inj₂; [_,_]) |
| 19 |
open import Data.Product.Base using (_,_) |
| 20 |
open import Function.Base using (id) |
| 21 |
open TotalOrder O renaming (Carrier to A) |
| 22 |
|
| 23 |
------------------------------------------------------------------------ |
| 24 |
-- Definition |
| 25 |
|
| 26 |
infixl 7 _⊓_ |
| 27 |
|
| 28 |
_⊓_ : Op₂ A |
| 29 |
x ⊓ y with total x y |
| 30 |
... | inj₁ x≤y = x |
| 31 |
... | inj₂ y≤x = y |
| 32 |
|
| 33 |
------------------------------------------------------------------------ |
| 34 |
-- Properties |
| 35 |
|
| 36 |
x≤y⇒x⊓y≈x : ∀ {x y} → x ≤ y → x ⊓ y ≈ x |
| 37 |
x≤y⇒x⊓y≈x {x} {y} x≤y with total x y |
| 38 |
... | inj₁ _ = Eq.refl |
| 39 |
... | inj₂ y≤x = antisym y≤x x≤y |
| 40 |
|
| 41 |
x≤y⇒y⊓x≈x : ∀ {x y} → x ≤ y → y ⊓ x ≈ x |
| 42 |
x≤y⇒y⊓x≈x {x} {y} x≤y with total y x |
| 43 |
... | inj₁ y≤x = antisym y≤x x≤y |
| 44 |
... | inj₂ _ = Eq.refl |
| 45 |
|
| 46 |
minOperator : MinOperator totalPreorder |
| 47 |
minOperator = record |
| 48 |
{ x≤y⇒x⊓y≈x = x≤y⇒x⊓y≈x |
| 49 |
; x≥y⇒x⊓y≈y = x≤y⇒y⊓x≈x |
| 50 |
} |
| 51 |
|
| 52 |
open MinOp minOperator public |