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