| author | wenzelm | 
| Sat, 12 Mar 2022 23:21:28 +0100 | |
| changeset 75273 | f1c6e778e412 | 
| parent 67312 | 0d25e02759b7 | 
| child 80914 | d97fdabd9e2b | 
| permissions | -rw-r--r-- | 
| 42151 | 1  | 
(* Title: HOL/HOLCF/Ssum.thy  | 
| 
40502
 
8e92772bc0e8
move map functions to new theory file Map_Functions; add theory file Plain_HOLCF
 
huffman 
parents: 
40327 
diff
changeset
 | 
2  | 
Author: Franz Regensburger  | 
| 
 
8e92772bc0e8
move map functions to new theory file Map_Functions; add theory file Plain_HOLCF
 
huffman 
parents: 
40327 
diff
changeset
 | 
3  | 
Author: Brian Huffman  | 
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
4  | 
*)  | 
| 
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
5  | 
|
| 62175 | 6  | 
section \<open>The type of strict sums\<close>  | 
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
7  | 
|
| 15577 | 8  | 
theory Ssum  | 
| 67312 | 9  | 
imports Tr  | 
| 15577 | 10  | 
begin  | 
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
11  | 
|
| 36452 | 12  | 
default_sort pcpo  | 
| 
16083
 
fca38c55c8fa
added defaultsort declaration, moved cpair_less to Cprod.thy
 
huffman 
parents: 
16070 
diff
changeset
 | 
13  | 
|
| 67312 | 14  | 
|
| 62175 | 15  | 
subsection \<open>Definition of strict sum type\<close>  | 
| 
15593
 
24d770bbc44a
reordered and arranged for document generation, cleaned up some proofs
 
huffman 
parents: 
15577 
diff
changeset
 | 
16  | 
|
| 67312 | 17  | 
definition "ssum =  | 
18  | 
  {p :: tr \<times> ('a \<times> 'b). p = \<bottom> \<or>
 | 
|
19  | 
(fst p = TT \<and> fst (snd p) \<noteq> \<bottom> \<and> snd (snd p) = \<bottom>) \<or>  | 
|
20  | 
(fst p = FF \<and> fst (snd p) = \<bottom> \<and> snd (snd p) \<noteq> \<bottom>)}"  | 
|
| 45695 | 21  | 
|
| 61998 | 22  | 
pcpodef ('a, 'b) ssum  ("(_ \<oplus>/ _)" [21, 20] 20) = "ssum :: (tr \<times> 'a \<times> 'b) set"
 | 
| 67312 | 23  | 
by (simp_all add: ssum_def)  | 
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
24  | 
|
| 35525 | 25  | 
instance ssum :: ("{chfin,pcpo}", "{chfin,pcpo}") chfin
 | 
| 67312 | 26  | 
by (rule typedef_chfin [OF type_definition_ssum below_ssum_def])  | 
| 
25827
 
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
 
huffman 
parents: 
25756 
diff
changeset
 | 
27  | 
|
| 61998 | 28  | 
type_notation (ASCII)  | 
29  | 
ssum (infixr "++" 10)  | 
|
| 35547 | 30  | 
|
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
31  | 
|
| 62175 | 32  | 
subsection \<open>Definitions of constructors\<close>  | 
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
33  | 
|
| 67312 | 34  | 
definition sinl :: "'a \<rightarrow> ('a ++ 'b)"
 | 
35  | 
where "sinl = (\<Lambda> a. Abs_ssum (seq\<cdot>a\<cdot>TT, a, \<bottom>))"  | 
|
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
36  | 
|
| 67312 | 37  | 
definition sinr :: "'b \<rightarrow> ('a ++ 'b)"
 | 
38  | 
where "sinr = (\<Lambda> b. Abs_ssum (seq\<cdot>b\<cdot>FF, \<bottom>, b))"  | 
|
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
39  | 
|
| 
40767
 
a3e505b236e7
rename function 'strict' to 'seq', which is its name in Haskell
 
huffman 
parents: 
40502 
diff
changeset
 | 
