src/HOLCF/Ssum.thy
author wenzelm
Thu, 11 Dec 2008 16:50:18 +0100
changeset 29063 7619f0561cd7
parent 27310 d0229bc6c461
child 29138 661a8db7e647
permissions -rw-r--r--
pcpodef package: state two goals, instead of encoded conjunction;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15600
a59f07556a8d fixed filename in header
huffman
parents: 15593
diff changeset
     1
(*  Title:      HOLCF/Ssum.thy
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
     2
    ID:         $Id$
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
     3
    Author:     Franz Regensburger and Brian Huffman
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
     4
16070
4a83dd540b88 removed LICENCE note -- everything is subject to Isabelle licence as
wenzelm
parents: 16060
diff changeset
     5
Strict sum with typedef.
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
     6
*)
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
     7
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
     8
header {* The type of strict sums *}
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
     9
15577
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
    10
theory Ssum
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    11
imports Cprod Tr
15577
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
    12
begin
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    13
16083
fca38c55c8fa added defaultsort declaration, moved cpair_less to Cprod.thy
huffman
parents: 16070
diff changeset
    14
defaultsort pcpo
fca38c55c8fa added defaultsort declaration, moved cpair_less to Cprod.thy
huffman
parents: 16070
diff changeset
    15
15593
24d770bbc44a reordered and arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    16
subsection {* Definition of strict sum type *}
24d770bbc44a reordered and arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    17
17817
405fb812e738 add names to infix declarations
huffman
parents: 16921
diff changeset
    18
pcpodef (Ssum)  ('a, 'b) "++" (infixr "++" 10) = 
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    19
  "{p :: tr \<times> ('a \<times> 'b).
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    20
    (cfst\<cdot>p \<sqsubseteq> TT \<longleftrightarrow> csnd\<cdot>(csnd\<cdot>p) = \<bottom>) \<and>
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    21
    (cfst\<cdot>p \<sqsubseteq> FF \<longleftrightarrow> cfst\<cdot>(csnd\<cdot>p) = \<bottom>)}"
29063
7619f0561cd7 pcpodef package: state two goals, instead of encoded conjunction;
wenzelm
parents: 27310
diff changeset
    22
by simp_all
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    23
25827
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
    24
instance "++" :: ("{finite_po,pcpo}", "{finite_po,pcpo}") finite_po
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
    25
by (rule typedef_finite_po [OF type_definition_Ssum])
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
    26
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
    27
instance "++" :: ("{chfin,pcpo}", "{chfin,pcpo}") chfin
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
    28
by (rule typedef_chfin [OF type_definition_Ssum less_Ssum_def])
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
    29
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    30
syntax (xsymbols)
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    31
  "++"		:: "[type, type] => type"	("(_ \<oplus>/ _)" [21, 20] 20)
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    32
syntax (HTML output)
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    33
  "++"		:: "[type, type] => type"	("(_ \<oplus>/ _)" [21, 20] 20)
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    34
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
    35
subsection {* Definitions of constructors *}
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
    36
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 19440
diff changeset
    37
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 19440
diff changeset
    38
  sinl :: "'a \<rightarrow> ('a ++ 'b)" where
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    39
  "sinl = (\<Lambda> a. Abs_Ssum <strictify\<cdot>(\<Lambda> _. TT)\<cdot>a, a, \<bottom>>)"
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
    40
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 19440
diff changeset
    41
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 19440
diff changeset
    42
  sinr :: "'b \<rightarrow> ('a ++ 'b)" where
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    43
  "sinr = (\<Lambda> b. Abs_Ssum <strictify\<cdot>(\<Lambda> _. FF)\<cdot>b, \<bottom>, b>)"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    44
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    45
lemma sinl_Ssum: "<strictify\<cdot>(\<Lambda> _. TT)\<cdot>a, a, \<bottom>> \<in> Ssum"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    46
by (simp add: Ssum_def strictify_conv_if)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    47
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    48
lemma sinr_Ssum: "<strictify\<cdot>(\<Lambda> _. FF)\<cdot>b, \<bottom>, b> \<in> Ssum"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    49
by (simp add: Ssum_def strictify_conv_if)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    50
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    51
lemma sinl_Abs_Ssum: "sinl\<cdot>a = Abs_Ssum <strictify\<cdot>(\<Lambda> _. TT)\<cdot>a, a, \<bottom>>"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    52
by (unfold sinl_def, simp add: cont_Abs_Ssum sinl_Ssum)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    53
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    54
lemma sinr_Abs_Ssum: "sinr\<cdot>b = Abs_Ssum <strictify\<cdot>(\<Lambda> _. FF)\<cdot>b, \<bottom>, b>"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    55
by (unfold sinr_def, simp add: cont_Abs_Ssum sinr_Ssum)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    56
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    57
lemma Rep_Ssum_sinl: "Rep_Ssum (sinl\<cdot>a) = <strictify\<cdot>(\<Lambda> _. TT)\<cdot>a, a, \<bottom>>"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    58
by (simp add: sinl_Abs_Ssum Abs_Ssum_inverse sinl_Ssum)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    59
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    60
lemma Rep_Ssum_sinr: "Rep_Ssum (sinr\<cdot>b) = <strictify\<cdot>(\<Lambda> _. FF)\<cdot>b, \<bottom>, b>"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    61
by (simp add: sinr_Abs_Ssum Abs_Ssum_inverse sinr_Ssum)
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
    62
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
    63
subsection {* Properties of @{term sinl} and @{term sinr} *}
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
    64
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    65
text {* Ordering *}
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    66
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    67
lemma sinl_less [simp]: "(sinl\<cdot>x \<sqsubseteq> sinl\<cdot>y) = (x \<sqsubseteq> y)"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    68
by (simp add: less_Ssum_def Rep_Ssum_sinl strictify_conv_if)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    69
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    70
lemma sinr_less [simp]: "(sinr\<cdot>x \<sqsubseteq> sinr\<cdot>y) = (x \<sqsubseteq> y)"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    71
by (simp add: less_Ssum_def Rep_Ssum_sinr strictify_conv_if)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    72
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    73
lemma sinl_less_sinr [simp]: "(sinl\<cdot>x \<sqsubseteq> sinr\<cdot>y) = (x = \<bottom>)"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    74
by (simp add: less_Ssum_def Rep_Ssum_sinl Rep_Ssum_sinr strictify_conv_if)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    75
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    76
lemma sinr_less_sinl [simp]: "(sinr\<cdot>x \<sqsubseteq> sinl\<cdot>y) = (x = \<bottom>)"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    77
by (simp add: less_Ssum_def Rep_Ssum_sinl Rep_Ssum_sinr strictify_conv_if)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    78
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    79
text {* Equality *}
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    80
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    81
lemma sinl_eq [simp]: "(sinl\<cdot>x = sinl\<cdot>y) = (x = y)"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    82
by (simp add: po_eq_conv)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    83
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    84
lemma sinr_eq [simp]: "(sinr\<cdot>x = sinr\<cdot>y) = (x = y)"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    85
by (simp add: po_eq_conv)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    86
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    87
lemma sinl_eq_sinr [simp]: "(sinl\<cdot>x = sinr\<cdot>y) = (x = \<bottom> \<and> y = \<bottom>)"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    88
by (subst po_eq_conv, simp)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    89
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    90
lemma sinr_eq_sinl [simp]: "(sinr\<cdot>x = sinl\<cdot>y) = (x = \<bottom> \<and> y = \<bottom>)"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    91
by (subst po_eq_conv, simp)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    92
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    93
lemma sinl_inject: "sinl\<cdot>x = sinl\<cdot>y \<Longrightarrow> x = y"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    94
by (rule sinl_eq [THEN iffD1])
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    95
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    96
lemma sinr_inject: "sinr\<cdot>x = sinr\<cdot>y \<Longrightarrow> x = y"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    97
by (rule sinr_eq [THEN iffD1])
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    98
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
    99
text {* Strictness *}
17837
2922be3544f8 added compactness lemmas; cleaned up
huffman
parents: 17817
diff changeset
   100
16211
faa9691da2bc changed to use new contI; renamed strict, defined, and inject lemmas
huffman
parents: 16083
diff changeset
   101
lemma sinl_strict [simp]: "sinl\<cdot>\<bottom> = \<bottom>"
25915
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   102
by (simp add: sinl_Abs_Ssum Abs_Ssum_strict)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   103
16211
faa9691da2bc changed to use new contI; renamed strict, defined, and inject lemmas
huffman
parents: 16083
diff changeset
   104
lemma sinr_strict [simp]: "sinr\<cdot>\<bottom> = \<bottom>"
25915
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   105
by (simp add: sinr_Abs_Ssum Abs_Ssum_strict)
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   106
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
   107
lemma sinl_defined_iff [simp]: "(sinl\<cdot>x = \<bottom>) = (x = \<bottom>)"
17837
2922be3544f8 added compactness lemmas; cleaned up
huffman
parents: 17817
diff changeset
   108
by (cut_tac sinl_eq [of "x" "\<bottom>"], simp)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   109
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
lemma sinr_defined_iff [simp]: "(sinr\<cdot>x = \<bottom>) = (x = \<bottom>)"
17837
2922be3544f8 added compactness lemmas; cleaned up
huffman
parents: 17817
diff changeset
   111
by (cut_tac sinr_eq [of "x" "\<bottom>"], simp)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   112
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
lemma sinl_defined [intro!]: "x \<noteq> \<bottom> \<Longrightarrow> sinl\<cdot>x \<noteq> \<bottom>"
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
   114
by simp
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
   115
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
   116
lemma sinr_defined [intro!]: "x \<noteq> \<bottom> \<Longrightarrow> sinr\<cdot>x \<noteq> \<bottom>"
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
   117
by simp
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
   118
25882
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   119
text {* Compactness *}
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   120
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   121
lemma compact_sinl: "compact x \<Longrightarrow> compact (sinl\<cdot>x)"
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   122
by (rule compact_Ssum, simp add: Rep_Ssum_sinl strictify_conv_if)
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_sinr: "compact x \<Longrightarrow> compact (sinr\<cdot>x)"
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   125
by (rule compact_Ssum, simp add: Rep_Ssum_sinr strictify_conv_if)
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   126
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   127
lemma compact_sinlD: "compact (sinl\<cdot>x) \<Longrightarrow> compact x"
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   128
unfolding compact_def
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   129
by (drule adm_subst [OF cont_Rep_CFun2 [where f=sinl]], simp)
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_sinrD: "compact (sinr\<cdot>x) \<Longrightarrow> compact x"
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   132
unfolding compact_def
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   133
by (drule adm_subst [OF cont_Rep_CFun2 [where f=sinr]], simp)
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   134
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   135
lemma compact_sinl_iff [simp]: "compact (sinl\<cdot>x) = compact x"
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   136
by (safe elim!: compact_sinl compact_sinlD)
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   137
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   138
lemma compact_sinr_iff [simp]: "compact (sinr\<cdot>x) = compact x"
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   139
by (safe elim!: compact_sinr compact_sinrD)
c58e380d9f7d new compactness lemmas; removed duplicated flat_less_iff
huffman
parents: 25827
diff changeset
   140
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   141
subsection {* Case analysis *}
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   142
16921
16094ed8ac6b renamed Exh_Ssum1 to Exh_Ssum; cleaned up
huffman
parents: 16823
diff changeset
   143
lemma Exh_Ssum: 
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   144
  "z = \<bottom> \<or> (\<exists>a. z = sinl\<cdot>a \<and> a \<noteq> \<bottom>) \<or> (\<exists>b. z = sinr\<cdot>b \<and> b \<noteq> \<bottom>)"
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
   145
apply (rule_tac x=z in Abs_Ssum_induct)
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   146
apply (rule_tac p=y in cprodE, rename_tac t x)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   147
apply (rule_tac p=x in cprodE, rename_tac a b)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   148
apply (rule_tac p=t in trE)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   149
apply (rule disjI1)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   150
apply (simp add: Ssum_def cpair_strict Abs_Ssum_strict)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   151
apply (rule disjI2, rule disjI1, rule_tac x=a in exI)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   152
apply (simp add: sinl_Abs_Ssum Ssum_def)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   153
apply (rule disjI2, rule disjI2, rule_tac x=b in exI)
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   154
apply (simp add: sinr_Abs_Ssum Ssum_def)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   155
done
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   156
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   157
lemma ssumE [cases type: ++]:
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   158
  "\<lbrakk>p = \<bottom> \<Longrightarrow> Q;
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   159
   \<And>x. \<lbrakk>p = sinl\<cdot>x; x \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> Q;
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   160
   \<And>y. \<lbrakk>p = sinr\<cdot>y; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
16921
16094ed8ac6b renamed Exh_Ssum1 to Exh_Ssum; cleaned up
huffman
parents: 16823
diff changeset
   161
