Zulip Chat Archive
Stream: new members
Topic: norm_num and abs
Rado Kirov (Sep 01 2025 at 05:20):
I have been using norm_num tactic to deal with all equalities and inequalities that have no variables, but was surprised that it failed to prove the following
example : |(1:ℚ) / 5| < 1 / 3 := by norm_num
while it has no problem showing
example : |(1:ℚ) / 5| = 1 / 5 := by norm_num
and
example : (1:ℚ) / 5 < 1 / 3 := by norm_num
Jakub Nowak (Sep 01 2025 at 05:23):
You can post code, instead of the link to live.lean-lang.org
import Mathlib
lemma l1: |(1:ℚ) / 5| = 1 / 5 := by norm_num
-- doesn't work
lemma l2: |(1:ℚ) / 5| < 1 / 3 := by norm_num
-- works
lemma l3: |(1:ℚ) / 5| < 1 / 3 := by
rw [l1]
norm_num
lemma l4: (1:ℚ) / 5 < 1 / 3 := by norm_num
There's a button in the upper-right corner of the code box, that opens live.lean-lang.org with that code. This is also preferred than posting a link, as this allows to view the code directly in your message without having to open the link.
Rado Kirov (Sep 01 2025 at 05:25):
Oh neat, I haven't noticed that button. In any case the repro is minimal, basically already in the post.
Jakub Nowak (Sep 01 2025 at 05:38):
I think there aren't extension to norm_num for abs (at least not for ℚ).
norm_num uses some parts of simp too, that's why it was able to solve l1. Notice that l3 and l4 can be solved by norm_num1, but cannot be solved by simp.
On the other hand l1 can be solved by simp, but cannot be solved by norm_num1.
Ruben Van de Velde (Sep 01 2025 at 05:53):
I'd say this is in scope for norm_num, but probably nobody's gotten around to writing the code for it
Rado Kirov (Sep 01 2025 at 06:30):
Should I file a GitHub issue somewhere? Also if someone points me in the right direction I can attempt to make a PR
Ruben Van de Velde (Sep 01 2025 at 06:56):
I've had a lot of help from @Robin Arnez when trying to extend norm_num
David Renshaw (Sep 01 2025 at 19:48):
I took a swing at it. Here's how far I got before getting frustrated with typeclasses and Qq: mathlib4#29223
David Renshaw (Sep 01 2025 at 19:49):
Please feel free to pick up where I left off.
Rado Kirov (Sep 01 2025 at 20:25):
Nice, thanks for sharing! Lots of new things to learn. I do have experience writing compilers and AST transformations for JS/TS but this feels a whole different world. Sounds like a fun challenge. Any documentation on writing tactics I should start with?
David Renshaw (Sep 02 2025 at 00:28):
I couldn't stop myself from finishing the remaining cases: mathlib4#29223
Last updated: Dec 20 2025 at 21:32 UTC