Zulip Chat Archive

Stream: general

Topic: alternative to set


Kenny Lau (Feb 27 2019 at 22:07):

I noticed that the set tactic doesn't interact well with revert (because in its core it's still a let, and when you revert it you see a let _ := _ in in the goal)

and I've come up with an alternative:

example : true :=
begin
  have :  n, n = 2 + 2 := ⟨_, rfl, cases this with n hn,
/-
state:
n : ℕ,
hn : n = 2 + 2
⊢ true
-/
  trivial
end

Kenny Lau (Feb 27 2019 at 22:09):

example : true :=
begin
  have :  n, n = 2 + 2 := ⟨_, rfl, cases this with n hn,
/-
n : ℕ,
hn : n = 2 + 2
⊢ true
-/
  revert n,
/-
⊢ ∀ (n : ℕ), n = 2 + 2 → true
-/
  intros, trivial
end

example : true :=
begin
  set n := 2 + 2 with hn,
/-
n : ℕ := 2 + 2,
hn : n = 2 + 2
⊢ true
-/
  revert n,
/-
⊢ let n : ℕ := 2 + 2
  in n = 2 + 2 → true
-/
  intros, trivial
end

Scott Morrison (Feb 27 2019 at 22:17):

Can you do this with a sigma type when the goal isn't propositional?

Kenny Lau (Feb 27 2019 at 22:19):

I'd imagine not

Rob Lewis (Feb 27 2019 at 22:20):

Your example doesn't do the same thing. Using let means that the new variable is definitionally equal to the term you set it to, which is sometimes useful.


Last updated: Dec 20 2023 at 11:08 UTC