Add a preorder instance for product
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
parent
2b3d429631
commit
c9b514e9af
45
Lattice.agda
45
Lattice.agda
|
@ -85,11 +85,9 @@ record Lattice {a} (A : Set a) : Set (lsuc a) where
|
||||||
|
|
||||||
open IsLattice isLattice public
|
open IsLattice isLattice public
|
||||||
|
|
||||||
private module NatInstances where
|
module PreorderInstances where
|
||||||
open Nat
|
module ForNat where
|
||||||
open NatProps
|
open NatProps
|
||||||
open Eq
|
|
||||||
open Data.Sum
|
|
||||||
|
|
||||||
NatPreorder : Preorder ℕ
|
NatPreorder : Preorder ℕ
|
||||||
NatPreorder = record
|
NatPreorder = record
|
||||||
|
@ -101,6 +99,45 @@ private module NatInstances where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module ForProd {a} {A B : Set a} {{ pA : Preorder A }} {{ pB : Preorder B }} where
|
||||||
|
open Eq
|
||||||
|
|
||||||
|
private
|
||||||
|
_≼_ : A × B → A × B → Set a
|
||||||
|
(a₁ , b₁) ≼ (a₂ , b₂) = Preorder._≼_ pA a₁ a₂ × Preorder._≼_ pB b₁ b₂
|
||||||
|
|
||||||
|
ispA = Preorder.isPreorder pA
|
||||||
|
ispB = Preorder.isPreorder pB
|
||||||
|
|
||||||
|
≼-refl : {p : A × B} → p ≼ p
|
||||||
|
≼-refl {(a , b)} = (IsPreorder.≼-refl ispA {a}, IsPreorder.≼-refl ispB {b})
|
||||||
|
|
||||||
|
≼-trans : {p₁ p₂ p₃ : A × B} → p₁ ≼ p₂ → p₂ ≼ p₃ → p₁ ≼ p₃
|
||||||
|
≼-trans (a₁≼a₂ , b₁≼b₂) (a₂≼a₃ , b₂≼b₃) =
|
||||||
|
( IsPreorder.≼-trans ispA a₁≼a₂ a₂≼a₃
|
||||||
|
, IsPreorder.≼-trans ispB b₁≼b₂ b₂≼b₃
|
||||||
|
)
|
||||||
|
|
||||||
|
≼-antisym : {p₁ p₂ : A × B} → p₁ ≼ p₂ → p₂ ≼ p₁ → p₁ ≡ p₂
|
||||||
|
≼-antisym (a₁≼a₂ , b₁≼b₂) (a₂≼a₁ , b₂≼b₁) = cong₂ (_,_) (IsPreorder.≼-antisym ispA a₁≼a₂ a₂≼a₁) (IsPreorder.≼-antisym ispB b₁≼b₂ b₂≼b₁)
|
||||||
|
|
||||||
|
ProdPreorder : Preorder (A × B)
|
||||||
|
ProdPreorder = record
|
||||||
|
{ _≼_ = _≼_
|
||||||
|
; isPreorder = record
|
||||||
|
{ ≼-refl = ≼-refl
|
||||||
|
; ≼-trans = ≼-trans
|
||||||
|
; ≼-antisym = ≼-antisym
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private module NatInstances where
|
||||||
|
open Nat
|
||||||
|
open NatProps
|
||||||
|
open Eq
|
||||||
|
open PreorderInstances.ForNat
|
||||||
|
|
||||||
private
|
private
|
||||||
max-bound₁ : {x y z : ℕ} → x ⊔ y ≡ z → x ≤ z
|
max-bound₁ : {x y z : ℕ} → x ⊔ y ≡ z → x ≤ z
|
||||||
max-bound₁ {x} {y} {z} x⊔y≡z rewrite sym x⊔y≡z rewrite ⊔-comm x y = m≤n⇒m≤o⊔n y (≤-refl)
|
max-bound₁ {x} {y} {z} x⊔y≡z rewrite sym x⊔y≡z rewrite ⊔-comm x y = m≤n⇒m≤o⊔n y (≤-refl)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user