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

feat: add simp_digits tactic #10428

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

feat: add simp_digits tactic #10428

wants to merge 2 commits into from

Conversation

dwrensha
Copy link
Member

@dwrensha dwrensha commented Feb 11, 2024

With the introduction of the simprocs reduceLE, reduceMod, reduceDiv etc. in Lean v4.6.0, now simp
can fully normalize typical Nat.digits calls that have concrete arguments. The situation is still a bit delicate
however, as we want to avoid invoking kernel reduction on Nat.digits, because the Acc-based ("well founded")
recursion in digitsAux can get bogged down.

This PR introduces a new tactic simp_digits tactic that contains only the simp lemmas and simprocs needed
to reduce Nat.digits. This allows proofs involving Nat.digits to be cleanly factored into two steps:

  1. reduce Nat.digits via simp_digits,
  2. do things that require kernel reduction such as simp_arith, decide, or rfl.

Open in Gitpod

end NormDigits
macro "simp_digits" : tactic =>
`(tactic| simp only [digits_of_two_le_of_pos, reduceLE, reduceMod, reduceDiv,
zero_lt_succ, digits_zero, reduceMul, reduceAdd])
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 would be nicer to make this a proper simp set via register_simp_attr, but as far as I can tell simprocs (like reduceLE, reduceMod...) cannot be added to simp sets (they seem to just get silently ignored).

@dwrensha
Copy link
Member Author

Maybe norm_num by itself is good enough: #10429

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-conflict The PR has a merge conflict with master, and needs manual merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants