src/HOL/Sum_Type.thy
author nipkow
Thu Oct 12 18:44:35 2000 +0200 (2000-10-12)
changeset 10213 01c2744a3786
child 10832 e33b47e4246d
permissions -rw-r--r--
*** empty log message ***
nipkow@10213
     1
(*  Title:      HOL/Sum_Type.thy
nipkow@10213
     2
    ID:         $Id$
nipkow@10213
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
nipkow@10213
     4
    Copyright   1992  University of Cambridge
nipkow@10213
     5
nipkow@10213
     6
The disjoint sum of two types.
nipkow@10213
     7
*)
nipkow@10213
     8
nipkow@10213
     9
Sum_Type = mono + Product_Type +
nipkow@10213
    10
nipkow@10213
    11
(* type definition *)
nipkow@10213
    12
nipkow@10213
    13
constdefs
nipkow@10213
    14
  Inl_Rep       :: ['a, 'a, 'b, bool] => bool
nipkow@10213
    15
  "Inl_Rep == (%a. %x y p. x=a & p)"
nipkow@10213
    16
nipkow@10213
    17
  Inr_Rep       :: ['b, 'a, 'b, bool] => bool
nipkow@10213
    18
  "Inr_Rep == (%b. %x y p. y=b & ~p)"
nipkow@10213
    19
nipkow@10213
    20
global
nipkow@10213
    21
nipkow@10213
    22
typedef (Sum)
nipkow@10213
    23
  ('a, 'b) "+"          (infixr 10)
nipkow@10213
    24
    = "{f. (? a. f = Inl_Rep(a::'a)) | (? b. f = Inr_Rep(b::'b))}"
nipkow@10213
    25
nipkow@10213
    26
nipkow@10213
    27
(* abstract constants and syntax *)
nipkow@10213
    28
nipkow@10213
    29
consts
nipkow@10213
    30
  Inl            :: "'a => 'a + 'b"
nipkow@10213
    31
  Inr            :: "'b => 'a + 'b"
nipkow@10213
    32
nipkow@10213
    33
  (*disjoint sum for sets; the operator + is overloaded with wrong type!*)
nipkow@10213
    34
  Plus          :: "['a set, 'b set] => ('a + 'b) set"        (infixr "<+>" 65)
nipkow@10213
    35
  Part          :: ['a set, 'b => 'a] => 'a set
nipkow@10213
    36
nipkow@10213
    37
local
nipkow@10213
    38
nipkow@10213
    39
defs
nipkow@10213
    40
  Inl_def       "Inl == (%a. Abs_Sum(Inl_Rep(a)))"
nipkow@10213
    41
  Inr_def       "Inr == (%b. Abs_Sum(Inr_Rep(b)))"
nipkow@10213
    42
nipkow@10213
    43
  sum_def       "A <+> B == (Inl``A) Un (Inr``B)"
nipkow@10213
    44
nipkow@10213
    45
  (*for selecting out the components of a mutually recursive definition*)
nipkow@10213
    46
  Part_def      "Part A h == A Int {x. ? z. x = h(z)}"
nipkow@10213
    47
nipkow@10213
    48
end