mirror of
https://github.com/leanprover/lean4.git
synced 2026-03-17 18:34:06 +00:00
This PR sets up the new integrated test/bench suite. It then migrates all benchmarks and some related tests to the new suite. There's also some documentation and some linting. For now, a lot of the old tests are left alone so this PR doesn't become even larger than it already is. Eventually, all tests should be migrated to the new suite though so there isn't a confusing mix of two systems.
25 lines
858 B
Lean4
25 lines
858 B
Lean4
def filter (p : α → Prop) [DecidablePred p] (xs : List α) : List α :=
|
||
match xs with
|
||
| [] => []
|
||
| x :: xs' => if p x then x :: filter p xs' else filter p xs'
|
||
|
||
attribute [simp] filter
|
||
|
||
set_option pp.explicit true
|
||
|
||
/--
|
||
info: filter.eq_2.{u_1} {α : Type u_1} (p : α → Prop) [@DecidablePred α p] (x : α) (xs' : List α) :
|
||
@Eq (List α) (@filter α p inst✝ (@List.cons α x xs'))
|
||
(@ite (List α) (p x) (inst✝ x) (@List.cons α x (@filter α p inst✝ xs')) (@filter α p inst✝ xs'))
|
||
-/
|
||
#guard_msgs in
|
||
#check filter.eq_2 -- We should not have terms of the form `@filter α p (fun x => inst✝ x) xs'`
|
||
|
||
|
||
def filter_length (p : α → Prop) [DecidablePred p] : (filter p xs).length ≤ xs.length := by
|
||
induction xs with
|
||
| nil => simp [filter]
|
||
| cons x xs ih =>
|
||
simp only [filter]
|
||
split <;> simp only [List.length] <;> omega
|