src/HOLCF/Sum_Cpo.thy
author huffman
Fri, 08 May 2009 16:19:51 -0700
changeset 31076 99fe356cbbc2
parent 31041 85b4843d9939
child 35900 aa5dfb03eb1e
permissions -rw-r--r--
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29534
247e4c816004 rename Dsum.thy to Sum_Cpo.thy
huffman
parents: 29130
diff changeset
     1
(*  Title:      HOLCF/Sum_Cpo.thy
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
     2
    Author:     Brian Huffman
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
     3
*)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
     4
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
     5
header {* The cpo of disjoint sums *}
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
     6
29534
247e4c816004 rename Dsum.thy to Sum_Cpo.thy
huffman
parents: 29130
diff changeset
     7
theory Sum_Cpo
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
     8
imports Bifinite
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
     9
begin
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    10
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    11
subsection {* Ordering on type @{typ "'a + 'b"} *}
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    12
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    13
instantiation "+" :: (below, below) below
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    14
begin
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    15
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    16
definition below_sum_def:
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    17
  "x \<sqsubseteq> y \<equiv> case x of
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    18
         Inl a \<Rightarrow> (case y of Inl b \<Rightarrow> a \<sqsubseteq> b | Inr b \<Rightarrow> False) |
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    19
         Inr a \<Rightarrow> (case y of Inl b \<Rightarrow> False | Inr b \<Rightarrow> a \<sqsubseteq> b)"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    20
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    21
instance ..
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    22
end
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    23
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    24
lemma Inl_below_Inl [simp]: "Inl x \<sqsubseteq> Inl y = x \<sqsubseteq> y"
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    25
unfolding below_sum_def by simp
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    26
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    27
lemma Inr_below_Inr [simp]: "Inr x \<sqsubseteq> Inr y = x \<sqsubseteq> y"
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    28
unfolding below_sum_def by simp
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    29
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    30
lemma Inl_below_Inr [simp]: "\<not> Inl x \<sqsubseteq> Inr y"
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    31
unfolding below_sum_def by simp
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    32
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    33
lemma Inr_below_Inl [simp]: "\<not> Inr x \<sqsubseteq> Inl y"
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    34
unfolding below_sum_def by simp
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    35
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    36
lemma Inl_mono: "x \<sqsubseteq> y \<Longrightarrow> Inl x \<sqsubseteq> Inl y"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    37
by simp
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    38
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    39
lemma Inr_mono: "x \<sqsubseteq> y \<Longrightarrow> Inr x \<sqsubseteq> Inr y"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    40
by simp
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    41
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    42
lemma Inl_belowE: "\<lbrakk>Inl a \<sqsubseteq> x; \<And>b. \<lbrakk>x = Inl b; a \<sqsubseteq> b\<rbrakk> \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R"
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    43
by (cases x, simp_all)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    44
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    45
lemma Inr_belowE: "\<lbrakk>Inr a \<sqsubseteq> x; \<And>b. \<lbrakk>x = Inr b; a \<sqsubseteq> b\<rbrakk> \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R"
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    46
by (cases x, simp_all)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    47
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    48
lemmas sum_below_elims = Inl_belowE Inr_belowE
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    49
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    50
lemma sum_below_cases:
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    51
  "\<lbrakk>x \<sqsubseteq> y;
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    52
    \<And>a b. \<lbrakk>x = Inl a; y = Inl b; a \<sqsubseteq> b\<rbrakk> \<Longrightarrow> R;
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    53
    \<And>a b. \<lbrakk>x = Inr a; y = Inr b; a \<sqsubseteq> b\<rbrakk> \<Longrightarrow> R\<rbrakk>
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    54
      \<Longrightarrow> R"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    55
by (cases x, safe elim!: sum_below_elims, auto)
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    56
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    57
subsection {* Sum type is a complete partial order *}
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    58
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    59
instance "+" :: (po, po) po
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    60
proof
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    61
  fix x :: "'a + 'b"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    62
  show "x \<sqsubseteq> x"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    63
    by (induct x, simp_all)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    64
