-
Notifications
You must be signed in to change notification settings - Fork 79
Syntax modules #1332
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
Comments
Related to #768. I remember discussing this with Egbert in September '23, where we identified two issues:
|
just so we are on the same page, we do not like the notation |
I wonder if the performance penalty of |
Regarding your second point, do I understand correctly that you see an issue with something like the following scenario? Consider the structure of a group, then we can define a group syntax It seems to me that, for the limited use case of modules for syntax, this is a very minor issue, and it is resolved by having the convention that every new syntax is added to a new syntax module with an appropriate name to describe what the syntax is for. |
To be clear, this means my previous suggestion for a syntax module name was bad. We shouldn't have a module called |
I agree that your first point is an issue, but I believe the benefits outweigh the drawbacks, and using the |
Just to elaborate a bit further with another example. For something like wild category theory, I think a syntax like this will be essential for raising the usability of the formalizations to a level where expressions aren't just drowned in I would envision a structure syntax module like the following, this example having identity morphisms, composition of 1-morphisms, composition of 2-morphisms, horizontal composition of 2-morphisms, and whiskering of 2-morphisms with 1-morphisms and vice versa. module
structure-syntax-Noncoherent-ω-Precategory
{l1 l2 : Level} (𝒞 : Noncoherent-ω-Precategory l1 l2)
where
id₁ :
{x : obj-Noncoherent-ω-Precategory 𝒞} →
hom-Noncoherent-ω-Precategory 𝒞 x x
id₁ = id-hom-Noncoherent-ω-Precategory 𝒞
_∘₁_ :
{x y z : obj-Noncoherent-ω-Precategory 𝒞} →
hom-Noncoherent-ω-Precategory 𝒞 y z →
hom-Noncoherent-ω-Precategory 𝒞 x y →
hom-Noncoherent-ω-Precategory 𝒞 x z
_∘₁_ = comp-hom-Noncoherent-ω-Precategory 𝒞
_∘₂_ :
{x y : obj-Noncoherent-ω-Precategory 𝒞}
{f g h : hom-Noncoherent-ω-Precategory 𝒞 x y} →
2-hom-Noncoherent-ω-Precategory 𝒞 g h →
2-hom-Noncoherent-ω-Precategory 𝒞 f g →
2-hom-Noncoherent-ω-Precategory 𝒞 f h
_∘₂_ =
comp-2-hom-Noncoherent-ω-Precategory 𝒞
_∙₂_ :
{x y z : obj-Noncoherent-ω-Precategory} →
{g g' : hom-Noncoherent-ω-Precategory y z}
{f f' : hom-Noncoherent-ω-Precategory x y} →
2-hom-Noncoherent-ω-Precategory g g' →
2-hom-Noncoherent-ω-Precategory f f' →
2-hom-Noncoherent-ω-Precategory
( comp-hom-Noncoherent-ω-Precategory g f)
( comp-hom-Noncoherent-ω-Precategory g' f')
_∙₂_ = horizontal-comp-2-hom-Noncoherent-ω-Precategory 𝒞
_₂·₁_ : ...
_₁·₂_ : ... |
Let me preface this by saying that I'm playing the devil's advocate. The two points I raised aren't necessarily my issues, I'm only arguing from the point of view of the current library's approach to code organization. The module vs namespace issue boils down to the question of how we split code into files. You propose a module defining syntax for over 5 definitions. Some of those are probably not just aliases for fields of the structure, but are derived notions (in this example whiskering would be horizontal composition of an n+1 cell and an identity on a composable n cell, right?). Then they should be defined in a separate file on whiskering. And that's where you encounter the problem: you either have a syntax module per file, and if you want to make sense of e.g. biwhiskering you would need to open three syntax modules (base, left whiskering, right whiskering), or you have a master syntax module which can't be used by any other file which participates in defining a symbol aliased by the syntax. Then there's the issue with algebraic hierarchies. When we currently define one structure as an instance of another with extra stuff (like a monoid being a unital semigroup), we write out all the deep accessors, not only because it makes the code using it easier to read, but because jumping to definition takes you to the file about monoids, not semigroups. If we bring syntax modules into the mix, we either a) reopen the syntax for working with the underlying structure, which means go to definition on operators goes too deep, b) don't reopen the underlying syntax and only define syntax for the new parts, which means use sites will want to open a hierarchy of syntax modules and go to definition still goes too deep, or c) don't reopen the underlying syntax, but manually copy over the definitions, which means that users will only have to open one module, and go to definition takes you to the right file, but we have to copy and paste code, which is yucky. |
Random thought today: Using instance arguments it seems possible, using a syntax module, to define dimension polymorphic composition operators on wild higher categories. I.e., it should be possible to have an operator |
Regarding the "we don't like module _
{l : Level} (L : Loop l)
(let Q = quasigroup-Loop L)
(let Q' = type-Quasigroup Q)
where which seem to be completely transparent for the outside world — all occurrences of |
Has this proposal been tested when more than one quasigroup/noncoherent category is around? We should avoid making some notational setup that just breaks on the first occasion you try to do something substantial (i.e., do something more than just making a basic definition that involves only one instance of the structure). |
If you want to use the notation for multiple objects of the same type, you can either
_ = {! Write a * b and x # y !}
where
open structure-syntax-Quasigroup Q
open structure-syntax-Quasigroup R renaming (_*_ to _#_) or
_ = {! Write a Q.* b and x R.* y !}
where
module Q = open structure-syntax-Quasigroup Q
module R = open structure-syntax-Quasigroup R |
It's not clear to me that we should want to use syntax modules when multiple choices of the same structure are present. Surely you're not implying that every scenario where only one instance of a structure is present must be basic? |
Perhaps you *object to that, that it will look weird to use syntax modules some of the time and some time not? |
I'm curious about opinions and input on this one @EgbertRijke @VojtechStep @lowasser. This is the kind of thing I had in mind when I mentioned syntax modules for wild categories the other day.
Originally posted by @fredrik-bakke in #1330 (comment)
EDIT: I would actually prefer the following syntax
The text was updated successfully, but these errors were encountered: