Skip to content
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

Respects₂-generic ? #31

Open
mechvel opened this issue Aug 27, 2014 · 7 comments
Open

Respects₂-generic ? #31

mechvel opened this issue Aug 27, 2014 · 7 comments
Assignees

Comments

@mechvel
Copy link
Contributor

mechvel commented Aug 27, 2014

Relation.Binary.Core has _Respects₂_ : ∀ {a ℓ₁ ℓ₂} {A : Set a} → Rel A ℓ₁ → Rel A ℓ₂ → Set _

And I introduce

  Respects₂gen :  {α α= β β= ℓ} {A : Set α} {B : Set β} 
                               (A  B  Set ℓ)  Rel A α=  Rel B β=  Set _  
  Respects₂gen _~_ _~₁_ _~₂_ =  {x x' y y'}  x ~₁ x'  y ~₂ y'  x ~ y  x' ~ y'

Example:

Respects₂gen _∈_ _≈_ _=set_ =    x ≈ x' → ys =set ys' → x ∈ xs → x' ∈ ys'`

expresses that the equality =set on lists (\xs ys -> xs ⊆ ys × ys ⊆ xs) agrees with
the equality _≈_ on elements and with the relation _∈_ betwen elements and lists.

Has Standard library a replacement for Respects₂gen ?
Has it a denotation for (A → B → Set ℓ) ?
(somewhat "Rel-heterogeneous A B" ? ...)

@mechvel
Copy link
Contributor Author

mechvel commented Aug 27, 2014

Strangely, this editor cancels many of underscores that I set in the code.
Let me try to copy-paste the underscore from the first line:

@mechvel
Copy link
Contributor Author

mechvel commented Aug 27, 2014

How to enter here the underscore symbol?

@fmap
Copy link

fmap commented Aug 27, 2014

@MatthewDaggitt
Copy link
Contributor

MatthewDaggitt commented Mar 18, 2018

Hmm I can envisage a use case for such a type. Not sure about the name Respects₂gen though. My alternative is:

_Respects₂_∧_ :  {a b ℓ₁ ℓ₂ ℓ₃} {A : Set a} {B : Set b} 
                REL A B ℓ₁  Rel A ℓ₂  Rel B ℓ₃  Set _
_∼_ Respects₂ _≈₁_ ∧ _≈₂_ =  {x y u v}  x ∼ u  x ≈₁ y  u ≈₂ v  y ∼ v

Still not entirely happy with it though. Thoughts?

The other question is whether we define it as a product ala _Respects₂_

_Respects₂_∧_ :  {a b ℓ₁ ℓ₂ ℓ₃} {A : Set a} {B : Set b} 
                REL A B ℓ₁  Rel A ℓ₂  Rel B ℓ₃  Set _
_∼_ Respects₂ _≈₁_ ∧ _≈₂_ = ( {y}  (_∼ y) Respects _≈₁_) ×
                            ( {x}  (x ∼_) Respects _≈₂_)

@MatthewDaggitt MatthewDaggitt added this to the 0.16 milestone Mar 18, 2018
@mechvel
Copy link
Contributor Author

mechvel commented Mar 18, 2018 via email

@MatthewDaggitt MatthewDaggitt removed this from the 0.16 milestone May 24, 2018
@gallais
Copy link
Member

gallais commented Feb 19, 2019

I keep introducing generalisations of the combinators in Relation.Binary.Core, the
latest being P ⟶ Q Respects _∼_ = ∀ {x y} → x ∼ y → P x → Q y so I can sympathise.

I would go even further and suggest:

_⟶_Respects₂_∧_ :
   {a b c d r s ℓ₁ ℓ₂} {A : Set a} {B : Set b} {C : Set c} {D : Set d}
  (R : REL A B r) (S : REL C D s) (_≈₁_ : REL A C ℓ₁) (_≈₂_ : REL B D ℓ₂)  Set _
R ⟶ S Respects₂ _≈₁_ ∧ _≈₂_ =  {a b c d}  a ≈₁ c  b ≈₂ d  R a b  S c d

The others can be defined as specialisations.

The other question is whether we define it as a product ala _Respects₂_

I would say yes because this one is usable even when the respected relations are not
reflexive. However it may be worth defining an ad-hoc record type rather than using
a product, this way we can provide the two-in-one-go as a definition in the record's
module.

@MatthewDaggitt MatthewDaggitt added this to the v2.0 milestone Jul 11, 2021
@MatthewDaggitt MatthewDaggitt removed this from the v2.0 milestone Oct 16, 2023
@mechvel
Copy link
Contributor Author

mechvel commented Feb 6, 2024

Currently I define and use

 RELRespects :  REL A B ℓ → Rel A ℓ₁ → Rel B ℓ₂ → Set _
 RELRespects _~_ _~₁_ _∼₂_ =
                         ∀ {x x' y y'} → x ~₁ x' → y ∼₂ y' → x ~ y → x' ~ y'

and suggest this for Standard library.

The attempt with _Respects_×_ failed because when it is applied to examples, it overlaps with applying _Respects_,
so that one is forced to apply (_Respects _×_ ~ ~'1 ~2) with ignoring the infix possibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants