Zulip Chat Archive

Stream: new members

Topic: using sub_eq_add_neg in calc


Pradana Aumars (Feb 26 2022 at 22:30):

Hello everyone,

I'm just getting started with Lean by proving 0x = 0 for any real x. Here's the code:

lemma prop1a (x : ) : 0*x = 0 :=
begin
  apply eq.symm,
  calc 0 = 0*x - 0*x : by rw sub_self
  ... = 0*x + (-0*x) : by rw sub_eq_add_neg
  ... = (0 + 0)*x  + (-0*x) : by rw add_zero
  ... = 0*x + 0*x + (-0*x) : by rw right_distrib
  ... = 0*x + (0*x + (-0*x)) : by rw add_assoc
  ... = 0*x : by rw sub_self
end

I do not understand why
rw sub_eq_add_neg
returns two different states: 0 * x + -(0 * x) = 0 * x + -0 * x and 0 = 0 * x

What's going on here?

Thank you

Eric Wieser (Feb 26 2022 at 22:52):

Does realizing -0 * x is interpreted as (-0)*x help?

Pradana Aumars (Feb 26 2022 at 23:06):

I got it now, thanks!


Last updated: Dec 20 2023 at 11:08 UTC