src/HOL/HOLCF/Ssum.thy
author wenzelm
Wed, 12 Mar 2025 11:39:00 +0100
changeset 82265 4b875a4c83b0
parent 81583 b6df83045178
permissions -rw-r--r--
update for release;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42151
4da4fc77664b tuned headers;
wenzelm
parents: 40834
diff changeset
     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
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
     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
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
     8
theory Ssum
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
     9
  imports Tr
15577
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
    10
begin
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    11
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    12
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
    13
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    14
definition "ssum =
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81095
diff changeset
    15
  {p :: tr \<times> ('a::pcpo \<times> 'b::pcpo). p = \<bottom> \<or>
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    16
    (fst p = TT \<and> fst (snd p) \<noteq> \<bottom> \<and> snd (snd p) = \<bottom>) \<or>
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    17
    (fst p = FF \<and> fst (snd p) = \<bottom> \<and> snd (snd p) \<noteq> \<bottom>)}"
45695
b108b3d7c49e prefer cpodef without extra definition;
wenzelm
parents: 44066
diff changeset
    18
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81095
diff changeset
    19
pcpodef ('a::pcpo, 'b::pcpo) ssum  (\<open>(\<open>notation=\<open>infix strict sum\<close>\<close>_ \<oplus>/ _)\<close> [21, 20] 20) =
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81095
diff changeset
    20
  "ssum :: (tr \<times> 'a \<times> 'b) set"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    21
  by (simp_all add: ssum_def)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    22
35525
fa231b86cb1e proper names for types cfun, sprod, ssum
huffman
parents: 35491
diff changeset
    23
instance ssum :: ("{chfin,pcpo}", "{chfin,pcpo}") chfin
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    24
  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
    25
61998
b66d2ca1f907 clarified print modes;
wenzelm
parents: 61378
diff changeset
    26
type_notation (ASCII)
80914
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 67312
diff changeset
    27
  ssum  (infixr \<open>++\<close> 10)
35547
991a6af75978 merged, resolving some basic conflicts;
wenzelm
parents: 35525 35427
diff changeset
    28
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    29
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    30
subsection \<open>Definitions of constructors\<close>
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    31
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81095
diff changeset
    32
definition sinl :: "'a::pcpo \<rightarrow> ('a ++ 'b::pcpo)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    33
  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
    34
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81095
diff changeset
    35
definition sinr :: "'b::pcpo \<rightarrow> ('a::pcpo ++ 'b)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    36
  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
    37
40767
a3e505b236e7 rename function 'strict' to 'seq', which is its name in Haskell
huffman
parents: 40502
diff changeset
    38
lemma sinl_ssum: "(seq\<cdot>a\<cdot>TT, a, \<bottom>) \<in> ssum"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    39
  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
    40
40767
a3e505b236e7 rename function 'strict' to 'seq', which is its name in Haskell
huffman
parents: 40502
diff changeset
    41
lemma sinr_ssum: "(seq\<cdot>b\<cdot>FF, \<bottom>, b) \<in> ssum"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    42
  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
    43
40767
a3e505b236e7 rename function 'strict' to 'seq', which is its name in Haskell
huffman
parents: 40502
diff changeset
    44
lemma Rep_ssum_sinl: "Rep_ssum (sinl\<cdot>a) = (seq\<cdot>a\<cdot>TT, a, \<bottom>)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    45
  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
    46
40767
a3e505b236e7 rename function 'strict' to 'seq', which is its name in Haskell
huffman
parents: 40502
diff changeset
    47
lemma Rep_ssum_sinr: "Rep_ssum (sinr\<cdot>b) = (seq\<cdot>b\<cdot>FF, \<bottom>, b)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    48
  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
    49
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
    50
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
    51
  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
    52
  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
    53
  Rep_ssum_strict Rep_ssum_sinl Rep_ssum_sinr
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
    54
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    55
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    56
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
    57
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    58
text \<open>Ordering\<close>
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    59
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    60
lemma sinl_below [simp]: "sinl\<cdot>x \<sqsubseteq> sinl\<cdot>y \<longleftrightarrow> x \<sqsubseteq> y"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    61
  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
    62
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    63
lemma sinr_below [simp]: "sinr\<cdot>x \<sqsubseteq> sinr\<cdot>y \<longleftrightarrow> x \<sqsubseteq> y"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    64
  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
    65
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    66
lemma sinl_below_sinr [simp]: "sinl\<cdot>x \<sqsubseteq> sinr\<cdot>y \<longleftrightarrow> x = \<bottom>"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    67
  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
    68
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    69
lemma sinr_below_sinl [simp]: "sinr\<cdot>x \<sqsubseteq> sinl\<cdot>y \<longleftrightarrow> x = \<bottom>"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    70
  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
    71
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    72
text \<open>Equality\<close>
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    73
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    74
lemma sinl_eq [simp]: "sinl\<cdot>x = sinl\<cdot>y \<longleftrightarrow> x = y"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    75
  by (simp add: po_eq_conv)
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    76
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    77
lemma sinr_eq [simp]: "sinr\<cdot>x = sinr\<cdot>y \<longleftrightarrow> x = y"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    78
  by (simp add: po_eq_conv)
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    79
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    80
lemma sinl_eq_sinr [simp]: "sinl\<cdot>x = sinr\<cdot>y \<longleftrightarrow> x = \<bottom> \<and> y = \<bottom>"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    81
  by (subst po_eq_conv) simp
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    82
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    83
lemma sinr_eq_sinl [simp]: "sinr\<cdot>x = sinl\<cdot>y \<longleftrightarrow> x = \<bottom> \<and> y = \<bottom>"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    84
  by (subst po_eq_conv) simp
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    85
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    86
lemma sinl_inject: "sinl\<cdot>x = sinl\<cdot>y \<Longrightarrow> x = y"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    87
  by (rule sinl_eq [THEN iffD1])
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    88
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    89
lemma sinr_inject: "sinr\<cdot>x = sinr\<cdot>y \<Longrightarrow> x = y"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    90
  by (rule sinr_eq [THEN iffD1])
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    91
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    92
text \<open>Strictness\<close>
17837
2922be3544f8 added compactness lemmas; cleaned up
huffman
parents: 17817
diff changeset
    93
16211
faa9691da2bc changed to use new contI; renamed strict, defined, and inject lemmas
huffman
parents: 16083
diff changeset
    94
lemma sinl_strict [simp]: "sinl\<cdot>\<bottom> = \<bottom>"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    95
  by (simp add: Rep_ssum_simps)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    96
16211
faa9691da2bc changed to use new contI; renamed strict, defined, and inject lemmas
huffman
parents: 16083
diff changeset
    97
lemma sinr_strict [simp]: "sinr\<cdot>\<bottom> = \<bottom>"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    98
  by (simp add: Rep_ssum_simps)
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
    99
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   100
lemma sinl_bottom_iff [simp]: "sinl\<cdot>x = \<bottom> \<longleftrightarrow> x = \<bottom>"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   101
  using sinl_eq [of "x" "\<bottom>"] by simp
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   102
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   103
lemma sinr_bottom_iff [simp]: "sinr\<cdot>x = \<bottom> \<longleftrightarrow> x = \<bottom>"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   104
  using sinr_eq [of "x" "\<bottom>"] by simp
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   105
40081
748911a00a51 remove intro! attribute from {sinl,sinr}_defined
huffman
parents: 40080
diff changeset
   106
lemma sinl_defined: "x \<noteq> \<bottom> \<Longrightarrow> sinl\<cdot>x \<noteq> \<bottom>"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   107
  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
   108
40081
748911a00a51 remove intro! attribute from {sinl,sinr}_defined
huffman
parents: 40080
diff changeset
   109
lemma sinr_defined: "x \<noteq> \<bottom> \<Longrightarrow> sinr\<cdot>x \<noteq> \<bottom>"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   110
  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
   111
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
   112
text \<open>Compactness\<close>
25882
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   113
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   114
lemma compact_sinl: "compact x \<Longrightarrow> compact (sinl\<cdot>x)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   115
  by (rule compact_ssum) (simp add: Rep_ssum_sinl)
25882
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   116
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   117
lemma compact_sinr: "compact x \<Longrightarrow> compact (sinr\<cdot>x)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   118
  by (rule compact_ssum) (simp add: Rep_ssum_sinr)
25882
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   119
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   120
lemma compact_sinlD: "compact (sinl\<cdot>x) \<Longrightarrow> compact x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   121
  unfolding compact_def
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   122
  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
   123
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   124
lemma compact_sinrD: "compact (sinr\<cdot>x) \<Longrightarrow> compact x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   125
  unfolding compact_def
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   126
  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
   127
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   128
lemma compact_sinl_iff [simp]: "compact (sinl\<cdot>x) = compact x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   129
  by (safe elim!: compact_sinl compact_sinlD)
25882
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   130
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   131
lemma compact_sinr_iff [simp]: "compact (sinr\<cdot>x) = compact x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   132
  by (safe elim!: compact_sinr compact_sinrD)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   133
25882
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   134
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
   135
subsection \<open>Case analysis\<close>
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   136
35783
38538bfe9ca6 declare case_names for various induction rules
huffman
parents: 35547
diff changeset
   137
lemma ssumE [case_names bottom sinl sinr, cases type: ssum]:
40080
435f9f5970f8 simplify proofs of ssumE, sprodE
huffman
parents: 40046
diff changeset
   138
  obtains "p = \<bottom>"
435f9f5970f8 simplify proofs of ssumE, sprodE
huffman
parents: 40046
diff changeset
   139
  | x where "p = sinl\<cdot>x" and "x \<noteq> \<bottom>"
435f9f5970f8 simplify proofs of ssumE, sprodE
huffman
parents: 40046
diff changeset
   140
  | y where "p = sinr\<cdot>y" and "y \<noteq> \<bottom>"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   141
  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
   142
35783
38538bfe9ca6 declare case_names for various induction rules
huffman
parents: 35547
diff changeset
   143
lemma ssum_induct [case_names bottom sinl sinr, induct type: ssum]:
25756
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   144
  "\<lbrakk>P \<bottom>;
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   145
   \<And>x. x \<noteq> \<bottom> \<Longrightarrow> P (sinl\<cdot>x);
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   146
   \<And>y. y \<noteq> \<bottom> \<Longrightarrow> P (sinr\<cdot>y)\<rbrakk> \<Longrightarrow> P x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   147
  by (cases x) simp_all
25756
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   148
35783
38538bfe9ca6 declare case_names for various induction rules
huffman
parents: 35547
diff changeset
   149
lemma ssumE2 [case_names sinl sinr]:
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   150
  "\<lbrakk>\<And>x. p = sinl\<cdot>x \<Longrightarrow> Q; \<And>y. p = sinr\<cdot>y \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   151
  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
   152
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
   153
lemma below_sinlD: "p \<sqsubseteq> sinl\<cdot>x \<Longrightarrow> \<exists>y. p = sinl\<cdot>y \<and> y \<sqsubseteq> x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   154
  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
   155
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
   156
lemma below_sinrD: "p \<sqsubseteq> sinr\<cdot>x \<Longrightarrow> \<exists>y. p = sinr\<cdot>y \<and> y \<sqsubseteq> x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   157
  by (cases p, rule_tac x="\<bottom>" in exI, simp_all)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   158
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   159
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
   160
subsection \<open>Case analysis combinator\<close>
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   161
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81095
diff changeset
   162
definition sscase :: "('a::pcpo \<rightarrow> 'c::pcpo) \<rightarrow> ('b::pcpo \<rightarrow> 'c) \<rightarrow> ('a ++ 'b) \<rightarrow> 'c"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   163
  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
   164
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   165
translations
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   166
  "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"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   167
  "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
   168
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
   169
translations
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   170
  "\<Lambda>(XCONST sinl\<cdot>x). t" \<rightleftharpoons> "CONST sscase\<cdot>(\<Lambda> x. t)\<cdot>\<bottom>"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   171
  "\<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
   172
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   173
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)"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   174
  by (simp add: sscase_def cont_Rep_ssum)
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   175
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   176
lemma sscase1 [simp]: "sscase\<cdot>f\<cdot>g\<cdot>\<bottom> = \<bottom>"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   177
  by (simp add: beta_sscase Rep_ssum_strict)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   178
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   179
lemma sscase2 [simp]: "x \<noteq> \<bottom> \<Longrightarrow> sscase\<cdot>f\<cdot>g\<cdot>(sinl\<cdot>x) = f\<cdot>x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   180
  by (simp add: beta_sscase Rep_ssum_sinl)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   181
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   182
lemma sscase3 [simp]: "y \<noteq> \<bottom> \<Longrightarrow> sscase\<cdot>f\<cdot>g\<cdot>(sinr\<cdot>y) = g\<cdot>y"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   183
  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
   184
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   185
lemma sscase4 [simp]: "sscase\<cdot>sinl\<cdot>sinr\<cdot>z = z"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   186
  by (cases z) simp_all
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   187
15593
24d770bbc44a reordered and arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   188
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
   189
subsection \<open>Strict sum preserves flatness\<close>
25827
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
   190
35525
fa231b86cb1e proper names for types cfun, sprod, ssum
huffman
parents: 35491
diff changeset
   191
instance ssum :: (flat, flat) flat
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   192
  apply (intro_classes, clarify)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   193
  apply (case_tac x, simp)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   194
   apply (case_tac y, simp_all add: flat_below_iff)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   195
  apply (case_tac y, simp_all add: flat_below_iff)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   196
  done
25827
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
   197
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   198
end