src/HOL/Sum.thy
author nipkow
Tue Apr 08 10:48:42 1997 +0200 (1997-04-08)
changeset 2919 953a47dc0519
parent 2212 bd705e9de196
child 2983 f914a1663b2a
permissions -rw-r--r--
Dep. on Provers/nat_transitive
clasohm@923
     1
(*  Title:      HOL/Sum.thy
clasohm@923
     2
    ID:         $Id$
clasohm@923
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@923
     4
    Copyright   1992  University of Cambridge
clasohm@923
     5
clasohm@923
     6
The disjoint sum of two types.
clasohm@923
     7
*)
clasohm@923
     8
nipkow@1515
     9
Sum = mono + Prod +
clasohm@923
    10
clasohm@923
    11
(* type definition *)
clasohm@923
    12
clasohm@1558
    13
constdefs
clasohm@1370
    14
  Inl_Rep       :: ['a, 'a, 'b, bool] => bool
clasohm@1558
    15
  "Inl_Rep == (%a. %x y p. x=a & p)"
clasohm@923
    16
clasohm@1558
    17
  Inr_Rep       :: ['b, 'a, 'b, bool] => bool
clasohm@1558
    18
  "Inr_Rep == (%b. %x y p. y=b & ~p)"
clasohm@923
    19
clasohm@1475
    20
typedef (Sum)
clasohm@923
    21
  ('a, 'b) "+"          (infixr 10)
clasohm@923
    22
    = "{f. (? a. f = Inl_Rep(a::'a)) | (? b. f = Inr_Rep(b::'b))}"
clasohm@923
    23
clasohm@923
    24
clasohm@923
    25
(* abstract constants and syntax *)
clasohm@923
    26
clasohm@923
    27
consts
clasohm@923
    28
  Inl           :: "'a => 'a + 'b"
clasohm@923
    29
  Inr           :: "'b => 'a + 'b"
clasohm@923
    30
  sum_case      :: "['a => 'c, 'b => 'c, 'a + 'b] => 'c"
clasohm@923
    31
clasohm@923
    32
  (*disjoint sum for sets; the operator + is overloaded with wrong type!*)
nipkow@2212
    33
  Plus          :: "['a set, 'b set] => ('a + 'b) set"        (infixr 65)
clasohm@1370
    34
  Part          :: ['a set, 'b => 'a] => 'a set
clasohm@923
    35
clasohm@923
    36
translations
clasohm@923
    37
  "case p of Inl(x) => a | Inr(y) => b" == "sum_case (%x.a) (%y.b) p"
clasohm@923
    38
clasohm@923
    39
defs
clasohm@923
    40
  Inl_def       "Inl == (%a. Abs_Sum(Inl_Rep(a)))"
clasohm@923
    41
  Inr_def       "Inr == (%b. Abs_Sum(Inr_Rep(b)))"
clasohm@1151
    42
  sum_case_def  "sum_case f g p == @z.  (!x. p=Inl(x) --> z=f(x))      
paulson@1423
    43
                                      & (!y. p=Inr(y) --> z=g(y))"
clasohm@923
    44
nipkow@2212
    45
  sum_def       "A Plus B == (Inl``A) Un (Inr``B)"
clasohm@923
    46
clasohm@923
    47
  (*for selecting out the components of a mutually recursive definition*)
clasohm@923
    48
  Part_def      "Part A h == A Int {x. ? z. x = h(z)}"
clasohm@923
    49
clasohm@923
    50
end