Zulip Chat Archive

Stream: general

Topic: rcases option unit


Johan Commelin (Mar 10 2022 at 11:33):

Which pattern should I use to completely destroy a term of type option unit?

import tactic

example (i : option unit) : true :=
begin
  rcases i with (_|i), -- how do I get rid of the `i` in the second goal?
  -- rcases i with (_|⟨)⟩, -- doesn't help, I still have an `i` in the second goal
  all_goals { trivial },
end

cc @Mario Carneiro

Jujian Zhang (Mar 10 2022 at 11:34):

How about this

example (i : option unit) : true :=
begin
/-
2 goals
⊢ true

⊢ true
-/

  rcases i with (_|_|_),
end

Eric Rodriguez (Mar 10 2022 at 11:40):

rcases i with _ | ⟨⟨⟩⟩

Eric Rodriguez (Mar 10 2022 at 11:40):

gotten from rcases? i

Eric Rodriguez (Mar 10 2022 at 11:40):

which is a very underrated extension to rcases

Kevin Buzzard (Mar 10 2022 at 13:04):

I use it a lot :-) It was really helpful for doing "reshuffling" proofs in my undergraduate course.

Eric Wieser (Mar 10 2022 at 15:15):

Use match instead?

Eric Rodriguez (Mar 10 2022 at 15:29):

how does match help here?

Eric Wieser (Mar 10 2022 at 15:31):

Sorry, I guess I mean the equation compiler:

example : Π (i : option unit), true
| none := trivial
| (some ()) := trivial

Eric Wieser (Mar 10 2022 at 15:31):

Indeed, match doesn't eliminate the variable

Mario Carneiro (Mar 10 2022 at 16:53):

Eric Rodriguez said:

rcases i with _ | ⟨⟨⟩⟩

gotten from rcases? i

@Johan Commelin ^ I wrote this bot to speak on my behalf :grinning:

Mario Carneiro (Mar 10 2022 at 16:56):

Although in this particular case there is an even shorter alternative: rcases i with _|-, which clears i instead of destructuring it


Last updated: Dec 20 2023 at 11:08 UTC