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
982 B
Text
25 lines
982 B
Text
example : (@OfNat.ofNat (Fin (1 + 1)) 0 Fin.instOfNat) = (0 : Fin 2) := by
|
||
grind
|
||
|
||
example {C : Type} (h : Fin 2 → C) :
|
||
h (@OfNat.ofNat (Fin (1 + 1)) 0 Fin.instOfNat) = h 0 := by
|
||
grind -- should work too
|
||
|
||
namespace Fin
|
||
|
||
protected def sum [Zero α] [Add α] (x : Fin n → α) : α :=
|
||
foldr n (x · + ·) 0
|
||
|
||
theorem sum_succ [Zero α] [Add α] (x : Fin (n + 1) → α) : Fin.sum x = x 0 + Fin.sum (fun i => x i.succ) := sorry
|
||
|
||
protected def count (p : Fin n → Bool) : Nat :=
|
||
Fin.sum (Bool.toNat ∘ p)
|
||
|
||
theorem count_succ (p : Fin (n + 1) → Bool) : Fin.count p =
|
||
if p 0 then Fin.count (fun i => p i.succ) + 1 else Fin.count (fun i => p i.succ) := by
|
||
-- This previously failed, reporting a false proposition `0 = 0`, which expanded to:
|
||
-- `@Eq.{1} Nat (@OfNat.ofNat.{0} Nat (nat_lit 0) (instOfNatNat (nat_lit 0))) (nat_lit 0)`
|
||
-- This was fixed in https://github.com/leanprover/lean4/pull/10323
|
||
grind [Fin.count, Function.comp_def, Fin.sum_succ]
|
||
|
||
end Fin
|