Skip to content

Commit 59e070c

Browse files
committed
corrections
1 parent 984c3cd commit 59e070c

File tree

7 files changed

+14
-10
lines changed

7 files changed

+14
-10
lines changed

src/Init/Data/Iterators/Combinators/Attach.lean

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ namespace Std.Iterators
1414
@[always_inline, inline, inherit_doc IterM.attachWith]
1515
def Iter.attachWith {α β : Type w}
1616
[Iterator α Id β]
17-
(it : Iter (α := α) β) (P : β → Prop) (h : ∀ out, it.IsPlausibleIndirectOutput out → P out) :=
18-
haveI h' : ∀ out, it.toIterM.IsPlausibleIndirectOutput out → P out := by
17+
(it : Iter (α := α) β) (P : β → Prop) (h : ∀ out, it.IsPlausibleIndirectOutput out → P out) :
18+
Iter (α := Types.Attach α Id P) { out : β // P out } :=
19+
(it.toIterM.attachWith P ?h).toIter
20+
where finally
21+
case h =>
1922
simp only [← isPlausibleIndirectOutput_iff_isPlausibleIndirectOutput_toIterM]
2023
exact h
21-
((it.toIterM.attachWith P h').toIter : Iter { out : β // P out })
2224

2325
end Std.Iterators

src/Init/Data/Iterators/Combinators/Monadic/Attach.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ instance {α β : Type w} {m : Type w → Type w'} [Monad m]
118118
end Types
119119

120120
/--
121-
“Attaches” individual proofs to an iterator of values that satisfy a predicate `P`, returning a list
122-
of iterators in the corresponding subtype `{ x // P x }`.
121+
“Attaches” individual proofs to an iterator of values that satisfy a predicate `P`, returning an
122+
iterator with values in the corresponding subtype `{ x // P x }`.
123123
124124
**Termination properties:**
125125

src/Init/Data/Iterators/ToIterator.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ converted into iterators.
1515

1616
open Std.Iterators
1717

18-
namespace Std.Slice
18+
namespace Std.Iterators
1919

2020
/--
2121
This typeclass provides an iterator for the given element `x : γ`. Usually, instances are provided
@@ -107,4 +107,4 @@ instance {x : γ} {State : Type w} {iter}
107107
IteratorSizePartial (α := i.State) m :=
108108
inferInstanceAs <| IteratorSizePartial (α := State) m
109109

110-
end Std.Slice
110+
end Std.Iterators

src/Init/Data/Slice/Array.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This module provides slice notation for array slices (a.k.a. `Subarray`) and imp
1919
for those slices.
2020
-/
2121

22-
open Std Slice PRange
22+
open Std Slice PRange Iterators
2323

2424
instance {shape} {α : Type u} [ClosedOpenIntersection shape Nat] :
2525
Sliceable shape (Array α) Nat (Subarray α) where

src/Init/Data/Slice/Operations.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def Internal.iter (s : Slice γ) [ToIterator s Id β] :=
2929
/--
3030
Returns the number of elements with distinct indices in the given slice.
3131
32-
Example: `#[1, 1, 1][0...2] = 2`.
32+
Example: `#[1, 1, 1][0...2].size = 2`.
3333
-/
3434
@[always_inline, inline]
3535
def size (s : Slice g) [ToIterator s Id β] [Iterator (ToIterator.State s Id) Id β]

src/Std/Data/Iterators/Producers/Slice.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Init.Data.Slice.Operations
1212
This module provides iterators over slices from `Std.Slice` via `Std.Slice.iter`.
1313
-/
1414

15-
open Std.Slice
15+
open Std Slice Iterators
1616

1717
/--
1818
Returns an iterator over the given slice. This iterator will emit the elements of the slice

tests/lean/run/slice.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ example : #[1, 2, 3][1...=1].toList = [2] := by native_decide
2727
example : #[1, 2, 3][1...<10].size = 2 := by native_decide
2828

2929
example : (#[1, 2, 3][1...*].take 1).toList = [2] := by native_decide
30+
31+
example : #[1, 1, 1][0...2].size = 2 := by native_decide

0 commit comments

Comments
 (0)