-
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
[ add ] Relation.Binary._Reflects_⟶_
as a companion to _Preserves_⟶_
#2566
Conversation
What's the intuition for the |
Nothing to do with But absolutely conventional usage in first-order logic/relational algebra (eg. discussion in McKinna&Pollack 1999 on preserving and reflecting α-conversion in λ-calculus representations...): the aim is to [DRY] reconcile |
@@ -31,7 +31,7 @@ module _ | |||
Congruent f = ∀ {x y} → x ≈₁ y → f x ≈₂ f y | |||
|
|||
Injective : (A → B) → Set _ | |||
Injective f = ∀ {x y} → f x ≈₂ f y → x ≈₁ y | |||
Injective = _Reflects _≈₂_ ⟶ _≈₁_ |
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.
I'm kind of against this change personally. I read Injective f = ∀ {x y} → f x ≈₂ f y → x ≈₁ y
and I understand exactly what it says.
I read Injective = _Reflects _≈₂_ ⟶ _≈₁_
and I have to do the following:
- Expand the missing function to
Injective f = f Reflects _≈₂_ ⟶ _≈₁_
(non-trivial for beginners) - Expand Reflects to
(_≈₁_ on f) ⇒ _≈₂_
which is equally baffling. - Expand
on
... - Expand
_⇒_
... - Only now do I get to the actual definition.
All of these definitions are in different modules and Agda currently provides no easy method of expanding them. In my mind the very small benefit of this change is outweighed by the quite large decrease in usability!
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.
@MatthewDaggitt very sharp critique from the ux perspective (I think perhaps we should have ux
as a new label category for tagging issues/PRs), for which all thanks.
As the preamble to this PR indicates, I wanted this concept/definition in stdlib
so that (eventually) all the Cancellative
properties could be rephrased in terms of it. Currently, under #1436 / #2573 we only treat the cancellative properties for equality... if you will, perhaps as another, more directly graspable concept, we should get rid of Cancellative
and friends altogether in favour of saying that eg m +_
is Injective
on Nat
with _≡_
(that would be the other way to go).
It's perhaps the case that my ideological/reformatory zeal on [DRY] issues leads to (over-)generalisations like those considered here (or most recently, in #2581 ), and that reflects what is (probably!) the greater abstraction power of higher-order languages such as Agda's type theory relative to the abstraction power of users (esp. wrt definitional expansion across modules, as you indicate so forcefully).
Against your suggestion, my own preference would be to record as a comment, the 'conventional' usage as being a definitional expansion of the abstract one. Something like
Injective : (A → B) → Set _
Injective = _Reflects _≈₂_ ⟶ _≈₁_
-- i.e. Injective f = ∀ {x y} → f x ≈₂ f y → x ≈₁ y
Of course, that would be a break from existing practice in the library, as well as opening the door to bit-rot if/when definitions change, but here I don't think we are at quite such a risk... precisely because the definition is so 'stable'?
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.
All of that said, happy to revert this particular instance of the definition (it was introduced above as 'illustrative'), but then what about Cancellative
in all its variety?
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.
I think adding non-type checked comments is very susceptible to bit rot as you say. I would be more open to a private definition that performed an equality check.
However, I'm still not entirely sure what advantages the generalisation brings in this case. It's not like we have either a) a set of properties/theory about these kinds of definitions in general or b) lots of definitions in this form? Injective
, Cancellative
, anything else?
Ditto, I'm not sure that I would be keen on replacing the definitions of Cancellative
for exactly the same reasons...
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.
I guess I would still try (but ) to justify the addition
- on formal grounds, as the 'opposite' of
Respects
- on abstraction grounds (I clearly prefer greater degrees of abstraction, yes ,for its own sake, so I'll try to keep that in mind in future)
but this particular stone seems to be getting harder to push uphill. I'll stop!
A preparatory PR ahead of tackling #1436 in earnest.
NB:
Function.Definitions.Injective
Function.Definitions.Congruent
in terms ofPreserves
results in many, many, unsolved metas... sigh. See [ refactor ]Function.Definitions
andFunction.Consequences
? #2565 for details