by (cut_tac z=p in Exh_Ssum, auto)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   162
25756
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   163
lemma ssum_induct [induct type: ++]:
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   164
  "\<lbrakk>P \<bottom>;
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   165
   \<And>x. x \<noteq> \<bottom> \<Longrightarrow> P (sinl\<cdot>x);
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   166
   \<And>y. y \<noteq> \<bottom> \<Longrightarrow> P (sinr\<cdot>y)\<rbrakk> \<Longrightarrow> P x"
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   167
by (cases x, simp_all)
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   168
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   169
lemma ssumE2:
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   170
  "\<lbrakk>\<And>x. p = sinl\<cdot>x \<Longrightarrow> Q; \<And>y. p = sinr\<cdot>y \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q"
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   171
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
   172
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   173
lemma less_sinlD: "p \<sqsubseteq> sinl\<cdot>x \<Longrightarrow> \<exists>y. p = sinl\<cdot>y \<and> y \<sqsubseteq> x"
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   174
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
   175
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   176
lemma less_sinrD: "p \<sqsubseteq> sinr\<cdot>x \<Longrightarrow> \<exists>y. p = sinr\<cdot>y \<and> y \<sqsubseteq> x"
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   177
by (cases p, rule_tac x="\<bottom>" in exI, simp_all)
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   178
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   179
subsection {* Case analysis combinator *}
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   180
25131
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 19440
diff changeset
   181
definition
2c8caac48ade modernized specifications ('definition', 'abbreviation', 'notation');
wenzelm
parents: 19440
diff changeset
   182
  sscase :: "('a \<rightarrow> 'c) \<rightarrow> ('b \<rightarrow> 'c) \<rightarrow> ('a ++ 'b) \<rightarrow> 'c" where
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   183
  "sscase = (\<Lambda> f g s. (\<Lambda><t, x, y>. If t then f\<cdot>x else g\<cdot>y fi)\<cdot>(Rep_Ssum s))"
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   184
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   185
translations
26046
1624b3304bb9 fix broken syntax translations
huffman
parents: 25915
diff changeset
   186
  "case s of XCONST sinl\<cdot>x \<Rightarrow> t1 | XCONST sinr\<cdot>y \<Rightarrow> t2" == "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
   187
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
   188
translations
26046
1624b3304bb9 fix broken syntax translations
huffman
parents: 25915
diff changeset
   189
  "\<Lambda>(XCONST sinl\<cdot>x). t" == "CONST sscase\<cdot>(\<Lambda> x. t)\<cdot>\<bottom>"
1624b3304bb9 fix broken syntax translations
huffman
parents: 25915
diff changeset
   190
  "\<Lambda>(XCONST sinr\<cdot>y). t" == "CONST sscase\<cdot>\<bottom>\<cdot>(\<Lambda> y. t)"
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   191
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   192
lemma beta_sscase:
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   193
  "sscase\<cdot>f\<cdot>g\<cdot>s = (\<Lambda><t, x, y>. If t then f\<cdot>x else g\<cdot>y fi)\<cdot>(Rep_Ssum s)"
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   194
unfolding sscase_def by (simp add: cont_Rep_Ssum)
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   195
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   196
lemma sscase1 [simp]: "sscase\<cdot>f\<cdot>g\<cdot>\<bottom> = \<bottom>"
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   197
unfolding beta_sscase by (simp add: Rep_Ssum_strict)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   198
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   199
lemma sscase2 [simp]: "x \<noteq> \<bottom> \<Longrightarrow> sscase\<cdot>f\<cdot>g\<cdot>(sinl\<cdot>x) = f\<cdot>x"
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   200
unfolding beta_sscase by (simp add: Rep_Ssum_sinl)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   201
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   202
lemma sscase3 [simp]: "y \<noteq> \<bottom> \<Longrightarrow> sscase\<cdot>f\<cdot>g\<cdot>(sinr\<cdot>y) = g\<cdot>y"
25740
de65baf89106 changed type definition to make Iwhen and reasoning about chains unnecessary;
huffman
parents: 25131
diff changeset
   203
unfolding beta_sscase by (simp add: Rep_Ssum_sinr)
15593
24d770bbc44a reordered and arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   204
16060
833be7f71ecd Simplified version of strict sum theory, using TypedefPcpo
huffman
parents: 15606
diff changeset
   205
lemma sscase4 [simp]: "sscase\<cdot>sinl\<cdot>sinr\<cdot>z = z"
25756
86d4930373a1 add induction rule ssum_induct
huffman
parents: 25740
diff changeset
   206
by (cases z, simp_all)
15593
24d770bbc44a reordered and arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   207
25827
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
   208
subsection {* Strict sum preserves flatness *}
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
   209
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
   210
instance "++" :: (flat, flat) flat
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
   211
apply (intro_classes, clarify)
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
   212
apply (rule_tac p=x in ssumE, simp)
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
   213
apply (rule_tac p=y in ssumE, simp_all add: flat_less_iff)
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
   214
apply (rule_tac p=y in ssumE, simp_all add: flat_less_iff)
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
   215
done
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 25756
diff changeset
   216
25915
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   217
subsection {* Strict sum is a bifinite domain *}
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   218
26962
c8b20f615d6c use new class package for classes profinite, bifinite; remove approx class
huffman
parents: 26046
diff changeset
   219
instantiation "++" :: (bifinite, bifinite) bifinite
c8b20f615d6c use new class package for classes profinite, bifinite; remove approx class
huffman
parents: 26046
diff changeset
   220
begin
25915
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   221
26962
c8b20f615d6c use new class package for classes profinite, bifinite; remove approx class
huffman
parents: 26046
diff changeset
   222
definition
25915
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   223
  approx_ssum_def:
26962
c8b20f615d6c use new class package for classes profinite, bifinite; remove approx class
huffman
parents: 26046
diff changeset
   224
    "approx = (\<lambda>n. sscase\<cdot>(\<Lambda> x. sinl\<cdot>(approx n\<cdot>x))\<cdot>(\<Lambda> y. sinr\<cdot>(approx n\<cdot>y)))"
25915
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   225
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   226
lemma approx_sinl [simp]: "approx i\<cdot>(sinl\<cdot>x) = sinl\<cdot>(approx i\<cdot>x)"
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   227
unfolding approx_ssum_def by (cases "x = \<bottom>") simp_all
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   228
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   229
lemma approx_sinr [simp]: "approx i\<cdot>(sinr\<cdot>x) = sinr\<cdot>(approx i\<cdot>x)"
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   230
unfolding approx_ssum_def by (cases "x = \<bottom>") simp_all
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   231
26962
c8b20f615d6c use new class package for classes profinite, bifinite; remove approx class
huffman
parents: 26046
diff changeset
   232
instance proof
25915
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   233
  fix i :: nat and x :: "'a \<oplus> 'b"
27310
d0229bc6c461 simplify profinite class axioms
huffman
parents: 26962
diff changeset
   234
  show "chain (approx :: nat \<Rightarrow> 'a \<oplus> 'b \<rightarrow> 'a \<oplus> 'b)"
25915
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   235
    unfolding approx_ssum_def by simp
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   236
  show "(\<Squnion>i. approx i\<cdot>x) = x"
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   237
    unfolding approx_ssum_def
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   238
    by (simp add: lub_distribs eta_cfun)
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   239
  show "approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x"
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   240
    by (cases x, simp add: approx_ssum_def, simp, simp)
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   241
  have "{x::'a \<oplus> 'b. approx i\<cdot>x = x} \<subseteq>
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   242
        (\<lambda>x. sinl\<cdot>x) ` {x. approx i\<cdot>x = x} \<union>
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   243
        (\<lambda>x. sinr\<cdot>x) ` {x. approx i\<cdot>x = x}"
27310
d0229bc6c461 simplify profinite class axioms
huffman
parents: 26962
diff changeset
   244
    by (rule subsetI, case_tac x rule: ssumE2, simp, simp)
25915
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   245
  thus "finite {x::'a \<oplus> 'b. approx i\<cdot>x = x}"
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   246
    by (rule finite_subset,
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   247
        intro finite_UnI finite_imageI finite_fixes_approx)
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   248
qed
f1bce5261dec add instance for class bifinite
huffman
parents: 25882
diff changeset
   249
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents:
diff changeset
   250
end
26962
c8b20f615d6c use new class package for classes profinite, bifinite; remove approx class
huffman
parents: 26046
diff changeset
   251
c8b20f615d6c use new class package for classes profinite, bifinite; remove approx class
huffman
parents: 26046
diff changeset
   252
end