Skip to content

Commit 0da37e4

Browse files
committed
Done modulo upstreaming
1 parent 80ae114 commit 0da37e4

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

HumanEvalLean/HumanEval15.lean

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module
22
import Std.Data.Iterators.Producers.Range
3+
import Std
34

45
@[inline]
56
def intercalateIter {α : Type} [Std.Iterator α Id String.Slice] [Std.IteratorLoop α Id Id]
@@ -18,8 +19,7 @@ theorem String.intercalate_append_of_ne_nil {l m : List String} {s : String} (hl
1819
induction l with
1920
| nil => simp_all
2021
| cons hd tl ih =>
21-
simp
22-
rw [String.intercalate_cons_of_ne_nil (by simp_all)]
22+
rw [List.cons_append, String.intercalate_cons_of_ne_nil (by simp_all)]
2323
by_cases ht : tl = []
2424
· simp_all
2525
· simp [ih ht, String.intercalate_cons_of_ne_nil ht, String.append_assoc]
@@ -55,12 +55,24 @@ theorem intercalateIter_eq {α : Type} [Std.Iterator α Id String.Slice] [Std.It
5555
rw [← List.cons_append, String.intercalate_append_of_ne_nil (by simp) (by simp),
5656
String.intercalate_singleton]
5757

58+
@[simp]
59+
theorem String.Slice.toNat?_comp_copy : String.toNat? ∘ String.Slice.copy = String.Slice.toNat? := by
60+
ext; simp
61+
62+
/-- Calling `stringSequence` and then splitting the result at space characters and attempting to
63+
parse the components into natural numbers yields the sequence `[some 0, some 1, ..., some n]`. -/
5864
theorem map_ofNat?_stringSequence {n : Nat} :
59-
((stringSequence n).split ' ').toList.map (String.toNat? ∘ String.Slice.copy) =
65+
((stringSequence n).split ' ').toList.map String.Slice.toNat? =
6066
(0...=n).toList.map Option.some := by
61-
simp [stringSequence]
62-
rw [intercalateIter_eq]q
63-
67+
rw [stringSequence, ← String.Slice.toNat?_comp_copy, ← List.map_map, intercalateIter_eq]
68+
erw [String.Slice.toList_split_intercalate]
69+
· rw [Std.Iter.toList_map]
70+
simp
71+
· rw [Std.Iter.toList_map]
72+
simp only [Std.Rcc.toList_iter, List.mem_map, Function.comp_apply, ↓Char.isValue,
73+
forall_exists_index, and_imp, forall_apply_eq_imp_iff₂, String.copy_toSlice, Nat.toList_repr]
74+
intro a ha h
75+
simpa using Nat.isDigit_of_mem_toDigits (by decide) (by decide) h
6476

6577
/-!
6678
## Prompt

0 commit comments

Comments
 (0)