Skip to content

Commit 167265f

Browse files
committed
improve verso docstrings
1 parent 9b16825 commit 167265f

File tree

2 files changed

+43
-36
lines changed

2 files changed

+43
-36
lines changed

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

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@ namespace Rxc
1919

2020
variable {α : Type u} {lo hi : α} {a : α}
2121

22-
/--
23-
This typeclass provides support for the size function for ranges with closed lower bound
24-
({name (scope := "Init.Data.Range.Polymorphic")}`Rcc.size`,
25-
{name (scope := "Init.Data.Range.Polymorphic")}`Rco.size` and
26-
{name (scope := "Init.Data.Range.Polymorphic")}`Rci.size`).
27-
28-
The returned size should be equal to the number of elements returned by {lit}`toList`. This
29-
condition is captured by the typeclass
30-
{name (scope := "Init.Data.Range.Polymorphic")}`LawfulRangeSize`.
31-
-/
3222
class HasSize (α : Type u) where
3323
/-- Returns the number of elements starting from {name}`lo` that satisfy the given upper bound. -/
3424
size (lo hi : α) : Nat
@@ -54,6 +44,18 @@ class LawfulHasSize (α : Type u) [LE α] [UpwardEnumerable α] [HasSize α] whe
5444
(h' : UpwardEnumerable.succ? lo = some lo') :
5545
HasSize.size lo hi = HasSize.size lo' hi + 1
5646

47+
/--
48+
This typeclass provides support for the size function for ranges with closed lower bound
49+
({name (scope := "Init.Data.Range.Polymorphic.Iterators")}`Rcc.size`,
50+
{name (scope := "Init.Data.Range.Polymorphic.Iterators")}`Rco.size` and
51+
{name (scope := "Init.Data.Range.Polymorphic.Iterators")}`Rci.size`).
52+
53+
The returned size should be equal to the number of elements returned by {lit}`toList`. This
54+
condition is captured by the typeclass
55+
{name}`LawfulHasSize`.
56+
-/
57+
add_decl_doc HasSize
58+
5759
export LawfulHasSize (size_eq_zero_of_not_le size_eq_one_of_succ?_eq_none
5860
size_eq_succ_of_succ?_eq_some)
5961

@@ -92,16 +94,6 @@ namespace Rxo
9294

9395
variable {α : Type u} {lo hi : α} {a : α}
9496

95-
/--
96-
This typeclass provides support for the size function for ranges with open lower bound
97-
({name (scope := "Init.Data.Range.Polymorphic")}`Roc.size`,
98-
{name (scope := "Init.Data.Range.Polymorphic")}`Roo.size` and
99-
{name (scope := "Init.Data.Range.Polymorphic")}`Roi.size`).
100-
101-
The returned size should be equal to the number of elements returned by {lit}`toList`. This
102-
condition is captured by the typeclass
103-
{name (scope := "Init.Data.Range.Polymorphic")}`LawfulRangeSize`.
104-
-/
10597
class HasSize (α : Type u) where
10698
/-- Returns the number of elements starting from {name}`lo` that satisfy the given upper bound. -/
10799
size (lo hi : α) : Nat
@@ -127,6 +119,18 @@ class LawfulHasSize (α : Type u) [LT α] [UpwardEnumerable α] [HasSize α] whe
127119
(h' : UpwardEnumerable.succ? lo = some lo') :
128120
HasSize.size lo hi = HasSize.size lo' hi + 1
129121

122+
/--
123+
This typeclass provides support for the size function for ranges with open lower bound
124+
({name (scope := "Init.Data.Range.Polymorphic.Iterators")}`Roc.size`,
125+
{name (scope := "Init.Data.Range.Polymorphic.Iterators")}`Roo.size` and
126+
{name (scope := "Init.Data.Range.Polymorphic.Iterators")}`Roi.size`).
127+
128+
The returned size should be equal to the number of elements returned by {lit}`toList`. This
129+
condition is captured by the typeclass
130+
{name}`LawfulHasSize`.
131+
-/
132+
add_decl_doc HasSize
133+
130134
export LawfulHasSize (size_eq_zero_of_not_le size_eq_one_of_succ?_eq_none
131135
size_eq_succ_of_succ?_eq_some)
132136

@@ -165,16 +169,6 @@ namespace Rxi
165169

166170
variable {α : Type u} {lo : α} {a : α}
167171

168-
/--
169-
This typeclass provides support for the size function for ranges with closed lower bound
170-
({name (scope := "Init.Data.Range.Polymorphic")}`Ric.size`,
171-
{name (scope := "Init.Data.Range.Polymorphic")}`Rio.size` and
172-
{name (scope := "Init.Data.Range.Polymorphic")}`Rii.size`).
173-
174-
The returned size should be equal to the number of elements returned by {lit}`toList`. This
175-
condition is captured by the typeclass
176-
{name (scope := "Init.Data.Range.Polymorphic")}`LawfulRangeSize`.
177-
-/
178172
class HasSize (α : Type u) where
179173
/-- Returns the number of elements starting from {name}`lo` that satisfy the given upper bound. -/
180174
size (lo : α) : Nat
@@ -197,6 +191,18 @@ class LawfulHasSize (α : Type u) [UpwardEnumerable α] [HasSize α] where
197191
(h : UpwardEnumerable.succ? lo = some lo') :
198192
HasSize.size lo = HasSize.size lo' + 1
199193

194+
/--
195+
This typeclass provides support for the size function for ranges with closed lower bound
196+
({name (scope := "Init.Data.Range.Polymorphic.Iterators")}`Ric.size`,
197+
{name (scope := "Init.Data.Range.Polymorphic.Iterators")}`Rio.size` and
198+
{name (scope := "Init.Data.Range.Polymorphic.Iterators")}`Rii.size`).
199+
200+
The returned size should be equal to the number of elements returned by {lit}`toList`. This
201+
condition is captured by the typeclass
202+
{name}`LawfulHasSize`.
203+
-/
204+
add_decl_doc HasSize
205+
200206
export LawfulHasSize (size_eq_one_of_succ?_eq_none size_eq_succ_of_succ?_eq_some)
201207

202208
theorem size_pos {α : Type u} [UpwardEnumerable α] [HasSize α] [LawfulHasSize α] {lo : α} :

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,6 @@ end Rxc
9090

9191
namespace Rxo
9292

93-
-- TODO: Replace the `lit` role with an intra-module forward reference.
94-
/--
95-
Creates a {lean}`HasSize α` from a {lean}`HasSize α` instance. If the latter is lawful
96-
and certain other conditions hold, then the former is also lawful by
97-
{lit}`Rxo.LawfulHasSize.open_of_closed`.
98-
-/
9993
@[inline]
10094
abbrev HasSize.ofClosed [Rxc.HasSize α] : HasSize α where
10195
size lo hi := Rxc.HasSize.size lo hi - 1
@@ -138,6 +132,13 @@ instance LawfulHasSize.of_closed [UpwardEnumerable α] [LE α] [DecidableLE α]
138132
refine ⟨h.choose, ?_⟩
139133
simpa [succMany?_succ?_eq_succ?_bind_succMany?, h'] using h.choose_spec
140134

135+
/--
136+
Creates a {lean}`HasSize α` from a {lean}`HasSize α` instance. If the latter is lawful
137+
and certain other conditions hold, then the former is also lawful by
138+
{name}`Rxo.LawfulHasSize.of_closed`.
139+
-/
140+
add_decl_doc HasSize.ofClosed
141+
141142
instance instIsAlwaysFiniteOfLawfulHasSize [LT α] [UpwardEnumerable α]
142143
[LawfulUpwardEnumerable α] [HasSize α] [LawfulHasSize α] :
143144
IsAlwaysFinite α where

0 commit comments

Comments
 (0)