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.
61 lines
1.2 KiB
Lean4
61 lines
1.2 KiB
Lean4
namespace Ex1
|
|
|
|
inductive Ty where
|
|
| int
|
|
| bool
|
|
| fn (a ty : Ty)
|
|
|
|
@[reducible] def Ty.interp : Ty → Type
|
|
| int => Int
|
|
| bool => Bool
|
|
| fn a b => a.interp → b.interp
|
|
|
|
def test {a b c : Ty} (f : a.interp → b.interp → c.interp) (x : a.interp) (y : b.interp) : c.interp :=
|
|
f x y
|
|
|
|
def f (a b : Ty.bool.interp) : Ty.bool.interp :=
|
|
test (.==.) a b
|
|
|
|
end Ex1
|
|
|
|
namespace Ex2
|
|
|
|
inductive Ty where
|
|
| int
|
|
| bool
|
|
|
|
@[reducible] def Ty.interp : Ty → Type
|
|
| int => Int
|
|
| bool => Bool
|
|
|
|
def test {a b c : Ty} (f : a.interp → b.interp → c.interp) (x : a.interp) (y : b.interp) : c.interp :=
|
|
f x y
|
|
|
|
def f (a b : Ty.bool.interp) : Ty.bool.interp :=
|
|
test (.==.) a b
|
|
|
|
end Ex2
|
|
|
|
namespace Ex3
|
|
|
|
inductive Ty where
|
|
| int
|
|
| bool
|
|
|
|
@[reducible] def Ty.interp (ty : Ty) : Type :=
|
|
Ty.casesOn (motive := fun _ => Type) ty Int Bool
|
|
|
|
/-
|
|
The discrimination tree module does not perform iota reduction. Thus, it does
|
|
not reduce the definition above, and we cannot synthesize `BEq Ty.bool.interp`.
|
|
We can workaround using `match` as in the ex
|
|
-/
|
|
|
|
def test {a b c : Ty} (f : a.interp → b.interp → c.interp) (x : a.interp) (y : b.interp) : c.interp :=
|
|
f x y
|
|
|
|
def f (a b : Ty.bool.interp) : Ty.bool.interp :=
|
|
test (.==.) a b
|
|
|
|
end Ex3
|