Zulip Chat Archive

Stream: mathlib4

Topic: rcases question


Matthew Ballard (Mar 01 2023 at 17:52):

I don't understand the behavior of rintro in the following. Hopefully I am just dense.

import Std.Tactic.RCases

inductive BaseType : Type where
  | one
  | two

open BaseType

inductive BaseTypeHom : BaseType  BaseType  Type where
  | left : BaseTypeHom one two
  | right : BaseTypeHom one two
  | id (X : BaseType) : BaseTypeHom X X

def triv : (X Y : BaseType)  BaseTypeHom X Y  Unit := by
  rintro (_|_) (_|_) (_|_|_);  --- rcases tactic failed: one is not a fvar

Matthew Ballard (Mar 01 2023 at 17:53):

I am guessing it is trying to pull the X from the id branch of BaseTypeHom but making it implicit doesn't help

Matthew Ballard (Mar 01 2023 at 17:56):

If my understanding is correct, what is the proper incantation with | and _ to capture all three constructors for BaseTypeHom?

Matthew Ballard (Mar 01 2023 at 18:15):

This is fine

def triv (X Y : BaseType) : BaseTypeHom X Y  Unit := by
  rintro (_|_|_)

Matthew Ballard (Mar 01 2023 at 18:31):

This works as expected

import Std.Tactic.RCases

inductive Hom : Unit  Unit  Type where
  | loop : Hom unit unit
  | id (X : Unit) : Hom X X

def triv₂ : Hom unit unit  Unit := by
  rintro (_|_)

Matthew Ballard (Mar 01 2023 at 18:45):

This does not

import Std.Tactic.RCases

inductive BaseType : Type where
  | one

open BaseType

inductive BaseTypeHom : BaseType  BaseType  Type where
  | loop : BaseTypeHom one one
  | id (X : BaseType) : BaseTypeHom X X

def triv₂ : BaseTypeHom one one  Unit := by
  rintro (_|_) -- rcases tactic failed: one is not a fvar

Matthew Ballard (Mar 01 2023 at 18:48):

@Mario Carneiro is this expected behavior?

Mario Carneiro (Mar 01 2023 at 18:49):

yes this is expected

Mario Carneiro (Mar 01 2023 at 18:49):

try using \<\<\>\> instead for the last pattern match

Mario Carneiro (Mar 01 2023 at 18:51):

if your goal is just to pattern match once on BaseTypeHom and get three cases, the earlier pattern matches are only confusing matters. Just use _ _ (_|_|_)

Matthew Ballard (Mar 01 2023 at 18:51):

def triv₂ : BaseTypeHom one one  Unit := by
  rintro ⟨⟨⟩⟩

gives the same not an fvar error

Mario Carneiro (Mar 01 2023 at 18:52):

does intro h; cases h work in the last example?

Matthew Ballard (Mar 01 2023 at 18:53):

Mario Carneiro said:

if your goal is just to pattern match once on BaseTypeHom and get three cases, the earlier pattern matches are only confusing matters. Just use _ _ (_|_|_)

I think this works for my use. Thanks

Matthew Ballard (Mar 01 2023 at 18:53):

Mario Carneiro said:

does intro h; cases h work in the last example?

Yes that does work for the last example.

Mario Carneiro (Mar 01 2023 at 18:55):

in that case I think there is a bug in rcases

Mario Carneiro (Mar 01 2023 at 18:56):

the "one is not an fvar" error is not supposed to happen

Matthew Ballard (Mar 01 2023 at 18:56):

Should I make an issue?

Matthew Ballard (Mar 01 2023 at 19:02):

Darn. The error also pops up in

def triv₃ : (X : BaseType)  BaseTypeHom X X  BaseTypeHom X X  Unit := by
  rintro _ (_|_) (_|_)

Matthew Ballard (Mar 01 2023 at 19:02):

Over the second hom

Mario Carneiro (Mar 01 2023 at 19:36):

you can probably just do rintro _ (_|_) h <;> cases h

Matthew Ballard (Mar 01 2023 at 19:46):

Mario Carneiro said:

you can probably just do rintro _ (_|_) h <;> cases h

Hmm that tosses the same error I think the infoview wasn't updating...It wasn't


Last updated: Dec 20 2023 at 11:08 UTC