-
Notifications
You must be signed in to change notification settings - Fork 257
[ add ] Pointed
extension of an ordering
#2813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
------------------------------------------------------------------------ | ||
-- The Agda standard library | ||
-- | ||
-- A pointwise lifting of a relation to incorporate an additional point, | ||
-- assumed to be 'below' everything else in `Pointed A`. | ||
------------------------------------------------------------------------ | ||
|
||
{-# OPTIONS --cubical-compatible --safe #-} | ||
|
||
-- This module is designed to be used with | ||
-- Relation.Nullary.Construct.Add.Point | ||
|
||
open import Relation.Binary.Core using (Rel; _⇒_) | ||
|
||
module Relation.Binary.Construct.Add.Point.Order | ||
{a ℓ} {A : Set a} (_≲_ : Rel A ℓ) where | ||
|
||
open import Data.Product.Base using (_,_) | ||
open import Level using (Level; _⊔_) | ||
open import Function.Base using (id; _∘_; _∘′_) | ||
import Relation.Binary.Construct.Add.Point.Equality as Equality | ||
open import Relation.Binary.Structures | ||
using (IsPreorder; IsPartialOrder) | ||
open import Relation.Binary.Definitions | ||
using (Reflexive; Transitive; Antisymmetric; Directed; Decidable; Irrelevant) | ||
import Relation.Binary.PropositionalEquality.Core as ≡ | ||
open import Relation.Nullary.Decidable.Core as Dec | ||
using (yes; no) | ||
open import Relation.Nullary.Construct.Add.Point as Point | ||
using (Pointed; ∙ ;[_]) | ||
|
||
|
||
private | ||
variable | ||
ℓ′ : Level | ||
x∙ : Pointed A | ||
x y : A | ||
|
||
------------------------------------------------------------------------ | ||
-- Definition | ||
|
||
infix 4 _≲∙_ | ||
|
||
data _≲∙_ : Rel (Pointed A) (a ⊔ ℓ) where | ||
∙≲_ : ∀ x∙ → ∙ ≲∙ x∙ | ||
[_] : x ≲ y → [ x ] ≲∙ [ y ] | ||
|
||
pattern ∙≲∙ = ∙≲ ∙ | ||
|
||
------------------------------------------------------------------------ | ||
-- Relational properties | ||
|
||
[≲]-injective : [ x ] ≲∙ [ y ] → x ≲ y | ||
[≲]-injective [ x≲y ] = x≲y | ||
|
||
≲∙-refl : Reflexive _≲_ → Reflexive _≲∙_ | ||
≲∙-refl ≲-refl {∙} = ∙≲∙ | ||
≲∙-refl ≲-refl {[ x ]} = [ ≲-refl ] | ||
|
||
≲∙-trans : Transitive _≲_ → Transitive _≲∙_ | ||
≲∙-trans ≲-trans (∙≲ _) _ = ∙≲ _ | ||
≲∙-trans ≲-trans [ x≲y ] [ y≲z ] = [ ≲-trans x≲y y≲z ] | ||
|
||
≲∙-directed : Directed _≲_ → Directed _≲∙_ | ||
≲∙-directed dir ∙ ∙ = ∙ , ∙≲∙ , ∙≲∙ | ||
≲∙-directed dir [ x ] ∙ = let z , x≲z , _ = dir x x in [ z ] , [ x≲z ] , (∙≲ _) | ||
≲∙-directed dir ∙ [ y ] = let z , _ , y≲z = dir y y in [ z ] , (∙≲ _) , [ y≲z ] | ||
≲∙-directed dir [ x ] [ y ] = let z , x≲z , y≲z = dir x y in [ z ] , [ x≲z ] , [ y≲z ] | ||
|
||
≲∙-dec : Decidable _≲_ → Decidable _≲∙_ | ||
≲∙-dec _≟_ ∙ _ = yes (∙≲ _) | ||
≲∙-dec _≟_ [ x ] ∙ = no λ() | ||
≲∙-dec _≟_ [ x ] [ y ] = Dec.map′ [_] [≲]-injective (x ≟ y) | ||
|
||
≲∙-irrelevant : Irrelevant _≲_ → Irrelevant _≲∙_ | ||
≲∙-irrelevant ≲-irr (∙≲ _) (∙≲ _) = ≡.refl | ||
≲∙-irrelevant ≲-irr [ p ] [ q ] = ≡.cong _ (≲-irr p q) | ||
|
||
------------------------------------------------------------------------ | ||
-- Relativised to a putative `Setoid` | ||
|
||
module _ {_≈_ : Rel A ℓ′} where | ||
|
||
open Equality _≈_ | ||
|
||
≲∙-reflexive : (_≈_ ⇒ _≲_) → (_≈∙_ ⇒ _≲∙_) | ||
≲∙-reflexive ≲-reflexive ∙≈∙ = ∙≲∙ | ||
≲∙-reflexive ≲-reflexive [ x≈y ] = [ ≲-reflexive x≈y ] | ||
|
||
≲∙-antisym : Antisymmetric _≈_ _≲_ → Antisymmetric _≈∙_ _≲∙_ | ||
≲∙-antisym ≲-antisym ∙≲∙ ∙≲∙ = ∙≈∙ | ||
≲∙-antisym ≲-antisym [ x≤y ] [ y≤x ] = [ ≲-antisym x≤y y≤x ] | ||
|
||
------------------------------------------------------------------------ | ||
-- Structures | ||
|
||
≲∙-isPreorder : IsPreorder _≈_ _≲_ → IsPreorder _≈∙_ _≲∙_ | ||
≲∙-isPreorder ≲-isPreorder = record | ||
{ isEquivalence = Equality.≈∙-isEquivalence _ isEquivalence | ||
; reflexive = ≲∙-reflexive reflexive | ||
; trans = ≲∙-trans trans | ||
} where open IsPreorder ≲-isPreorder | ||
|
||
|
||
≲∙-isPartialOrder : IsPartialOrder _≈_ _≲_ → IsPartialOrder _≈∙_ _≲∙_ | ||
≲∙-isPartialOrder ≲-isPartialOrder = record | ||
{ isPreorder = ≲∙-isPreorder isPreorder | ||
; antisym = ≲∙-antisym antisym | ||
} where open IsPartialOrder ≲-isPartialOrder |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,11 @@ Asymmetric _<_ = ∀ {x y} → x < y → ¬ (y < x) | |
Dense : Rel A ℓ → Set _ | ||
Dense _<_ = ∀ {x y} → x < y → ∃[ z ] x < z × z < y | ||
|
||
-- Directedness (but: we drop the inhabitedness condition) | ||
|
||
Directed : Rel A ℓ → Set _ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you give a reference for this definition? Google did not help me find anything relevant. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://en.wikipedia.org/wiki/Directed_set The definition is taken from #2809 where it is currently called The official definition requires The lemma But it perhaps/probably makes more sense to uncouple the definition of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks - and @TOTBWF also expanded on this. There's a fairly non-trivial refactor of that PR incoming, after we discussed how to make things more There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comments on #2829 ... I (still) think that we should isolate, and agree upon, a definition of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm... if we instead go for FinitelyDirected : Rel A ℓ → Set _
FinitelyDirected _≤_ = ∀ {n} (f : Fin n → A) → ∃[ z ] ∀ i → f i ≲ z then UPDATED: but introducing such a definition causes a dependency cycle between
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Directed definitely does need to include the point! The unbiased definition is cute, but ends up not being the most ergonomic definition. It's akin to defining For semidirected, we could just call it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TOTBWF As I have said elsewhere, in any deployment context in which we want a But given the experiments I've made on https://github.com/jamesmckinna/agda-stdlib/tree/directed I'm happy that the Reifying ' I guess things will bottom out when DCPO/Filter/... reaches a stable point, at which point I'd be happy to refactor the original content here, namely that passage to the lifting-with-bottom-element preserve such any directedness, to such a future. |
||
Directed _≤_ = ∀ x y → ∃[ z ] x ≤ z × y ≤ z | ||
|
||
-- Generalised connex - at least one of the two relations holds. | ||
|
||
Connex : REL A B ℓ₁ → REL B A ℓ₂ → Set _ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why binary? Don't you want to say that for any I-indexed family of points, there's a 'z' that is below all of them?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See below.
But indeed, generalising may also be worthwhile, but ... downstream?