Zulip Chat Archive
Stream: new members
Topic: Substitute away let binding in tactic mode
Donald Sebastian Leung (Feb 28 2020 at 15:09):
Suppose I have a context of the following form (not sure how to type the turnstile in Lean):
x := <some_term> |- <some_goal_involving_x>
How do I substitute the value of x into the goal (or hypotheses mentioning x)? rw x does not seem to work.
Kevin Buzzard (Feb 28 2020 at 16:08):
If you defined x using let then you might be able to write change [what you want the goal to be]. If you have defined it using set x := blah using hx then you can probably just rw hx.
Donald Sebastian Leung (Feb 28 2020 at 16:09):
So would set x := <some_term> be a better option here?
Kevin Buzzard (Feb 28 2020 at 16:09):
PS turnstile is \|-. If you copy and paste a turnstile into a Lean file and then hover over it then there's a high chance that it will tell you the keyboard shortcut.
Kevin Buzzard (Feb 28 2020 at 16:09):
I always use set rather than let but then again I find let quite confusing and I always work in tactic mode.
Kevin Buzzard (Feb 28 2020 at 16:09):
The change tactic changes a goal to a defeq goal
Kevin Buzzard (Feb 28 2020 at 16:11):
example : true := begin let n := 3, have h : n = 4, change 3 = 4, -- works end
So n is definitionally equal to 3 and so the change tactic works.
Donald Sebastian Leung (Feb 28 2020 at 16:19):
Kevin Buzzard said:
If you defined
xusingletthen you might be able to writechange [what you want the goal to be]. If you have defined it usingset x := blah using hxthen you can probably justrw hx.
Thank you - set x := <some_term> with hx (and then rw hx later on) worked for me
Gabriel Ebner (Feb 28 2020 at 16:56):
Another way to rewrite a let definition x by its value is dsimp [x].
Last updated: May 02 2025 at 03:31 UTC