0
|
1 |
(* Title: HOL/sum
|
|
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 = Prod +
|
51
|
10 |
|
|
11 |
types
|
|
12 |
('a,'b) "+" (infixl 10)
|
|
13 |
|
|
14 |
arities
|
|
15 |
"+" :: (term,term)term
|
|
16 |
|
0
|
17 |
consts
|
51
|
18 |
Inl_Rep :: "['a,'a,'b,bool] => bool"
|
|
19 |
Inr_Rep :: "['b,'a,'b,bool] => bool"
|
|
20 |
Sum :: "(['a,'b,bool] => bool)set"
|
|
21 |
Rep_Sum :: "'a + 'b => (['a,'b,bool] => bool)"
|
|
22 |
Abs_Sum :: "(['a,'b,bool] => bool) => 'a+'b"
|
|
23 |
Inl :: "'a => 'a+'b"
|
|
24 |
Inr :: "'b => 'a+'b"
|
|
25 |
sum_case :: "['a+'b, 'a=>'c,'b=>'c] =>'c"
|
|
26 |
|
0
|
27 |
rules
|
|
28 |
Inl_Rep_def "Inl_Rep == (%a. %x y p. x=a & p)"
|
|
29 |
Inr_Rep_def "Inr_Rep == (%b. %x y p. y=b & ~p)"
|
|
30 |
Sum_def "Sum == {f. (? a. f = Inl_Rep(a)) | (? b. f = Inr_Rep(b))}"
|
|
31 |
(*faking a type definition...*)
|
|
32 |
Rep_Sum "Rep_Sum(s): Sum"
|
|
33 |
Rep_Sum_inverse "Abs_Sum(Rep_Sum(s)) = s"
|
|
34 |
Abs_Sum_inverse "f: Sum ==> Rep_Sum(Abs_Sum(f)) = f"
|
|
35 |
(*defining the abstract constants*)
|
|
36 |
Inl_def "Inl == (%a. Abs_Sum(Inl_Rep(a)))"
|
|
37 |
Inr_def "Inr == (%b. Abs_Sum(Inr_Rep(b)))"
|
38
|
38 |
sum_case_def "sum_case == (%p f g. @z. (!x. p=Inl(x) --> z=f(x))\
|
|
39 |
\ & (!y. p=Inr(y) --> z=g(y)))"
|
0
|
40 |
end
|