Skip to content

Commit e55175d

Browse files
committed
seekIdx? -> atIdxSlow?
1 parent dbc7c90 commit e55175d

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/Std/Data/Iterators/Consumers/Access.lean

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ before emitting `n` values.
1515
1616
This function requires a `Productive` instance proving that the iterator will always emit a value
1717
after a finite number of skips. If the iterator is not productive or such an instance is not
18-
available, consider using `it.allowNontermination.seekIdx?` instead of `it.seekIdx?`. However, it is
19-
not possible to formally verify the behavior of the partial variant.
18+
available, consider using `it.allowNontermination.atIdxSlow?` instead of `it.atIdxSlow?`. However,
19+
it is not possible to formally verify the behavior of the partial variant.
2020
-/
2121
@[specialize]
22-
def Iter.seekIdx? {α β} [Iterator α Id β] [Productive α Id]
22+
def Iter.atIdxSlow? {α β} [Iterator α Id β] [Productive α Id]
2323
(n : Nat) (it : Iter (α := α) β) : Option β :=
2424
match it.step with
2525
| .yield it' out _ =>
2626
match n with
2727
| 0 => some out
28-
| k + 1 => it'.seekIdx? k
29-
| .skip it' _ => it'.seekIdx? n
28+
| k + 1 => it'.atIdxSlow? k
29+
| .skip it' _ => it'.atIdxSlow? n
3030
| .done _ => none
3131
termination_by (n, it.finitelyManySkips)
3232

@@ -36,17 +36,17 @@ returns the `n`-th emitted value, or `none` if `it` finished
3636
before emitting `n` values.
3737
3838
This is a partial, potentially nonterminating, function. It is not possible to formally verify
39-
its behavior. If the iterator has a `Productive` instance, consider using `Iter.seekIdx?` instead.
39+
its behavior. If the iterator has a `Productive` instance, consider using `Iter.atIdxSlow?` instead.
4040
-/
4141
@[specialize]
42-
partial def Iter.Partial.seekIdx? {α β} [Iterator α Id β] [Monad Id]
42+
partial def Iter.Partial.atIdxSlow? {α β} [Iterator α Id β] [Monad Id]
4343
(n : Nat) (it : Iter.Partial (α := α) β) : Option β := do
4444
match it.it.step with
4545
| .yield it' out _ =>
4646
match n with
4747
| 0 => some out
48-
| k + 1 => (⟨it'⟩ : Iter.Partial (α := α) β).seekIdx? k
49-
| .skip it' _ => (⟨it'⟩ : Iter.Partial (α := α) β).seekIdx? n
48+
| k + 1 => (⟨it'⟩ : Iter.Partial (α := α) β).atIdxSlow? k
49+
| .skip it' _ => (⟨it'⟩ : Iter.Partial (α := α) β).atIdxSlow? n
5050
| .done _ => none
5151

5252
end Std.Iterators

src/Std/Data/Iterators/Lemmas/Consumers/Collect.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,24 @@ theorem Iter.toListRev_eq_match_step {α β} [Iterator α Id β] [Finite α Id]
8686
generalize it.toIterM.step = step
8787
cases step using PlausibleIterStep.casesOn <;> simp
8888

89-
theorem Iter.getElem?_toList_eq_seekIdx? {α β}
89+
theorem Iter.getElem?_toList_eq_atIdxSlow? {α β}
9090
[Iterator α Id β] [Finite α Id] [IteratorCollect α Id] [LawfulIteratorCollect α Id]
9191
{it : Iter (α := α) β} {k : Nat} :
92-
it.toList[k]? = it.seekIdx? k := by
92+
it.toList[k]? = it.atIdxSlow? k := by
9393
induction it using Iter.inductSteps generalizing k with | step it ihy ihs =>
94-
rw [toList_eq_match_step, seekIdx?]
94+
rw [toList_eq_match_step, atIdxSlow?]
9595
obtain ⟨step, h⟩ := it.step
9696
cases step
9797
· cases k <;> simp [ihy h]
9898
· simp [ihs h]
9999
· simp
100100

101-
theorem Iter.toList_eq_of_seekIdx?_eq {α₁ α₂ β}
101+
theorem Iter.toList_eq_of_atIdxSlow?_eq {α₁ α₂ β}
102102
[Iterator α₁ Id β] [Finite α₁ Id] [IteratorCollect α₁ Id] [LawfulIteratorCollect α₁ Id]
103103
[Iterator α₂ Id β] [Finite α₂ Id] [IteratorCollect α₂ Id] [LawfulIteratorCollect α₂ Id]
104104
{it₁ : Iter (α := α₁) β} {it₂ : Iter (α := α₂) β}
105-
(h : ∀ k, it₁.seekIdx? k = it₂.seekIdx? k) :
105+
(h : ∀ k, it₁.atIdxSlow? k = it₂.atIdxSlow? k) :
106106
it₁.toList = it₂.toList := by
107-
ext; simp [getElem?_toList_eq_seekIdx?, h]
107+
ext; simp [getElem?_toList_eq_atIdxSlow?, h]
108108

109109
end Std.Iterators

0 commit comments

Comments
 (0)