Zulip Chat Archive
Stream: maths
Topic: picking up lean4 with math
Iocta (Mar 25 2023 at 18:54):
linarith
used to do the trick for both of these in lean3, what do I need now in lean4?
import Mathlib.Tactic.Linarith
import Mathlib.Data.Real.Basic
example (a b : ℝ) (h : ∀(ε:ℝ), ε > 0 → a ≤ b + ε) : a ≤ b :=
by_contradiction (fun not_a_le_b => by
have foo: a ≤ b + ((a - b) / 2) := by
have: 0 < ((a - b) / 2) := by linarith
apply h ((a - b) / 2) this
linarith)
Heather Macbeth (Mar 25 2023 at 21:07):
@Iocta You need to wait until someone writes that functionality into linarith. See !4#2714.
Kevin Buzzard (Mar 25 2023 at 21:13):
Alternatively you can go back to how we were doing this in 2017 before linarith
existed, just applying lemmas like div_pos
manually.
Iocta (Mar 26 2023 at 02:25):
(deleted)
Notification Bot (Mar 26 2023 at 02:31):
Iocta has marked this topic as resolved.
Notification Bot (Mar 26 2023 at 06:28):
Iocta has marked this topic as unresolved.
Iocta (Mar 26 2023 at 06:29):
If I've defined a variable let e := a + b
then e
appears in a hypothesis, how can I replace e
in that hypothesis with a + b
? I tried subst e at this
but tactic 'subst' failed, variable '' is a let-declaration
Sophie Morel (Mar 26 2023 at 06:48):
set e :=a+b with he
and then you do a rw he at this
Sophie Morel (Mar 26 2023 at 06:49):
(Uh, in Lean 3 at least. I just noticed that you're using Lean4, sorry...)
Sophie Morel (Mar 26 2023 at 07:29):
Kevin Buzzard said:
Alternatively you can go back to how we were doing this in 2017 before
linarith
existed, just applying lemmas likediv_pos
manually.
I thought that was what we all still did... Oops... :oops:
Iocta (Mar 26 2023 at 08:40):
Why does this fail?
import Mathlib.Data.Real.Basic
example (a y : ℝ) (x:ℕ→ℝ) (h: abs (x n - y) < abs ε / abs a) : abs a * abs (x n - y) < abs ε := by
/-
tactic 'rewrite' failed, did not find instance of the pattern in the target expression
-/
rw [lt_div_iff_mul_lt]
Iocta (Mar 26 2023 at 08:41):
Also is it just me, I can't copy text from the vscode infoview. I press copy but it doesn't do anything.
Reid Barton (Mar 26 2023 at 08:42):
did you mean at h
? or <-
?
Iocta (Mar 26 2023 at 08:42):
yeah but it doesn't like that either
Reid Barton (Mar 26 2023 at 08:44):
What is the new error?
Reid Barton (Mar 26 2023 at 08:44):
And what is the new code?
Iocta (Mar 26 2023 at 08:44):
example (a y : ℝ) (x:ℕ→ℝ) (h: abs (x n - y) < abs ε / abs a) : abs a * abs (x n - y) < abs ε := by
/-
tactic 'rewrite' failed, did not find instance of the pattern in the target expression
-/
rw [lt_div_iff_mul_lt] at h
Reid Barton (Mar 26 2023 at 08:47):
Oh because the reals are not a group.
Reid Barton (Mar 26 2023 at 08:47):
(under multiplication)
Reid Barton (Mar 26 2023 at 08:49):
Reid Barton (Mar 26 2023 at 08:50):
or docs4#lt_div_iff' even
Reid Barton (Mar 26 2023 at 08:54):
It would be neat if rw
could detect that it "almost" found an occurrence to rewrite, but failed to synthesize some instance, and report that if it fails
Moritz Doll (Mar 26 2023 at 09:17):
Or we compile a list of all 'generic' algebra lemmas and have a tactic that tries every one (in both directions) and reports back those that do not fail
Reid Barton (Mar 26 2023 at 09:39):
Or both :smile:
Last updated: Dec 20 2023 at 11:08 UTC