{-# OPTIONS --cubical-compatible --safe #-}
module Relation.Binary.Construct.Interior.Symmetric where
open import Function.Base using (flip)
open import Level
open import Relation.Binary
private
variable
a b c ℓ r s t : Level
A : Set a
R S T : Rel A r
record SymInterior (R : Rel A ℓ) (x y : A) : Set ℓ where
constructor _,_
field
lhs≤rhs : R x y
rhs≤lhs : R y x
open SymInterior public
symmetric : Symmetric (SymInterior R)
symmetric (r , r′) = r′ , r
unfold : Symmetric S → S ⇒ R → S ⇒ SymInterior R
unfold sym f s = f s , f (sym s)
reflexive : Reflexive R → Reflexive (SymInterior R)
reflexive refl = refl , refl
trans : Trans R S T → Trans S R T →
Trans (SymInterior R) (SymInterior S) (SymInterior T)
trans trans-rs trans-sr (r , r′) (s , s′) = trans-rs r s , trans-sr s′ r′
transitive : Transitive R → Transitive (SymInterior R)
transitive tr = trans tr tr
asymmetric⇒empty : Asymmetric R → Empty (SymInterior R)
asymmetric⇒empty asym (r , r′) = asym r r′
isEquivalence : Reflexive R → Transitive R → IsEquivalence (SymInterior R)
isEquivalence refl trans = record
{ refl = reflexive refl
; sym = symmetric
; trans = transitive trans
}
isPartialOrder : Reflexive R → Transitive R → IsPartialOrder (SymInterior R) R
isPartialOrder refl trans = record
{ isPreorder = record
{ isEquivalence = isEquivalence refl trans
; reflexive = lhs≤rhs
; trans = trans
}
; antisym = _,_
}
poset : ∀ {a} {A : Set a} {R : Rel A ℓ} → Reflexive R → Transitive R → Poset a ℓ ℓ
poset {R = R} refl trans = record
{ _≤_ = R
; isPartialOrder = isPartialOrder refl trans
}