next
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    65
  fix x y :: "'a + 'b"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    66
  assume "x \<sqsubseteq> y" and "y \<sqsubseteq> x" thus "x = y"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    67
    by (induct x, auto elim!: sum_below_elims intro: below_antisym)
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    68
next
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    69
  fix x y z :: "'a + 'b"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    70
  assume "x \<sqsubseteq> y" and "y \<sqsubseteq> z" thus "x \<sqsubseteq> z"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    71
    by (induct x, auto elim!: sum_below_elims intro: below_trans)
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    72
qed
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    73
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    74
lemma monofun_inv_Inl: "monofun (\<lambda>p. THE a. p = Inl a)"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    75
by (rule monofunI, erule sum_below_cases, simp_all)
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    76
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    77
lemma monofun_inv_Inr: "monofun (\<lambda>p. THE b. p = Inr b)"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    78
by (rule monofunI, erule sum_below_cases, simp_all)
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    79
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    80
lemma sum_chain_cases:
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    81
  assumes Y: "chain Y"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    82
  assumes A: "\<And>A. \<lbrakk>chain A; Y = (\<lambda>i. Inl (A i))\<rbrakk> \<Longrightarrow> R"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    83
  assumes B: "\<And>B. \<lbrakk>chain B; Y = (\<lambda>i. Inr (B i))\<rbrakk> \<Longrightarrow> R"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    84
  shows "R"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    85
 apply (cases "Y 0")
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    86
  apply (rule A)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    87
   apply (rule ch2ch_monofun [OF monofun_inv_Inl Y])
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    88
  apply (rule ext)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    89
  apply (cut_tac j=i in chain_mono [OF Y le0], simp)
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    90
  apply (erule Inl_belowE, simp)
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    91
 apply (rule B)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    92
  apply (rule ch2ch_monofun [OF monofun_inv_Inr Y])
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    93
 apply (rule ext)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    94
 apply (cut_tac j=i in chain_mono [OF Y le0], simp)
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
    95
 apply (erule Inr_belowE, simp)
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    96
done
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    97
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    98
lemma is_lub_Inl: "range S <<| x \<Longrightarrow> range (\<lambda>i. Inl (S i)) <<| Inl x"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
    99
 apply (rule is_lubI)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   100
  apply (rule ub_rangeI)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   101
  apply (simp add: is_ub_lub)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   102
 apply (frule ub_rangeD [where i=arbitrary])
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
   103
 apply (erule Inl_belowE, simp)
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   104
 apply (erule is_lub_lub)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   105
 apply (rule ub_rangeI)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   106
 apply (drule ub_rangeD, simp)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   107
done
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   108
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   109
lemma is_lub_Inr: "range S <<| x \<Longrightarrow> range (\<lambda>i. Inr (S i)) <<| Inr x"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   110
 apply (rule is_lubI)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   111
  apply (rule ub_rangeI)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   112
  apply (simp add: is_ub_lub)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   113
 apply (frule ub_rangeD [where i=arbitrary])
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
   114
 apply (erule Inr_belowE, simp)
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   115
 apply (erule is_lub_lub)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   116
 apply (rule ub_rangeI)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   117
 apply (drule ub_rangeD, simp)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   118
done
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   119
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   120
instance "+" :: (cpo, cpo) cpo
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   121
 apply intro_classes
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   122
 apply (erule sum_chain_cases, safe)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   123
  apply (rule exI)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   124
  apply (rule is_lub_Inl)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   125
  apply (erule cpo_lubI)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   126
 apply (rule exI)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   127
 apply (rule is_lub_Inr)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   128
 apply (erule cpo_lubI)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   129
