2015-05-30 23:44:26 +00:00
|
|
|
open nat
|
|
|
|
|
|
|
|
inductive tree (A : Type) :=
|
|
|
|
leaf : A → tree A,
|
|
|
|
node : tree A → tree A → tree A
|
|
|
|
|
|
|
|
check tree.node
|
|
|
|
|
2015-10-13 22:39:03 +00:00
|
|
|
definition size {A : Type} (t : tree A) : nat :=
|
2015-05-30 23:44:26 +00:00
|
|
|
tree.rec (λ a, 1) (λ t₁ t₂ n₁ n₂, n₁ + n₂) t
|
|
|
|
|
|
|
|
check size
|
|
|
|
|
|
|
|
eval size (tree.node (tree.node (tree.leaf 0) (tree.leaf 1))
|
|
|
|
(tree.leaf 0))
|