Skip to content

Commit ff547b6

Browse files
committed
use Nat namespace and update deprecations
1 parent 5dd283e commit ff547b6

File tree

1 file changed

+72
-49
lines changed

1 file changed

+72
-49
lines changed

src/Init/Data/Range/Polymorphic/NatLemmas.lean

Lines changed: 72 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,22 @@ theorem succ_eq {n : Nat} : succ n = n + 1 :=
3131
theorem succMany_eq {n : Nat} : succMany n m = m + n := by
3232
rfl
3333

34+
end Std.PRange.Nat
35+
36+
namespace Nat
37+
open Std Std.PRange Std.PRange.Nat
38+
3439
@[simp]
3540
theorem size_rcc {a b : Nat} :
3641
(a...=b).size = b + 1 - a := by
3742
simp [Rcc.size, Rxc.HasSize.size]
3843

44+
@[deprecated size_rcc (since := "2025-10-30")]
45+
def _root_.Std.PRange.Nat.size_Rcc := @_root_.Nat.size_rcc
46+
47+
@[deprecated size_rcc (since := "2025-12-01")]
48+
def _root_.Std.PRange.Nat.size_rcc := @_root_.Nat.size_rcc
49+
3950
@[simp]
4051
theorem length_toList_rcc {a b : Nat} :
4152
(a...=b).toList.length = b + 1 - a := by
@@ -46,15 +57,18 @@ theorem size_toArray_rcc {a b : Nat} :
4657
(a...=b).toArray.size = b + 1 - a := by
4758
simp only [Rcc.size_toArray, size_rcc]
4859

49-
@[deprecated size_rcc (since := "2025-10-30")]
50-
def size_Rcc := @size_rcc
51-
5260
@[simp]
5361
theorem size_rco {a b : Nat} :
5462
(a...b).size = b - a := by
5563
simp only [Rco.size, Rxo.HasSize.size, Rxc.HasSize.size]
5664
omega
5765

66+
@[deprecated size_rco (since := "2025-10-30")]
67+
def _root_.Std.PRange.Nat.size_Rco := @_root_.Nat.size_rco
68+
69+
@[deprecated size_rco (since := "2025-12-01")]
70+
def _root_.Std.PRange.Nat.size_rco := @_root_.Nat.size_rco
71+
5872
@[simp]
5973
theorem length_toList_rco {a b : Nat} :
6074
(a...b).toList.length = b - a := by
@@ -65,14 +79,17 @@ theorem size_toArray_rco {a b : Nat} :
6579
(a...b).toArray.size = b - a := by
6680
simp only [Rco.size_toArray, size_rco]
6781

68-
@[deprecated size_rco (since := "2025-10-30")]
69-
def size_Rco := @size_rco
70-
7182
@[simp]
7283
theorem size_roc {a b : Nat} :
7384
(a<...=b).size = b - a := by
7485
simp [Roc.size, Rxc.HasSize.size]
7586

87+
@[deprecated size_roc (since := "2025-10-30")]
88+
def _root_.Std.PRange.Nat.size_Roc := @_root_.Nat.size_roc
89+
90+
@[deprecated size_roc (since := "2025-12-01")]
91+
def _root_.Std.PRange.Nat.size_roc := @_root_.Nat.size_roc
92+
7693
@[simp]
7794
theorem length_toList_roc {a b : Nat} :
7895
(a<...=b).toList.length = b - a := by
@@ -83,14 +100,17 @@ theorem size_toArray_roc {a b : Nat} :
83100
(a<...=b).toArray.size = b - a := by
84101
simp only [Roc.size_toArray, size_roc]
85102

86-
@[deprecated size_roc (since := "2025-10-30")]
87-
def size_Roc := @size_roc
88-
89103
@[simp]
90104
theorem size_roo {a b : Nat} :
91105
(a<...b).size = b - a - 1 := by
92106
simp [Roo.size, Rxo.HasSize.size, Rxc.HasSize.size]
93107

