Zulip Chat Archive

Stream: mathlib4

Topic: Proof by rfl fails after adding rcases on choose


Michael Rothgang (Dec 20 2023 at 17:22):

I'd like to prove a "trivial lemma" about a new definition I've made; this ought to be a proof by rfl, but fails. I don't understand why; I've narrowed it down to an rcases call on the result of a choose tactic. Any pointers appreciated.
(Broader context is my in-progress PR #8738xx.)

Somewhat minimal example; I suspect this is not related to my new definition:

import Mathlib

variable {π•œ : Type*} [NontriviallyNormedField π•œ]
  {E : Type*} [NormedAddCommGroup E] [NormedSpace π•œ E]
  {F : Type*} [NormedAddCommGroup F] [NormedSpace π•œ F]
  {H : Type*} [TopologicalSpace H]
  {G : Type*} [TopologicalSpace G]
  (I : ModelWithCorners π•œ E H) (J : ModelWithCorners π•œ F G)
  (M : Type*) [TopologicalSpace M] [ChartedSpace H M]
  (N : Type*) [TopologicalSpace N] [ChartedSpace G N] (n : β„•βˆž)
  [SmoothManifoldWithCorners I M] [SmoothManifoldWithCorners J N]

structure PartialDiffeomorph extends PartialEquiv M N where
  open_source : IsOpen source
  open_target : IsOpen target
  contMDiffOn_toFun : ContMDiffOn I J n toFun source
  contMDiffOn_invFun : ContMDiffOn J I n invFun target

instance : CoeFun (PartialDiffeomorph I J M N n) fun _ => M β†’ N :=
  ⟨fun Φ => Φ.toFun⟩

variable {M N} in
def IsLocalDiffeomorphAt (f : M β†’ N) (x : M) : Prop :=
  βˆƒ Ξ¦ : PartialDiffeomorph I J M N n, x ∈ Ξ¦.source ∧ Set.EqOn f Ξ¦ Ξ¦.source

noncomputable def IsLocalDiffeomorphAt.mydef {f : M β†’ N} {x : M}
    (hf : IsLocalDiffeomorphAt I J n f x) :
    ContinuousLinearEquiv (RingHom.id π•œ) (TangentSpace I x) (TangentSpace J (f x)) := by
  choose Ξ¦ hyp using hf
  --rcases hyp with ⟨hxU, heq⟩ -- uncommenting this line breaks the proof below!
  exact {
    toFun := mfderiv I J f x
    invFun := sorry
    left_inv := sorry
    right_inv := sorry
    continuous_toFun := sorry
    continuous_invFun := sorry
    map_add' := sorry
    map_smul' := sorry
  }

lemma foo {f : M β†’ N} {x : M} (hf : IsLocalDiffeomorphAt I J n f x) :
  hf.mydef = mfderiv I J f x := by rfl

Michael Rothgang (Dec 20 2023 at 17:23):

I'm not sure if this is best posted in #new members, #mathlib4 or #lean4; feel free to move accordingly.

Eric Wieser (Dec 20 2023 at 19:02):

This is because eta reduction does not work on And, cf https://leanprover.zulipchat.com/#narrow/stream/236446-Type-theory/topic/And.2Erec/near/398483665

Eric Wieser (Dec 20 2023 at 19:02):

But also, using tactic blocks for anything non-trivial (ie, anything more than refine, intro, convert) when constructing data is usually ill-advised

Eric Wieser (Dec 20 2023 at 19:04):

Is docs#ContinuousLinearEquiv.ofBijective helpful to you?

Michael Rothgang (Dec 22 2023 at 11:37):

Thanks for the prompt response, this is really helpful!

Michael Rothgang (Dec 22 2023 at 11:38):

Eric Wieser said:

Is docs#ContinuousLinearEquiv.ofBijective helpful to you?

It solves my problem - at the price of having to impose a completeness assumption. (This means my result will only apply to Banach manifolds, as opposed to ones modelled on general normed space. I guess that's fine in practice.)

Kevin Buzzard (Dec 22 2023 at 11:43):

I think it's good practice to try and make everything work in as much generality as possible; future generations will thank you!


Last updated: May 02 2025 at 03:31 UTC