| author | wenzelm | 
| Mon, 12 Jul 1999 22:23:31 +0200 | |
| changeset 6977 | 4781c0673e83 | 
| parent 5978 | fa2c2dd74f8c | 
| child 7014 | 11ee650edcd2 | 
| permissions | -rw-r--r-- | 
| 923 | 1 | (* Title: HOL/Univ.thy | 
| 2 | ID: $Id$ | |
| 3 | Author: Lawrence C Paulson, Cambridge University Computer Laboratory | |
| 4 | Copyright 1993 University of Cambridge | |
| 5 | ||
| 6 | Declares the type 'a node, a subtype of (nat=>nat) * ('a+nat)
 | |
| 7 | ||
| 8 | Defines "Cartesian Product" and "Disjoint Sum" as set operations. | |
| 9 | Could <*> be generalized to a general summation (Sigma)? | |
| 10 | *) | |
| 11 | ||
| 12 | Univ = Arith + Sum + | |
| 13 | ||
| 14 | (** lists, trees will be sets of nodes **) | |
| 15 | ||
| 3947 | 16 | global | 
| 17 | ||
| 1475 | 18 | typedef (Node) | 
| 972 
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
 clasohm parents: 
923diff
changeset | 19 |   'a node = "{p. EX f x k. p = (f::nat=>nat, x::'a+nat) & f(k)=0}"
 | 
| 923 | 20 | |
| 21 | types | |
| 1384 | 22 | 'a item = 'a node set | 
| 923 | 23 | |
| 24 | consts | |
| 25 | apfst :: "['a=>'c, 'a*'b] => 'c*'b" | |
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1151diff
changeset | 26 | Push :: [nat, nat=>nat] => (nat=>nat) | 
| 923 | 27 | |
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1151diff
changeset | 28 | Push_Node :: [nat, 'a node] => 'a node | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1151diff
changeset | 29 | ndepth :: 'a node => nat | 
| 923 | 30 | |
| 31 |   Atom      :: "('a+nat) => 'a item"
 | |
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1151diff
changeset | 32 | Leaf :: 'a => 'a item | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1151diff
changeset | 33 | Numb :: nat => 'a item | 
| 5191 
8ceaa19f7717
Renamed '$' to 'Scons' because of clashes with constants of the same
 berghofe parents: 
3947diff
changeset | 34 | Scons :: ['a item, 'a item]=> 'a item | 
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1151diff
changeset | 35 | In0,In1 :: 'a item => 'a item | 
| 923 | 36 | |
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1151diff
changeset | 37 | ntrunc :: [nat, 'a item] => 'a item | 
| 923 | 38 | |
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1151diff
changeset | 39 | "<*>" :: ['a item set, 'a item set]=> 'a item set (infixr 80) | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1151diff
changeset | 40 | "<+>" :: ['a item set, 'a item set]=> 'a item set (infixr 70) | 
| 923 | 41 | |
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1151diff
changeset | 42 | Split :: [['a item, 'a item]=>'b, 'a item] => 'b | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1151diff
changeset | 43 | Case :: [['a item]=>'b, ['a item]=>'b, 'a item] => 'b | 
| 923 | 44 | |
| 1151 | 45 |   "<**>" :: "[('a item * 'a item)set, ('a item * 'a item)set] 
 | 
| 46 |            => ('a item * 'a item)set" (infixr 80)
 | |
| 47 |   "<++>" :: "[('a item * 'a item)set, ('a item * 'a item)set] 
 | |
| 48 |            => ('a item * 'a item)set" (infixr 70)
 | |
| 923 | 49 | |
| 3947 | 50 | |
| 51 | local | |
| 52 | ||
| 923 | 53 | defs | 
| 54 | ||
| 55 | Push_Node_def "Push_Node == (%n x. Abs_Node (apfst (Push n) (Rep_Node x)))" | |
| 56 | ||
| 57 | (*crude "lists" of nats -- needed for the constructions*) | |
| 1396 | 58 | apfst_def "apfst == (%f (x,y). (f(x),y))" | 
| 923 | 59 | Push_def "Push == (%b h. nat_case (Suc b) h)" | 
| 60 | ||
| 61 | (** operations on S-expressions -- sets of nodes **) | |
| 62 | ||
| 63 | (*S-expression constructors*) | |
| 972 
e61b058d58d2
changed syntax of tuples from <..., ...> to (..., ...)
 clasohm parents: 
923diff
changeset | 64 |   Atom_def   "Atom == (%x. {Abs_Node((%k.0, x))})"
 | 
| 5191 
8ceaa19f7717
Renamed '$' to 'Scons' because of clashes with constants of the same
 berghofe parents: 
3947diff
changeset | 65 | Scons_def "Scons M N == (Push_Node(0) `` M) Un (Push_Node(Suc(0)) `` N)" | 
| 923 | 66 | |
| 67 | (*Leaf nodes, with arbitrary or nat labels*) | |
| 68 | Leaf_def "Leaf == Atom o Inl" | |
| 69 | Numb_def "Numb == Atom o Inr" | |
| 70 | ||
| 71 | (*Injections of the "disjoint sum"*) | |
| 5191 
8ceaa19f7717
Renamed '$' to 'Scons' because of clashes with constants of the same
 berghofe parents: 
3947diff
changeset | 72 | In0_def "In0(M) == Scons (Numb 0) M" | 
| 
8ceaa19f7717
Renamed '$' to 'Scons' because of clashes with constants of the same
 berghofe parents: 
3947diff
changeset | 73 | In1_def "In1(M) == Scons (Numb 1) M" | 
| 923 | 74 | |
| 75 | (*the set of nodes with depth less than k*) | |
| 1068 | 76 | ndepth_def "ndepth(n) == (%(f,x). LEAST k. f(k)=0) (Rep_Node n)" | 
| 923 | 77 |   ntrunc_def "ntrunc k N == {n. n:N & ndepth(n)<k}"
 | 
| 78 | ||
| 79 | (*products and sums for the "universe"*) | |
| 5191 
8ceaa19f7717
Renamed '$' to 'Scons' because of clashes with constants of the same
 berghofe parents: 
3947diff
changeset | 80 |   uprod_def  "A<*>B == UN x:A. UN y:B. { Scons x y }"
 | 
| 923 | 81 | usum_def "A<+>B == In0``A Un In1``B" | 
| 82 | ||
| 83 | (*the corresponding eliminators*) | |
| 5191 
8ceaa19f7717
Renamed '$' to 'Scons' because of clashes with constants of the same
 berghofe parents: 
3947diff
changeset | 84 | Split_def "Split c M == @u. ? x y. M = Scons x y & u = c x y" | 
| 923 | 85 | |
| 1151 | 86 | Case_def "Case c d M == @u. (? x . M = In0(x) & u = c(x)) | 
| 87 | | (? y . M = In1(y) & u = d(y))" | |
| 923 | 88 | |
| 89 | ||
| 5978 
fa2c2dd74f8c
moved diag (diagonal relation) from Univ to Relation
 paulson parents: 
5191diff
changeset | 90 | (** equality for the "universe" **) | 
| 923 | 91 | |
| 5191 
8ceaa19f7717
Renamed '$' to 'Scons' because of clashes with constants of the same
 berghofe parents: 
3947diff
changeset | 92 |   dprod_def  "r<**>s == UN (x,x'):r. UN (y,y'):s. {(Scons x y, Scons x' y')}"
 | 
| 923 | 93 | |
| 1151 | 94 |   dsum_def   "r<++>s == (UN (x,x'):r. {(In0(x),In0(x'))}) Un 
 | 
| 5978 
fa2c2dd74f8c
moved diag (diagonal relation) from Univ to Relation
 paulson parents: 
5191diff
changeset | 95 |                         (UN (y,y'):s. {(In1(y),In1(y'))})"
 | 
| 923 | 96 | |
| 97 | end |