Skip to content

Commit

Permalink
feat(data/nat/basic): b = c if b - a = c - a
Browse files Browse the repository at this point in the history
  • Loading branch information
semorrison committed Mar 30, 2019
1 parent c2bb4c5 commit c4e7ae7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/data/nat/basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ by rw [add_comm, nat.sub_add_cancel h]
protected theorem sub_eq_of_eq_add (h : k = m + n) : k - m = n :=
begin rw [h, nat.add_sub_cancel_left] end

theorem sub_cancel {a b c : ℕ} (h₁ : a ≤ b) (h₂ : a ≤ c) (w : b - a = c - a) : b = c :=
begin
replace w := congr_arg (λ x, x + a) w,
dsimp at w,
rwa [nat.sub_add_cancel h₁, nat.sub_add_cancel h₂] at w,
end

lemma sub_sub_sub_cancel_right {a b c : ℕ} (h₂ : c ≤ b) : (a - c) - (b - c) = a - b :=
by rw [nat.sub_sub, ←nat.add_sub_assoc h₂, nat.add_sub_cancel_left]

Expand Down

0 comments on commit c4e7ae7

Please sign in to comment.