Skip to content

Commit 2356f65

Browse files
committed
Use termination infrastructure
1 parent 32b1a99 commit 2356f65

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Init/Data/String/Pattern/String.lean

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ prelude
99
public import Init.Data.String.Pattern.Basic
1010
public import Init.Data.Iterators.Internal.Termination
1111
public import Init.Data.Iterators.Consumers.Monadic.Loop
12+
import Init.Data.String.Termination
1213

1314
set_option doc.verso true
1415

@@ -152,8 +153,8 @@ instance (s : Slice) : Std.Iterators.Iterator (ForwardSliceSearcher s) Id (Searc
152153
| .atEnd => pure (.deflate ⟨.done, by simp⟩)
153154

154155
private def toOption : ForwardSliceSearcher s → Option (Nat × Nat)
155-
| .emptyBefore pos => some (s.utf8ByteSize - pos.offset.byteIdx, 1)
156-
| .emptyAt pos _ => some (s.utf8ByteSize - pos.offset.byteIdx, 0)
156+
| .emptyBefore pos => some (pos.remainingBytes, 1)
157+
| .emptyAt pos _ => some (pos.remainingBytes, 0)
157158
| .proper _ _ sp _ => some (s.utf8ByteSize - sp.byteIdx, 0)
158159
| .atEnd => none
159160

@@ -179,12 +180,10 @@ private def finitenessRelation :
179180
| .emptyBefore pos =>
180181
rintro (⟨h, h'⟩|h') <;> simp [h', ForwardSliceSearcher.toOption, Option.lt, Prod.lex_def]
181182
| .emptyAt pos h =>
182-
simp
183+
simp only [forall_exists_index, and_imp]
183184
intro x hx h
184-
have := x.isValidForSlice.le_utf8ByteSize
185-
simp [h, ForwardSliceSearcher.toOption, Option.lt, Prod.lex_def, Slice.Pos.lt_iff,
186-
Pos.Raw.lt_iff] at ⊢ hx
187-
omega
185+
simpa [h, ForwardSliceSearcher.toOption, Option.lt, Prod.lex_def,
186+
← Pos.lt_iff_remainingBytes_lt]
188187
| .proper needle table stackPos needlePos =>
189188
simp only [exists_and_left]
190189
rintro (⟨newStackPos, h₁, h₂, ⟨x, hx⟩⟩|h)

0 commit comments

Comments
 (0)