done
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   131
subsection {* Continuity of @{term Inl}, @{term Inr}, @{term sum_case} *}
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   132
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   133
lemma cont_Inl: "cont Inl"
31041
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   134
by (intro contI is_lub_Inl cpo_lubI)
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   135
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   136
lemma cont_Inr: "cont Inr"
31041
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   137
by (intro contI is_lub_Inr cpo_lubI)
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   138
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   139
lemmas cont2cont_Inl [cont2cont] = cont_compose [OF cont_Inl]
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   140
lemmas cont2cont_Inr [cont2cont] = cont_compose [OF cont_Inr]
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   141
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   142
lemmas ch2ch_Inl [simp] = ch2ch_cont [OF cont_Inl]
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   143
lemmas ch2ch_Inr [simp] = ch2ch_cont [OF cont_Inr]
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   144
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   145
lemmas lub_Inl = cont2contlubE [OF cont_Inl, symmetric]
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   146
lemmas lub_Inr = cont2contlubE [OF cont_Inr, symmetric]
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   147
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   148
lemma cont_sum_case1:
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   149
  assumes f: "\<And>a. cont (\<lambda>x. f x a)"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   150
  assumes g: "\<And>b. cont (\<lambda>x. g x b)"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   151
  shows "cont (\<lambda>x. case y of Inl a \<Rightarrow> f x a | Inr b \<Rightarrow> g x b)"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   152
by (induct y, simp add: f, simp add: g)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   153
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   154
lemma cont_sum_case2: "\<lbrakk>cont f; cont g\<rbrakk> \<Longrightarrow> cont (sum_case f g)"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   155
apply (rule contI)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   156
apply (erule sum_chain_cases)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   157
apply (simp add: cont2contlubE [OF cont_Inl, symmetric] contE)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   158
apply (simp add: cont2contlubE [OF cont_Inr, symmetric] contE)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   159
done
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   160
31041
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   161
lemma cont2cont_sum_case:
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   162
  assumes f1: "\<And>a. cont (\<lambda>x. f x a)" and f2: "\<And>x. cont (\<lambda>a. f x a)"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   163
  assumes g1: "\<And>b. cont (\<lambda>x. g x b)" and g2: "\<And>x. cont (\<lambda>b. g x b)"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   164
  assumes h: "cont (\<lambda>x. h x)"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   165
  shows "cont (\<lambda>x. case h x of Inl a \<Rightarrow> f x a | Inr b \<Rightarrow> g x b)"
