Files
lean4/tests/elab/do_eqv.lean
Garmelon 08eb78a5b2 chore: switch to new test/bench suite (#12590)
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.
2026-02-25 13:51:53 +00:00

58 lines
1.7 KiB
Lean4
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
theorem byCases_Bool_bind [Monad m] (x : m Bool) (f g : Bool m β) (isTrue : f true = g true) (isFalse : f false = g false) : (x >>= f) = (x >>= g) := by
have : f = g := by
funext b; cases b <;> assumption
rw [this]
theorem eq_findM [Monad m] [LawfulMonad m] (p : α m Bool) (xs : List α) :
(do for x in xs do
let b p x
if b then
return some x
return none)
=
xs.findM? p := by
induction xs with simp [List.findM?]
| cons x xs ih =>
rw [ ih]; simp
apply byCases_Bool_bind <;> simp
theorem eq_findSomeM_findM [Monad m] [LawfulMonad m] (p : α m Bool) (xss : List (List α)) :
(do for xs in xss do
for x in xs do
let b p x
if b then
return some x
return none)
=
xss.findSomeM? (fun xs => xs.findM? p) := by
induction xss with simp [List.findSomeM?]
| cons xs xss ih =>
rw [ ih, eq_findM]
induction xs with simp
| cons x xs ih =>
apply byCases_Bool_bind <;> simp [ih]
theorem eq_findSomeM_findM' [Monad m] [LawfulMonad m] (p : α m Bool) (xss : List (List α)) :
(do for xs in xss do
for x in xs do
let b p x
if b then
return some x
return none)
=
xss.findSomeM? (fun xs => xs.findM? p) := by
induction xss <;> simp [List.findSomeM?]
rename List α => xs
rename _ = _ => ih
rw [ ih, eq_findM]
induction xs <;> simp
rename _ = _ => ih
apply byCases_Bool_bind <;> simp [ih]
theorem z_add (x : Nat) : 0 + x = x := by
induction x
rfl
rename _ = _ => ih
show Nat.succ (0 + _) = _
rw [ih]