-
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
Ergonomics of trying to add 'constructors' in Data.Vec.Functional.Relation.Binary.Pointwise.Properties
#1731
Comments
Sorry for taking so long to reply to this! I have also on occasion run into similar problems! In the end I always found that if I needed to inductively extend the vectors or their proofs then I should really been using I'm unsure what you and @gallais are doing, but are you sure |
Unusually this is actually documented 😆 agda-stdlib/src/Data/Vec/Functional.agda Lines 7 to 12 in 6630bd9
|
So, a couple of things things in play:
The first, viz the use of a functional representation, there was to profit from an observation of Alan Jeffrey to the effect that, 'function composition is easier than...' well, most things, actually (cf. lists vs. difference lists). The solution we adopted was akin to that in The application I had been working on is a variation on that theme, namely a streamlined proof of the logical relations-style argument about CBN simulating CBV. So it's not that I need a So indeed, perhaps the correct answer is to rewrite in terms of a Regarding the second and third points: the second, duly noted; the third, perhaps, remains moot. I'll play around with the alternative, and presuming it all goes smoothly, abandon the issue (and the branch I had been developing towards a PR...) |
Resolved with very little fuss. The only wrinkle seems to be agda's concern about ambiguity between |
I don't know about fixed size, @laMudri's original motivation to use I think the |
OK @gallais thanks very much for re-opening this, and for the pointers back into the history of stdlib and I was aware of the I was also aware (and perhaps complaining about) the need to finesse the typechecker into correctly inferring the associated For the intended modes of use (big Operators) how much performance overhead might one expect if As to that intended mode of use, the examples in the library seem to revolve around n-ary summation in |
I haven't carefully read the above discussion, but maybe I have something relevant to add (now I've been summoned). Subsequent to working on the _∷₂_ : {xxs yys : Vector A (suc n)} → R (head xxs) (head yys) → Pointwise R (tail xxs) (tail yys) → Pointwise R xxs yys The idea is to turn a green-green unification problem into green-purple problem (for the real constructors of inductively defined Occasionally the green and purple are the other way round, because we're synthesising the parameters |
Hmmm... wow!? regarding a much more sophisticated collection of insights than I was quite expecting (what did I expect, really?). |
In Collie (declarative hierarchical command line interface library for Idris2) we have a similar story because we https://github.com/ohad/collie/blob/main/src/Data/Record/SmartConstructors.idr for the curious (the important
I don't know what purple is but I'm assuming it's a mixture of green & red (e.g. record projections because eta means we can solve more green-looking stuff?) |
Again: great to have the additional (rich; expert) insights from other settings, and in particular the need/utility of smart constructors... but with the additional twist of the infer/check distinction. Plus, I've seen references to collie before, nice to find out (a glimpse of) what's going on there... |
Purple is variables. |
I'd be happy to close this 'issue' now, but grateful in the meantime for all that it has helped teach me about (some of the |
So the issue title is a huge mouthful (and the text of this issue; -- sorry!), but the issue falls into two parts:
Data.Vec.Functional.Relation.Binary.Pointwise{.Properties}
I'll use the second to illustrate the first (see branch
vec-functional
on my fork; it seems to be the easiest way to flesh out the issue):Data.Vec.Functional.Relation.Binary.Pointwise
defines a relation transformerPointwise
, defined onR : REL A B ℓ
,All
-style as a function returning instances ofR
for each indexi
of a functional representation ofVector
s overA
(resp.B
);[]
and_∷_
casesBUT
Pointwise
at a givenR
is OK;Pointwise R
So...
R
when appealing to the constructors;Constructors
of...Properties
which declares them, explicitly parametrised onR
(see branch), and thenopen
ing an instance of that at the same time as defining aPointwise
instanceI've created a branch (towards a PR?), and example uses of it (not shown), but the 'issue' for me is two-fold:
record
to overcome the limitations of the typechecker, but is that the only way to deal with this? EDITED: also cf.Data/Vec/Relation/Binary/Pointwise/Extensional
)The other side of the 'issue' is that it seems (to me at least) that when
stdlib
introduces new concepts, it should also provide appropriate introduction/elimination forms, as in theConstructors
module. This is 'easy' for inductively-defined concepts, the constructors (or pattern synonyms on top of them) do the work; but this is an instance where they both seem useful/systematic to add, but are nonetheless absent.(Similar consideration apply, more easily, to
...Relation.Unary.All
cases for[]
and_∷_
)The text was updated successfully, but these errors were encountered: