src/ZF/ex/TF.thy
author wenzelm
Sat, 15 Apr 2000 15:00:57 +0200
changeset 8717 20c42415c07d
parent 6112 5e4871c5136b
child 11316 b4e71bd751e4
permissions -rw-r--r--
plain ASCII;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
     1
(*  Title:      ZF/ex/TF.thy
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     2
    ID:         $Id$
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     4
    Copyright   1994  University of Cambridge
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     5
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     6
Trees & forests, a mutually recursive type definition.
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     7
*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     8
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     9
TF = List +
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    10
consts
6112
5e4871c5136b datatype package improvements
paulson
parents: 6046
diff changeset
    11
  tree, forest, tree_forest    :: i=>i
5e4871c5136b datatype package improvements
paulson
parents: 6046
diff changeset
    12
5e4871c5136b datatype package improvements
paulson
parents: 6046
diff changeset
    13
datatype
5e4871c5136b datatype package improvements
paulson
parents: 6046
diff changeset
    14
  "tree(A)"   = Tcons ("a: A",  "f: forest(A)")
5e4871c5136b datatype package improvements
paulson
parents: 6046
diff changeset
    15
and
5e4871c5136b datatype package improvements
paulson
parents: 6046
diff changeset
    16
  "forest(A)" = Fnil  |  Fcons ("t: tree(A)",  "f: forest(A)")
5e4871c5136b datatype package improvements
paulson
parents: 6046
diff changeset
    17
5e4871c5136b datatype package improvements
paulson
parents: 6046
diff changeset
    18
5e4871c5136b datatype package improvements
paulson
parents: 6046
diff changeset
    19
consts
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    20
  map      :: [i=>i, i] => i
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    21
  size     :: i=>i
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    22
  preorder :: i=>i
1401
0c439768f45c removed quotes from consts and syntax sections
clasohm
parents: 1155
diff changeset
    23
  list_of_TF  :: i=>i
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    24
  of_list  :: i=>i
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    25
  reflect  :: i=>i
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    26
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    27
primrec
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    28
  "list_of_TF (Tcons(x,f))  = [Tcons(x,f)]"
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    29
  "list_of_TF (Fnil)        = []"
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    30
  "list_of_TF (Fcons(t,tf)) = Cons (t, list_of_TF(tf))"
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    31
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    32
primrec
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    33
  "of_list([])        = Fnil"
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    34
  "of_list(Cons(t,l)) = Fcons(t, of_list(l))"
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    35
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    36
primrec
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    37
  "map (h, Tcons(x,f))  = Tcons(h(x), map(h,f))"
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    38
  "map (h, Fnil)        = Fnil"
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    39
  "map (h, Fcons(t,tf)) = Fcons (map(h, t), map(h, tf))"
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    40
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    41
primrec
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    42
  "size (Tcons(x,f))  = succ(size(f))"
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    43
  "size (Fnil)        = 0"
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    44
  "size (Fcons(t,tf)) = size(t) #+ size(tf)"
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    45
 
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    46
primrec
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    47
  "preorder (Tcons(x,f))  = Cons(x, preorder(f))"
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    48
  "preorder (Fnil)        = Nil"
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    49
  "preorder (Fcons(t,tf)) = preorder(t) @ preorder(tf)"
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    50
 
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    51
primrec
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    52
  "reflect (Tcons(x,f))  = Tcons(x, reflect(f))"
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    53
  "reflect (Fnil)        = Fnil"
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    54
  "reflect (Fcons(t,tf)) = of_list
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    55
                               (list_of_TF (reflect(tf)) @
2c8a8be36c94 converted to use new primrec section
paulson
parents: 3840
diff changeset
    56
				Cons(reflect(t), Nil))"
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    57
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    58
end