src/HOL/Sum.thy
changeset 923 ff1574a81019
child 1151 c820b3cc3df0
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/Sum.thy	Fri Mar 03 12:02:25 1995 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +(*  Title:      HOL/Sum.thy
     1.5 +    ID:         $Id$
     1.6 +    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     1.7 +    Copyright   1992  University of Cambridge
     1.8 +
     1.9 +The disjoint sum of two types.
    1.10 +*)
    1.11 +
    1.12 +Sum = Prod +
    1.13 +
    1.14 +(* type definition *)
    1.15 +
    1.16 +consts
    1.17 +  Inl_Rep       :: "['a, 'a, 'b, bool] => bool"
    1.18 +  Inr_Rep       :: "['b, 'a, 'b, bool] => bool"
    1.19 +
    1.20 +defs
    1.21 +  Inl_Rep_def   "Inl_Rep == (%a. %x y p. x=a & p)"
    1.22 +  Inr_Rep_def   "Inr_Rep == (%b. %x y p. y=b & ~p)"
    1.23 +
    1.24 +subtype (Sum)
    1.25 +  ('a, 'b) "+"          (infixr 10)
    1.26 +    = "{f. (? a. f = Inl_Rep(a::'a)) | (? b. f = Inr_Rep(b::'b))}"
    1.27 +
    1.28 +
    1.29 +(* abstract constants and syntax *)
    1.30 +
    1.31 +consts
    1.32 +  Inl           :: "'a => 'a + 'b"
    1.33 +  Inr           :: "'b => 'a + 'b"
    1.34 +  sum_case      :: "['a => 'c, 'b => 'c, 'a + 'b] => 'c"
    1.35 +
    1.36 +  (*disjoint sum for sets; the operator + is overloaded with wrong type!*)
    1.37 +  "plus"        :: "['a set, 'b set] => ('a + 'b) set"        (infixr 65)
    1.38 +  Part          :: "['a set, 'b => 'a] => 'a set"
    1.39 +
    1.40 +translations
    1.41 +  "case p of Inl(x) => a | Inr(y) => b" == "sum_case (%x.a) (%y.b) p"
    1.42 +
    1.43 +defs
    1.44 +  Inl_def       "Inl == (%a. Abs_Sum(Inl_Rep(a)))"
    1.45 +  Inr_def       "Inr == (%b. Abs_Sum(Inr_Rep(b)))"
    1.46 +  sum_case_def  "sum_case f g p == @z.  (!x. p=Inl(x) --> z=f(x))      \
    1.47 +\                                     & (!y. p=Inr(y) --> z=g(y))"
    1.48 +
    1.49 +  sum_def       "A plus B == (Inl``A) Un (Inr``B)"
    1.50 +
    1.51 +  (*for selecting out the components of a mutually recursive definition*)
    1.52 +  Part_def      "Part A h == A Int {x. ? z. x = h(z)}"
    1.53 +
    1.54 +end