108+
@[deprecated size_roo (since := "2025-10-30")]
109+
def _root_.Std.PRange.Nat.size_Roo := @_root_.Nat.size_roo
110+
111+
@[deprecated size_roo (since := "2025-12-01")]
112+
def _root_.Std.PRange.Nat.size_roo := @_root_.Nat.size_roo
113+
94114
@[simp]
95115
theorem length_toList_roo {a b : Nat} :
96116
(a<...b).toList.length = b - a - 1 := by
@@ -101,14 +121,17 @@ theorem size_toArray_roo {a b : Nat} :
101121
(a<...b).toArray.size = b - a - 1 := by
102122
simp only [Roo.size_toArray, size_roo]
103123

104-
@[deprecated size_roo (since := "2025-10-30")]
105-
def size_Roo := @size_roo
106-
107124
@[simp]
108125
theorem size_ric {b : Nat} :
109126
(*...=b).size = b + 1 := by
110127
simp [Ric.size, Rxc.HasSize.size]
111128

129+
@[deprecated size_ric (since := "2025-10-30")]
130+
def _root_.Std.PRange.Nat.size_Ric := @_root_.Nat.size_ric
131+
132+
@[deprecated size_ric (since := "2025-12-01")]
133+
def _root_.Std.PRange.Nat.size_ric := @_root_.Nat.size_ric
134+
112135
@[simp]
113136
theorem length_toList_ric {b : Nat} :
114137
(*...=b).toList.length = b + 1 := by
@@ -119,14 +142,17 @@ theorem size_toArray_ric {b : Nat} :
119142
(*...=b).toArray.size = b + 1 := by
120143
simp only [Ric.size_toArray, size_ric]
121144

122-
@[deprecated size_ric (since := "2025-10-30")]
123-
def size_Ric := @size_ric
124-
125145
@[simp]
126146
theorem size_rio {b : Nat} :
127147
(*...b).size = b := by
128148
simp [Rio.size, Rxo.HasSize.size, Rxc.HasSize.size]
129149

150+
@[deprecated size_rio (since := "2025-10-30")]
151+
def _root_.Std.PRange.Nat.size_Rio := @_root_.Nat.size_rio
152+
153+
@[deprecated size_rio (since := "2025-12-01")]
154+
def _root_.Std.PRange.Nat.size_rio := @_root_.Nat.size_rio
155+
130156
@[simp]
131157
theorem length_toList_rio {b : Nat} :
132158
(*...b).toList.length = b := by
@@ -137,9 +163,6 @@ theorem size_toArray_rio {b : Nat} :
137163
(*...b).toArray.size = b := by
138164
simp only [Rio.size_toArray, size_rio]
139165

140-
@[deprecated size_rio (since := "2025-10-30")]
141-
def size_Rio := @size_rio
142-
143166
@[simp]
144167
theorem toList_toArray_rco {m n : Nat} :
145168
(m...n).toArray.toList = (m...n).toList := by
@@ -159,11 +182,11 @@ theorem toList_rco_succ_succ {m n : Nat} :
159182
((m+1)...(n+1)).toList = (m...n).toList.map (· + 1) := by
160183
simp [← succ_eq, Rco.toList_succ_succ_eq_map]
161184

162-
@[deprecated toList_rco_succ_succ (since := "2025-10-30")]
163-
def toList_Rco_succ_succ := @toList_rco_succ_succ
185+
@[deprecated _root_.Nat.toList_rco_succ_succ (since := "2025-10-30")]
186+
def _root_.Std.PRange.Nat.toList_Rco_succ_succ := @_root_.Nat.toList_rco_succ_succ
164187

165-
@[deprecated toList_rco_succ_succ (since := "2025-08-22")]
166-
def ClosedOpen.toList_succ_succ := @toList_rco_succ_succ
188+
@[deprecated _root_.Nat.toList_rco_succ_succ (since := "2025-12-01")]
189+
def _root_.Std.PRange.Nat.toList_rco_succ_succ := @_root_.Nat.toList_rco_succ_succ
167190

