Zulip Chat Archive
Stream: lean4
Topic: tactic to re-replace let-bound terms
Jakob von Raumer (May 07 2024 at 13:45):
Is there a tactic somewhere which reapplies all let-bindings to the goal and to other hypothesis, i.e. if I have foo : T := bar 1 2 3
in the context, replacing each occurrence of bar 1 2 3
by foo
?
Markus Himmel (May 07 2024 at 13:53):
It's not exactly what you're asking for, but the set
tactic does the let
binding and the replacement in one step:
import Mathlib
theorem bla {x : ℕ} (hx : 5 = x) : 5 = 5 := by
set y := 5
/-
x: ℕ
y: ℕ := 5
hx: y = x
⊢ y = y
-/
Jakob von Raumer (May 07 2024 at 13:54):
Yea, I know set
, but my let bindings get intro
ed because they appear in the goal and then later on I want to apply them in other hypotheses
Jakob von Raumer (May 07 2024 at 14:13):
How do I re-fold let bindings at all? Unfolding works with rw
but, contrary to definitions, I cant use ←
on them inside rw
or simp
...
Markus Himmel (May 07 2024 at 14:15):
The set
tactic just does rw [(show bar 1 2 3 = foo from rfl)] at *
Yaël Dillies (May 07 2024 at 14:15):
You use change
:grimacing:
Jakob von Raumer (May 07 2024 at 14:15):
Yaël Dillies said:
You use
change
:grimacing:
Mhhh, big goal :sweat_smile:
Yaël Dillies (May 07 2024 at 14:16):
Keep your goals big and your dreams even bigger :punch:
Jakob von Raumer (May 07 2024 at 14:18):
Guess I should just write my own tactic for that stuff, then tidy_let
or so...
Ruben Van de Velde (May 07 2024 at 14:21):
You can do have hx : x = ... := rfl
and rewrite with that
Jakob von Raumer (May 07 2024 at 14:23):
True, but that means for each of my let-bindings doing
have hx : x = ... := rfl
subst hx
clear hx
which is quite a bit unwieldy... but maybe that's exactly how I should implement said automated tactic
Yaël Dillies (May 07 2024 at 14:24):
Wait why subst hx
? That undoes the binding
Markus Himmel (May 07 2024 at 14:24):
How would that work? Doesn't subst
do the exact opposite of what you want?
Jakob von Raumer (May 07 2024 at 14:25):
Ah I meant simp only [← hx] at *
Jakob von Raumer (May 07 2024 at 14:29):
*
isn't right either because it includes hx
itself, it's supposed to rewrite everwhere except for hx
...
example (h : x = 6 - 1) : let y := 6; x = y - 1 := by
intro y
have hy : y = 6 := rfl
rw [← hy] at h
clear hy
assumption
Yaël Dillies (May 07 2024 at 14:29):
In Lean 3, rw [h] at h
was a no-op
Markus Himmel (May 07 2024 at 14:30):
I don't see what introducing the hypothesis gains you over the direct way
example (h : x = 6 - 1) : let y := 6; x = y - 1 := by
intro y
rw [show 6 = y from rfl] at *
assumption
Ruben Van de Velde (May 07 2024 at 14:32):
You might want to use the hypothesis more than once or in a more targeted way
Jakob von Raumer (May 07 2024 at 14:32):
@Markus Himmel Nothing, I guess, you're right
Jakob von Raumer (May 07 2024 at 14:33):
I guess I will really write a tactic... The body of the let bindings contain lots of :cross:'ed variables, so stating their body explicitly is also not good
Kyle Miller (May 07 2024 at 22:34):
@Jakob von Raumer I just created #12745 for refold_let
Jakob von Raumer (May 08 2024 at 11:38):
Will test it tomorrow!
Last updated: May 02 2025 at 03:31 UTC