Zulip Chat Archive

Stream: new members

Topic: How to write in Lean


Ipojucã Moraes da Cruz (May 16 2022 at 15:12):

I´d like to prove a * 0 = 0 by proving if a + ( a * 0 ) = a then a * 0 = 0 , how can I end this

theorem ZA_AnR:  (a : ), a * 0 = 0 :=
begin
  intro a,

  have h: a + (a * 0) = a,

    calc
    a + (a * 0) = a * 1 + (a * 0) : by rw [int.mul_one a]
            ... = a * (1 + 0)     : by rw  int.distrib_left
            ... = a * 1           : by rw int.add_zero
            ... = a               : by rw int.mul_one,

end

Ruben Van de Velde (May 16 2022 at 15:34):

Maybe with this substep:

theorem ZA_AnR:  (a : ), a * 0 = 0 :=
begin
  intro a,

  have h: a + (a * 0) = a,

    calc
    a + (a * 0) = a * 1 + (a * 0) : by rw [int.mul_one a]
            ... = a * (1 + 0)     : by rw  int.distrib_left
            ... = a * 1           : by rw int.add_zero
            ... = a               : by rw int.mul_one,
  have h' : a + (a * 0) = a + 0, sorry,
  exact add_left_cancel h',
end

Yaël Dillies (May 16 2022 at 15:39):

I've wanted a + b = b -> a = 0 as a lemma periodically, so we might just add it.

Kyle Miller (May 16 2022 at 15:52):

@Yaël Dillies docs#add_left_eq_self?

example (a b : ) : a + b = b  a = 0 := add_left_eq_self.mp

Ruben Van de Velde (May 16 2022 at 15:53):

Looked for that, but I needed kyle_search, clearly :)

Yaël Dillies (May 16 2022 at 15:53):

Ah right. It's not missing but it's misnamed.

Yaël Dillies (May 16 2022 at 15:54):

Each time I look for add_eq_right, add_eq_right_iff...


Last updated: Dec 20 2023 at 11:08 UTC