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