Zulip Chat Archive

Stream: general

Topic: Diagnosing diamonds


Eric Wieser (Dec 16 2020 at 17:57):

I'm in a proof where my final goal is alternating_map.has_scalar = mul_action.to_has_scalar.

has_scalar has only one field - how do I change the equality to that field and get things to unfold?

Alex J. Best (Dec 16 2020 at 18:00):

Do cases or congr do what you want?

Eric Wieser (Dec 16 2020 at 18:00):

cases needs an argument

Eric Wieser (Dec 16 2020 at 18:01):

And congr fails with no error

Eric Wieser (Dec 16 2020 at 18:01):

(I got to this goal by applying congr anyway)

Eric Wieser (Dec 16 2020 at 18:17):

A mwe:

lemma has_scalar.ext {R M : Type*} (a b : has_scalar R M) : a.smul = b.smul  a = b :=
begin
  intro h,
  sorry,
end

Eric Wieser (Dec 16 2020 at 18:31):

@Bhavik Mehta golfed it with

lemma has_scalar.ext {R M : Type*} :  (a b : has_scalar R M), a.smul = b.smul  a = b
| _ _ rfl := rfl

Sebastien Gouezel (Dec 16 2020 at 18:36):

A non-golfed version:

lemma has_scalar.ext {R M : Type*} (a b : has_scalar R M) : a.smul = b.smul  a = b :=
begin
  intro h,
  tactic.unfreeze_local_instances,
  cases a,
  cases b,
  dsimp at h,
  induction h,
  refl,
end

Rob Lewis (Dec 16 2020 at 18:39):

Golfed even more:

attribute [ext] has_scalar

Eric Wieser (Dec 16 2020 at 18:52):

I just noticed that we actually already have docs#module_ext, perhaps this should be expanded to at least semimodule_ext

Eric Wieser (Dec 16 2020 at 18:52):

And I think ultimately I need a nat version of docs#add_comm_group.module.subsingleton to close my diamond, which ought to be straightforward

Eric Wieser (Dec 16 2020 at 19:11):

Done in #5396


Last updated: Dec 20 2023 at 11:08 UTC