src/HOL/Univ.thy
author clasohm
Fri, 03 Mar 1995 12:02:25 +0100
changeset 923 ff1574a81019
child 972 e61b058d58d2
permissions -rw-r--r--
new version of HOL with curried function application
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     1
(*  Title:      HOL/Univ.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     6
Move LEAST to Nat.thy???  Could it be defined for all types 'a::ord?
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
Declares the type 'a node, a subtype of (nat=>nat) * ('a+nat)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     9
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
Defines "Cartesian Product" and "Disjoint Sum" as set operations.
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    11
Could <*> be generalized to a general summation (Sigma)?
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    12
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
Univ = Arith + Sum +
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
(** lists, trees will be sets of nodes **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
subtype (Node)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
  'a node = "{p. EX f x k. p = <f::nat=>nat, x::'a+nat> & f(k)=0}"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
types
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    22
  'a item = "'a node set"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    23
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    24
consts
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    25
  Least     :: "(nat=>bool) => nat"    (binder "LEAST " 10)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    26
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    27
  apfst     :: "['a=>'c, 'a*'b] => 'c*'b"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    28
  Push      :: "[nat, nat=>nat] => (nat=>nat)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    29
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    30
  Push_Node :: "[nat, 'a node] => 'a node"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    31
  ndepth    :: "'a node => nat"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    32
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    33
  Atom      :: "('a+nat) => 'a item"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    34
  Leaf      :: "'a => 'a item"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    35
  Numb      :: "nat => 'a item"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    36
  "$"       :: "['a item, 'a item]=> 'a item"   (infixr 60)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    37
  In0,In1   :: "'a item => 'a item"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    39
  ntrunc    :: "[nat, 'a item] => 'a item"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    40
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    41
  "<*>"  :: "['a item set, 'a item set]=> 'a item set" (infixr 80)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    42
  "<+>"  :: "['a item set, 'a item set]=> 'a item set" (infixr 70)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    43
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    44
  Split  :: "[['a item, 'a item]=>'b, 'a item] => 'b"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
  Case   :: "[['a item]=>'b, ['a item]=>'b, 'a item] => 'b"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    46
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    47
  diag   :: "'a set => ('a * 'a)set"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    48
  "<**>" :: "[('a item * 'a item)set, ('a item * 'a item)set] \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    49
\           => ('a item * 'a item)set" (infixr 80)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    50
  "<++>" :: "[('a item * 'a item)set, ('a item * 'a item)set] \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    51
\           => ('a item * 'a item)set" (infixr 70)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    53
defs
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    54
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
  (*least number operator*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    56
  Least_def      "Least(P) == @k. P(k) & (ALL j. j<k --> ~P(j))"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    57
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    58
  Push_Node_def  "Push_Node == (%n x. Abs_Node (apfst (Push n) (Rep_Node x)))"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    59
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    60
  (*crude "lists" of nats -- needed for the constructions*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    61
  apfst_def  "apfst == (%f. split(%x y. <f(x),y>))"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    62
  Push_def   "Push == (%b h. nat_case (Suc b) h)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    63
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    64
  (** operations on S-expressions -- sets of nodes **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    65
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    66
  (*S-expression constructors*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    67
  Atom_def   "Atom == (%x. {Abs_Node(<%k.0, x>)})"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    68
  Scons_def  "M$N == (Push_Node(0) `` M) Un (Push_Node(Suc(0)) `` N)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    69
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    70
  (*Leaf nodes, with arbitrary or nat labels*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    71
  Leaf_def   "Leaf == Atom o Inl"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    72
  Numb_def   "Numb == Atom o Inr"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    73
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    74
  (*Injections of the "disjoint sum"*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    75
  In0_def    "In0(M) == Numb(0) $ M"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    76
  In1_def    "In1(M) == Numb(Suc(0)) $ M"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    77
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    78
  (*the set of nodes with depth less than k*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    79
  ndepth_def "ndepth(n) == split (%f x. LEAST k. f(k)=0) (Rep_Node n)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    80
  ntrunc_def "ntrunc k N == {n. n:N & ndepth(n)<k}"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    81
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    82
  (*products and sums for the "universe"*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    83
  uprod_def  "A<*>B == UN x:A. UN y:B. { (x$y) }"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    84
  usum_def   "A<+>B == In0``A Un In1``B"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    85
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    86
  (*the corresponding eliminators*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    87
  Split_def  "Split c M == @u. ? x y. M = x$y & u = c x y"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    89
  Case_def   "Case c d M == @u.  (? x . M = In0(x) & u = c(x)) \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    90
\                              | (? y . M = In1(y) & u = d(y))"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    91
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    92
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    93
  (** diagonal sets and equality for the "universe" **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    94
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    95
  diag_def   "diag(A) == UN x:A. {<x,x>}"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    96
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    97
  dprod_def  "r<**>s == UN u:r. split (%x x'. \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    98
\                       UN v:s. split (%y y'. {<x$y,x'$y'>}) v) u"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    99
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   100
  dsum_def   "r<++>s == (UN u:r. split (%x x'. {<In0(x),In0(x')>}) u) Un \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   101
\                       (UN v:s. split (%y y'. {<In1(y),In1(y')>}) v)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   102
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   103
end