src/HOL/Sum_Type.thy
 changeset 10213 01c2744a3786 child 10832 e33b47e4246d
1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/HOL/Sum_Type.thy	Thu Oct 12 18:44:35 2000 +0200
1.3 @@ -0,0 +1,48 @@
1.4 +(*  Title:      HOL/Sum_Type.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_Type = mono + Product_Type +
1.13 +
1.14 +(* type definition *)
1.15 +
1.16 +constdefs
1.17 +  Inl_Rep       :: ['a, 'a, 'b, bool] => bool
1.18 +  "Inl_Rep == (%a. %x y p. x=a & p)"
1.19 +
1.20 +  Inr_Rep       :: ['b, 'a, 'b, bool] => bool
1.21 +  "Inr_Rep == (%b. %x y p. y=b & ~p)"
1.22 +
1.23 +global
1.24 +
1.25 +typedef (Sum)
1.26 +  ('a, 'b) "+"          (infixr 10)
1.27 +    = "{f. (? a. f = Inl_Rep(a::'a)) | (? b. f = Inr_Rep(b::'b))}"
1.28 +
1.29 +
1.30 +(* abstract constants and syntax *)
1.31 +
1.32 +consts
1.33 +  Inl            :: "'a => 'a + 'b"
1.34 +  Inr            :: "'b => 'a + 'b"
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 +local
1.41 +
1.42 +defs
1.43 +  Inl_def       "Inl == (%a. Abs_Sum(Inl_Rep(a)))"
1.44 +  Inr_def       "Inr == (%b. Abs_Sum(Inr_Rep(b)))"
1.45 +
1.46 +  sum_def       "A <+> B == (Inl``A) Un (Inr``B)"
1.47 +
1.48 +  (*for selecting out the components of a mutually recursive definition*)
1.49 +  Part_def      "Part A h == A Int {x. ? z. x = h(z)}"
1.50 +
1.51 +end