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.
35 lines
1.3 KiB
Text
35 lines
1.3 KiB
Text
set_option warn.sorry false
|
||
namespace Test
|
||
set_option backward.grind.inferPattern false -- Force new pattern inference procedure
|
||
|
||
inductive Vector (α : Type) : Nat → Type where
|
||
| nil : Vector α 0
|
||
| cons (x : α) (xs : Vector α n) : Vector α (n + 1)
|
||
|
||
def Vector.ofList (xs : List α) (h : xs.length = n) : Vector α n :=
|
||
match n, xs with
|
||
| 0, [] => .nil
|
||
| (n + 1), x :: xs => .cons x (.ofList xs (by grind))
|
||
|
||
def Vector.toList (xs : Vector α n) : List α :=
|
||
match xs with
|
||
| .nil => []
|
||
| .cons x xs => x :: xs.toList
|
||
|
||
/-- info: length_toList: [@toList #2 #1 #0] -/
|
||
#guard_msgs (info) in
|
||
@[grind!? ←] theorem Vector.length_toList (xs : Vector α n) : xs.toList.length = n := by sorry
|
||
|
||
def wrapper (f : Nat → Nat → List α → List α) (h : ∀ n m xs, xs.length = n → (f n m xs).length = m) :
|
||
(n m : Nat) → Vector α n → Vector α m :=
|
||
fun n m xs => Vector.ofList (f n m xs.toList) (by grind) -- apply h; apply Vector.length_toList) -- fails here: (by grind)
|
||
|
||
/--
|
||
warning: found discrepancy between old and new `grind` pattern inference procedures, old:
|
||
[@List.length #2 (@toList _ #1 #0)]
|
||
new:
|
||
[@toList #2 #1 #0]
|
||
-/
|
||
#guard_msgs in
|
||
set_option backward.grind.checkInferPatternDiscrepancy true in
|
||
@[grind! ←] theorem Vector.length_toList' (xs : Vector α n) : xs.toList.length = n := by sorry
|