-
Notifications
You must be signed in to change notification settings - Fork 247
Lighten dependencies of Data.Nat.Induction
#1698
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
Conversation
There's an potential alternative proof using Part of the issue seems to be how much ... and the fact that |
And indeed... the lemma above doesn't really belong, as now, in
but rather in
in that vast collection... |
So the thing that surprised me is that in As you have observed many times before, there are no right answers here, so my comment/question is really about trying to understanding why certain design decisions have been made in stdlib, and specifically here, why the preorder relation/structure is considered conceptually prior to the strict order, when the builtin version appears to make the 'opposite' choice... |
If I had to guess: accident of history. Various pieces of code evolving independently, and only later clashing by using opposite conventions. As you say, there's no right/wrong here, just lack of harmony. |
Indeed, I can imagine. The curiosity, such as it is, about the, viz. Matthew's, issue/PR, is that judicious choices, congruent with certain others in the stdlib, would/could remove the dependence on Data.Nat.Properties entirely... but that alone is not, perhaps, a hill large enough on which to take a stand... |
I've been on a bit of a simplify-the-dependency graph kick (actively so some months ago, on pause right now mostly for lack of time.) Weird dependencies, in my opinion, will have a real effect down the road when growth becomes increasingly difficult because of cycles. Axiom went down the route to allow cycles... and ended up with cycles with over 150 modules needing to be type-checked "as one" ! |
Hmmm. Maybe I spoke too soon. The lemma one actually requires for If interested, I made a branch, |
Thanks for the investigations! Yes I agree, the way that the orders are defined in
That's a curious lemma. I've currently broken my installation of Agda, but will have a look at your branch once I've got it running again. |
So... the 'curious' lemma indeed has the identical proof structure to |
So... there's a discussion perhaps to take offline, until I can get my ideas straight in advance of raising an issue/PR (but see below). Some points, more or less in dependency order:
Such smart constructors could usefully be put in
So there are (at least) two possible directions to take this towards one (or more) PRs:
Matthew's concerns about dependency on the existing 'fat' module which prompted this PR suggests that, sooner or later, it is this size issue which needs dealing with, rather than isolating the actual dependencies on which EDITED (*) there would be knock-on viscosity to this proposal, concerning |
@MatthewDaggitt if I take your hint from earlier... is it the case that certain functions in |
Hmm so we have the original issue discussing why And the original PR that implemented it, along the discussion of irrelevance here: 1690f69#r34691463 In my memory there were much stronger reasons for implementing it, but it looks like I've been getting confused with So in answer I think we should open a PR with your minimalist approach to change the definitions of As I've mentioned the middle-way would result in an (unacceptable?) hit to searchability of the library, and I'm still hoping that with a smart design, we can avoid the maximalist approach as it feels... unprincipled somehow, as I'm unsure how it would generalise, e.g. what would go in
To be honest I'm not aware of anyone has ever really thought about it in those terms before, so no it's not formalised anywhere.
Unfortunately I can't find any link to my talk. It certainly didn't go into this amount of depth however... |
I am not currently using the agda-stdlib, so it is up to you. In general though, I believe that I have spent too much effort to make agda happy, by understanding its quirks. Instead we should spend time on the mathematical problem at hand. For example, take + of naturals, from @jespercockx 's taming of the rew . I have spent so much time optimizing this. So maybe the solution is extensive use of rewrite rules everywhere. edit : The other solution being cubical type theory. |
Thanks @xekoukou for the comment, and with sympathy over the trials and tribulations (and development costs) of library development vs. application of such a library to "mathematical problem"s. My current version doesn't fundamentally change what was already there; rather, it simplifies one anomalous dependency in favour of a (more) deliberate use of the choices of constructors/admissible pattern-matches already present. The cost seems to be that some definitions/proofs (in The new versions, such as they are, also pave the way (I hope) to support removing (some of) the dependency of properties of |
To compare equals for equals we would need to move the comparison relations The numeric types are a bit special in that we include way more in |
My feeling is that the module sub-hierarchy has gone a little crazy. Minimalist me would certainly be happy with a meta-rule along the lines: non-fat modules can't have more than 20 definitions in them (type, data types, properties, what have you; basically 20 exported names). Fat modules should then go crazy in the opposite direction. But as to @xekoukou tribulations: in theory, we know what to do. Define Nat whichever way you want, prove the basic properties that make it a rig / ordered rig / lattice / etc, then prove everything else on top of that. Don't allow "proofs by induction" on Nat for properties that are provable from that core. That 'core' becomes the interface to Nat. In theory, we could then change Nat's definition without altering anything else. In practice, I seriously doubt we're ready for that. I do think it is something worth aiming for. |
Re @JacquesCarette 's last comment (with which I broadly agree, modulo... history, stdlib as it now is): why is there no distinction made in the library between |
Just doing a last |
Merging this in as it still zaps a few unused dependencies. |
Removed a bunch of unused imports. Would really really like to get rid of the last remaining dependency on
Data.Nat.Properties
...