Zulip Chat Archive

Stream: Is there code for X?

Topic: add_tsub_add_le_tsub_add_tsub


Andrew Yang (Jul 02 2022 at 16:58):

Do we have this (or an easy proof of this) somewhere?

lemma add_tsub_add_le_tsub_add_tsub {a b c d : } :
  (a + b) - (c + d)  (a - c) + (b - d) :=
begin
  cases le_total (a + b) (c + d) with h₁ h₁,
  { rw tsub_eq_zero_of_le h₁, exact zero_le _ },
  cases le_total (a) (c) with h₂ h₂,
  { rw [tsub_eq_zero_of_le h₂, zero_add, tsub_le_iff_tsub_le],
    exact add_tsub_le_assoc.trans (add_le_add h₂ tsub_tsub_le) },
  cases le_total (b) (d) with h₃ h₃,
  { rw [tsub_eq_zero_of_le h₃, add_zero, tsub_le_iff_tsub_le, add_comm a, add_comm c],
    exact add_tsub_le_assoc.trans (add_le_add h₃ tsub_tsub_le) },
  { simp only [ int.coe_nat_le_coe_nat_iff, nat.cast_sub, nat.cast_add, *], linarith }
end

Yaël Dillies (Jul 02 2022 at 16:59):

The equality is docs#tsub_add_tsub_comm

Andrew Yang (Jul 02 2022 at 17:03):

This is a proof with a more reasonable length

lemma add_tsub_add_le_tsub_add_tsub {a b c d : } :
  (a + b) - (c + d)  (a - c) + (b - d) :=
begin
  rw [add_comm c,  tsub_tsub],
  refine (tsub_le_tsub_right add_tsub_le_assoc c).trans _,
  rw [add_comm a, add_comm (a - c)],
  exact add_tsub_le_assoc
end

Yaël Dillies (Jul 11 2022 at 16:16):

@Andrew Yang, did you ever PR the above? If not, I am about to PR very similar lemmas so I'll include that one.

Andrew Yang (Jul 11 2022 at 16:21):

It is somewhere in #15105, but the right thing to do is probably to put this lemma in your PR and to make my PR depend on it.

Andrew Yang (Jul 17 2022 at 13:36):

@Yaël Dillies Did you end up PRing the lemma?

Yaël Dillies (Jul 17 2022 at 13:54):

I was working on it this morning. I can probably finish it up now.

Andrew Yang (Jul 17 2022 at 16:25):

I see. In this case, I think I will merge my PR containing it (#15459) first, so you can leave it out from your PR?

Yaël Dillies (Jul 18 2022 at 15:53):

@Andrew Yang, here you go: #15497


Last updated: Dec 20 2023 at 11:08 UTC