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