src/HOL/Datatype_Universe.thy
author oheimb
Wed Jan 31 10:15:55 2001 +0100 (2001-01-31)
changeset 11008 f7333f055ef6
parent 10832 e33b47e4246d
child 11451 8abfb4f7bd02
permissions -rw-r--r--
improved theory reference in comment
nipkow@10213
     1
(*  Title:      HOL/Datatype_Universe.thy
nipkow@10213
     2
    ID:         $Id$
nipkow@10213
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
nipkow@10213
     4
    Copyright   1993  University of Cambridge
nipkow@10213
     5
nipkow@10213
     6
Declares the type ('a, 'b) node, a subtype of (nat=>'b+nat) * ('a+nat)
nipkow@10213
     7
nipkow@10213
     8
Defines "Cartesian Product" and "Disjoint Sum" as set operations.
nipkow@10213
     9
Could <*> be generalized to a general summation (Sigma)?
nipkow@10213
    10
*)
nipkow@10213
    11
nipkow@10214
    12
Datatype_Universe = NatArith + Sum_Type +
nipkow@10213
    13
nipkow@10213
    14
nipkow@10213
    15
(** lists, trees will be sets of nodes **)
nipkow@10213
    16
nipkow@10213
    17
typedef (Node)
nipkow@10213
    18
  ('a, 'b) node = "{p. EX f x k. p = (f::nat=>'b+nat, x::'a+nat) & f k = Inr 0}"
nipkow@10213
    19
nipkow@10213
    20
types
nipkow@10213
    21
  'a item = ('a, unit) node set
nipkow@10213
    22
  ('a, 'b) dtree = ('a, 'b) node set
nipkow@10213
    23
nipkow@10213
    24
consts
nipkow@10213
    25
  apfst     :: "['a=>'c, 'a*'b] => 'c*'b"
nipkow@10213
    26
  Push      :: "[('b + nat), nat => ('b + nat)] => (nat => ('b + nat))"
nipkow@10213
    27
nipkow@10213
    28
  Push_Node :: "[('b + nat), ('a, 'b) node] => ('a, 'b) node"
nipkow@10213
    29
  ndepth    :: ('a, 'b) node => nat
nipkow@10213
    30
nipkow@10213
    31
  Atom      :: "('a + nat) => ('a, 'b) dtree"
nipkow@10213
    32
  Leaf      :: 'a => ('a, 'b) dtree
nipkow@10213
    33
  Numb      :: nat => ('a, 'b) dtree
nipkow@10213
    34
  Scons     :: [('a, 'b) dtree, ('a, 'b) dtree] => ('a, 'b) dtree
nipkow@10213
    35
  In0,In1   :: ('a, 'b) dtree => ('a, 'b) dtree
nipkow@10213
    36
