Skip to content

Commit 8978a41

Browse files
committed
Done
1 parent c51c556 commit 8978a41

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

HumanEvalLean/HumanEval161.lean

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module
2+
import all Init.Data.String.Lemmas.Pattern.Find.Pred -- TODO: remove when `nightly-2026-03-06` is out
23

34
def reverseString (s : String) : String :=
45
s.revChars.fold (init := "") fun sofar c => sofar.push c
@@ -32,16 +33,12 @@ theorem toList_reverseString {s : String} : (reverseString s).toList = s.toList.
3233
List.foldl_reverse]
3334
induction s.toList <;> simp_all
3435

35-
@[simp]
36-
theorem String.contains_bool {s : String} {p : Char → Bool} :
37-
s.contains p = s.toList.any p := sorry
38-
3936
theorem toList_solve {s : String} : (solve s).toList =
4037
if s.toList.any Char.isAlpha then
4138
s.toList.map swapCase
4239
else
4340
s.toList.reverse := by
44-
simp only [solve, String.contains_bool, List.any_eq_true]
41+
simp only [solve, String.contains_bool_eq, List.any_eq_true]
4542
rw [apply_ite String.toList, toList_reverseString, String.toList_map]
4643

4744
/-!

HumanEvalLean/HumanEval7.lean

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
module
22

33
def filterBySubstring (strings : Array String) (substring : String) : Array String :=
4+
-- Uses KMP string search!
45
strings.filter (·.contains substring)
56

67
example : filterBySubstring #[] "john" = #[] := by native_decide
78
example : filterBySubstring #["xxx", "asd", "xxy", "john doe", "xxxAAA", "xxx"] "xxx" = #["xxx", "xxxAAA", "xxx"] := by native_decide
89
example : filterBySubstring #["xxx", "asd", "aaaxxy", "john doe", "xxxAAA", "xxx"] "xx" = #["xxx", "aaaxxy", "xxxAAA", "xxx"] := by native_decide
910
example : filterBySubstring #["grunt", "trumpet", "prune", "gruesome"] "run" = #["grunt", "prune"] := by native_decide
1011

11-
@[simp]
12-
theorem String.contains_string_iff_infix {s t : String} : s.contains t ↔ t.toList <:+: s.toList := sorry
13-
1412
open Classical in
1513
theorem filterBySubstring_eq {strings : Array String} {substring : String} :
1614
filterBySubstring strings substring = strings.filter (decide <| substring.toList <:+: ·.toList) := by

lean-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
leanprover/lean4:nightly-2026-03-04
1+
leanprover/lean4:nightly-2026-03-05

0 commit comments

Comments
 (0)