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] - chore: remove no-longer-needed Nat.digits workarounds #10429

Closed
wants to merge 1 commit into from

Conversation

dwrensha
Copy link
Member

@dwrensha dwrensha commented Feb 11, 2024

norm_num now successfully reduces Nat.digits calls that have concrete arguments, so we can clean up some old workarounds.

This all works because Lean 4.6.0 introduced "simprocs", including the default-enabled reduceLE, reduceMod, reduceDiv, etc. which norm_num can invoke to discharge the side-goals required by applications of digits_of_two_le_of_pos.

Another crucial aspect is that { decide := false } is the default for simp (and norm_num) after #8366. Otherwise,
the Acc-based recursion in digitsAux would bog down kernel reduction.


Open in Gitpod

-- manually rewrite with `Nat.digits_of_two_le_of_pos` first.
rw [Nat.digits_of_two_le_of_pos (by norm_num) (by norm_num)]
norm_num <;> decide)
(by norm_num <;> decide)
Copy link
Member Author

Choose a reason for hiding this comment

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

on master:

[Elab.command] [3.090407s] theorem right_direction

after this change:

[Elab.command] [2.878866s] theorem right_direction

exact searchUpTo_end this
#align imo1960_q1.right_direction Imo1960Q1.right_direction

/-
Now we just need to prove the equivalence, for the precise problem statement.
-/
theorem left_direction (n : ℕ) (spn : SolutionPredicate n) : ProblemPredicate n := by
-- Porting note: This is very slow
rcases spn with (rfl | rfl) <;> refine' ⟨_, by decide, _⟩ <;> rfl
rcases spn with (rfl | rfl) <;> refine' ⟨_, by decide, _⟩ <;> norm_num <;> rfl
Copy link
Member Author

Choose a reason for hiding this comment

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

on master:

[Elab.command] [13.806512s] theorem left_direction

after this change:

[Elab.command] [0.087602s] theorem left_direction

rw [Nat.digits_of_two_le_of_pos two_le_ten (by norm_num)]
rw [Nat.digits_of_two_le_of_pos two_le_ten (by norm_num)]
norm_num
norm_num [ProblemPredicate]
Copy link
Member Author

Choose a reason for hiding this comment

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

on master:

[Elab.command] [0.058644s] theorem satisfied_by_153846

after this change:

[Elab.command] [0.059744s] theorem satisfied_by_153846

(within measurement noise of each other)

Copy link
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

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

Great work!

bors merge

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review labels Feb 13, 2024
mathlib-bors bot pushed a commit that referenced this pull request Feb 13, 2024
`norm_num` now successfully reduces `Nat.digits` calls that have concrete arguments, so we can clean up some old workarounds.

This all works because Lean 4.6.0 introduced "simprocs", including the default-enabled `reduceLE`, `reduceMod`, `reduceDiv`, etc. which `norm_num` can invoke to discharge the side-goals required by applications of `digits_of_two_le_of_pos`.

Another crucial aspect is that `{ decide := false }` is the default for `simp` (and `norm_num`) after #8366.  Otherwise,
the `Acc`-based recursion in `digitsAux` would bog down kernel reduction.
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Feb 13, 2024

This PR was included in a batch that was canceled, it will be automatically retried

mathlib-bors bot pushed a commit that referenced this pull request Feb 13, 2024
`norm_num` now successfully reduces `Nat.digits` calls that have concrete arguments, so we can clean up some old workarounds.

This all works because Lean 4.6.0 introduced "simprocs", including the default-enabled `reduceLE`, `reduceMod`, `reduceDiv`, etc. which `norm_num` can invoke to discharge the side-goals required by applications of `digits_of_two_le_of_pos`.

Another crucial aspect is that `{ decide := false }` is the default for `simp` (and `norm_num`) after #8366.  Otherwise,
the `Acc`-based recursion in `digitsAux` would bog down kernel reduction.
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Feb 13, 2024

Build failed (retrying...):

mathlib-bors bot pushed a commit that referenced this pull request Feb 13, 2024
`norm_num` now successfully reduces `Nat.digits` calls that have concrete arguments, so we can clean up some old workarounds.

This all works because Lean 4.6.0 introduced "simprocs", including the default-enabled `reduceLE`, `reduceMod`, `reduceDiv`, etc. which `norm_num` can invoke to discharge the side-goals required by applications of `digits_of_two_le_of_pos`.

Another crucial aspect is that `{ decide := false }` is the default for `simp` (and `norm_num`) after #8366.  Otherwise,
the `Acc`-based recursion in `digitsAux` would bog down kernel reduction.
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Feb 13, 2024

Build failed (retrying...):

mathlib-bors bot pushed a commit that referenced this pull request Feb 13, 2024
`norm_num` now successfully reduces `Nat.digits` calls that have concrete arguments, so we can clean up some old workarounds.

This all works because Lean 4.6.0 introduced "simprocs", including the default-enabled `reduceLE`, `reduceMod`, `reduceDiv`, etc. which `norm_num` can invoke to discharge the side-goals required by applications of `digits_of_two_le_of_pos`.

Another crucial aspect is that `{ decide := false }` is the default for `simp` (and `norm_num`) after #8366.  Otherwise,
the `Acc`-based recursion in `digitsAux` would bog down kernel reduction.
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Feb 13, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title chore: remove no-longer-needed Nat.digits workarounds [Merged by Bors] - chore: remove no-longer-needed Nat.digits workarounds Feb 13, 2024
@mathlib-bors mathlib-bors bot closed this Feb 13, 2024
@mathlib-bors mathlib-bors bot deleted the digits-norm-num branch February 13, 2024 21:12
riccardobrasca pushed a commit that referenced this pull request Feb 18, 2024
`norm_num` now successfully reduces `Nat.digits` calls that have concrete arguments, so we can clean up some old workarounds.

This all works because Lean 4.6.0 introduced "simprocs", including the default-enabled `reduceLE`, `reduceMod`, `reduceDiv`, etc. which `norm_num` can invoke to discharge the side-goals required by applications of `digits_of_two_le_of_pos`.

Another crucial aspect is that `{ decide := false }` is the default for `simp` (and `norm_num`) after #8366.  Otherwise,
the `Acc`-based recursion in `digitsAux` would bog down kernel reduction.
dagurtomas pushed a commit that referenced this pull request Mar 22, 2024
`norm_num` now successfully reduces `Nat.digits` calls that have concrete arguments, so we can clean up some old workarounds.

This all works because Lean 4.6.0 introduced "simprocs", including the default-enabled `reduceLE`, `reduceMod`, `reduceDiv`, etc. which `norm_num` can invoke to discharge the side-goals required by applications of `digits_of_two_le_of_pos`.

Another crucial aspect is that `{ decide := false }` is the default for `simp` (and `norm_num`) after #8366.  Otherwise,
the `Acc`-based recursion in `digitsAux` would bog down kernel reduction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has been sent to bors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants