Skip to content

Commit 5b86271

Browse files
committed
docs/cleanups
1 parent b075eca commit 5b86271

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

src/Init/Data/Iterators/Lemmas/Combinators/Monadic/ULift.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ module
77

88
prelude
99
public import Init.Data.Iterators.Combinators.Monadic.ULift
10-
--import all Init.Data.Iterators.Combinators.Monadic.ULift
1110
public import Init.Data.Iterators.Lemmas.Consumers.Monadic.Collect
1211
public import Init.Data.Iterators.Lemmas.Consumers.Monadic.Loop
1312

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,23 @@ public theorem toArray_eq_if_roo [UpwardEnumerable α] [LT α] [DecidableLT α]
819819
#[] := by
820820
rw [Internal.toArray_eq_toArray_iter, Rxo.Iterator.toArray_eq_match]; rfl
821821

822+
public theorem toArray_eq_if_rco [UpwardEnumerable α] [LT α] [DecidableLT α]
823+
[LawfulUpwardEnumerable α] [Rxo.IsAlwaysFinite α] [LawfulUpwardEnumerableLT α] :
824+
r.toArray = if r.lower < r.upper then
825+
match UpwardEnumerable.succ? r.lower with
826+
| none => #[r.lower]
827+
| some next => #[r.lower] ++ (next...r.upper).toArray
828+
else
829+
#[] := by
830+
rw [Internal.toArray_eq_toArray_iter, Rxo.Iterator.toArray_eq_match]
831+
simp only [Internal.iter]
832+
split
833+
· split
834+
· simp [Rxo.Iterator.toArray_eq_match, *]
835+
· simp only [*]
836+
rfl
837+
· rfl
838+
822839
@[deprecated toArray_eq_if_roo (since := "2025-10-29")]
823840
def toArray_eq_if := @toArray_eq_if_roo
824841

src/Init/Data/Slice/Operations.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,22 @@ and use `Std.Slice.iter` instead.
2828
def Internal.iter (s : Slice γ) [ToIterator s Id β] :=
2929
ToIterator.iter s
3030

31+
/--
32+
This type class provides support for the `Slice.size` function.
33+
-/
3134
class SliceSize (α : Type u) where
35+
/-- Computes the slice of a `Slice`. Use `Slice.size` instead. -/
3236
size (slice : Slice α) : Nat
3337

38+
/--
39+
This type class states that the slice's iterator emits exactly `Slice.size` elements before
40+
terminating.
41+
-/
3442
class LawfulSliceSize (α : Type u) [SliceSize α] [∀ s : Slice α, ToIterator s Id β]
3543
[∀ s : Slice α, Iterator (ToIterator.State s Id) Id β] where
44+
/-- The iterator for every `Slice α` is finite. -/
3645
[finite : ∀ s : Slice α, Finite (ToIterator.State s Id) Id]
46+
/-- The iterator of a slice `s` of type `Slice α` emits exactly `SliceSize.size s` elements. -/
3747
lawful :
3848
letI (s : Slice α) : IteratorLoop (ToIterator.State s Id) Id Id := .defaultImplementation
3949
∀ s : Slice α, SliceSize.size s = (ToIterator.iter s).count

tests/lean/run/rangePolymorphic.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ open Std.Iterators
3939
#eval (2<...<15).iter.stepSize 2 |>.toList
4040

4141
example : (1...5).size = 4 := by
42-
rw [← Std.Rco.size_toArray]
43-
simp [Std.Rco.toArray_eq_if, Std.Roo.toArray_eq_match_rco]
42+
simp [← Std.Rco.size_toArray, Std.Rco.toArray_eq_if_rco]
4443

4544
/-- info: true -/
4645
#guard_msgs in

0 commit comments

Comments
 (0)