Files
lean4/tests/elab/def7.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

45 lines
1.4 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.
inductive InfTree.{u} (α : Type u)
| leaf : α InfTree α
| node : (Nat InfTree α) InfTree α
open InfTree
def szn.{u} {α : Type u} (n : Nat) : InfTree α InfTree α Nat
| leaf a, t2 => 1
| node c, leaf b => 0
| node c, node d => szn n (c n) (d n)
universe u
theorem ex1 {α : Type u} (n : Nat) (c : Nat InfTree α) (d : Nat InfTree α) : szn n (node c) (node d) = szn n (c n) (d n) :=
rfl
inductive BTree (α : Type u)
| leaf : α BTree α
| node : (Bool Bool BTree α) BTree α
def BTree.sz {α : Type u} : BTree α Nat
| leaf a => 1
| node c => sz (c true true) + sz (c true false) + sz (c false true) + sz (c false false) + 1
theorem ex2 {α : Type u} (c : Bool Bool BTree α) : (BTree.node c).sz = (c true true).sz + (c true false).sz + (c false true).sz + (c false false).sz + 1 :=
rfl
inductive L (α : Type u)
| nil : L α
| cons : (Unit α) (Unit L α) L α
def L.append {α} : L α L α L α
| nil, bs => bs
| cons a as, bs => cons a (fun _ => append (as ()) bs)
theorem L.appendNil {α} : (as : L α) append as nil = as
| nil => rfl
| cons a as =>
show cons a (fun _ => append (as ()) nil) = cons a as from
have ih : append (as ()) nil = as () := appendNil $ as ()
have thunkAux : (fun _ => as ()) = as := funext fun x => by
cases x
exact rfl
by rw [ih, thunkAux]