Zulip Chat Archive

Stream: new members

Topic: nat lemmas


Scott Morrison (May 12 2019 at 23:34):

Could anyone help me with an apparently easy lemma:

lemma sub_add_eq_add_sub_of_le {a b c : ℕ} (h : b ≤ a) : (a - b) + c = (a + c) - b :=
by omega -- overkill!

Reid Barton (May 12 2019 at 23:40):

lemma sub_add_eq_add_sub_of_le {a b c : } (h : b  a) : (a - b) + c = (a + c) - b :=
begin
  symmetry,
  apply nat.sub_eq_of_eq_add,
  rw [add_assoc, nat.add_sub_cancel' h],
end

Reid Barton (May 12 2019 at 23:40):

Seems like a candidate for addition to the library

Mario Carneiro (May 13 2019 at 00:03):

lemma sub_add_eq_add_sub_of_le {a b c : } (h : b  a) : (a - b) + c = (a + c) - b :=
by rw [add_comm a, nat.add_sub_assoc h, add_comm]

I suggest the name nat.sub_add_eq_add_sub

Scott Morrison (May 13 2019 at 00:15):

Thanks!

Scott Morrison (May 13 2019 at 00:16):

I have a bunch more lemmas about nat (mostly about divisibility) that I would like to have in mathlib.

Scott Morrison (May 13 2019 at 00:16):

They are all proved, but I don't doubt my proofs are highly golfable.

Scott Morrison (May 13 2019 at 00:16):

(and maybe some are in the library, just library_search and I failed to find them)

Scott Morrison (May 13 2019 at 00:16):

What is the best way to proceed?

Scott Morrison (May 13 2019 at 00:17):

Should I just make a PR with all the lemmas, with my proofs?

Scott Morrison (May 13 2019 at 00:17):

Or should I post just the statements here for someone to give a thumbs-up or thumbs-down to each?

Scott Morrison (May 13 2019 at 00:17):

Or post the proofs here too?

Mario Carneiro (May 13 2019 at 00:26):

post a PR, we can suggest improvements in the review comments if necessary

Mario Carneiro (May 13 2019 at 00:26):

you are more likely to get an individual proof golfed if you post here, but don't overdo it


Last updated: Dec 20 2023 at 11:08 UTC