| author | blanchet |
| Wed, 12 Feb 2014 08:35:56 +0100 | |
| changeset 55400 | 1e8dd9cd320b |
| parent 55393 | ce5cebfaedda |
| child 55403 | 677569668824 |
| permissions | -rw-r--r-- |
| 10213 | 1 |
(* Title: HOL/Sum_Type.thy |
2 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
3 |
Copyright 1992 University of Cambridge |
|
4 |
*) |
|
5 |
||
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
6 |
header{*The Disjoint Sum of Two Types*}
|
| 10213 | 7 |
|
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
8 |
theory Sum_Type |
| 33961 | 9 |
imports Typedef Inductive Fun |
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
10 |
begin |
|
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
11 |
|
| 33962 | 12 |
subsection {* Construction of the sum type and its basic abstract operations *}
|
| 10213 | 13 |
|
| 33962 | 14 |
definition Inl_Rep :: "'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool \<Rightarrow> bool" where |
15 |
"Inl_Rep a x y p \<longleftrightarrow> x = a \<and> p" |
|
| 10213 | 16 |
|
| 33962 | 17 |
definition Inr_Rep :: "'b \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool \<Rightarrow> bool" where |
18 |
"Inr_Rep b x y p \<longleftrightarrow> y = b \<and> \<not> p" |
|
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
19 |
|
|
45694
4a8743618257
prefer typedef without extra definition and alternative name;
wenzelm
parents:
45204
diff
changeset
|
20 |
definition "sum = {f. (\<exists>a. f = Inl_Rep (a::'a)) \<or> (\<exists>b. f = Inr_Rep (b::'b))}"
|
|
4a8743618257
prefer typedef without extra definition and alternative name;
wenzelm
parents:
45204
diff
changeset
|
21 |
|
| 49834 | 22 |
typedef ('a, 'b) sum (infixr "+" 10) = "sum :: ('a => 'b => bool => bool) set"
|
|
45694
4a8743618257
prefer typedef without extra definition and alternative name;
wenzelm
parents:
45204
diff
changeset
|
23 |
unfolding sum_def by auto |
| 10213 | 24 |
|
| 37388 | 25 |
lemma Inl_RepI: "Inl_Rep a \<in> sum" |
26 |
by (auto simp add: sum_def) |
|
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
27 |
|
| 37388 | 28 |
lemma Inr_RepI: "Inr_Rep b \<in> sum" |
29 |
by (auto simp add: sum_def) |
|
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
30 |
|
| 37388 | 31 |
lemma inj_on_Abs_sum: "A \<subseteq> sum \<Longrightarrow> inj_on Abs_sum A" |
32 |
by (rule inj_on_inverseI, rule Abs_sum_inverse) auto |
|
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
33 |
|
| 33962 | 34 |
lemma Inl_Rep_inject: "inj_on Inl_Rep A" |
35 |
proof (rule inj_onI) |
|
36 |
show "\<And>a c. Inl_Rep a = Inl_Rep c \<Longrightarrow> a = c" |
|
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
37 |
by (auto simp add: Inl_Rep_def fun_eq_iff) |
| 33962 | 38 |
qed |
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
39 |
|
| 33962 | 40 |
lemma Inr_Rep_inject: "inj_on Inr_Rep A" |
41 |
proof (rule inj_onI) |
|
42 |
show "\<And>b d. Inr_Rep b = Inr_Rep d \<Longrightarrow> b = d" |
|
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
43 |
by (auto simp add: Inr_Rep_def fun_eq_iff) |
| 33962 | 44 |
qed |
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
45 |
|
| 33962 | 46 |
lemma Inl_Rep_not_Inr_Rep: "Inl_Rep a \<noteq> Inr_Rep b" |
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
47 |
by (auto simp add: Inl_Rep_def Inr_Rep_def fun_eq_iff) |
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
48 |
|
| 33962 | 49 |
definition Inl :: "'a \<Rightarrow> 'a + 'b" where |
| 37388 | 50 |
"Inl = Abs_sum \<circ> Inl_Rep" |
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
51 |
|
| 33962 | 52 |
definition Inr :: "'b \<Rightarrow> 'a + 'b" where |
| 37388 | 53 |
"Inr = Abs_sum \<circ> Inr_Rep" |
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
54 |
|
|
29025
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28524
diff
changeset
|
55 |
lemma inj_Inl [simp]: "inj_on Inl A" |
| 37388 | 56 |
by (auto simp add: Inl_def intro!: comp_inj_on Inl_Rep_inject inj_on_Abs_sum Inl_RepI) |
|
29025
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28524
diff
changeset
|
57 |
|
| 33962 | 58 |
lemma Inl_inject: "Inl x = Inl y \<Longrightarrow> x = y" |
59 |
using inj_Inl by (rule injD) |
|
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
60 |
|
|
29025
8c8859c0d734
move lemmas from Numeral_Type.thy to other theories
huffman
parents:
28524
diff
changeset
|
61 |
lemma inj_Inr [simp]: "inj_on Inr A" |
| 37388 | 62 |
by (auto simp add: Inr_def intro!: comp_inj_on Inr_Rep_inject inj_on_Abs_sum Inr_RepI) |
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
63 |
|
| 33962 | 64 |
lemma Inr_inject: "Inr x = Inr y \<Longrightarrow> x = y" |
65 |
using inj_Inr by (rule injD) |
|
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
66 |
|
| 33962 | 67 |
lemma Inl_not_Inr: "Inl a \<noteq> Inr b" |
68 |
proof - |
|
| 37388 | 69 |
from Inl_RepI [of a] Inr_RepI [of b] have "{Inl_Rep a, Inr_Rep b} \<subseteq> sum" by auto
|
70 |
with inj_on_Abs_sum have "inj_on Abs_sum {Inl_Rep a, Inr_Rep b}" .
|
|
71 |
with Inl_Rep_not_Inr_Rep [of a b] inj_on_contraD have "Abs_sum (Inl_Rep a) \<noteq> Abs_sum (Inr_Rep b)" by auto |
|
| 33962 | 72 |
then show ?thesis by (simp add: Inl_def Inr_def) |
73 |
qed |
|
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
74 |
|
| 33962 | 75 |
lemma Inr_not_Inl: "Inr b \<noteq> Inl a" |
76 |
using Inl_not_Inr by (rule not_sym) |
|
|
15391
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
77 |
|
|
797ed46d724b
converted Sum_Type to new-style theory: Inl, Inr are NO LONGER global
paulson
parents:
11609
diff
changeset
|
78 |
lemma sumE: |
| 33962 | 79 |
assumes "\<And>x::'a. s = Inl x \<Longrightarrow> P" |
80 |
and "\<And>y::'b. s = Inr y \<Longrightarrow> P" |
|
81 |
shows P |
|
| 37388 | 82 |
proof (rule Abs_sum_cases [of s]) |
| 33962 | 83 |
fix f |
| 37388 | 84 |
assume "s = Abs_sum f" and "f \<in> sum" |
85 |
with assms show P by (auto simp add: sum_def Inl_def Inr_def) |
|
| 33962 | 86 |
qed |
| 33961 | 87 |
|
|
55393
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
88 |
wrap_free_constructors [Inl, Inr] sum_case [isl] [[projl], [projr]] |
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
89 |
by (erule sumE, assumption) (auto dest: Inl_inject Inr_inject simp add: Inl_not_Inr) |
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
90 |
|
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
91 |
-- {* Avoid name clashes by prefixing the output of @{text rep_datatype} with @{text old}. *}
|
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
92 |
setup {* Sign.mandatory_path "old" *}
|
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
93 |
|
|
37678
0040bafffdef
"prod" and "sum" replace "*" and "+" respectively
haftmann
parents:
37388
diff
changeset
|
94 |
rep_datatype Inl Inr |
| 33961 | 95 |
proof - |
96 |
fix P |
|
97 |
fix s :: "'a + 'b" |
|
98 |
assume x: "\<And>x\<Colon>'a. P (Inl x)" and y: "\<And>y\<Colon>'b. P (Inr y)" |
|
99 |
then show "P s" by (auto intro: sumE [of s]) |
|
| 33962 | 100 |
qed (auto dest: Inl_inject Inr_inject simp add: Inl_not_Inr) |
101 |
||
|
55393
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
102 |
setup {* Sign.parent_path *}
|
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
103 |
|
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
104 |
-- {* But erase the prefix for properties that are not generated by @{text wrap_free_constructors}. *}
|
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
105 |
setup {* Sign.mandatory_path "sum" *}
|
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
106 |
|
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
107 |
declare |
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
108 |
old.sum.inject[iff del] |
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
109 |
old.sum.distinct(1)[simp del, induct_simp del] |
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
110 |
old.sum.cases[simp del] |
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
111 |
|
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
112 |
lemmas induct = old.sum.induct |
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
113 |
lemmas inducts = old.sum.inducts |
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
114 |
lemmas recs = old.sum.recs |
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
115 |
lemmas cases = sum.case |
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
116 |
lemmas simps = sum.inject sum.distinct sum.case old.sum.recs |
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
117 |
|
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
118 |
setup {* Sign.parent_path *}
|
|
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
119 |
|
| 40610 | 120 |
primrec sum_map :: "('a \<Rightarrow> 'c) \<Rightarrow> ('b \<Rightarrow> 'd) \<Rightarrow> 'a + 'b \<Rightarrow> 'c + 'd" where
|
121 |
"sum_map f1 f2 (Inl a) = Inl (f1 a)" |
|
122 |
| "sum_map f1 f2 (Inr a) = Inr (f2 a)" |
|
123 |
||
|
41505
6d19301074cf
"enriched_type" replaces less specific "type_lifting"
haftmann
parents:
41372
diff
changeset
|
124 |
enriched_type sum_map: sum_map proof - |
| 41372 | 125 |
fix f g h i |
126 |
show "sum_map f g \<circ> sum_map h i = sum_map (f \<circ> h) (g \<circ> i)" |
|
127 |
proof |
|
128 |
fix s |
|
129 |
show "(sum_map f g \<circ> sum_map h i) s = sum_map (f \<circ> h) (g \<circ> i) s" |
|
130 |
by (cases s) simp_all |
|
131 |
qed |
|
| 40610 | 132 |
next |
133 |
fix s |
|
| 41372 | 134 |
show "sum_map id id = id" |
135 |
proof |
|
136 |
fix s |
|
137 |
show "sum_map id id s = id s" |
|
138 |
by (cases s) simp_all |
|
139 |
qed |
|
| 40610 | 140 |
qed |
141 |
||
| 53010 | 142 |
lemma split_sum_all: "(\<forall>x. P x) \<longleftrightarrow> (\<forall>x. P (Inl x)) \<and> (\<forall>x. P (Inr x))" |
143 |
by (auto intro: sum.induct) |
|
144 |
||
145 |
lemma split_sum_ex: "(\<exists>x. P x) \<longleftrightarrow> (\<exists>x. P (Inl x)) \<or> (\<exists>x. P (Inr x))" |
|
146 |
using split_sum_all[of "\<lambda>x. \<not>P x"] by blast |
|
| 33961 | 147 |
|
| 33962 | 148 |
subsection {* Projections *}
|
149 |
||
150 |
lemma sum_case_KK [simp]: "sum_case (\<lambda>x. a) (\<lambda>x. a) = (\<lambda>x. a)" |
|
| 33961 | 151 |
by (rule ext) (simp split: sum.split) |
152 |
||
| 33962 | 153 |
lemma surjective_sum: "sum_case (\<lambda>x::'a. f (Inl x)) (\<lambda>y::'b. f (Inr y)) = f" |
154 |
proof |
|
155 |
fix s :: "'a + 'b" |
|
156 |
show "(case s of Inl (x\<Colon>'a) \<Rightarrow> f (Inl x) | Inr (y\<Colon>'b) \<Rightarrow> f (Inr y)) = f s" |
|
157 |
by (cases s) simp_all |
|
158 |
qed |
|
| 33961 | 159 |
|
| 33962 | 160 |
lemma sum_case_inject: |
161 |
assumes a: "sum_case f1 f2 = sum_case g1 g2" |
|
162 |
assumes r: "f1 = g1 \<Longrightarrow> f2 = g2 \<Longrightarrow> P" |
|
163 |
shows P |
|
164 |
proof (rule r) |
|
165 |
show "f1 = g1" proof |
|
166 |
fix x :: 'a |
|
167 |
from a have "sum_case f1 f2 (Inl x) = sum_case g1 g2 (Inl x)" by simp |
|
168 |
then show "f1 x = g1 x" by simp |
|
169 |
qed |
|
170 |
show "f2 = g2" proof |
|
171 |
fix y :: 'b |
|
172 |
from a have "sum_case f1 f2 (Inr y) = sum_case g1 g2 (Inr y)" by simp |
|
173 |
then show "f2 y = g2 y" by simp |
|
174 |
qed |
|
175 |
qed |
|
176 |
||
177 |
primrec Suml :: "('a \<Rightarrow> 'c) \<Rightarrow> 'a + 'b \<Rightarrow> 'c" where
|
|
178 |
"Suml f (Inl x) = f x" |
|
179 |
||
180 |
primrec Sumr :: "('b \<Rightarrow> 'c) \<Rightarrow> 'a + 'b \<Rightarrow> 'c" where
|
|
181 |
"Sumr f (Inr x) = f x" |
|
182 |
||
183 |
lemma Suml_inject: |
|
184 |
assumes "Suml f = Suml g" shows "f = g" |
|
185 |
proof |
|
186 |
fix x :: 'a |
|
187 |
let ?s = "Inl x \<Colon> 'a + 'b" |
|
188 |
from assms have "Suml f ?s = Suml g ?s" by simp |
|
189 |
then show "f x = g x" by simp |
|
| 33961 | 190 |
qed |
191 |
||
| 33962 | 192 |
lemma Sumr_inject: |
193 |
assumes "Sumr f = Sumr g" shows "f = g" |
|
194 |
proof |
|
195 |
fix x :: 'b |
|
196 |
let ?s = "Inr x \<Colon> 'a + 'b" |
|
197 |
from assms have "Sumr f ?s = Sumr g ?s" by simp |
|
198 |
then show "f x = g x" by simp |
|
199 |
qed |
|
| 33961 | 200 |
|
| 33995 | 201 |
|
| 33962 | 202 |
subsection {* The Disjoint Sum of Sets *}
|
| 33961 | 203 |
|
| 33962 | 204 |
definition Plus :: "'a set \<Rightarrow> 'b set \<Rightarrow> ('a + 'b) set" (infixr "<+>" 65) where
|
205 |
"A <+> B = Inl ` A \<union> Inr ` B" |
|
206 |
||
| 40271 | 207 |
hide_const (open) Plus --"Valuable identifier" |
208 |
||
| 33962 | 209 |
lemma InlI [intro!]: "a \<in> A \<Longrightarrow> Inl a \<in> A <+> B" |
210 |
by (simp add: Plus_def) |
|
| 33961 | 211 |
|
| 33962 | 212 |
lemma InrI [intro!]: "b \<in> B \<Longrightarrow> Inr b \<in> A <+> B" |
213 |
by (simp add: Plus_def) |
|
| 33961 | 214 |
|
| 33962 | 215 |
text {* Exhaustion rule for sums, a degenerate form of induction *}
|
216 |
||
217 |
lemma PlusE [elim!]: |
|
218 |
"u \<in> A <+> B \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> u = Inl x \<Longrightarrow> P) \<Longrightarrow> (\<And>y. y \<in> B \<Longrightarrow> u = Inr y \<Longrightarrow> P) \<Longrightarrow> P" |
|
219 |
by (auto simp add: Plus_def) |
|
| 33961 | 220 |
|
| 33962 | 221 |
lemma Plus_eq_empty_conv [simp]: "A <+> B = {} \<longleftrightarrow> A = {} \<and> B = {}"
|
222 |
by auto |
|
| 33961 | 223 |
|
| 33962 | 224 |
lemma UNIV_Plus_UNIV [simp]: "UNIV <+> UNIV = UNIV" |
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
225 |
proof (rule set_eqI) |
| 33962 | 226 |
fix u :: "'a + 'b" |
227 |
show "u \<in> UNIV <+> UNIV \<longleftrightarrow> u \<in> UNIV" by (cases u) auto |
|
228 |
qed |
|
| 33961 | 229 |
|
|
49948
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49834
diff
changeset
|
230 |
lemma UNIV_sum: |
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49834
diff
changeset
|
231 |
"UNIV = Inl ` UNIV \<union> Inr ` UNIV" |
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49834
diff
changeset
|
232 |
proof - |
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49834
diff
changeset
|
233 |
{ fix x :: "'a + 'b"
|
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49834
diff
changeset
|
234 |
assume "x \<notin> range Inr" |
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49834
diff
changeset
|
235 |
then have "x \<in> range Inl" |
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49834
diff
changeset
|
236 |
by (cases x) simp_all |
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49834
diff
changeset
|
237 |
} then show ?thesis by auto |
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49834
diff
changeset
|
238 |
qed |
|
744934b818c7
moved quite generic material from theory Enum to more appropriate places
haftmann
parents:
49834
diff
changeset
|
239 |
|
|
55393
ce5cebfaedda
se 'wrap_free_constructors' to register 'sum' , 'prod', 'unit', 'bool' with their discriminators/selectors
blanchet
parents:
53010
diff
changeset
|
240 |
hide_const (open) Suml Sumr sum |
|
45204
5e4a1270c000
hide typedef-generated constants Product_Type.prod and Sum_Type.sum
huffman
parents:
41505
diff
changeset
|
241 |
|
| 10213 | 242 |
end |