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.
26 lines
749 B
Lean4
26 lines
749 B
Lean4
theorem modifySize {A : Type u} (as : Array A) (f : A → A) (n : Nat) : (as.modify n f).size = as.size := by
|
|
simp [Array.modify, Array.modifyM]; split <;> simp
|
|
|
|
structure Idx (p : Array String) where
|
|
n : Fin p.size
|
|
|
|
structure Store where
|
|
arr : Array String
|
|
-- integer pointers into `arr`, type-indexed by `arr`
|
|
ids : Array (Idx arr)
|
|
|
|
instance {arr : Array String} {f : String → String} {n : Nat} : Coe (Array (Idx arr)) (Array (Idx (arr.modify n f))) where
|
|
coe xs :=
|
|
xs.map (fun x => Idx.mk ((modifySize arr f n) ▸ x.n))
|
|
|
|
def store1 : Store := {
|
|
arr := #["a", "b", "c", "d", "e"]
|
|
ids := #[⟨2, by decide⟩]
|
|
}
|
|
|
|
def tryCoeStore := {
|
|
store1 with
|
|
-- using a lambda here hangs
|
|
arr := store1.arr.modify 2 (fun _ => "Z")
|
|
}
|