author | nipkow |
Fri, 04 Jul 1997 14:37:30 +0200 | |
changeset 3499 | ce1664057431 |
parent 2983 | f914a1663b2a |
child 3842 | b55686a7b22c |
permissions | -rw-r--r-- |
923 | 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 |
||
1515 | 9 |
Sum = mono + Prod + |
923 | 10 |
|
11 |
(* type definition *) |
|
12 |
||
1558 | 13 |
constdefs |
1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1151
diff
changeset
|
14 |
Inl_Rep :: ['a, 'a, 'b, bool] => bool |
1558 | 15 |
"Inl_Rep == (%a. %x y p. x=a & p)" |
923 | 16 |
|
1558 | 17 |
Inr_Rep :: ['b, 'a, 'b, bool] => bool |
18 |
"Inr_Rep == (%b. %x y p. y=b & ~p)" |
|
923 | 19 |
|
1475 | 20 |
typedef (Sum) |
923 | 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!*) |
|
2212 | 33 |
Plus :: "['a set, 'b set] => ('a + 'b) set" (infixr 65) |
1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1151
diff
changeset
|
34 |
Part :: ['a set, 'b => 'a] => 'a set |
923 | 35 |
|
36 |
translations |
|
2983 | 37 |
"case p of Inl x => a | Inr y => b" == "sum_case (%x.a) (%y.b) p" |
923 | 38 |
|
39 |
defs |
|
40 |
Inl_def "Inl == (%a. Abs_Sum(Inl_Rep(a)))" |
|
41 |
Inr_def "Inr == (%b. Abs_Sum(Inr_Rep(b)))" |
|
1151 | 42 |
sum_case_def "sum_case f g p == @z. (!x. p=Inl(x) --> z=f(x)) |
1423 | 43 |
& (!y. p=Inr(y) --> z=g(y))" |
923 | 44 |
|
2212 | 45 |
sum_def "A Plus B == (Inl``A) Un (Inr``B)" |
923 | 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 |