Replies: 13 comments 4 replies
-
Just as an aesthetic matter, I kinda hate having the operations be parameters to the record. Imagine the size of a theorem that's parametrised over a ring, or a Heyting algebra! As a more practical justification for this, in univalent mathematics, we want equality of "structured types" to be homomorphic equivalence - the Structure Identity Principle - and our current infra for that requires that the structure be a family |
Beta Was this translation helpful? Give feedback.
-
I don't know, I think "there exists S : Group Int such that S.* = +" is pretty ugly to write as well, and sometimes there's a need for these statements in more general contexts, like for example in the Eckmann-Hilton argument |
Beta Was this translation helpful? Give feedback.
-
This whole issue of parameters vs fields, bundling vs unbundling, is a well-known design problem in libraries. I've dabbled around it. There's an active discussion of that design for stdlib. Arend seems nice here. Yes, the SIP says that none of this matters. Unfortunately the "engineering" work so adapt Agda (plain or cubical) to deal gracefully with the SIP has not yet been done. |
Beta Was this translation helpful? Give feedback.
-
Interesting and pretty impressive tool - it'd force one to abandon the literate Agda approach though, at least to some degree. I don't know how much effort it would take to figure out how to connect code and text in a more modular way, but to me it'd be worth consideration at least. |
Beta Was this translation helpful? Give feedback.
-
A thought is that we could potentially only write the unbundled version (i.e. Sadly you can't add new record definitions with reflection, but I think we could generate |
Beta Was this translation helpful? Give feedback.
-
Similarly I assume we could write reflection helpers that could automatically generate |
Beta Was this translation helpful? Give feedback.
-
Somewhat related discussion: https://lists.chalmers.se/pipermail/agda/2020/011747.html |
Beta Was this translation helpful? Give feedback.
-
Note: I am not at all suggesting that my tools be adopted here. Think of them as an exploration of the design space, food for thought. To expand on @adamse 's comment for those too lazy to read the thread: Jesper confirms that generating |
Beta Was this translation helpful? Give feedback.
-
Every approach is obnoxious, of course. I prefer the approach like because it makes defining structures that inherit from multiple other structures easier. Like, in my pet project, I defined a group as a loop and a monoid on the same set and operation, so isGroup just had the fields isLoop and isMonoid and that's it. The alternative, a GroupOn A having the fields LoopOn A and MonoidOn A with the operations and units being equal doesn't work for me because I don't want the operation to be propositionally equal. I want them to be judgementally equal. |
Beta Was this translation helpful? Give feedback.
-
I'm back, because of the call on twitter. I've more than dabbled around this - I've had 2 PhD students write their thesis around the topic: Yasmine Sharoda and Musa Al-hassy. Yasmine's tools are available in a separate repo. In both cases, I would recommend looking at their material for their defense as a good entry point. It's fun to look at Musa's early prototype written in e-lisp. It generates quite a lot of Agda (as does Yasmine's). In Yasmine's notation, here is what the hierarchy up to
when unwound, that single line for Again, I'm not saying that this is the way to do it. But it is one part of what is known about the design space. |
Beta Was this translation helpful? Give feedback.
-
A few key points I've thought about:
|
Beta Was this translation helpful? Give feedback.
-
Yeah, that's an accurate description of the situation. I did some research into what prevents the generation of records: it seems that the scope-checker needs to know what names exists before macro expansion, which means that any sort of WRT to iterated sigmas, I'm always a bit leery of them. Once you add large numbers of fields, the compile time performance can really suffer. Furthermore, we would run into the exact same problems with the scope-checker + macros. That's not to say it wouldn't work, just that we ought to seriously consider the ratio of what we are giving up vs. what we are getting. @plt-amy suggested a great idea: Adding something akin to For now, I think the best option may to go with iterated sigma types as our "core" abstraction, and provide records as a nice interface for working with various representations. From a purely selfish perspective, I'd like to experiment with some ideas regarding reflection, and using the iterated sigmas is table stakes for doing so. References
|
Beta Was this translation helpful? Give feedback.
-
Here's the design I came up with: https://github.com/plt-amy/cubical-1lab/blob/404d451798e230b7fbce9acc2fbd0c84157b7fd4/src/Algebra/Monoid.lagda.md (rendered: https://cubical.1lab.dev/Algebra.Monoid.html#2847) |
Beta Was this translation helpful? Give feedback.
-
Since some kind of record hierarchy is definitely required for, say, algebra, category theory, topology, and pretty much any other sort of mathematics, the implementation details need some consideration.
Usually, there are at least two separate kinds of records related to a single kind of structure:
One that parameterizes over all the data involved in the structure, e.g.
which is needed to state that a specific operation does conform to laws required for a structure, as well as another one that parameterizes only over the involved type:
which is mainly required to avoid clutter in type signatures and allow for more general theorems.
One probably needs both of these types, but which approach should be used primarily?
It does get even more complicated when considering "inheritance"/nested records: given the semigroup definitions above, how exactly would one extend these to monoids? Would
MonoidOn A
haveSemigroupOn A
as a field, or would it include the_*_
operator as a field as well as a proof ofisMonoid A _*_
?The questions do not stop there - for example, given that it is unique, should the unit of a monoid be included in the type signature of
isMonoid
? That's why this issue is meant as a place to collect ideas on how to find solutions to all of these topics.Beta Was this translation helpful? Give feedback.
All reactions