168191
theorem toList_rco_succ_right_eq_cons_map {m n : Nat} (h : m ≤ n) :
169192
(m...(n + 1)).toList = m :: (m...n).toList.map (· + 1) := by
@@ -541,11 +564,11 @@ The following is an example reproving {name}`length_toList_rco`.
541564
542565
```lean
543566
example (a b : Nat) : (a...b).toList.length = b - a := by
544-
induction a, b using Std.PRange.Nat.induct_rco_left
567+
induction a, b using Nat.induct_rco_left
545568
case base =>
546-
simp only [Std.PRange.Nat.toList_rco_eq_nil, List.length_nil, Nat.sub_eq_zero_of_le, *]
569+
simp only [Nat.toList_rco_eq_nil, List.length_nil, Nat.sub_eq_zero_of_le, *]
547570
case step =>
548-
simp only [Std.PRange.Nat.toList_rco_eq_cons, List.length_cons, *]; omega
571+
simp only [Nat.toList_rco_eq_cons, List.length_cons, *]; omega
549572
```
550573
-/
551574
theorem induct_rco_left (motive : Nat → Nat → Prop)
@@ -573,11 +596,11 @@ The following is an example reproving {name}`length_toList_rco`.
573596
574597
```lean
575598
example (a b : Nat) : (a...b).toList.length = b - a := by
576-
induction a, b using Std.PRange.Nat.induct_rco_right
599+
induction a, b using Nat.induct_rco_right
577600
case base =>
578-
simp only [Std.PRange.Nat.toList_rco_eq_nil, List.length_nil, Nat.sub_eq_zero_of_le, *]
601+
simp only [Nat.toList_rco_eq_nil, List.length_nil, Nat.sub_eq_zero_of_le, *]
579602
case step a b hle ih =>
580-
rw [Std.PRange.Nat.toList_rco_eq_append (by omega),
603+
rw [Nat.toList_rco_eq_append (by omega),
581604
List.length_append, List.length_singleton, Nat.add_sub_cancel, ih]
582605
omega
583606
```
@@ -940,11 +963,11 @@ The following is an example reproving {name}`length_toList_rcc`.
940963
941964
```lean
942965
example (a b : Nat) : (a...=b).toList.length = b + 1 - a := by
943-
induction a, b using Std.PRange.Nat.induct_rcc_left
966+
induction a, b using Nat.induct_rcc_left
944967
case base =>
945-
simp only [Std.PRange.Nat.toList_rcc_eq_nil, List.length_nil, *]; omega
968+
simp only [Nat.toList_rcc_eq_nil, List.length_nil, *]; omega
946969
case step =>
947-
simp only [Std.PRange.Nat.toList_rcc_eq_cons, List.length_cons, *]; omega
970+
simp only [Nat.toList_rcc_eq_cons, List.length_cons, *]; omega
948971
```
949972
-/
950973
theorem induct_rcc_left (motive : Nat → Nat → Prop)
@@ -972,17 +995,17 @@ The following is an example reproving {name}`length_toList_rcc`.
972995
973996
```lean
974997
example (a b : Nat) : (a...=b).toList.length = b + 1 - a := by
975-
induction a, b using Std.PRange.Nat.induct_rcc_right
998+
induction a, b using Nat.induct_rcc_right
976999
case base a b hge =>
9771000
by_cases h : b < a
978-
· simp only [Std.PRange.Nat.toList_rcc_eq_nil, List.length_nil, *]
1001+
· simp only [Nat.toList_rcc_eq_nil, List.length_nil, *]
9791002
omega
9801003
· have : b = a := by omega
981-
simp only [Std.PRange.Nat.toList_rcc_eq_singleton, List.length_singleton,
1004+
simp only [Nat.toList_rcc_eq_singleton, List.length_singleton,
9821005
Nat.add_sub_cancel_left, *]
9831006
case step a b hle ih =>
984-
rw [Std.PRange.Nat.toList_rcc_succ_right_eq_append (by omega),
985-
List.length_append, List.length_singleton, ih] <;> omega
1007+
rw [Nat.toList_rcc_succ_right_eq_append (by omega), List.length_append,
1008+
List.length_singleton, ih] <;> omega
9861009
```
9871010
-/
9881011
theorem induct_rcc_right (motive : Nat → Nat → Prop)
@@ -1346,11 +1369,11 @@ The following is an example reproving {name}`length_toList_roo`.
13461369
13471370
```lean
13481371
example (a b : Nat) : (a<...b).toList.length = b - a - 1 := by
1349-
induction a, b using Std.PRange.Nat.induct_roo_left
1372+
induction a, b using Nat.induct_roo_left
13501373
case base =>
1351-
simp only [Std.PRange.Nat.toList_roo_eq_nil, List.length_nil, *]; omega
1374+
simp only [Nat.toList_roo_eq_nil, List.length_nil, *]; omega
13521375
case step =>
1353-
simp only [Std.PRange.Nat.toList_roo_eq_cons, List.length_cons, *]; omega
1376+
simp only [Nat.toList_roo_eq_cons, List.length_cons, *]; omega
13541377
```
13551378
-/
13561379
theorem induct_roo_left (motive : Nat → Nat → Prop)
@@ -1378,11 +1401,11 @@ The following is an example reproving {name}`length_toList_roo`.
13781401
13791402
```lean
13801403
example (a b : Nat) : (a<...b).toList.length = b - a - 1 := by
1381-
induction a, b using Std.PRange.Nat.induct_roo_right
1404+
induction a, b using Nat.induct_roo_right
13821405
case base =>
1383-
simp only [Std.PRange.Nat.toList_roo_eq_nil, List.length_nil, *]; omega
1406+
simp only [Nat.toList_roo_eq_nil, List.length_nil, *]; omega
13841407
case step a b hle ih =>
1385-
rw [Std.PRange.Nat.toList_roo_eq_append (by omega),
1408+
rw [Nat.toList_roo_eq_append (by omega),
13861409
List.length_append, List.length_singleton, Nat.add_sub_cancel, ih]
13871410
omega
13881411
```
@@ -1773,11 +1796,11 @@ The following is an example reproving {name}`length_toList_roc`.
17731796
17741797
```lean
17751798
example (a b : Nat) : (a<...=b).toList.length = b - a := by
1776-
induction a, b using Std.PRange.Nat.induct_roc_left
1799+
induction a, b using Nat.induct_roc_left
17771800
case base =>
1778-
simp only [Std.PRange.Nat.toList_roc_eq_nil, List.length_nil, *]; omega
1801+
simp only [Nat.toList_roc_eq_nil, List.length_nil, *]; omega
17791802
case step =>
1780-
simp only [Std.PRange.Nat.toList_roc_eq_cons, List.length_cons, *]; omega
1803+
simp only [Nat.toList_roc_eq_cons, List.length_cons, *]; omega
17811804
```
17821805
-/
17831806
theorem induct_roc_left (motive : Nat → Nat → Prop)
@@ -1800,11 +1823,11 @@ The following is an example reproving {name}`length_toList_roc`.
18001823
18011824
```lean
18021825
example (a b : Nat) : (a<...=b).toList.length = b - a := by
1803-
induction a, b using Std.PRange.Nat.induct_roc_right
1826+
induction a, b using Nat.induct_roc_right
18041827
case base =>
1805-
simp only [Std.PRange.Nat.toList_roc_eq_nil, List.length_nil, *]; omega
1828+
simp only [Nat.toList_roc_eq_nil, List.length_nil, *]; omega
18061829
case step a b hle ih =>
1807-
rw [Std.PRange.Nat.toList_roc_eq_append (by omega),
1830+
rw [Nat.toList_roc_eq_append (by omega),
18081831
List.length_append, List.length_singleton, Nat.add_sub_cancel, ih]
18091832
omega
18101833
```
@@ -2437,7 +2460,7 @@ theorem getD_toArray_ric_eq_fallback {n i fallback : Nat} (h : n < i) :
24372460
(*...=n).toArray.getD i fallback = fallback := by
24382461
rw [toArray_ric_eq_toArray_rio, getD_toArray_rio_eq_fallback]; omega
24392462

2440-
end Std.PRange.Nat
2463+
end Nat
24412464

24422465
theorem List.range_eq_toList_rco {n : Nat} :
24432466
List.range n = (0...n).toList := by

0 commit comments

Comments
 (0)