Skip to content

Commit

Permalink
feat(Data/Nat/Basic): self_add_sub_one and friends (#7123)
Browse files Browse the repository at this point in the history
Co-authored-by: Moritz Firsching <firsching@google.com>
  • Loading branch information
mo271 and mo271 committed Sep 13, 2023
1 parent 2a9e72b commit 0444e0c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Mathlib/Data/Nat/Basic.lean
Expand Up @@ -327,6 +327,21 @@ theorem le_of_pred_lt {m n : ℕ} : pred m < n → m ≤ n :=
| _ + 1 => id
#align nat.le_of_pred_lt Nat.le_of_pred_lt

theorem self_add_sub_one (n : ℕ) : n + (n - 1) = 2 * n - 1 := by
cases n
· rfl
· rw [two_mul]
convert (add_succ_sub_one (Nat.succ _) _).symm

theorem sub_one_add_self (n : ℕ) : (n - 1) + n = 2 * n - 1 :=
add_comm _ n ▸ self_add_sub_one n

theorem self_add_pred (n : ℕ) : n + pred n = (2 * n).pred :=
self_add_sub_one n

theorem pred_add_self (n : ℕ) : pred n + n = (2 * n).pred :=
sub_one_add_self n

/-- This ensures that `simp` succeeds on `pred (n + 1) = n`. -/
@[simp]
theorem pred_one_add (n : ℕ) : pred (1 + n) = n := by rw [add_comm, add_one, Nat.pred_succ]
Expand Down

0 comments on commit 0444e0c

Please sign in to comment.