Zulip Chat Archive
Stream: Is there code for X?
Topic: abs with constant
Henrik Böving (Jun 30 2021 at 17:20):
I'm currently trying to solve a goal of the form:
c : ℝ,
f : ℝ → ℝ,
n : ℝ
⊢ abs (c * f n) ≤ c * abs (f n)
but neither the tactics i tried managed to automatically solve this, nor library_search were able to solve this for me although it seems quite trivially true to me?
Eric Wieser (Jun 30 2021 at 17:20):
It's false if c = -1
Eric Wieser (Jun 30 2021 at 17:21):
You need the hypothesis 0 ≤ c
. If you add that, then library_search
might be able to help you
Henrik Böving (Jun 30 2021 at 17:23):
Ohh right it would have to be positive c, still no luck with library search even with that hypothesis though :/
Yaël Dillies (Jun 30 2021 at 17:24):
abs_mul
will get you closer.
Eric Wieser (Jun 30 2021 at 17:25):
Heather Macbeth (Jun 30 2021 at 17:26):
The new lemma docs#abs_cases is designed precisely to automate this kind of thing.
import data.real.basic
variables (c : ℝ) (f : ℝ → ℝ) (n : ℝ)
example (h: 0 ≤ c) : abs (c * f n) ≤ c * abs (f n) :=
by cases abs_cases (c * f n); cases abs_cases (f n); nlinarith
Heather Macbeth (Jun 30 2021 at 17:27):
(new in #8124, so it won't work in the web editor yet)
Eric Wieser (Jun 30 2021 at 17:27):
(but it will work in gitpod!)
Henrik Böving (Jun 30 2021 at 17:28):
Very cool, thanks!
Heather Macbeth (Jun 30 2021 at 17:28):
(cc @Alex Kontorovich)
Last updated: Dec 20 2023 at 11:08 UTC