nipkow@10213
    37
  Lim       :: ('b => ('a, 'b) dtree) => ('a, 'b) dtree
nipkow@10213
    38
  Funs      :: "'u set => ('t => 'u) set"
nipkow@10213
    39
nipkow@10213
    40
  ntrunc    :: [nat, ('a, 'b) dtree] => ('a, 'b) dtree
nipkow@10213
    41
nipkow@10213
    42
  uprod     :: [('a, 'b) dtree set, ('a, 'b) dtree set]=> ('a, 'b) dtree set
nipkow@10213
    43
  usum      :: [('a, 'b) dtree set, ('a, 'b) dtree set]=> ('a, 'b) dtree set
nipkow@10213
    44
nipkow@10213
    45
  Split     :: [[('a, 'b) dtree, ('a, 'b) dtree]=>'c, ('a, 'b) dtree] => 'c
nipkow@10213
    46
  Case      :: [[('a, 'b) dtree]=>'c, [('a, 'b) dtree]=>'c, ('a, 'b) dtree] => 'c
nipkow@10213
    47
nipkow@10213
    48
  dprod     :: "[(('a, 'b) dtree * ('a, 'b) dtree)set, (('a, 'b) dtree * ('a, 'b) dtree)set] 
nipkow@10213
    49
                => (('a, 'b) dtree * ('a, 'b) dtree)set"
nipkow@10213
    50
  dsum      :: "[(('a, 'b) dtree * ('a, 'b) dtree)set, (('a, 'b) dtree * ('a, 'b) dtree)set] 
nipkow@10213
    51
                => (('a, 'b) dtree * ('a, 'b) dtree)set"
nipkow@10213
    52
nipkow@10213
    53
nipkow@10213
    54
defs
nipkow@10213
    55
nipkow@10213
    56
  Push_Node_def  "Push_Node == (%n x. Abs_Node (apfst (Push n) (Rep_Node x)))"
nipkow@10213
    57
nipkow@10213
    58
  (*crude "lists" of nats -- needed for the constructions*)
nipkow@10213
    59
  apfst_def  "apfst == (%f (x,y). (f(x),y))"
nipkow@10213
    60
  Push_def   "Push == (%b h. nat_case b h)"
nipkow@10213
    61
nipkow@10213
    62
  (** operations on S-expressions -- sets of nodes **)
nipkow@10213
    63
nipkow@10213
    64
  (*S-expression constructors*)
nipkow@10213
    65
  Atom_def   "Atom == (%x. {Abs_Node((%k. Inr 0, x))})"
nipkow@10832
    66
  Scons_def  "Scons M N == (Push_Node (Inr 1) ` M) Un (Push_Node (Inr 2) ` N)"
nipkow@10213
    67
nipkow@10213
    68
  (*Leaf nodes, with arbitrary or nat labels*)
nipkow@10213
    69
  Leaf_def   "Leaf == Atom o Inl"
nipkow@10213
    70
  Numb_def   "Numb == Atom o Inr"
nipkow@10213
    71
nipkow@10213
    72
  (*Injections of the "disjoint sum"*)
nipkow@10213
    73
  In0_def    "In0(M) == Scons (Numb 0) M"
nipkow@10213
    74
  In1_def    "In1(M) == Scons (Numb 1) M"
nipkow@10213
    75
nipkow@10213
    76
  (*Function spaces*)
nipkow@10832
    77
  Lim_def "Lim f == Union {z. ? x. z = Push_Node (Inl x) ` (f x)}"
nipkow@10213
    78
  Funs_def "Funs S == {f. range f <= S}"
nipkow@10213
    79
nipkow@10213
    80
  (*the set of nodes with depth less than k*)
nipkow@10213
    81
  ndepth_def "ndepth(n) == (%(f,x). LEAST k. f k = Inr 0) (Rep_Node n)"
nipkow@10213
    82
  ntrunc_def "ntrunc k N == {n. n:N & ndepth(n)<k}"
nipkow@10213
    83
nipkow@10213
    84
  (*products and sums for the "universe"*)
nipkow@10213
    85
  uprod_def  "uprod A B == UN x:A. UN y:B. { Scons x y }"
nipkow@10832
    86
  usum_def   "usum A B == In0`A Un In1`B"
nipkow@10213
    87
nipkow@10213
    88
  (*the corresponding eliminators*)
nipkow@10213
    89
  Split_def  "Split c M == @u. ? x y. M = Scons x y & u = c x y"
nipkow@10213
    90
nipkow@10213
    91
  Case_def   "Case c d M == @u.  (? x . M = In0(x) & u = c(x)) 
nipkow@10213
    92
                               | (? y . M = In1(y) & u = d(y))"
nipkow@10213
    93
nipkow@10213
    94
nipkow@10213
    95
  (** equality for the "universe" **)
nipkow@10213
    96
nipkow@10213
    97
  dprod_def  "dprod r s == UN (x,x'):r. UN (y,y'):s. {(Scons x y, Scons x' y')}"
nipkow@10213
    98
nipkow@10213
    99
  dsum_def   "dsum r s == (UN (x,x'):r. {(In0(x),In0(x'))}) Un 
nipkow@10213
   100
                          (UN (y,y'):s. {(In1(y),In1(y'))})"
nipkow@10213
   101
nipkow@10213
   102
end