31041
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   166
apply (rule cont_apply [OF h])
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   167
apply (rule cont_sum_case2 [OF f2 g2])
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   168
apply (rule cont_sum_case1 [OF f1 g1])
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   169
done
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   170
31041
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   171
lemma cont2cont_sum_case' [cont2cont]:
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   172
  assumes f: "cont (\<lambda>p. f (fst p) (snd p))"
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   173
  assumes g: "cont (\<lambda>p. g (fst p) (snd p))"
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   174
  assumes h: "cont (\<lambda>x. h x)"
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   175
  shows "cont (\<lambda>x. case h x of Inl a \<Rightarrow> f x a | Inr b \<Rightarrow> g x b)"
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   176
proof -
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   177
  note f1 = f [THEN cont_fst_snd_D1]
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   178
  note f2 = f [THEN cont_fst_snd_D2]
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   179
  note g1 = g [THEN cont_fst_snd_D1]
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   180
  note g2 = g [THEN cont_fst_snd_D2]
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   181
  show ?thesis
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   182
    apply (rule cont_apply [OF h])
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   183
    apply (rule cont_sum_case2 [OF f2 g2])
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   184
    apply (rule cont_sum_case1 [OF f1 g1])
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   185
    done
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   186
qed
85b4843d9939 replace cont2cont_apply with cont_apply; add new cont2cont lemmas
huffman
parents: 29534
diff changeset
   187
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   188
subsection {* Compactness and chain-finiteness *}
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   189
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   190
lemma compact_Inl: "compact a \<Longrightarrow> compact (Inl a)"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   191
apply (rule compactI2)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   192
apply (erule sum_chain_cases, safe)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   193
apply (simp add: lub_Inl)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   194
apply (erule (2) compactD2)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   195
apply (simp add: lub_Inr)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   196
done
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   197
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   198
lemma compact_Inr: "compact a \<Longrightarrow> compact (Inr a)"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   199
apply (rule compactI2)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   200
apply (erule sum_chain_cases, safe)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   201
apply (simp add: lub_Inl)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   202
apply (simp add: lub_Inr)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   203
apply (erule (2) compactD2)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   204
done
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   205
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   206
lemma compact_Inl_rev: "compact (Inl a) \<Longrightarrow> compact a"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   207
unfolding compact_def
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   208
by (drule adm_subst [OF cont_Inl], simp)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   209
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   210
lemma compact_Inr_rev: "compact (Inr a) \<Longrightarrow> compact a"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   211
unfolding compact_def
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   212
by (drule adm_subst [OF cont_Inr], simp)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   213
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   214
lemma compact_Inl_iff [simp]: "compact (Inl a) = compact a"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   215
by (safe elim!: compact_Inl compact_Inl_rev)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   216
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   217
lemma compact_Inr_iff [simp]: "compact (Inr a) = compact a"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   218
by (safe elim!: compact_Inr compact_Inr_rev)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   219
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   220
instance "+" :: (chfin, chfin) chfin
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   221
apply intro_classes
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   222
apply (erule compact_imp_max_in_chain)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   223
apply (case_tac "\<Squnion>i. Y i", simp_all)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   224
done
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   225
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   226
instance "+" :: (finite_po, finite_po) finite_po ..
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   227
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   228
instance "+" :: (discrete_cpo, discrete_cpo) discrete_cpo
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31041
diff changeset
   229
by intro_classes (simp add: below_sum_def split: sum.split)
29130
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   230
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   231
subsection {* Sum type is a bifinite domain *}
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   232
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   233
instantiation "+" :: (profinite, profinite) profinite
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   234
begin
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   235
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   236
definition
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   237
  approx_sum_def: "approx =
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   238
    (\<lambda>n. \<Lambda> x. case x of Inl a \<Rightarrow> Inl (approx n\<cdot>a) | Inr b \<Rightarrow> Inr (approx n\<cdot>b))"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   239
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   240
lemma approx_Inl [simp]: "approx n\<cdot>(Inl x) = Inl (approx n\<cdot>x)"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   241
  unfolding approx_sum_def by simp
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   242
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   243
lemma approx_Inr [simp]: "approx n\<cdot>(Inr x) = Inr (approx n\<cdot>x)"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   244
  unfolding approx_sum_def by simp
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   245
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   246
instance proof
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   247
  fix i :: nat and x :: "'a + 'b"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   248
  show "chain (approx :: nat \<Rightarrow> 'a + 'b \<rightarrow> 'a + 'b)"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   249
    unfolding approx_sum_def
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   250
    by (rule ch2ch_LAM, case_tac x, simp_all)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   251
  show "(\<Squnion>i. approx i\<cdot>x) = x"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   252
    by (induct x, simp_all add: lub_Inl lub_Inr)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   253
  show "approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   254
    by (induct x, simp_all)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   255
  have "{x::'a + 'b. approx i\<cdot>x = x} \<subseteq>
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   256
        {x::'a. approx i\<cdot>x = x} <+> {x::'b. approx i\<cdot>x = x}"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   257
    by (rule subsetI, case_tac x, simp_all add: InlI InrI)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   258
  thus "finite {x::'a + 'b. approx i\<cdot>x = x}"
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   259
    by (rule finite_subset,
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   260
        intro finite_Plus finite_fixes_approx)
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   261
qed
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   262
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   263
end
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   264
685c9e05a6ab new theory Dsum: cpo of disjoint sum
huffman
parents:
diff changeset
   265
end