1478
|
1 |
(* Title: ZF/ex/BT.thy
|
515
|
2 |
ID: $Id$
|
1478
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
515
|
4 |
Copyright 1992 University of Cambridge
|
|
5 |
|
|
6 |
Binary trees
|
|
7 |
*)
|
|
8 |
|
6112
|
9 |
BT = Main +
|
|
10 |
consts
|
|
11 |
bt :: i=>i
|
|
12 |
|
|
13 |
datatype
|
|
14 |
"bt(A)" = Lf | Br ("a: A", "t1: bt(A)", "t2: bt(A)")
|
|
15 |
|
515
|
16 |
consts
|
1478
|
17 |
n_nodes :: i=>i
|
|
18 |
n_leaves :: i=>i
|
|
19 |
bt_reflect :: i=>i
|
515
|
20 |
|
6046
|
21 |
primrec
|
|
22 |
"n_nodes(Lf) = 0"
|
|
23 |
"n_nodes(Br(a,l,r)) = succ(n_nodes(l) #+ n_nodes(r))"
|
515
|
24 |
|
6046
|
25 |
primrec
|
|
26 |
"n_leaves(Lf) = 1"
|
|
27 |
"n_leaves(Br(a,l,r)) = n_leaves(l) #+ n_leaves(r)"
|
|
28 |
|
|
29 |
primrec
|
|
30 |
"bt_reflect(Lf) = Lf"
|
|
31 |
"bt_reflect(Br(a,l,r)) = Br(a, bt_reflect(r), bt_reflect(l))"
|
515
|
32 |
|
|
33 |
end
|