Skip to content
Merged

57 #265

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions HumanEvalLean/HumanEval57.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
module

def monotonic : Unit :=
()
/-! ## Implementation -/

def monotonic (xs : List Int) : Bool :=
xs.Pairwise (· ≤ ·) || xs.Pairwise (· ≥ ·)

/-! ## Tests -/

set_option cbv.warning false

example : monotonic [1, 2, 4, 10] = true := by cbv
example : monotonic [1, 2, 4, 20] = true := by cbv
example : monotonic [1, 20, 4, 10] = false := by cbv
example : monotonic [4, 1, 0, -10] = true := by cbv
example : monotonic [4, 1, 1, 0] = true := by cbv
example : monotonic [1, 2, 3, 2, 5, 60] = false := by cbv
example : monotonic [1, 2, 3, 4, 5, 60] = true := by cbv
example : monotonic [9, 9, 9, 9] = true := by cbv

/-! ## Verification -/

theorem monotonic_iff :
monotonic xs ↔
(∀ (i j : Nat) (hi : i < j) (hj : j < xs.length), xs[i] ≤ xs[j]) ∨
(∀ (i j : Nat) (hi : i < j) (hj : j < xs.length), xs[i] ≥ xs[j]) := by
grind [monotonic, List.pairwise_iff_getElem]

/-!
## Prompt
Expand Down Expand Up @@ -47,4 +70,4 @@ def check(candidate):
assert candidate([9, 9, 9, 9]) == True

```
-/
-/