src/HOL/Univ.thy
author nipkow
Mon Mar 04 14:37:33 1996 +0100 (1996-03-04)
changeset 1531 e5eb247ad13c
parent 1475 7f5a4cd08209
child 1562 e98c7f6165c9
permissions -rw-r--r--
Added a constant UNIV == {x.True}
Added many new rewrite rules for sets.
Moved LEAST into Nat.
Added cardinality to Finite.
     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 Move LEAST to Nat.thy???  Could it be defined for all types 'a::ord?
     7 
     8 Declares the type 'a node, a subtype of (nat=>nat) * ('a+nat)
     9 
    10 Defines "Cartesian Product" and "Disjoint Sum" as set operations.
    11 Could <*> be generalized to a general summation (Sigma)?
    12 *)
    13 
    14 Univ = Arith + Sum +
    15 
    16 (** lists, trees will be sets of nodes **)
    17 
    18 typedef (Node)
    19   'a node = "{p. EX f x k. p = (f::nat=>nat, x::'a+nat) & f(k)=0}"
    20 
    21 types
    22   'a item = 'a node set
    23 
    24 consts
    25   apfst     :: "['a=>'c, 'a*'b] => 'c*'b"
    26   Push      :: [nat, nat=>nat] => (nat=>nat)
    27 
    28   Push_Node :: [nat, 'a node] => 'a node
    29   ndepth    :: 'a node => nat
    30 
    31   Atom      :: "('a+nat) => 'a item"
    32   Leaf      :: 'a => 'a item
    33   Numb      :: nat => 'a item
    34   "$"       :: ['a item, 'a item]=> 'a item   (infixr 60)
    35   In0,In1   :: 'a item => 'a item
    36 
    37   ntrunc    :: [nat, 'a item] => 'a item
    38 
    39   "<*>"  :: ['a item set, 'a item set]=> 'a item set (infixr 80)
    40   "<+>"  :: ['a item set, 'a item set]=> 'a item set (infixr 70)
    41 
    42   Split  :: [['a item, 'a item]=>'b, 'a item] => 'b
    43   Case   :: [['a item]=>'b, ['a item]=>'b, 'a item] => 'b
    44 
    45   diag   :: "'a set => ('a * 'a)set"
    46   "<**>" :: "[('a item * 'a item)set, ('a item * 'a item)set] 
    47            => ('a item * 'a item)set" (infixr 80)
    48   "<++>" :: "[('a item * 'a item)set, ('a item * 'a item)set] 
    49            => ('a item * 'a item)set" (infixr 70)
    50 
    51 defs
    52 
    53   Push_Node_def  "Push_Node == (%n x. Abs_Node (apfst (Push n) (Rep_Node x)))"
    54 
    55   (*crude "lists" of nats -- needed for the constructions*)
    56   apfst_def  "apfst == (%f (x,y). (f(x),y))"
    57   Push_def   "Push == (%b h. nat_case (Suc b) h)"
    58 
    59   (** operations on S-expressions -- sets of nodes **)
    60 
    61   (*S-expression constructors*)
    62   Atom_def   "Atom == (%x. {Abs_Node((%k.0, x))})"
    63   Scons_def  "M$N == (Push_Node(0) `` M) Un (Push_Node(Suc(0)) `` N)"
    64 
    65   (*Leaf nodes, with arbitrary or nat labels*)
    66   Leaf_def   "Leaf == Atom o Inl"
    67   Numb_def   "Numb == Atom o Inr"
    68 
    69   (*Injections of the "disjoint sum"*)
    70   In0_def    "In0(M) == Numb(0) $ M"
    71   In1_def    "In1(M) == Numb(Suc(0)) $ M"
    72 
    73   (*the set of nodes with depth less than k*)
    74   ndepth_def "ndepth(n) == (%(f,x). LEAST k. f(k)=0) (Rep_Node n)"
    75   ntrunc_def "ntrunc k N == {n. n:N & ndepth(n)<k}"
    76 
    77   (*products and sums for the "universe"*)
    78   uprod_def  "A<*>B == UN x:A. UN y:B. { (x$y) }"
    79   usum_def   "A<+>B == In0``A Un In1``B"
    80 
    81   (*the corresponding eliminators*)
    82   Split_def  "Split c M == @u. ? x y. M = x$y & u = c x y"
    83 
    84   Case_def   "Case c d M == @u.  (? x . M = In0(x) & u = c(x)) 
    85                               | (? y . M = In1(y) & u = d(y))"
    86 
    87 
    88   (** diagonal sets and equality for the "universe" **)
    89 
    90   diag_def   "diag(A) == UN x:A. {(x,x)}"
    91 
    92   dprod_def  "r<**>s == UN (x,x'):r. UN (y,y'):s. {(x$y,x'$y')}"
    93 
    94   dsum_def   "r<++>s == (UN (x,x'):r. {(In0(x),In0(x'))}) Un 
    95                        (UN (y,y'):s. {(In1(y),In1(y'))})"
    96 
    97 end