mathlib icon indicating copy to clipboard operation
mathlib copied to clipboard

`ext` recurses into subgoals, `ext x y z` and `ext : n` do not

Open eric-wieser opened this issue 4 years ago • 2 comments

Reproduction (on mathlib 8fd86366a4472716b25100e831a2ba0f266b28b8)

import linear_algebra.basic

variables {R : Type*} {M : Type*} {M₂ : Type*} {M₃ : Type*} {M₄ : Type*}
variables [semiring R]
variables [add_comm_monoid M] [add_comm_monoid M₂] [add_comm_monoid M₃] [add_comm_monoid M₄]
variables [semimodule R M] [semimodule R M₂] [semimodule R M₃] [semimodule R M₄]

open linear_map

@[ext] theorem prod_ext {f g : M × M₂ →ₗ[R] M₃}
  (hl : f.comp (inl _ _ _) = g.comp (inl _ _ _))
  (hr : f.comp (inr _ _ _) = g.comp (inr _ _ _)) :
  f = g :=
begin
  apply (coprod_equiv ℕ).symm.injective,
  simp only [coprod_equiv_symm_apply, hl, hr],
  apply_instance, apply_instance,
end

example {f g : M × M₂ × M₃ →ₗ[R] M₄ } : f = g :=
begin
  ext x y z, -- 2 goals
  sorry, sorry,
end


example {f g : M × M₂ × M₃ →ₗ[R] M₄ } : f = g :=
begin
  ext : 1000, -- 2 goals
  sorry, sorry,
end

example {f g : M × M₂ × M₃ →ₗ[R] M₄ } : f = g :=
begin
  ext, -- 3 goals, with x: M, x: M₂, x: M₃
  sorry, sorry,  sorry,
end

The cause is these lines:

https://github.com/leanprover-community/mathlib/blob/8fd86366a4472716b25100e831a2ba0f266b28b8/src/tactic/ext.lean#L533-L537

Only the repeat1 branch goes on to call ext on all subgoals.

eric-wieser avatar Feb 09 '21 10:02 eric-wieser