src/HOL/Univ.thy
changeset 923 ff1574a81019
child 972 e61b058d58d2
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/Univ.thy	Fri Mar 03 12:02:25 1995 +0100
     1.3 @@ -0,0 +1,103 @@
     1.4 +(*  Title:      HOL/Univ.thy
     1.5 +    ID:         $Id$
     1.6 +    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     1.7 +    Copyright   1993  University of Cambridge
     1.8 +
     1.9 +Move LEAST to Nat.thy???  Could it be defined for all types 'a::ord?
    1.10 +
    1.11 +Declares the type 'a node, a subtype of (nat=>nat) * ('a+nat)
    1.12 +
    1.13 +Defines "Cartesian Product" and "Disjoint Sum" as set operations.
    1.14 +Could <*> be generalized to a general summation (Sigma)?
    1.15 +*)
    1.16 +
    1.17 +Univ = Arith + Sum +
    1.18 +
    1.19 +(** lists, trees will be sets of nodes **)
    1.20 +
    1.21 +subtype (Node)
    1.22 +  'a node = "{p. EX f x k. p = <f::nat=>nat, x::'a+nat> & f(k)=0}"
    1.23 +
    1.24 +types
    1.25 +  'a item = "'a node set"
    1.26 +
    1.27 +consts
    1.28 +  Least     :: "(nat=>bool) => nat"    (binder "LEAST " 10)
    1.29 +
    1.30 +  apfst     :: "['a=>'c, 'a*'b] => 'c*'b"
    1.31 +  Push      :: "[nat, nat=>nat] => (nat=>nat)"
    1.32 +
    1.33 +  Push_Node :: "[nat, 'a node] => 'a node"
    1.34 +  ndepth    :: "'a node => nat"
    1.35 +
    1.36 +  Atom      :: "('a+nat) => 'a item"
    1.37 +  Leaf      :: "'a => 'a item"
    1.38 +  Numb      :: "nat => 'a item"
    1.39 +  "$"       :: "['a item, 'a item]=> 'a item"   (infixr 60)
    1.40 +  In0,In1   :: "'a item => 'a item"
    1.41 +
    1.42 +  ntrunc    :: "[nat, 'a item] => 'a item"
    1.43 +
    1.44 +  "<*>"  :: "['a item set, 'a item set]=> 'a item set" (infixr 80)
    1.45 +  "<+>"  :: "['a item set, 'a item set]=> 'a item set" (infixr 70)
    1.46 +
    1.47 +  Split  :: "[['a item, 'a item]=>'b, 'a item] => 'b"
    1.48 +  Case   :: "[['a item]=>'b, ['a item]=>'b, 'a item] => 'b"
    1.49 +
    1.50 +  diag   :: "'a set => ('a * 'a)set"
    1.51 +  "<**>" :: "[('a item * 'a item)set, ('a item * 'a item)set] \
    1.52 +\           => ('a item * 'a item)set" (infixr 80)
    1.53 +  "<++>" :: "[('a item * 'a item)set, ('a item * 'a item)set] \
    1.54 +\           => ('a item * 'a item)set" (infixr 70)
    1.55 +
    1.56 +defs
    1.57 +
    1.58 +  (*least number operator*)
    1.59 +  Least_def      "Least(P) == @k. P(k) & (ALL j. j<k --> ~P(j))"
    1.60 +
    1.61 +  Push_Node_def  "Push_Node == (%n x. Abs_Node (apfst (Push n) (Rep_Node x)))"
    1.62 +
    1.63 +  (*crude "lists" of nats -- needed for the constructions*)
    1.64 +  apfst_def  "apfst == (%f. split(%x y. <f(x),y>))"
    1.65 +  Push_def   "Push == (%b h. nat_case (Suc b) h)"
    1.66 +
    1.67 +  (** operations on S-expressions -- sets of nodes **)
    1.68 +
    1.69 +  (*S-expression constructors*)
    1.70 +  Atom_def   "Atom == (%x. {Abs_Node(<%k.0, x>)})"
    1.71 +  Scons_def  "M$N == (Push_Node(0) `` M) Un (Push_Node(Suc(0)) `` N)"
    1.72 +
    1.73 +  (*Leaf nodes, with arbitrary or nat labels*)
    1.74 +  Leaf_def   "Leaf == Atom o Inl"
    1.75 +  Numb_def   "Numb == Atom o Inr"
    1.76 +
    1.77 +  (*Injections of the "disjoint sum"*)
    1.78 +  In0_def    "In0(M) == Numb(0) $ M"
    1.79 +  In1_def    "In1(M) == Numb(Suc(0)) $ M"
    1.80 +
    1.81 +  (*the set of nodes with depth less than k*)
    1.82 +  ndepth_def "ndepth(n) == split (%f x. LEAST k. f(k)=0) (Rep_Node n)"
    1.83 +  ntrunc_def "ntrunc k N == {n. n:N & ndepth(n)<k}"
    1.84 +
    1.85 +  (*products and sums for the "universe"*)
    1.86 +  uprod_def  "A<*>B == UN x:A. UN y:B. { (x$y) }"
    1.87 +  usum_def   "A<+>B == In0``A Un In1``B"
    1.88 +
    1.89 +  (*the corresponding eliminators*)
    1.90 +  Split_def  "Split c M == @u. ? x y. M = x$y & u = c x y"
    1.91 +
    1.92 +  Case_def   "Case c d M == @u.  (? x . M = In0(x) & u = c(x)) \
    1.93 +\                              | (? y . M = In1(y) & u = d(y))"
    1.94 +
    1.95 +
    1.96 +  (** diagonal sets and equality for the "universe" **)
    1.97 +
    1.98 +  diag_def   "diag(A) == UN x:A. {<x,x>}"
    1.99 +
   1.100 +  dprod_def  "r<**>s == UN u:r. split (%x x'. \
   1.101 +\                       UN v:s. split (%y y'. {<x$y,x'$y'>}) v) u"
   1.102 +
   1.103 +  dsum_def   "r<++>s == (UN u:r. split (%x x'. {<In0(x),In0(x')>}) u) Un \
   1.104 +\                       (UN v:s. split (%y y'. {<In1(y),In1(y')>}) v)"
   1.105 +
   1.106 +end