Skip to content

[Merged by Bors] - chore: remove no-longer-needed Nat.digits workarounds#10429

Closed
dwrensha wants to merge 1 commit intomasterfrom
digits-norm-num
Closed

[Merged by Bors] - chore: remove no-longer-needed Nat.digits workarounds#10429
dwrensha wants to merge 1 commit intomasterfrom
digits-norm-num

Conversation

@dwrensha
Copy link
Copy Markdown
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
Copy Markdown
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

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@ghost ghost 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants