src/ZF/ex/BT.thy
changeset 515 abcc438e7c27
child 753 ec86863e87c8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/ZF/ex/BT.thy	Fri Aug 12 12:28:46 1994 +0200
     1.3 @@ -0,0 +1,29 @@
     1.4 +(*  Title: 	ZF/ex/bt-fn.thy
     1.5 +    ID:         $Id$
     1.6 +    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
     1.7 +    Copyright   1992  University of Cambridge
     1.8 +
     1.9 +Binary trees
    1.10 +*)
    1.11 +
    1.12 +BT = Univ +
    1.13 +consts
    1.14 +    bt_rec    	:: "[i, i, [i,i,i,i,i]=>i] => i"
    1.15 +    n_nodes	:: "i=>i"
    1.16 +    n_leaves   	:: "i=>i"
    1.17 +    bt_reflect 	:: "i=>i"
    1.18 +
    1.19 +    bt 	        :: "i=>i"
    1.20 +
    1.21 +datatype
    1.22 +  "bt(A)" = Lf  |  Br ("a: A",  "t1: bt(A)",  "t2: bt(A)")
    1.23 +  
    1.24 +rules
    1.25 +  bt_rec_def
    1.26 +    "bt_rec(t,c,h) == Vrec(t, %t g.bt_case(c, %x y z. h(x,y,z,g`y,g`z), t))"
    1.27 +
    1.28 +  n_nodes_def	"n_nodes(t) == bt_rec(t,  0,  %x y z r s. succ(r#+s))"
    1.29 +  n_leaves_def	"n_leaves(t) == bt_rec(t,  succ(0),  %x y z r s. r#+s)"
    1.30 +  bt_reflect_def "bt_reflect(t) == bt_rec(t,  Lf,  %x y z r s. Br(x,s,r))"
    1.31 +
    1.32 +end