40  | 
lemma sinl_ssum: "(seq\<cdot>a\<cdot>TT, a, \<bottom>) \<in> ssum"  | 
| 67312 | 41  | 
by (simp add: ssum_def seq_conv_if)  | 
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
42  | 
|
| 
40767
 
a3e505b236e7
rename function 'strict' to 'seq', which is its name in Haskell
 
huffman 
parents: 
40502 
diff
changeset
 | 
43  | 
lemma sinr_ssum: "(seq\<cdot>b\<cdot>FF, \<bottom>, b) \<in> ssum"  | 
| 67312 | 44  | 
by (simp add: ssum_def seq_conv_if)  | 
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
45  | 
|
| 
40767
 
a3e505b236e7
rename function 'strict' to 'seq', which is its name in Haskell
 
huffman 
parents: 
40502 
diff
changeset
 | 
46  | 
lemma Rep_ssum_sinl: "Rep_ssum (sinl\<cdot>a) = (seq\<cdot>a\<cdot>TT, a, \<bottom>)"  | 
| 67312 | 47  | 
by (simp add: sinl_def cont_Abs_ssum Abs_ssum_inverse sinl_ssum)  | 
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
48  | 
|
| 
40767
 
a3e505b236e7
rename function 'strict' to 'seq', which is its name in Haskell
 
huffman 
parents: 
40502 
diff
changeset
 | 
49  | 
lemma Rep_ssum_sinr: "Rep_ssum (sinr\<cdot>b) = (seq\<cdot>b\<cdot>FF, \<bottom>, b)"  | 
| 67312 | 50  | 
by (simp add: sinr_def cont_Abs_ssum Abs_ssum_inverse sinr_ssum)  | 
| 
40092
 
baf5953615da
do proofs using Rep_Sprod_simps, Rep_Ssum_simps; remove unused lemmas
 
huffman 
parents: 
40089 
diff
changeset
 | 
51  | 
|
| 
40098
 
9dbb01456031
use default names sprod/Rep_sprod/Abs_sprod from pcpodef instead of Sprod/Rep_Sprod/Abs_Sprod; similarly for ssum
 
huffman 
parents: 
40092 
diff
changeset
 | 
52  | 
lemmas Rep_ssum_simps =  | 
| 
 
9dbb01456031
use default names sprod/Rep_sprod/Abs_sprod from pcpodef instead of Sprod/Rep_Sprod/Abs_Sprod; similarly for ssum
 
huffman 
parents: 
40092 
diff
changeset
 | 
53  | 
Rep_ssum_inject [symmetric] below_ssum_def  | 
| 
44066
 
d74182c93f04
rename Pair_fst_snd_eq to prod_eq_iff (keeping old name too)
 
huffman 
parents: 
42151 
diff
changeset
 | 
54  | 
prod_eq_iff below_prod_def  | 
| 
40098
 
9dbb01456031
use default names sprod/Rep_sprod/Abs_sprod from pcpodef instead of Sprod/Rep_Sprod/Abs_Sprod; similarly for ssum
 
huffman 
parents: 
40092 
diff
changeset
 | 
55  | 
Rep_ssum_strict Rep_ssum_sinl Rep_ssum_sinr  | 
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
56  | 
|
| 67312 | 57  | 
|
| 62175 | 58  | 
subsection \<open>Properties of \emph{sinl} and \emph{sinr}\<close>
 | 
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
59  | 
|
| 62175 | 60  | 
text \<open>Ordering\<close>  | 
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
61  | 
|
| 67312 | 62  | 
lemma sinl_below [simp]: "sinl\<cdot>x \<sqsubseteq> sinl\<cdot>y \<longleftrightarrow> x \<sqsubseteq> y"  | 
63  | 
by (simp add: Rep_ssum_simps seq_conv_if)  | 
|
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
64  | 
|
| 67312 | 65  | 
lemma sinr_below [simp]: "sinr\<cdot>x \<sqsubseteq> sinr\<cdot>y \<longleftrightarrow> x \<sqsubseteq> y"  | 
66  | 
by (simp add: Rep_ssum_simps seq_conv_if)  | 
|
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
67  | 
|
| 67312 | 68  | 
lemma sinl_below_sinr [simp]: "sinl\<cdot>x \<sqsubseteq> sinr\<cdot>y \<longleftrightarrow> x = \<bottom>"  | 
69  | 
by (simp add: Rep_ssum_simps seq_conv_if)  | 
|
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
70  | 
|
| 67312 | 71  | 
lemma sinr_below_sinl [simp]: "sinr\<cdot>x \<sqsubseteq> sinl\<cdot>y \<longleftrightarrow> x = \<bottom>"  | 
72  | 
by (simp add: Rep_ssum_simps seq_conv_if)  | 
|
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
73  | 
|
| 62175 | 74  | 
text \<open>Equality\<close>  | 
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
75  | 
|
| 67312 | 76  | 
lemma sinl_eq [simp]: "sinl\<cdot>x = sinl\<cdot>y \<longleftrightarrow> x = y"  | 
77  | 
by (simp add: po_eq_conv)  | 
|
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
78  | 
|
| 67312 | 79  | 
lemma sinr_eq [simp]: "sinr\<cdot>x = sinr\<cdot>y \<longleftrightarrow> x = y"  | 
80  | 
by (simp add: po_eq_conv)  | 
|
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
81  | 
|
| 67312 | 82  | 
lemma sinl_eq_sinr [simp]: "sinl\<cdot>x = sinr\<cdot>y \<longleftrightarrow> x = \<bottom> \<and> y = \<bottom>"  | 
83  | 
by (subst po_eq_conv) simp  | 
|
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
84  | 
|
| 67312 | 85  | 
lemma sinr_eq_sinl [simp]: "sinr\<cdot>x = sinl\<cdot>y \<longleftrightarrow> x = \<bottom> \<and> y = \<bottom>"  | 
86  | 
by (subst po_eq_conv) simp  | 
|
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
87  | 
|
| 
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
88  | 
lemma sinl_inject: "sinl\<cdot>x = sinl\<cdot>y \<Longrightarrow> x = y"  | 
| 67312 | 89  | 
by (rule sinl_eq [THEN iffD1])  | 
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
90  | 
|
| 
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
91  | 
lemma sinr_inject: "sinr\<cdot>x = sinr\<cdot>y \<Longrightarrow> x = y"  | 
| 67312 | 92  | 
by (rule sinr_eq [THEN iffD1])  | 
| 
25740
 
de65baf89106
changed type definition to make Iwhen and reasoning about chains unnecessary;
 
huffman 
parents: 
25131 
diff
changeset
 | 
93  | 
|
| 62175 | 94  | 
text \<open>Strictness\<close>  | 
| 17837 | 95  | 
|
| 
16211
 
faa9691da2bc
changed to use new contI; renamed strict, defined, and inject lemmas
 
huffman 
parents: 
16083 
diff
changeset
 | 
96  | 
lemma sinl_strict [simp]: "sinl\<cdot>\<bottom> = \<bottom>"  | 
| 67312 | 97  | 
by (simp add: Rep_ssum_simps)  | 
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
98  | 
|
| 
16211
 
faa9691da2bc
changed to use new contI; renamed strict, defined, and inject lemmas
 
huffman 
parents: 
16083 
diff
changeset
 | 
99  | 
lemma sinr_strict [simp]: "sinr\<cdot>\<bottom> = \<bottom>"  | 
| 67312 | 100  | 
by (simp add: Rep_ssum_simps)  | 
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
101  | 
|
| 67312 | 102  | 
lemma sinl_bottom_iff [simp]: "sinl\<cdot>x = \<bottom> \<longleftrightarrow> x = \<bottom>"  | 
103  | 
using sinl_eq [of "x" "\<bottom>"] by simp  | 
|
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
104  | 
|
| 67312 | 105  | 
lemma sinr_bottom_iff [simp]: "sinr\<cdot>x = \<bottom> \<longleftrightarrow> x = \<bottom>"  | 
106  | 
using sinr_eq [of "x" "\<bottom>"] by simp  | 
|
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
107  | 
|
| 40081 | 108  | 
lemma sinl_defined: "x \<noteq> \<bottom> \<Longrightarrow> sinl\<cdot>x \<noteq> \<bottom>"  | 
| 67312 | 109  | 
by simp  | 
| 
16752
 
270ec60cc9e8
added lemmas sinl_defined_iff sinr_defined_iff, sinl_eq_sinr, sinr_eq_sinl; added more simp rules; cleaned up
 
huffman 
parents: 
16742 
diff
changeset
 | 
110  | 
|
| 40081 | 111  | 
lemma sinr_defined: "x \<noteq> \<bottom> \<Longrightarrow> sinr\<cdot>x \<noteq> \<bottom>"  | 
| 67312 | 112  | 
by simp  | 
| 
16752
 
270ec60cc9e8
added lemmas sinl_defined_iff sinr_defined_iff, sinl_eq_sinr, sinr_eq_sinl; added more simp rules; cleaned up
 
huffman 
parents: 
16742 
diff
changeset
 | 
113  | 
|
| 62175 | 114  | 
text \<open>Compactness\<close>  | 
| 
25882
 
c58e380d9f7d
new compactness lemmas; removed duplicated flat_less_iff
 
huffman 
parents: 
25827 
diff
changeset
 | 
115  | 
|
| 
 
c58e380d9f7d
new compactness lemmas; removed duplicated flat_less_iff
 
huffman 
parents: 
25827 
diff
changeset
 | 
116  | 
lemma compact_sinl: "compact x \<Longrightarrow> compact (sinl\<cdot>x)"  | 
| 67312 | 117  | 
by (rule compact_ssum) (simp add: Rep_ssum_sinl)  | 
| 
25882
 
c58e380d9f7d
new compactness lemmas; removed duplicated flat_less_iff
 
huffman 
parents: 
25827 
diff
changeset
 | 
118  | 
|
| 
 
c58e380d9f7d
new compactness lemmas; removed duplicated flat_less_iff
 
huffman 
parents: 
25827 
diff
changeset
 | 
119  | 
lemma compact_sinr: "compact x \<Longrightarrow> compact (sinr\<cdot>x)"  | 
| 67312 | 120  | 
by (rule compact_ssum) (simp add: Rep_ssum_sinr)  | 
| 
25882
 
c58e380d9f7d
new compactness lemmas; removed duplicated flat_less_iff
 
huffman 
parents: 
25827 
diff
changeset
 | 
121  | 
|
| 
 
c58e380d9f7d
new compactness lemmas; removed duplicated flat_less_iff
 
huffman 
parents: 
25827 
diff
changeset
 | 
122  | 
lemma compact_sinlD: "compact (sinl\<cdot>x) \<Longrightarrow> compact x"  | 
| 67312 | 123  | 
unfolding compact_def  | 
124  | 
by (drule adm_subst [OF cont_Rep_cfun2 [where f=sinl]], simp)  | 
|
| 
25882
 
c58e380d9f7d
new compactness lemmas; removed duplicated flat_less_iff
 
huffman 
parents: 
25827 
diff
changeset
 | 
125  | 
|
| 
 
c58e380d9f7d
new compactness lemmas; removed duplicated flat_less_iff
 
huffman 
parents: 
25827 
diff
changeset
 | 
126  | 
lemma compact_sinrD: "compact (sinr\<cdot>x) \<Longrightarrow> compact x"  | 
| 67312 | 127  | 
unfolding compact_def  | 
128  | 
by (drule adm_subst [OF cont_Rep_cfun2 [where f=sinr]], simp)  | 
|
| 
25882
 
c58e380d9f7d
new compactness lemmas; removed duplicated flat_less_iff
 
huffman 
parents: 
25827 
diff
changeset
 | 
129  | 
|
| 
 
c58e380d9f7d
new compactness lemmas; removed duplicated flat_less_iff
 
huffman 
parents: 
25827 
diff
changeset
 | 
130  | 
lemma compact_sinl_iff [simp]: "compact (sinl\<cdot>x) = compact x"  | 
| 67312 | 131  | 
by (safe elim!: compact_sinl compact_sinlD)  | 
| 
25882
 
c58e380d9f7d
new compactness lemmas; removed duplicated flat_less_iff
 
huffman 
parents: 
25827 
diff
changeset
 | 
132  | 
|
| 
 
c58e380d9f7d
new compactness lemmas; removed duplicated flat_less_iff
 
huffman 
parents: 
25827 
diff
changeset
 | 
133  | 
lemma compact_sinr_iff [simp]: "compact (sinr\<cdot>x) = compact x"  | 
| 67312 | 134  | 
by (safe elim!: compact_sinr compact_sinrD)  | 
135  | 
||
| 
25882
 
c58e380d9f7d
new compactness lemmas; removed duplicated flat_less_iff
 
huffman 
parents: 
25827 
diff
changeset
 | 
136  | 
|
| 62175 | 137  | 
subsection \<open>Case analysis\<close>  | 
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
138  | 
|
| 35783 | 139  | 
lemma ssumE [case_names bottom sinl sinr, cases type: ssum]:  | 
| 40080 | 140  | 
obtains "p = \<bottom>"  | 
141  | 
| x where "p = sinl\<cdot>x" and "x \<noteq> \<bottom>"  | 
|
142  | 
| y where "p = sinr\<cdot>y" and "y \<noteq> \<bottom>"  | 
|
| 67312 | 143  | 
using Rep_ssum [of p] by (auto simp add: ssum_def Rep_ssum_simps)  | 
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
144  | 
|
| 35783 | 145  | 
lemma ssum_induct [case_names bottom sinl sinr, induct type: ssum]:  | 
| 25756 | 146  | 
"\<lbrakk>P \<bottom>;  | 
147  | 
\<And>x. x \<noteq> \<bottom> \<Longrightarrow> P (sinl\<cdot>x);  | 
|
148  | 
\<And>y. y \<noteq> \<bottom> \<Longrightarrow> P (sinr\<cdot>y)\<rbrakk> \<Longrightarrow> P x"  | 
|
| 67312 | 149  | 
by (cases x) simp_all  | 
| 25756 | 150  | 
|
| 35783 | 151  | 
lemma ssumE2 [case_names sinl sinr]:  | 
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
152  | 
"\<lbrakk>\<And>x. p = sinl\<cdot>x \<Longrightarrow> Q; \<And>y. p = sinr\<cdot>y \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"  | 
| 67312 | 153  | 
by (cases p, simp only: sinl_strict [symmetric], simp, simp)  | 
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
154  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
29530 
diff
changeset
 | 
155  | 
lemma below_sinlD: "p \<sqsubseteq> sinl\<cdot>x \<Longrightarrow> \<exists>y. p = sinl\<cdot>y \<and> y \<sqsubseteq> x"  | 
| 67312 | 156  | 
by (cases p, rule_tac x="\<bottom>" in exI, simp_all)  | 
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
157  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
29530 
diff
changeset
 | 
158  | 
lemma below_sinrD: "p \<sqsubseteq> sinr\<cdot>x \<Longrightarrow> \<exists>y. p = sinr\<cdot>y \<and> y \<sqsubseteq> x"  | 
| 67312 | 159  | 
by (cases p, rule_tac x="\<bottom>" in exI, simp_all)  | 
160  | 
||
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
161  | 
|
| 62175 | 162  | 
subsection \<open>Case analysis combinator\<close>  | 
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
163  | 
|
| 67312 | 164  | 
definition sscase :: "('a \<rightarrow> 'c) \<rightarrow> ('b \<rightarrow> 'c) \<rightarrow> ('a ++ 'b) \<rightarrow> 'c"
 | 
165  | 
where "sscase = (\<Lambda> f g s. (\<lambda>(t, x, y). If t then f\<cdot>x else g\<cdot>y) (Rep_ssum s))"  | 
|
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
166  | 
|
| 
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
167  | 
translations  | 
| 67312 | 168  | 
"case s of XCONST sinl\<cdot>x \<Rightarrow> t1 | XCONST sinr\<cdot>y \<Rightarrow> t2" \<rightleftharpoons> "CONST sscase\<cdot>(\<Lambda> x. t1)\<cdot>(\<Lambda> y. t2)\<cdot>s"  | 
169  | 
"case s of (XCONST sinl :: 'a)\<cdot>x \<Rightarrow> t1 | XCONST sinr\<cdot>y \<Rightarrow> t2" \<rightharpoonup> "CONST sscase\<cdot>(\<Lambda> x. t1)\<cdot>(\<Lambda> y. t2)\<cdot>s"  | 
|
| 
18078
 
20e5a6440790
change syntax for LAM to use expressions as patterns; define LAM pattern syntax for cpair, spair, sinl, sinr, up
 
huffman 
parents: 
17837 
diff
changeset
 | 
170  | 
|
| 
 
20e5a6440790
change syntax for LAM to use expressions as patterns; define LAM pattern syntax for cpair, spair, sinl, sinr, up
 
huffman 
parents: 
17837 
diff
changeset
 | 
171  | 
translations  | 
| 67312 | 172  | 
"\<Lambda>(XCONST sinl\<cdot>x). t" \<rightleftharpoons> "CONST sscase\<cdot>(\<Lambda> x. t)\<cdot>\<bottom>"  | 
173  | 
"\<Lambda>(XCONST sinr\<cdot>y). t" \<rightleftharpoons> "CONST sscase\<cdot>\<bottom>\<cdot>(\<Lambda> y. t)"  | 
|
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
174  | 
|
| 67312 | 175  | 
lemma beta_sscase: "sscase\<cdot>f\<cdot>g\<cdot>s = (\<lambda>(t, x, y). If t then f\<cdot>x else g\<cdot>y) (Rep_ssum s)"  | 
176  | 
by (simp add: sscase_def cont_Rep_ssum)  | 
|
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
177  | 
|
| 
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
178  | 
lemma sscase1 [simp]: "sscase\<cdot>f\<cdot>g\<cdot>\<bottom> = \<bottom>"  | 
| 67312 | 179  | 
by (simp add: beta_sscase Rep_ssum_strict)  | 
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
180  | 
|
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
181  | 
lemma sscase2 [simp]: "x \<noteq> \<bottom> \<Longrightarrow> sscase\<cdot>f\<cdot>g\<cdot>(sinl\<cdot>x) = f\<cdot>x"  | 
| 67312 | 182  | 
by (simp add: beta_sscase Rep_ssum_sinl)  | 
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
183  | 
|
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
184  | 
lemma sscase3 [simp]: "y \<noteq> \<bottom> \<Longrightarrow> sscase\<cdot>f\<cdot>g\<cdot>(sinr\<cdot>y) = g\<cdot>y"  | 
| 67312 | 185  | 
by (simp add: beta_sscase Rep_ssum_sinr)  | 
| 
15593
 
24d770bbc44a
reordered and arranged for document generation, cleaned up some proofs
 
huffman 
parents: 
15577 
diff
changeset
 | 
186  | 
|
| 
16060
 
833be7f71ecd
Simplified version of strict sum theory, using TypedefPcpo
 
huffman 
parents: 
15606 
diff
changeset
 | 
187  | 
lemma sscase4 [simp]: "sscase\<cdot>sinl\<cdot>sinr\<cdot>z = z"  | 
| 67312 | 188  | 
by (cases z) simp_all  | 
189  | 
||
| 
15593
 
24d770bbc44a
reordered and arranged for document generation, cleaned up some proofs
 
huffman 
parents: 
15577 
diff
changeset
 | 
190  | 
|
| 62175 | 191  | 
subsection \<open>Strict sum preserves flatness\<close>  | 
| 
25827
 
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
 
huffman 
parents: 
25756 
diff
changeset
 | 
192  | 
|
| 35525 | 193  | 
instance ssum :: (flat, flat) flat  | 
| 67312 | 194  | 
apply (intro_classes, clarify)  | 
195  | 
apply (case_tac x, simp)  | 
|
196  | 
apply (case_tac y, simp_all add: flat_below_iff)  | 
|
197  | 
apply (case_tac y, simp_all add: flat_below_iff)  | 
|
198  | 
done  | 
|
| 
25827
 
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
 
huffman 
parents: 
25756 
diff
changeset
 | 
199  | 
|
| 
15576
 
efb95d0d01f7
converted to new-style theories, and combined numbered files
 
huffman 
parents:  
diff
changeset
 | 
200  | 
end  |