src/HOLCF/ConvexPD.thy
author huffman
Fri, 18 Jan 2008 20:22:07 +0100
changeset 25925 3dc4acca4388
parent 25904 8161f137b0e9
child 26041 c2e15e65165f
permissions -rw-r--r--
change lemma admD to rule_format
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     1
(*  Title:      HOLCF/ConvexPD.thy
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     2
    ID:         $Id$
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     3
    Author:     Brian Huffman
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     4
*)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     5
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     6
header {* Convex powerdomain *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     7
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     8
theory ConvexPD
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     9
imports UpperPD LowerPD
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    10
begin
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    11
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    12
subsection {* Basis preorder *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    13
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    14
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    15
  convex_le :: "'a pd_basis \<Rightarrow> 'a pd_basis \<Rightarrow> bool" (infix "\<le>\<natural>" 50) where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    16
  "convex_le = (\<lambda>u v. u \<le>\<sharp> v \<and> u \<le>\<flat> v)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    17
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    18
lemma convex_le_refl [simp]: "t \<le>\<natural> t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    19
unfolding convex_le_def by (fast intro: upper_le_refl lower_le_refl)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    20
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    21
lemma convex_le_trans: "\<lbrakk>t \<le>\<natural> u; u \<le>\<natural> v\<rbrakk> \<Longrightarrow> t \<le>\<natural> v"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    22
unfolding convex_le_def by (fast intro: upper_le_trans lower_le_trans)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    23
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    24
interpretation convex_le: preorder [convex_le]
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    25
by (rule preorder.intro, rule convex_le_refl, rule convex_le_trans)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    26
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    27
lemma upper_le_minimal [simp]: "PDUnit compact_bot \<le>\<natural> t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    28
unfolding convex_le_def Rep_PDUnit by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    29
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    30
lemma PDUnit_convex_mono: "compact_le x y \<Longrightarrow> PDUnit x \<le>\<natural> PDUnit y"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    31
unfolding convex_le_def by (fast intro: PDUnit_upper_mono PDUnit_lower_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    32
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    33
lemma PDPlus_convex_mono: "\<lbrakk>s \<le>\<natural> t; u \<le>\<natural> v\<rbrakk> \<Longrightarrow> PDPlus s u \<le>\<natural> PDPlus t v"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    34
unfolding convex_le_def by (fast intro: PDPlus_upper_mono PDPlus_lower_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    35
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    36
lemma convex_le_PDUnit_PDUnit_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    37
  "(PDUnit a \<le>\<natural> PDUnit b) = compact_le a b"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    38
unfolding convex_le_def upper_le_def lower_le_def Rep_PDUnit by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    39
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    40
lemma convex_le_PDUnit_lemma1:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    41
  "(PDUnit a \<le>\<natural> t) = (\<forall>b\<in>Rep_pd_basis t. compact_le a b)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    42
unfolding convex_le_def upper_le_def lower_le_def Rep_PDUnit
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    43
using Rep_pd_basis_nonempty [of t, folded ex_in_conv] by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    44
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    45
lemma convex_le_PDUnit_PDPlus_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    46
  "(PDUnit a \<le>\<natural> PDPlus t u) = (PDUnit a \<le>\<natural> t \<and> PDUnit a \<le>\<natural> u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    47
unfolding convex_le_PDUnit_lemma1 Rep_PDPlus by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    48
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    49
lemma convex_le_PDUnit_lemma2:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    50
  "(t \<le>\<natural> PDUnit b) = (\<forall>a\<in>Rep_pd_basis t. compact_le a b)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    51
unfolding convex_le_def upper_le_def lower_le_def Rep_PDUnit
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    52
using Rep_pd_basis_nonempty [of t, folded ex_in_conv] by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    53
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    54
lemma convex_le_PDPlus_PDUnit_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    55
  "(PDPlus t u \<le>\<natural> PDUnit a) = (t \<le>\<natural> PDUnit a \<and> u \<le>\<natural> PDUnit a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    56
unfolding convex_le_PDUnit_lemma2 Rep_PDPlus by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    57
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    58
lemma convex_le_PDPlus_lemma:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    59
  assumes z: "PDPlus t u \<le>\<natural> z"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    60
  shows "\<exists>v w. z = PDPlus v w \<and> t \<le>\<natural> v \<and> u \<le>\<natural> w"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    61
proof (intro exI conjI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    62
  let ?A = "{b\<in>Rep_pd_basis z. \<exists>a\<in>Rep_pd_basis t. compact_le a b}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    63
  let ?B = "{b\<in>Rep_pd_basis z. \<exists>a\<in>Rep_pd_basis u. compact_le a b}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    64
  let ?v = "Abs_pd_basis ?A"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    65
  let ?w = "Abs_pd_basis ?B"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    66
  have Rep_v: "Rep_pd_basis ?v = ?A"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    67
    apply (rule Abs_pd_basis_inverse)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    68
    apply (rule Rep_pd_basis_nonempty [of t, folded ex_in_conv, THEN exE])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    69
    apply (cut_tac z, simp only: convex_le_def lower_le_def, clarify)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    70
    apply (drule_tac x=x in bspec, simp add: Rep_PDPlus, erule bexE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    71
    apply (simp add: pd_basis_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    72
    apply fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    73
    done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    74
  have Rep_w: "Rep_pd_basis ?w = ?B"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    75
    apply (rule Abs_pd_basis_inverse)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    76
    apply (rule Rep_pd_basis_nonempty [of u, folded ex_in_conv, THEN exE])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    77
    apply (cut_tac z, simp only: convex_le_def lower_le_def, clarify)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    78
    apply (drule_tac x=x in bspec, simp add: Rep_PDPlus, erule bexE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    79
    apply (simp add: pd_basis_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    80
    apply fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    81
    done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    82
  show "z = PDPlus ?v ?w"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    83
    apply (insert z)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    84
    apply (simp add: convex_le_def, erule conjE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    85
    apply (simp add: Rep_pd_basis_inject [symmetric] Rep_PDPlus)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    86
    apply (simp add: Rep_v Rep_w)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    87
    apply (rule equalityI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    88
     apply (rule subsetI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    89
     apply (simp only: upper_le_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    90
     apply (drule (1) bspec, erule bexE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    91
     apply (simp add: Rep_PDPlus)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    92
     apply fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    93
    apply fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    94
    done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    95
  show "t \<le>\<natural> ?v" "u \<le>\<natural> ?w"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    96
   apply (insert z)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    97
   apply (simp_all add: convex_le_def upper_le_def lower_le_def Rep_PDPlus Rep_v Rep_w)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    98
   apply fast+
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    99
   done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   100
qed
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   101
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   102
lemma convex_le_induct [induct set: convex_le]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   103
  assumes le: "t \<le>\<natural> u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   104
  assumes 2: "\<And>t u v. \<lbrakk>P t u; P u v\<rbrakk> \<Longrightarrow> P t v"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   105
  assumes 3: "\<And>a b. compact_le a b \<Longrightarrow> P (PDUnit a) (PDUnit b)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   106
  assumes 4: "\<And>t u v w. \<lbrakk>P t v; P u w\<rbrakk> \<Longrightarrow> P (PDPlus t u) (PDPlus v w)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   107
  shows "P t u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   108
using le apply (induct t arbitrary: u rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   109
apply (erule rev_mp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   110
apply (induct_tac u rule: pd_basis_induct1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   111
apply (simp add: 3)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   112
apply (simp, clarify, rename_tac a b t)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   113
apply (subgoal_tac "P (PDPlus (PDUnit a) (PDUnit a)) (PDPlus (PDUnit b) t)")
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   114
apply (simp add: PDPlus_absorb)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   115
apply (erule (1) 4 [OF 3])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   116
apply (drule convex_le_PDPlus_lemma, clarify)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   117
apply (simp add: 4)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   118
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   119
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   120
lemma approx_pd_convex_mono1:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   121
  "i \<le> j \<Longrightarrow> approx_pd i t \<le>\<natural> approx_pd j t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   122
apply (induct t rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   123
apply (simp add: compact_approx_mono1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   124
apply (simp add: PDPlus_convex_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   125
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   126
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   127
lemma approx_pd_convex_le: "approx_pd i t \<le>\<natural> t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   128
apply (induct t rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   129
apply (simp add: compact_approx_le)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   130
apply (simp add: PDPlus_convex_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   131
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   132
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   133
lemma approx_pd_convex_mono:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   134
  "t \<le>\<natural> u \<Longrightarrow> approx_pd n t \<le>\<natural> approx_pd n u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   135
apply (erule convex_le_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   136
apply (erule (1) convex_le_trans)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   137
apply (simp add: compact_approx_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   138
apply (simp add: PDPlus_convex_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   139
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   140
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   141
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   142
subsection {* Type definition *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   143
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   144
cpodef (open) 'a convex_pd =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   145
  "{S::'a::bifinite pd_basis set. convex_le.ideal S}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   146
apply (simp add: convex_le.adm_ideal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   147
apply (fast intro: convex_le.ideal_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   148
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   149
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   150
lemma ideal_Rep_convex_pd: "convex_le.ideal (Rep_convex_pd xs)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   151
by (rule Rep_convex_pd [simplified])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   152
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   153
lemma Rep_convex_pd_mono: "xs \<sqsubseteq> ys \<Longrightarrow> Rep_convex_pd xs \<subseteq> Rep_convex_pd ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   154
unfolding less_convex_pd_def less_set_def .
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   155
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   156
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   157
subsection {* Principal ideals *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   158
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   159
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   160
  convex_principal :: "'a pd_basis \<Rightarrow> 'a convex_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   161
  "convex_principal t = Abs_convex_pd {u. u \<le>\<natural> t}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   162
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   163
lemma Rep_convex_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   164
  "Rep_convex_pd (convex_principal t) = {u. u \<le>\<natural> t}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   165
unfolding convex_principal_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   166
apply (rule Abs_convex_pd_inverse [simplified])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   167
apply (rule convex_le.ideal_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   168
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   169
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   170
interpretation convex_pd:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   171
  bifinite_basis [convex_le convex_principal Rep_convex_pd approx_pd]
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   172
apply unfold_locales
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   173
apply (rule ideal_Rep_convex_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   174
apply (rule cont_Rep_convex_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   175
apply (rule Rep_convex_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   176
apply (simp only: less_convex_pd_def less_set_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   177
apply (rule approx_pd_convex_le)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   178
apply (rule approx_pd_idem)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   179
apply (erule approx_pd_convex_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   180
apply (rule approx_pd_convex_mono1, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   181
apply (rule finite_range_approx_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   182
apply (rule ex_approx_pd_eq)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   183
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   184
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   185
lemma convex_principal_less_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   186
  "(convex_principal t \<sqsubseteq> convex_principal u) = (t \<le>\<natural> u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   187
unfolding less_convex_pd_def Rep_convex_principal less_set_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   188
by (fast intro: convex_le_refl elim: convex_le_trans)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   189
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   190
lemma convex_principal_mono:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   191
  "t \<le>\<natural> u \<Longrightarrow> convex_principal t \<sqsubseteq> convex_principal u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   192
by (rule convex_principal_less_iff [THEN iffD2])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   193
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   194
lemma compact_convex_principal: "compact (convex_principal t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   195
by (rule convex_pd.compact_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   196
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   197
lemma convex_pd_minimal: "convex_principal (PDUnit compact_bot) \<sqsubseteq> ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   198
by (induct ys rule: convex_pd.principal_induct, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   199
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   200
instance convex_pd :: (bifinite) pcpo
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   201
by (intro_classes, fast intro: convex_pd_minimal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   202
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   203
lemma inst_convex_pd_pcpo: "\<bottom> = convex_principal (PDUnit compact_bot)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   204
by (rule convex_pd_minimal [THEN UU_I, symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   205
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   206
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   207
subsection {* Approximation *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   208
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   209
instance convex_pd :: (bifinite) approx ..
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   210
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   211
defs (overloaded)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   212
  approx_convex_pd_def:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   213
    "approx \<equiv> (\<lambda>n. convex_pd.basis_fun (\<lambda>t. convex_principal (approx_pd n t)))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   214
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   215
lemma approx_convex_principal [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   216
  "approx n\<cdot>(convex_principal t) = convex_principal (approx_pd n t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   217
unfolding approx_convex_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   218
apply (rule convex_pd.basis_fun_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   219
apply (erule convex_principal_mono [OF approx_pd_convex_mono])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   220
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   221
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   222
lemma chain_approx_convex_pd:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   223
  "chain (approx :: nat \<Rightarrow> 'a convex_pd \<rightarrow> 'a convex_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   224
unfolding approx_convex_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   225
by (rule convex_pd.chain_basis_fun_take)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   226
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   227
lemma lub_approx_convex_pd:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   228
  "(\<Squnion>i. approx i\<cdot>xs) = (xs::'a convex_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   229
unfolding approx_convex_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   230
by (rule convex_pd.lub_basis_fun_take)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   231
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   232
lemma approx_convex_pd_idem:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   233
  "approx n\<cdot>(approx n\<cdot>xs) = approx n\<cdot>(xs::'a convex_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   234
apply (induct xs rule: convex_pd.principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   235
apply (simp add: approx_pd_idem)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   236
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   237
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   238
lemma approx_eq_convex_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   239
  "\<exists>t\<in>Rep_convex_pd xs. approx n\<cdot>xs = convex_principal (approx_pd n t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   240
unfolding approx_convex_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   241
by (rule convex_pd.basis_fun_take_eq_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   242
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   243
lemma finite_fixes_approx_convex_pd:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   244
  "finite {xs::'a convex_pd. approx n\<cdot>xs = xs}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   245
unfolding approx_convex_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   246
by (rule convex_pd.finite_fixes_basis_fun_take)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   247
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   248
instance convex_pd :: (bifinite) bifinite
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   249
apply intro_classes
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   250
apply (simp add: chain_approx_convex_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   251
apply (rule lub_approx_convex_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   252
apply (rule approx_convex_pd_idem)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   253
apply (rule finite_fixes_approx_convex_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   254
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   255
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   256
lemma compact_imp_convex_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   257
  "compact xs \<Longrightarrow> \<exists>t. xs = convex_principal t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   258
apply (drule bifinite_compact_eq_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   259
apply (erule exE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   260
apply (erule subst)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   261
apply (cut_tac n=i and xs=xs in approx_eq_convex_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   262
apply fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   263
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   264
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   265
lemma convex_principal_induct:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   266
  "\<lbrakk>adm P; \<And>t. P (convex_principal t)\<rbrakk> \<Longrightarrow> P xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   267
apply (erule approx_induct, rename_tac xs)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   268
apply (cut_tac n=n and xs=xs in approx_eq_convex_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   269
apply (clarify, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   270
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   271
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   272
lemma convex_principal_induct2:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   273
  "\<lbrakk>\<And>ys. adm (\<lambda>xs. P xs ys); \<And>xs. adm (\<lambda>ys. P xs ys);
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   274
    \<And>t u. P (convex_principal t) (convex_principal u)\<rbrakk> \<Longrightarrow> P xs ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   275
apply (rule_tac x=ys in spec)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   276
apply (rule_tac xs=xs in convex_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   277
apply (rule allI, rename_tac ys)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   278
apply (rule_tac xs=ys in convex_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   279
apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   280
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   281
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   282
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   283
subsection {* Monadic unit *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   284
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   285
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   286
  convex_unit :: "'a \<rightarrow> 'a convex_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   287
  "convex_unit = compact_basis.basis_fun (\<lambda>a. convex_principal (PDUnit a))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   288
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   289
lemma convex_unit_Rep_compact_basis [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   290
  "convex_unit\<cdot>(Rep_compact_basis a) = convex_principal (PDUnit a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   291
unfolding convex_unit_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   292
apply (rule compact_basis.basis_fun_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   293
apply (rule convex_principal_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   294
apply (erule PDUnit_convex_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   295
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   296
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   297
lemma convex_unit_strict [simp]: "convex_unit\<cdot>\<bottom> = \<bottom>"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   298
unfolding inst_convex_pd_pcpo Rep_compact_bot [symmetric] by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   299
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   300
lemma approx_convex_unit [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   301
  "approx n\<cdot>(convex_unit\<cdot>x) = convex_unit\<cdot>(approx n\<cdot>x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   302
apply (induct x rule: compact_basis_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   303
apply (simp add: approx_Rep_compact_basis)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   304
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   305
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   306
lemma convex_unit_less_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   307
  "(convex_unit\<cdot>x \<sqsubseteq> convex_unit\<cdot>y) = (x \<sqsubseteq> y)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   308
 apply (rule iffI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   309
  apply (rule bifinite_less_ext)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   310
  apply (drule_tac f="approx i" in monofun_cfun_arg, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   311
  apply (cut_tac x="approx i\<cdot>x" in compact_imp_Rep_compact_basis, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   312
  apply (cut_tac x="approx i\<cdot>y" in compact_imp_Rep_compact_basis, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   313
  apply (clarify, simp add: compact_le_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   314
 apply (erule monofun_cfun_arg)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   315
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   316
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   317
lemma convex_unit_eq_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   318
  "(convex_unit\<cdot>x = convex_unit\<cdot>y) = (x = y)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   319
unfolding po_eq_conv by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   320
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   321
lemma convex_unit_strict_iff [simp]: "(convex_unit\<cdot>x = \<bottom>) = (x = \<bottom>)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   322
unfolding convex_unit_strict [symmetric] by (rule convex_unit_eq_iff)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   323
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   324
lemma compact_convex_unit_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   325
  "compact (convex_unit\<cdot>x) = compact x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   326
unfolding bifinite_compact_iff by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   327
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   328
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   329
subsection {* Monadic plus *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   330
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   331
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   332
  convex_plus :: "'a convex_pd \<rightarrow> 'a convex_pd \<rightarrow> 'a convex_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   333
  "convex_plus = convex_pd.basis_fun (\<lambda>t. convex_pd.basis_fun (\<lambda>u.
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   334
      convex_principal (PDPlus t u)))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   335
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   336
abbreviation
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   337
  convex_add :: "'a convex_pd \<Rightarrow> 'a convex_pd \<Rightarrow> 'a convex_pd"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   338
    (infixl "+\<natural>" 65) where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   339
  "xs +\<natural> ys == convex_plus\<cdot>xs\<cdot>ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   340
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   341
lemma convex_plus_principal [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   342
  "convex_plus\<cdot>(convex_principal t)\<cdot>(convex_principal u) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   343
   convex_principal (PDPlus t u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   344
unfolding convex_plus_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   345
by (simp add: convex_pd.basis_fun_principal
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   346
    convex_pd.basis_fun_mono PDPlus_convex_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   347
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   348
lemma approx_convex_plus [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   349
  "approx n\<cdot>(convex_plus\<cdot>xs\<cdot>ys) = convex_plus\<cdot>(approx n\<cdot>xs)\<cdot>(approx n\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   350
by (induct xs ys rule: convex_principal_induct2, simp, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   351
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   352
lemma convex_plus_commute: "convex_plus\<cdot>xs\<cdot>ys = convex_plus\<cdot>ys\<cdot>xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   353
apply (induct xs ys rule: convex_principal_induct2, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   354
apply (simp add: PDPlus_commute)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   355
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   356
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   357
lemma convex_plus_assoc:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   358
  "convex_plus\<cdot>(convex_plus\<cdot>xs\<cdot>ys)\<cdot>zs = convex_plus\<cdot>xs\<cdot>(convex_plus\<cdot>ys\<cdot>zs)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   359
apply (induct xs ys arbitrary: zs rule: convex_principal_induct2, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   360
apply (rule_tac xs=zs in convex_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   361
apply (simp add: PDPlus_assoc)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   362
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   363
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   364
lemma convex_plus_absorb: "convex_plus\<cdot>xs\<cdot>xs = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   365
apply (induct xs rule: convex_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   366
apply (simp add: PDPlus_absorb)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   367
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   368
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   369
lemma convex_unit_less_plus_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   370
  "(convex_unit\<cdot>x \<sqsubseteq> convex_plus\<cdot>ys\<cdot>zs) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   371
   (convex_unit\<cdot>x \<sqsubseteq> ys \<and> convex_unit\<cdot>x \<sqsubseteq> zs)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   372
 apply (rule iffI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   373
  apply (subgoal_tac
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   374
    "adm (\<lambda>f. f\<cdot>(convex_unit\<cdot>x) \<sqsubseteq> f\<cdot>ys \<and> f\<cdot>(convex_unit\<cdot>x) \<sqsubseteq> f\<cdot>zs)")
25925
3dc4acca4388 change lemma admD to rule_format
huffman
parents: 25904
diff changeset
   375
   apply (drule admD, rule chain_approx)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   376
    apply (drule_tac f="approx i" in monofun_cfun_arg)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   377
    apply (cut_tac x="approx i\<cdot>x" in compact_imp_Rep_compact_basis, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   378
    apply (cut_tac xs="approx i\<cdot>ys" in compact_imp_convex_principal, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   379
    apply (cut_tac xs="approx i\<cdot>zs" in compact_imp_convex_principal, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   380
    apply (clarify, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   381
   apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   382
  apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   383
 apply (erule conjE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   384
 apply (subst convex_plus_absorb [of "convex_unit\<cdot>x", symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   385
 apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   386
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   387
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   388
lemma convex_plus_less_unit_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   389
  "(convex_plus\<cdot>xs\<cdot>ys \<sqsubseteq> convex_unit\<cdot>z) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   390
   (xs \<sqsubseteq> convex_unit\<cdot>z \<and> ys \<sqsubseteq> convex_unit\<cdot>z)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   391
 apply (rule iffI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   392
  apply (subgoal_tac
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   393
    "adm (\<lambda>f. f\<cdot>xs \<sqsubseteq> f\<cdot>(convex_unit\<cdot>z) \<and> f\<cdot>ys \<sqsubseteq> f\<cdot>(convex_unit\<cdot>z))")
25925
3dc4acca4388 change lemma admD to rule_format
huffman
parents: 25904
diff changeset
   394
   apply (drule admD, rule chain_approx)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   395
    apply (drule_tac f="approx i" in monofun_cfun_arg)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   396
    apply (cut_tac xs="approx i\<cdot>xs" in compact_imp_convex_principal, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   397
    apply (cut_tac xs="approx i\<cdot>ys" in compact_imp_convex_principal, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   398
    apply (cut_tac x="approx i\<cdot>z" in compact_imp_Rep_compact_basis, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   399
    apply (clarify, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   400
   apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   401
  apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   402
 apply (erule conjE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   403
 apply (subst convex_plus_absorb [of "convex_unit\<cdot>z", symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   404
 apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   405
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   406
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   407
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   408
subsection {* Induction rules *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   409
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   410
lemma convex_pd_induct1:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   411
  assumes P: "adm P"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   412
  assumes unit: "\<And>x. P (convex_unit\<cdot>x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   413
  assumes insert:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   414
    "\<And>x ys. \<lbrakk>P (convex_unit\<cdot>x); P ys\<rbrakk> \<Longrightarrow> P (convex_plus\<cdot>(convex_unit\<cdot>x)\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   415
  shows "P (xs::'a convex_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   416
apply (induct xs rule: convex_principal_induct, rule P)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   417
apply (induct_tac t rule: pd_basis_induct1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   418
apply (simp only: convex_unit_Rep_compact_basis [symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   419
apply (rule unit)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   420
apply (simp only: convex_unit_Rep_compact_basis [symmetric]
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   421
                  convex_plus_principal [symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   422
apply (erule insert [OF unit])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   423
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   424
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   425
lemma convex_pd_induct:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   426
  assumes P: "adm P"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   427
  assumes unit: "\<And>x. P (convex_unit\<cdot>x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   428
  assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (convex_plus\<cdot>xs\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   429
  shows "P (xs::'a convex_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   430
apply (induct xs rule: convex_principal_induct, rule P)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   431
apply (induct_tac t rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   432
apply (simp only: convex_unit_Rep_compact_basis [symmetric] unit)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   433
apply (simp only: convex_plus_principal [symmetric] plus)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   434
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   435
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   436
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   437
subsection {* Monadic bind *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   438
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   439
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   440
  convex_bind_basis ::
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   441
  "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b convex_pd) \<rightarrow> 'b convex_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   442
  "convex_bind_basis = fold_pd
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   443
    (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   444
    (\<lambda>x y. \<Lambda> f. convex_plus\<cdot>(x\<cdot>f)\<cdot>(y\<cdot>f))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   445
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   446
lemma ACI_convex_bind: "ACIf (\<lambda>x y. \<Lambda> f. convex_plus\<cdot>(x\<cdot>f)\<cdot>(y\<cdot>f))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   447
apply unfold_locales
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   448
apply (simp add: convex_plus_commute)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   449
apply (simp add: convex_plus_assoc)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   450
apply (simp add: convex_plus_absorb eta_cfun)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   451
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   452
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   453
lemma convex_bind_basis_simps [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   454
  "convex_bind_basis (PDUnit a) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   455
    (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   456
  "convex_bind_basis (PDPlus t u) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   457
    (\<Lambda> f. convex_plus\<cdot>(convex_bind_basis t\<cdot>f)\<cdot>(convex_bind_basis u\<cdot>f))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   458
unfolding convex_bind_basis_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   459
apply -
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   460
apply (rule ACIf.fold_pd_PDUnit [OF ACI_convex_bind])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   461
apply (rule ACIf.fold_pd_PDPlus [OF ACI_convex_bind])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   462
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   463
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   464
lemma monofun_LAM:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   465
  "\<lbrakk>cont f; cont g; \<And>x. f x \<sqsubseteq> g x\<rbrakk> \<Longrightarrow> (\<Lambda> x. f x) \<sqsubseteq> (\<Lambda> x. g x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   466
by (simp add: expand_cfun_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   467
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   468
lemma convex_bind_basis_mono:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   469
  "t \<le>\<natural> u \<Longrightarrow> convex_bind_basis t \<sqsubseteq> convex_bind_basis u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   470
apply (erule convex_le_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   471
apply (erule (1) trans_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   472
apply (simp add: monofun_LAM compact_le_def monofun_cfun)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   473
apply (simp add: monofun_LAM compact_le_def monofun_cfun)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   474
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   475
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   476
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   477
  convex_bind :: "'a convex_pd \<rightarrow> ('a \<rightarrow> 'b convex_pd) \<rightarrow> 'b convex_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   478
  "convex_bind = convex_pd.basis_fun convex_bind_basis"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   479
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   480
lemma convex_bind_principal [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   481
  "convex_bind\<cdot>(convex_principal t) = convex_bind_basis t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   482
unfolding convex_bind_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   483
apply (rule convex_pd.basis_fun_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   484
apply (erule convex_bind_basis_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   485
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   486
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   487
lemma convex_bind_unit [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   488
  "convex_bind\<cdot>(convex_unit\<cdot>x)\<cdot>f = f\<cdot>x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   489
by (induct x rule: compact_basis_induct, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   490
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   491
lemma convex_bind_plus [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   492
  "convex_bind\<cdot>(convex_plus\<cdot>xs\<cdot>ys)\<cdot>f =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   493
   convex_plus\<cdot>(convex_bind\<cdot>xs\<cdot>f)\<cdot>(convex_bind\<cdot>ys\<cdot>f)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   494
by (induct xs ys rule: convex_principal_induct2, simp, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   495
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   496
lemma convex_bind_strict [simp]: "convex_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   497
unfolding convex_unit_strict [symmetric] by (rule convex_bind_unit)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   498
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   499
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   500
subsection {* Map and join *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   501
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   502
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   503
  convex_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a convex_pd \<rightarrow> 'b convex_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   504
  "convex_map = (\<Lambda> f xs. convex_bind\<cdot>xs\<cdot>(\<Lambda> x. convex_unit\<cdot>(f\<cdot>x)))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   505
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   506
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   507
  convex_join :: "'a convex_pd convex_pd \<rightarrow> 'a convex_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   508
  "convex_join = (\<Lambda> xss. convex_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   509
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   510
lemma convex_map_unit [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   511
  "convex_map\<cdot>f\<cdot>(convex_unit\<cdot>x) = convex_unit\<cdot>(f\<cdot>x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   512
unfolding convex_map_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   513
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   514
lemma convex_map_plus [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   515
  "convex_map\<cdot>f\<cdot>(convex_plus\<cdot>xs\<cdot>ys) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   516
   convex_plus\<cdot>(convex_map\<cdot>f\<cdot>xs)\<cdot>(convex_map\<cdot>f\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   517
unfolding convex_map_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   518
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   519
lemma convex_join_unit [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   520
  "convex_join\<cdot>(convex_unit\<cdot>xs) = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   521
unfolding convex_join_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   522
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   523
lemma convex_join_plus [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   524
  "convex_join\<cdot>(convex_plus\<cdot>xss\<cdot>yss) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   525
   convex_plus\<cdot>(convex_join\<cdot>xss)\<cdot>(convex_join\<cdot>yss)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   526
unfolding convex_join_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   527
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   528
lemma convex_map_ident: "convex_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   529
by (induct xs rule: convex_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   530
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   531
lemma convex_map_map:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   532
  "convex_map\<cdot>f\<cdot>(convex_map\<cdot>g\<cdot>xs) = convex_map\<cdot>(\<Lambda> x. f\<cdot>(g\<cdot>x))\<cdot>xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   533
by (induct xs rule: convex_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   534
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   535
lemma convex_join_map_unit:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   536
  "convex_join\<cdot>(convex_map\<cdot>convex_unit\<cdot>xs) = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   537
by (induct xs rule: convex_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   538
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   539
lemma convex_join_map_join:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   540
  "convex_join\<cdot>(convex_map\<cdot>convex_join\<cdot>xsss) = convex_join\<cdot>(convex_join\<cdot>xsss)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   541
by (induct xsss rule: convex_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   542
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   543
lemma convex_join_map_map:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   544
  "convex_join\<cdot>(convex_map\<cdot>(convex_map\<cdot>f)\<cdot>xss) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   545
   convex_map\<cdot>f\<cdot>(convex_join\<cdot>xss)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   546
by (induct xss rule: convex_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   547
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   548
lemma convex_map_approx: "convex_map\<cdot>(approx n)\<cdot>xs = approx n\<cdot>xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   549
by (induct xs rule: convex_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   550
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   551
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   552
subsection {* Conversions to other powerdomains *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   553
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   554
text {* Convex to upper *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   555
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   556
lemma convex_le_imp_upper_le: "t \<le>\<natural> u \<Longrightarrow> t \<le>\<sharp> u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   557
unfolding convex_le_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   558
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   559
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   560
  convex_to_upper :: "'a convex_pd \<rightarrow> 'a upper_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   561
  "convex_to_upper = convex_pd.basis_fun upper_principal"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   562
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   563
lemma convex_to_upper_principal [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   564
  "convex_to_upper\<cdot>(convex_principal t) = upper_principal t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   565
unfolding convex_to_upper_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   566
apply (rule convex_pd.basis_fun_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   567
apply (rule upper_principal_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   568
apply (erule convex_le_imp_upper_le)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   569
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   570
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   571
lemma convex_to_upper_unit [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   572
  "convex_to_upper\<cdot>(convex_unit\<cdot>x) = upper_unit\<cdot>x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   573
by (induct x rule: compact_basis_induct, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   574
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   575
lemma convex_to_upper_plus [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   576
  "convex_to_upper\<cdot>(convex_plus\<cdot>xs\<cdot>ys) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   577
   upper_plus\<cdot>(convex_to_upper\<cdot>xs)\<cdot>(convex_to_upper\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   578
by (induct xs ys rule: convex_principal_induct2, simp, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   579
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   580
lemma approx_convex_to_upper:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   581
  "approx i\<cdot>(convex_to_upper\<cdot>xs) = convex_to_upper\<cdot>(approx i\<cdot>xs)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   582
by (induct xs rule: convex_pd_induct, simp, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   583
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   584
text {* Convex to lower *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   585
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   586
lemma convex_le_imp_lower_le: "t \<le>\<natural> u \<Longrightarrow> t \<le>\<flat> u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   587
unfolding convex_le_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   588
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   589
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   590
  convex_to_lower :: "'a convex_pd \<rightarrow> 'a lower_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   591
  "convex_to_lower = convex_pd.basis_fun lower_principal"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   592
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   593
lemma convex_to_lower_principal [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   594
  "convex_to_lower\<cdot>(convex_principal t) = lower_principal t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   595
unfolding convex_to_lower_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   596
apply (rule convex_pd.basis_fun_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   597
apply (rule lower_principal_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   598
apply (erule convex_le_imp_lower_le)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   599
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   600
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   601
lemma convex_to_lower_unit [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   602
  "convex_to_lower\<cdot>(convex_unit\<cdot>x) = lower_unit\<cdot>x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   603
by (induct x rule: compact_basis_induct, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   604
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   605
lemma convex_to_lower_plus [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   606
  "convex_to_lower\<cdot>(convex_plus\<cdot>xs\<cdot>ys) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   607
   lower_plus\<cdot>(convex_to_lower\<cdot>xs)\<cdot>(convex_to_lower\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   608
by (induct xs ys rule: convex_principal_induct2, simp, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   609
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   610
lemma approx_convex_to_lower:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   611
  "approx i\<cdot>(convex_to_lower\<cdot>xs) = convex_to_lower\<cdot>(approx i\<cdot>xs)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   612
by (induct xs rule: convex_pd_induct, simp, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   613
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   614
text {* Ordering property *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   615
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   616
lemma convex_pd_less_iff:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   617
  "(xs \<sqsubseteq> ys) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   618
    (convex_to_upper\<cdot>xs \<sqsubseteq> convex_to_upper\<cdot>ys \<and>
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   619
     convex_to_lower\<cdot>xs \<sqsubseteq> convex_to_lower\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   620
 apply (safe elim!: monofun_cfun_arg)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   621
 apply (rule bifinite_less_ext)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   622
 apply (drule_tac f="approx i" in monofun_cfun_arg)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   623
 apply (drule_tac f="approx i" in monofun_cfun_arg)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   624
 apply (cut_tac xs="approx i\<cdot>xs" in compact_imp_convex_principal, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   625
 apply (cut_tac xs="approx i\<cdot>ys" in compact_imp_convex_principal, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   626
 apply clarify
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   627
 apply (simp add: approx_convex_to_upper approx_convex_to_lower convex_le_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   628
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   629
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   630
end