Skip to content
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

[Merged by Bors] - refactor(library): decouple algebraic hierarchy from core lib #229

Closed
wants to merge 97 commits into from

Conversation

jcommelin
Copy link
Member

@jcommelin jcommelin commented May 11, 2020

This PR allows moving ordered_monoid, semiring, and all the other algebraic classes into mathlib.
Classes that are only about orders, such as decidable_linear_order remain in core.

@jcommelin jcommelin added WIP Work in progress rfc labels May 11, 2020
@gebner
Copy link
Member

gebner commented May 11, 2020

Can you merge master? The diff is full with changes from your norm_num PR.

@gebner gebner added the enhancement New feature or request label May 11, 2020
@gebner
Copy link
Member

gebner commented May 11, 2020

Also: PR title!

@jcommelin jcommelin changed the title Strip algebra -- decouple algebraic hierarchy from core lib refactor(library): decouple algebraic hierarchy from core lib May 11, 2020
@urkud
Copy link
Member

urkud commented May 11, 2020

What's the point of commenting out the code instead of deleting it?

@jcommelin
Copy link
Member Author

Because it's still somewhat WIPpy. I didn't know if it had to be resurrected or not.

@jcommelin
Copy link
Member Author

I've now also removed a whole bunch of commented code.

@jcommelin
Copy link
Member Author

There's a whole bunch of tests failing. What do we want to do with them? I've removed one that I think clearly could be removed, but I'm not sure what to do with most of them.

@gebner
Copy link
Member

gebner commented May 12, 2020

There's a whole bunch of tests failing. What do we want to do with them? I've removed one that I think clearly could be removed, but I'm not sure what to do with most of them.

I've quickly looked over the failing tests:

  1. Some tests fail because you've removed lemmas that the C++ code relies on (and that are listed in constants.txt). Check the errors in the check_constants.lean and put the lemmas back.
  2. (by cc : a + b = b + a) requires instances for is_associative (+) and is_commutative (+). Add them back (locally?). Same goes for ac_refl.
  3. Often add_comm can be replaced by nat.add_comm.
  4. Try to keep the spirit of the test.
  5. Many tests are named after the issue number, check the old Lean bug tracker to figure out what the test is supposed to be testing. That is, for 1898.lean go to segfault with broken code (accessing H.0 if H : comm_ring R) leanprover/lean3#1898

@gebner gebner removed the WIP Work in progress label May 14, 2020
Copy link
Member

@gebner gebner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests look good. The commented-out stuff should be removed.

As I've said, I'm not sure we should remove nat.gcd and int.gcd.

library/init/algebra/functions.lean Outdated Show resolved Hide resolved
library/init/algebra/functions.lean Outdated Show resolved Hide resolved
library/init/algebra/functions.lean Outdated Show resolved Hide resolved
library/init/data/int/basic.lean Outdated Show resolved Hide resolved
library/init/data/int/basic.lean Outdated Show resolved Hide resolved
library/init/data/int/order.lean Outdated Show resolved Hide resolved
library/init/data/int/order.lean Outdated Show resolved Hide resolved
library/init/data/nat/bitwise.lean Outdated Show resolved Hide resolved
@@ -9,7 +9,7 @@ prelude
import init.data.nat.lemmas init.meta.well_founded_tactics

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if you should remove the gcd. nat.gcd and int.gcd have an efficient VM implementations using GMP.

One option is to keep the gcd implementation as meta constants, and then use vm_override in mathlib to hook up to fast implementation:

meta constant nat.gcd_gmp : ℕ → ℕ → ℕ

-- in mathlib:
@[vm_override nat.gcd_gmp]
def nat.gcd : ℕ → ℕ → ℕ := ...

Copy link
Member Author

@jcommelin jcommelin May 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@digama0 I thought you said it could go. I'll let you two decide, and then fix accordingly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'm putting the defs back

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't know that these were vm overridden. If so, then they should stay. But AFAIR they don't require much automation, although the def has to be stated a bit differently for the decreasing proof to work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@digama0 I don't follow. Is there something that should be changed? The CI seems happy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the latest version of this is, but you've probably fixed it. You asked about it earlier and I said to shift the | (succ x) y := ... cases to | (succ x) := \lam y, ... so that lean gets the recursion domain right.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@digama0 Aah, that was on a different branch. I decided not to pursue that here.
Anyways, that settles this discussion, I think.

Copy link
Member

@digama0 digama0 May 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to removing default_dec_tac? Isn't that needed for the decoupling project?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it turns out that it isn't needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might still be a good idea. But it can be a different PR.

library/init/data/nat/lemmas.lean Outdated Show resolved Hide resolved
@gebner
Copy link
Member

gebner commented May 15, 2020

LGTM.

bors merge

bors bot pushed a commit that referenced this pull request May 15, 2020
This PR allows moving `ordered_monoid`, `semiring`, and all the other algebraic classes into mathlib.
Classes that are only about orders, such as `decidable_linear_order` remain in core.

Co-authored-by: Gabriel Ebner <gebner@gebner.org>
@bors
Copy link

bors bot commented May 15, 2020

Build failed:

@bryangingechen
Copy link
Collaborator

A test from #237 needs to be updated: https://github.com/leanprover-community/lean/runs/678900032#step:8:1241

@gebner
Copy link
Member

gebner commented May 15, 2020

bors d+

@bors
Copy link

bors bot commented May 15, 2020

✌️ jcommelin can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@jcommelin
Copy link
Member Author

bors merge

pleeeease.....

bors bot pushed a commit that referenced this pull request May 15, 2020
This PR allows moving `ordered_monoid`, `semiring`, and all the other algebraic classes into mathlib.
Classes that are only about orders, such as `decidable_linear_order` remain in core.

Co-authored-by: Gabriel Ebner <gebner@gebner.org>
@bors
Copy link

bors bot commented May 15, 2020

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title refactor(library): decouple algebraic hierarchy from core lib [Merged by Bors] - refactor(library): decouple algebraic hierarchy from core lib May 15, 2020
@bors bors bot closed this May 15, 2020
@bors bors bot deleted the strip-algebra branch May 15, 2020 18:28
bors bot pushed a commit that referenced this pull request May 16, 2020
Features:
 - use persistent data structures, to improve performance
   of (module) docstrings (#241)
 - cache constructed `simp_lemma` objects (#234)
 - support `local attribute [-instance]` (#240)
 - show goal after `;` (#239)
 - `==`: compare id (#238)
 - mark deps of fixed as fixed (#237)

Changes:
 - Most of `library/init/algebra/*` has been deleted,
   as part of moving the algebraic hierarchy to mathlib (#229)
bors bot pushed a commit that referenced this pull request May 17, 2020
…at and int lemmas (#245)

This PR protects the lemmas listed in leanprover-community/mathlib@85ce04a since they are superseded in mathlib. They were all added in #229. 

Also, this PR removes:
- `int.mul_sub_left_distrib` in favor of the shorter `int.mul_sub`,
- `int.mul_sub_right_distrib` in favor of the shorter `int.sub_mul`.

Zulip: https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/preparing.20for.20lean-3.2E13.2E0/near/197817609
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rfc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants