src/HOL/HOLCF/Ssum.thy
author haftmann
Mon, 04 Nov 2019 20:38:15 +0000
changeset 71042 400e9512f1d3
parent 67312 0d25e02759b7
permissions -rw-r--r--
proof-of-concept theory for bit operations without a constructivistic representation and a minimal common logical foundation
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
36452
d37c6eed8117 renamed command 'defaultsort' to 'default_sort';
wenzelm
parents: 35900
diff changeset
    12
default_sort pcpo
16083
fca38c55c8fa added defaultsort declaration, moved cpair_less to Cprod.thy
huffman
parents: 16070
diff changeset
    13
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    14
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    17
definition "ssum =
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    18
  {p :: tr \<times> ('a \<times> 'b). p = \<bottom> \<or>
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    19
    (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
    20
    (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
    21
61998
b66d2ca1f907 clarified print modes;
wenzelm
parents: 61378
diff changeset
    22
pcpodef ('a, 'b) ssum  ("(_ \<oplus>/ _)" [21, 20] 20) = "ssum :: (tr \<times> 'a \<times> 'b) set"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    23
  by (simp_all add: ssum_def)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    24
35525
fa231b86cb1e proper names for types cfun, sprod, ssum
huffman
parents: 35491
diff changeset
    25
instance ssum :: ("{chfin,pcpo}", "{chfin,pcpo}") chfin
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    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
b66d2ca1f907 clarified print modes;
wenzelm
parents: 61378
diff changeset
    28
type_notation (ASCII)
b66d2ca1f907 clarified print modes;
wenzelm
parents: 61378
diff changeset
    29
  ssum  (infixr "++" 10)
35547
991a6af75978 merged, resolving some basic conflicts;
wenzelm
parents: 35525 35427
diff changeset
    30
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    31
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    32
subsection \<open>Definitions of constructors\<close>
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    33
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    34
definition sinl :: "'a \<rightarrow> ('a ++ 'b)"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    37
definition sinr :: "'b \<rightarrow> ('a ++ 'b)"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    57
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    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
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    62
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
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    65
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
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    68
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
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    71
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
    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
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    76
lemma sinl_eq [simp]: "sinl\<cdot>x = sinl\<cdot>y \<longleftrightarrow> x = y"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    79
lemma sinr_eq [simp]: "sinr\<cdot>x = sinr\<cdot>y \<longleftrightarrow> x = y"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    82
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
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    85
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
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    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
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
    94
text \<open>Strictness\<close>
17837
2922be3544f8 added compactness lemmas; cleaned up
huffman
parents: 17817
diff changeset
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   100
  by (simp add: Rep_ssum_simps)
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   101
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   102
lemma sinl_bottom_iff [simp]: "sinl\<cdot>x = \<bottom> \<longleftrightarrow> x = \<bottom>"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   105
lemma sinr_bottom_iff [simp]: "sinr\<cdot>x = \<bottom> \<longleftrightarrow> x = \<bottom>"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
748911a00a51 remove intro! attribute from {sinl,sinr}_defined
huffman
parents: 40080
diff changeset
   108
lemma sinl_defined: "x \<noteq> \<bottom> \<Longrightarrow> sinl\<cdot>x \<noteq> \<bottom>"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
748911a00a51 remove intro! attribute from {sinl,sinr}_defined
huffman
parents: 40080
diff changeset
   111
lemma sinr_defined: "x \<noteq> \<bottom> \<Longrightarrow> sinr\<cdot>x \<noteq> \<bottom>"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   123
  unfolding compact_def
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   127
  unfolding compact_def
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   134
  by (safe elim!: compact_sinr compact_sinrD)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   135
25882
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   136
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
   137
subsection \<open>Case analysis\<close>
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   138
35783
38538bfe9ca6 declare case_names for various induction rules
huffman
parents: 35547
diff changeset
   139
lemma ssumE [case_names bottom sinl sinr, cases type: ssum]:
40080
435f9f5970f8 simplify proofs of ssumE, sprodE
huffman
parents: 40046
diff changeset
   140
  obtains "p = \<bottom>"
435f9f5970f8 simplify proofs of ssumE, sprodE
huffman
parents: 40046
diff changeset
   141
  | x where "p = sinl\<cdot>x" and "x \<noteq> \<bottom>"
435f9f5970f8 simplify proofs of ssumE, sprodE
huffman
parents: 40046
diff changeset
   142
  | y where "p = sinr\<cdot>y" and "y \<noteq> \<bottom>"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
38538bfe9ca6 declare case_names for various induction rules
huffman
parents: 35547
diff changeset
   145
lemma ssum_induct [case_names bottom sinl sinr, induct type: ssum]:
25756
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   146
  "\<lbrakk>P \<bottom>;
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   147
   \<And>x. x \<noteq> \<bottom> \<Longrightarrow> P (sinl\<cdot>x);
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   148
   \<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
   149
  by (cases x) simp_all
25756
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   150
35783
38538bfe9ca6 declare case_names for various induction rules
huffman
parents: 35547
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   159
  by (cases p, rule_tac x="\<bottom>" in exI, simp_all)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   160
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   161
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
   162
subsection \<open>Case analysis combinator\<close>
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   163
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   164
definition sscase :: "('a \<rightarrow> 'c) \<rightarrow> ('b \<rightarrow> 'c) \<rightarrow> ('a ++ 'b) \<rightarrow> 'c"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   172
  "\<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
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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)"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   188
  by (cases z) simp_all
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   189
15593
24d770bbc44a reordered and arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   190
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61998
diff changeset
   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
fa231b86cb1e proper names for types cfun, sprod, ssum
huffman
parents: 35491
diff changeset
   193
instance ssum :: (flat, flat) flat
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   194
  apply (intro_classes, clarify)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   195
  apply (case_tac x, simp)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   196
   apply (case_tac y, simp_all add: flat_below_iff)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   197
  apply (case_tac y, simp_all add: flat_below_iff)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   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