-
Notifications
You must be signed in to change notification settings - Fork 260
[ draft ] Alternative design for sub- and quotient- (Abelian)Groups
#2859
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
base: master
Are you sure you want to change the base?
Conversation
| { isMonoid = record | ||
| { isSemigroup = record | ||
| { isMagma = record | ||
| { isEquivalence = record |
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 know this is just an experiment, but I'd certainly with that this IsEquivalence record was pulled out.
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.
One thing that impressed me about @Taneb 's code was the extent to which, in various places, it manages to produces huge nested record blocks which nevertheless 'do the right thing'.
I've flip-flopped over the years between this style, and a much more incremental, define every sub-record at top-level, put the pieces together step-by-step style, which the library has to date favoured.
One reason (perhaps two or more!) I am now turning towards the 'one big record' style arises from #2391 :
- a single large object, suitably re-opened as
public, (re-)introduces all the 'correct' substructure, moreover with the 'rectified'/'official' names, rather than trying to invent proxy names for the top-level substructure in the other style - when any client imports the new constructions, they aren't faced with a (DRY) choice between cherry-picking the ad-hoc names (which may be the 'correct' ones), or facing a clash/choicepoint between such names and those names introduced by
openof substructures
In this instance (as perhaps elsewhere...) the definition of distinct isEquivalence : IsEquivalence ... fields at top-level is starting to emerge as an anti-pattern for me: once an Algebra.Structures.IsX object is in scope, or has been defined, then isEquivalence is available as a canonical projection from that, and indeed that should be the preferred mode-of-access (via open if necessary) for a substructure which exists solely
- to export canonical names
refl,sym,transfor the properties, and their derived forms - to construct
Setoids from whichRelation.Binary.Reasoning.Setoidsyntax may then be brought into scope - ...
... much of which functionality/behaviour can be achieved at a higher-level of the nesting hierarchy by suitable re-organisation of the Algebra.Properties.X hierarchy #2804 #2858 etc.
| record IsNormal {c′ ℓ′} (subgroup : Subgroup c′ ℓ′) : Set (c ⊔ ℓ ⊔ c′) where | ||
| open Subgroup subgroup using (ι) | ||
| field | ||
| conjugate : ∀ n g → _ |
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.
That _ is perverse. Sure, it can be reconstructed -- so what? Record declarations serve as documentation too!
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.
Thanks for "perverse"... ;-)
I surely agree that
recorddeclarations should be self-documenting
but, here, I think that- an-line comment would here do as much work in explaining why a name isn't necessary...
- ... rather than, as now, having to introduce a private manifest field defining a
module(or else expose a new name for a subfield of thesubgroupobject), solely for the sake of projecting out the name of itsCarrier.
So... at rock-bottom, I chose this design as a optimisation for space (as well as that of my cognitive load, but it seems YMMV) and like all such, doing this prematurely might be harmful.
But as with the comment above about isEquivalence, I am starting to find that when we create/open substructures of this sort, it is usually in a context in which the 'missing'/'hidden' name of the type is already in scope with another pre-existing name which is more salient in that deployment context.
So the private module name, and or that of its sub-fields, is being created solely for the purpose of documentation.
Accordingly, in this setting, I made a design choice to avoid committing to creating such an 'ephemeral' name. But an inline comment should, I think, solve this problem?
I'd still be OK if you disagreed with my above thought process (which should, in any case, be documented towards any eventual codification of a library-design philosophy ;-)), and I guess part of the point of offering an 'alternative' design for these fundamantal structures was to create an opportunity for debate around such questions.
| open AbelianGroup abelianGroup public | ||
|
|
||
| isNormal : IsNormal subgroup | ||
| isNormal = record { normal = λ n → G.comm (ι n) } |
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.
eta contract?
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.
Yes! In that, it is itself an eta-contraction of the original
isNormal = record { normal = λ n g → G.comm (ι n) g }Is it harmful to have done this?
Or are you asking whether the definition could be contracted further? Perhaps, but only via one of those odd Function.Base composition operators which compose only in one argument position of an n+2-ary function, which I find obscure rather than illuminate (my point-free fu is not always as strong as it might be).
|
I'm sure this alternative design makes a lot of sense to you @jamesmckinna and to @Taneb , but since I don't have the original in mind, your description relative to it does not really inform me in any substantial way of the pros and cons of each. i.e. could the PR description be made less relative to knowing the original, but rather have more information about both designs in the description please? |
|
I think that the best answer to the above comment might be to give a more detailed commentary in the source? (See ongoing/recent commits) I think that this is probably more portable/surveyable than a complex interweaving of the GitHub comment trail? This still seems to be a major bugbear in using git to debate alternatives, and to document discussion around such things, as we have observed in the past, elsewhere in this project. |
| -- which is already inherited (by definitional equality!) from the type of | ||
| -- the `⟦_⟧` parameter to `IsXHomomorphism`... | ||
|
|
||
| ι : _ → G.Carrier -- where _ = RawGroup.Carrier domain |
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.
A last thought on this (or two, depending on how you count; maybe it's 3/2 of a thought): either of the following would also typecheck:
| ι : _ → G.Carrier -- where _ = RawGroup.Carrier domain | |
| ι : _ → _ |
or
| ι : _ → G.Carrier -- where _ = RawGroup.Carrier domain | |
| ι : _ -- where _ = RawGroup.Carrier domain → G.Carrier |
Alternative to #2852 and #2854 , based on @Taneb's original design, but:
Normalis now belowAlgebra.Construct.Sub.GroupAlgebra.Construct.Sub.AbelianGroups added, and are automaticallyNormalHence:
Algebra.Module.Construct.Sub.Bimodules are automatically suitable asIdealsAlgebra.Construct.Sub.RingAlgebra.Construct.Quotient.RingThe high-level differences between the two approaches mostly consist in:
publicly re-export properties/structure? #2391 , in terms of making large single definitions of nestedrecords, andopening them to expose substructureAlgebrahierarchy, and their mutual dependency (aiming to flatten/linearise the latter, and making the former follow a more conventional inheritance based directory/sub-directory tree structureRing) which are based on an underlying (additive) Abelian group structure, which slightly alters the conceptual, as well as concrete dependency graph compared to Taneb's Add subgroups and submodules #2852 Normal subgroups and quotient groups #2854 and Add ideals and quotient rings #2855