Skip to content

Commit a7f9fbe

Browse files
committed
feat: Nat.cast_one_add (leanprover-community#40168)
1 parent 01e91cd commit a7f9fbe

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

Mathlib/Data/Nat/Cast/Defs.lean

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,28 +86,31 @@ theorem cast_zero : ((0 : ℕ) : R) = 0 :=
8686
theorem cast_succ (n : ℕ) : ((succ n : ℕ) : R) = n + 1 :=
8787
AddMonoidWithOne.natCast_succ _
8888

89-
theorem cast_add_one (n : ℕ) : ((n + 1 : ℕ) : R) = n + 1 :=
90-
cast_succ _
91-
9289
@[simp, norm_cast]
9390
theorem cast_ite (P : Prop) [Decidable P] (m n : ℕ) :
9491
((ite P m n : ℕ) : R) = ite P (m : R) (n : R) := by
9592
split_ifs <;> rfl
9693

97-
end Nat
98-
99-
namespace Nat
100-
10194
@[simp, norm_cast]
102-
theorem cast_one [AddMonoidWithOne R] : ((1 : ℕ) : R) = 1 := by
95+
theorem cast_one : ((1 : ℕ) : R) = 1 := by
10396
rw [cast_succ, Nat.cast_zero, zero_add]
10497

10598
@[simp, norm_cast]
106-
theorem cast_add [AddMonoidWithOne R] (m n : ℕ) : ((m + n : ℕ) : R) = m + n := by
99+
theorem cast_add (m n : ℕ) : ((m + n : ℕ) : R) = m + n := by
107100
induction n with
108101
| zero => simp
109102
| succ n ih => rw [add_succ, cast_succ, ih, cast_succ, add_assoc]
110103

104+
theorem cast_add_one (n : ℕ) : ((n + 1 : ℕ) : R) = n + 1 :=
105+
cast_succ _
106+
107+
theorem cast_one_add (n : ℕ) : ((1 + n : ℕ) : R) = 1 + n := by
108+
rw [Nat.cast_add, Nat.cast_one]
109+
110+
end Nat
111+
112+
namespace Nat
113+
111114
/-- Computationally friendlier cast than `Nat.unaryCast`, using binary representation. -/
112115
protected def binCast [Zero R] [One R] [Add R] : ℕ → R
113116
| 0 => 0

0 commit comments

Comments
 (0)