src/HOL/Univ.thy
author berghofe
Fri Jul 24 13:39:47 1998 +0200 (1998-07-24)
changeset 5191 8ceaa19f7717
parent 3947 eb707467f8c5
child 5978 fa2c2dd74f8c
permissions -rw-r--r--
Renamed '$' to 'Scons' because of clashes with constants of the same
name in theories using datatypes.
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
clasohm@923
     6
Declares the type 'a node, a subtype of (nat=>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
clasohm@923
    14
(** lists, trees will be sets of nodes **)
clasohm@923
    15
wenzelm@3947
    16
global
wenzelm@3947
    17
clasohm@1475
    18
typedef (Node)
clasohm@972
    19
  'a node = "{p. EX f x k. p = (f::nat=>nat, x::'a+nat) & f(k)=0}"
clasohm@923
    20
clasohm@923
    21
types
clasohm@1384
    22
  'a item = 'a node set
clasohm@923
    23
clasohm@923
    24
consts
clasohm@923
    25
  apfst     :: "['a=>'c, 'a*'b] => 'c*'b"
clasohm@1370
    26
  Push      :: [nat, nat=>nat] => (nat=>nat)
clasohm@923
    27
clasohm@1370
    28
  Push_Node :: [nat, 'a node] => 'a node
clasohm@1370
    29
  ndepth    :: 'a node => nat
clasohm@923
    30
clasohm@923
    31
  Atom      :: "('a+nat) => 'a item"
clasohm@1370
    32
  Leaf      :: 'a => 'a item
clasohm@1370
    33
  Numb      :: nat => 'a item
berghofe@5191
    34
  Scons     :: ['a item, 'a item]=> 'a item
clasohm@1370
    35
  In0,In1   :: 'a item => 'a item
clasohm@923
    36
clasohm@1370
    37
  ntrunc    :: [nat, 'a item] => 'a item
clasohm@923
    38
clasohm@1370
    39
  "<*>"  :: ['a item set, 'a item set]=> 'a item set (infixr 80)
clasohm@1370
    40
  "<+>"  :: ['a item set, 'a item set]=> 'a item set (infixr 70)
clasohm@923
    41
clasohm@1370
    42
  Split  :: [['a item, 'a item]=>'b, 'a item] => 'b
clasohm@1370
    43
  Case   :: [['a item]=>'b, ['a item]=>'b, 'a item] => 'b
clasohm@923
    44
clasohm@923
    45
  diag   :: "'a set => ('a * 'a)set"
clasohm@1151
    46
  "<**>" :: "[('a item * 'a item)set, ('a item * 'a item)set] 
clasohm@1151
    47
           => ('a item * 'a item)set" (infixr 80)
clasohm@1151
    48
  "<++>" :: "[('a item * 'a item)set, ('a item * 'a item)set] 
clasohm@1151
    49
           => ('a item * 'a item)set" (infixr 70)
clasohm@923
    50
wenzelm@3947
    51
wenzelm@3947
    52
local
wenzelm@3947
    53
clasohm@923
    54
defs
clasohm@923
    55
clasohm@923
    56
  Push_Node_def  "Push_Node == (%n x. Abs_Node (apfst (Push n) (Rep_Node x)))"
clasohm@923
    57
clasohm@923
    58
  (*crude "lists" of nats -- needed for the constructions*)
paulson@1396
    59
  apfst_def  "apfst == (%f (x,y). (f(x),y))"
clasohm@923
    60
  Push_def   "Push == (%b h. nat_case (Suc b) h)"
clasohm@923
    61
clasohm@923
    62
  (** operations on S-expressions -- sets of nodes **)
clasohm@923
    63
clasohm@923
    64
  (*S-expression constructors*)
clasohm@972
    65
  Atom_def   "Atom == (%x. {Abs_Node((%k.0, x))})"
berghofe@5191
    66
  Scons_def  "Scons M N == (Push_Node(0) `` M) Un (Push_Node(Suc(0)) `` N)"
clasohm@923
    67
clasohm@923
    68
  (*Leaf nodes, with arbitrary or nat labels*)
clasohm@923
    69
  Leaf_def   "Leaf == Atom o Inl"
clasohm@923
    70
  Numb_def   "Numb == Atom o Inr"
clasohm@923
    71
clasohm@923
    72
  (*Injections of the "disjoint sum"*)
berghofe@5191
    73
  In0_def    "In0(M) == Scons (Numb 0) M"
berghofe@5191
    74
  In1_def    "In1(M) == Scons (Numb 1) M"
clasohm@923
    75
clasohm@923
    76
  (*the set of nodes with depth less than k*)
nipkow@1068
    77
  ndepth_def "ndepth(n) == (%(f,x). LEAST k. f(k)=0) (Rep_Node n)"
clasohm@923
    78
  ntrunc_def "ntrunc k N == {n. n:N & ndepth(n)<k}"
clasohm@923
    79
clasohm@923
    80
  (*products and sums for the "universe"*)
berghofe@5191
    81
  uprod_def  "A<*>B == UN x:A. UN y:B. { Scons x y }"
clasohm@923
    82
  usum_def   "A<+>B == In0``A Un In1``B"
clasohm@923
    83
clasohm@923
    84
  (*the corresponding eliminators*)
berghofe@5191
    85
  Split_def  "Split c M == @u. ? x y. M = Scons x y & u = c x y"
clasohm@923
    86
clasohm@1151
    87
  Case_def   "Case c d M == @u.  (? x . M = In0(x) & u = c(x)) 
clasohm@1151
    88
                              | (? y . M = In1(y) & u = d(y))"
clasohm@923
    89
clasohm@923
    90
clasohm@923
    91
  (** diagonal sets and equality for the "universe" **)
clasohm@923
    92
clasohm@972
    93
  diag_def   "diag(A) == UN x:A. {(x,x)}"
clasohm@923
    94
berghofe@5191
    95
  dprod_def  "r<**>s == UN (x,x'):r. UN (y,y'):s. {(Scons x y, Scons x' y')}"
clasohm@923
    96
clasohm@1151
    97
  dsum_def   "r<++>s == (UN (x,x'):r. {(In0(x),In0(x'))}) Un 
clasohm@1151
    98
                       (UN (y,y'):s. {(In1(y),In1(y'))})"
clasohm@923
    99
clasohm@923
   100
end