-
Notifications
You must be signed in to change notification settings - Fork 246
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
An alternative to generalised implication in Relation.Binary.Core? #669
Comments
Quite possibly though I'm a little confused about your use case. Could you expand it for a concrete datatype? I've tried letting "MyDatatype"=List and I'm not coming up with something useful, but maybe I'm just not seeing it. |
Here's a MWE of what I'm trying to do: -- ** common stuff
open import Function
open import Data.Product
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.Core
_⇒[_]=_ : ∀ {a b ℓ₁ ℓ₂} {A : Set a} {B : Set b} →
Rel A ℓ₁ → (B → A) → Rel B ℓ₂ → Set _
P ⇒[ f ]= Q = (P on f) ⇒ Q
-- ** Nat stuff
open import Data.Nat
variable
m n s : ℕ
-- ** particular datatype stuff here
-- my datatype (an encoding of summation)
data Add : ℕ → ℕ → ℕ → Set where
zero : Add zero m m
suc : Add n m s → Add (suc n) m (suc s)
-- a proof that Add is functional
≡-from-Add : _×_ ⇒[ Add n m ]= _≡_
≡-from-Add (zero , zero) = refl
≡-from-Add (suc add1 , suc add2) rewrite ≡-from-Add (add1 , add2) = refl
add = _+_ -- just a renaming here for brevity, but you can imagine I might have written a new function
-- creating `Add`s on-the-fly
runAdd : Add n m (add n m)
runAdd {zero} = zero
runAdd {suc n} = suc runAdd
|
Here are two more use-cases, coming directly out of ≤′-step-injective-from-stdlib : _≡_ ⇒[ ≤′-step {m} {n} ]= _≡_ -- N.B. generalised variables
≤′-step-injective-from-stdlib refl = refl
≤-pred-from-stdlib : _≤_ ⇒[ suc ]= _≤_
≤-pred-from-stdlib (s≤s m≤n) = m≤n |
Ah okay, that makes sense. Yup, it would be fine to open a PR. As for names I'm okay with your suggestion though I agree it's a little strange. To be honest I think the existing notation for |
I do not find the MWE very compelling, since the following also works, and it is only a few keystrokes more: ≡-from-Add : (_×_ on Add n m) ⇒ _≡_ The most natural naming would then be P on[ f ]⇒ Q = (P on f) ⇒ Q
...
≡-from-Add : _×_ on[ Add n m ]⇒ _≡_ But I am not very convinced this is above the Fairbairn threshold. Tentatively closing, feel free to reopen and continue the discussion. |
If Fwiw, if |
@andreasabel and/or @MatthewDaggitt, thoughts? Btw, I would have reopened the issue but github does not give me that option. |
Apologies for the delay in replying, I've been away for the last week. I have to agree with @andreasabel here. I think Sorry @m0davis I know that's probably not the answer you wanted. |
Actually, I'm perfectly happy with not adding |
Excellent.
I think
|
Whatever is done here, it'd be nice if unary and binary relations had more consistent naming for their combinators. It's a bit annoying that predicates have |
@laMudri Have you considered using |
No. Is that module:
|
I don't know what you need. Have a look
Yes, expect for conflicting conventions naturally (it uses the same convention as |
I find the following definition useful.
It looks quite similar to generalised implication (or
_Preserves_⟶_
) fromRelation.Binary.Core
but I don't find the above definition there.My current use-case is
_×_ ⇒[ MyDatatype ]= _≡_
. If there is a more clever way to write this using the standard library as-is, I'd be happy if someone pointed it out to me.Would it make sense for me to make a pull request to add it? I'm somewhat unsure about the name. The
⇒
looks a bit strange to me sitting on the left-hand side. If it were to be added, I would figure we would need synonyms similar toPreserves
et al. But again, I'm unsure how to name them.The text was updated successfully, but these errors were encountered: