src/HOLCF/Representable.thy
author huffman
Fri, 13 Nov 2009 15:31:20 -0800
changeset 33679 331712879666
parent 33589 e7ba88cdf3a2
child 33779 b8efeea2cebd
permissions -rw-r--r--
automate definition of representable domains from algebraic deflations
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33589
e7ba88cdf3a2 add title/author block
huffman
parents: 33588
diff changeset
     1
(*  Title:      HOLCF/Representable.thy
e7ba88cdf3a2 add title/author block
huffman
parents: 33588
diff changeset
     2
    Author:     Brian Huffman
e7ba88cdf3a2 add title/author block
huffman
parents: 33588
diff changeset
     3
*)
e7ba88cdf3a2 add title/author block
huffman
parents: 33588
diff changeset
     4
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
     5
header {* Representable Types *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
     6
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
     7
theory Representable
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
     8
imports Algebraic Universal Ssum Sprod One ConvexPD
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
     9
uses ("Tools/repdef.ML")
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    10
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    11
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    12
subsection {* Class of representable types *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    13
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    14
text "Overloaded embedding and projection functions between
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    15
      a representable type and the universal domain."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    16
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    17
class rep = bifinite +
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    18
  fixes emb :: "'a::pcpo \<rightarrow> udom"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    19
  fixes prj :: "udom \<rightarrow> 'a::pcpo"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    20
  assumes ep_pair_emb_prj: "ep_pair emb prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    21
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    22
interpretation rep!:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    23
  pcpo_ep_pair
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    24
    "emb :: 'a::rep \<rightarrow> udom"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    25
    "prj :: udom \<rightarrow> 'a::rep"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    26
  unfolding pcpo_ep_pair_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    27
  by (rule ep_pair_emb_prj)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    28
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    29
lemmas emb_inverse = rep.e_inverse
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    30
lemmas emb_prj_below = rep.e_p_below
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    31
lemmas emb_eq_iff = rep.e_eq_iff
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    32
lemmas emb_strict = rep.e_strict
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    33
lemmas prj_strict = rep.p_strict
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    34
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    35
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    36
subsection {* Making @{term rep} the default class *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    37
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    38
text {*
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    39
  From now on, free type variables are assumed to be in class
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    40
  @{term rep}, unless specified otherwise.
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    41
*}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    42
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    43
defaultsort rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    44
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    45
subsection {* Representations of types *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    46
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    47
text "A TypeRep is an algebraic deflation over the universe of values."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    48
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    49
types TypeRep = "udom alg_defl"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    50
translations "TypeRep" \<leftharpoondown> (type) "udom alg_defl"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    51
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    52
definition
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    53
  Rep_of :: "'a::rep itself \<Rightarrow> TypeRep"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    54
where
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    55
  "Rep_of TYPE('a::rep) =
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    56
    (\<Squnion>i. alg_defl_principal (Abs_fin_defl
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    57
      (emb oo (approx i :: 'a \<rightarrow> 'a) oo prj)))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    58
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    59
syntax "_REP" :: "type \<Rightarrow> TypeRep"  ("(1REP/(1'(_')))")
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    60
translations "REP(t)" \<rightleftharpoons> "CONST Rep_of TYPE(t)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    61
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    62
lemma cast_REP:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    63
  "cast\<cdot>REP('a::rep) = (emb::'a \<rightarrow> udom) oo (prj::udom \<rightarrow> 'a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    64
proof -
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    65
  let ?a = "\<lambda>i. emb oo approx i oo (prj::udom \<rightarrow> 'a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    66
  have a: "\<And>i. finite_deflation (?a i)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    67
    apply (rule rep.finite_deflation_e_d_p)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    68
    apply (rule finite_deflation_approx)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    69
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    70
  show ?thesis
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    71
    unfolding Rep_of_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    72
    apply (subst contlub_cfun_arg)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    73
    apply (rule chainI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    74
    apply (rule alg_defl.principal_mono)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    75
    apply (rule Abs_fin_defl_mono [OF a a])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    76
    apply (rule chainE, simp)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    77
    apply (subst cast_alg_defl_principal)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    78
    apply (simp add: Abs_fin_defl_inverse a)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    79
    apply (simp add: expand_cfun_eq lub_distribs)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    80
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    81
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    82
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    83
lemma emb_prj: "emb\<cdot>((prj\<cdot>x)::'a::rep) = cast\<cdot>REP('a)\<cdot>x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    84
by (simp add: cast_REP)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    85
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    86
lemma in_REP_iff:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    87
  "x ::: REP('a::rep) \<longleftrightarrow> emb\<cdot>((prj\<cdot>x)::'a) = x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    88
by (simp add: in_deflation_def cast_REP)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    89
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    90
lemma prj_inverse:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    91
  "x ::: REP('a::rep) \<Longrightarrow> emb\<cdot>((prj\<cdot>x)::'a) = x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    92
by (simp only: in_REP_iff)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    93
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    94
lemma emb_in_REP [simp]:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    95
  "emb\<cdot>(x::'a::rep) ::: REP('a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    96
by (simp add: in_REP_iff)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    97
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    98
subsection {* Coerce operator *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    99
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   100
definition coerce :: "'a \<rightarrow> 'b"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   101
where "coerce = prj oo emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   102
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   103
lemma beta_coerce: "coerce\<cdot>x = prj\<cdot>(emb\<cdot>x)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   104
by (simp add: coerce_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   105
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   106
lemma prj_emb: "prj\<cdot>(emb\<cdot>x) = coerce\<cdot>x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   107
by (simp add: coerce_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   108
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   109
lemma coerce_strict [simp]: "coerce\<cdot>\<bottom> = \<bottom>"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   110
by (simp add: coerce_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   111
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   112
lemma coerce_eq_ID [simp]: "(coerce :: 'a \<rightarrow> 'a) = ID"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   113
by (rule ext_cfun, simp add: beta_coerce)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   114
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   115
lemma emb_coerce:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   116
  "REP('a) \<sqsubseteq> REP('b)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   117
   \<Longrightarrow> emb\<cdot>((coerce::'a \<rightarrow> 'b)\<cdot>x) = emb\<cdot>x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   118
 apply (simp add: beta_coerce)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   119
 apply (rule prj_inverse)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   120
 apply (erule subdeflationD)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   121
 apply (rule emb_in_REP)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   122
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   123
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   124
lemma coerce_prj:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   125
  "REP('a) \<sqsubseteq> REP('b)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   126
   \<Longrightarrow> (coerce::'b \<rightarrow> 'a)\<cdot>(prj\<cdot>x) = prj\<cdot>x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   127
 apply (simp add: coerce_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   128
 apply (rule emb_eq_iff [THEN iffD1])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   129
 apply (simp only: emb_prj)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   130
 apply (rule deflation_below_comp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   131
   apply (rule deflation_cast)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   132
  apply (rule deflation_cast)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   133
 apply (erule monofun_cfun_arg)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   134
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   135
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   136
lemma coerce_coerce [simp]:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   137
  "REP('a) \<sqsubseteq> REP('b)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   138
   \<Longrightarrow> coerce\<cdot>((coerce::'a \<rightarrow> 'b)\<cdot>x) = coerce\<cdot>x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   139
by (simp add: beta_coerce prj_inverse subdeflationD)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   140
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   141
lemma coerce_inverse:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   142
  "emb\<cdot>(x::'a) ::: REP('b) \<Longrightarrow> coerce\<cdot>(coerce\<cdot>x :: 'b) = x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   143
by (simp only: beta_coerce prj_inverse emb_inverse)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   144
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   145
lemma coerce_type:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   146
  "REP('a) \<sqsubseteq> REP('b)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   147
   \<Longrightarrow> emb\<cdot>((coerce::'a \<rightarrow> 'b)\<cdot>x) ::: REP('a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   148
by (simp add: beta_coerce prj_inverse subdeflationD)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   149
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   150
lemma ep_pair_coerce:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   151
  "REP('a) \<sqsubseteq> REP('b)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   152
   \<Longrightarrow> ep_pair (coerce::'a \<rightarrow> 'b) (coerce::'b \<rightarrow> 'a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   153
 apply (rule ep_pair.intro)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   154
  apply simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   155
 apply (simp only: beta_coerce)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   156
 apply (rule below_trans)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   157
  apply (rule monofun_cfun_arg)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   158
  apply (rule emb_prj_below)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   159
 apply simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   160
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   161
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   162
subsection {* Proving a subtype is representable *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   163
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   164
text {*
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   165
  Temporarily relax type constraints for @{term "approx"},
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   166
  @{term emb}, and @{term prj}.
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   167
*}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   168
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   169
setup {* Sign.add_const_constraint
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   170
  (@{const_name "approx"}, SOME @{typ "nat \<Rightarrow> 'a::cpo \<rightarrow> 'a"}) *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   171
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   172
setup {* Sign.add_const_constraint
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   173
  (@{const_name emb}, SOME @{typ "'a::pcpo \<rightarrow> udom"}) *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   174
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   175
setup {* Sign.add_const_constraint
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   176
  (@{const_name prj}, SOME @{typ "udom \<rightarrow> 'a::pcpo"}) *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   177
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   178
definition
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   179
  repdef_approx ::
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   180
    "('a::pcpo \<Rightarrow> udom) \<Rightarrow> (udom \<Rightarrow> 'a) \<Rightarrow> udom alg_defl \<Rightarrow> nat \<Rightarrow> 'a \<rightarrow> 'a"
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   181
where
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   182
  "repdef_approx Rep Abs t = (\<lambda>i. \<Lambda> x. Abs (cast\<cdot>(approx i\<cdot>t)\<cdot>(Rep x)))"
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   183
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   184
lemma typedef_rep_class:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   185
  fixes Rep :: "'a::pcpo \<Rightarrow> udom"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   186
  fixes Abs :: "udom \<Rightarrow> 'a::pcpo"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   187
  fixes t :: TypeRep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   188
  assumes type: "type_definition Rep Abs {x. x ::: t}"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   189
  assumes below: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   190
  assumes emb: "emb \<equiv> (\<Lambda> x. Rep x)"
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   191
  assumes prj: "prj \<equiv> (\<Lambda> x. Abs (cast\<cdot>t\<cdot>x))"
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   192
  assumes approx: "(approx :: nat \<Rightarrow> 'a \<rightarrow> 'a) \<equiv> repdef_approx Rep Abs t"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   193
  shows "OFCLASS('a, rep_class)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   194
proof
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   195
  have adm: "adm (\<lambda>x. x \<in> {x. x ::: t})"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   196
    by (simp add: adm_in_deflation)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   197
  have emb_beta: "\<And>x. emb\<cdot>x = Rep x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   198
    unfolding emb
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   199
    apply (rule beta_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   200
    apply (rule typedef_cont_Rep [OF type below adm])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   201
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   202
  have prj_beta: "\<And>y. prj\<cdot>y = Abs (cast\<cdot>t\<cdot>y)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   203
    unfolding prj
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   204
    apply (rule beta_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   205
    apply (rule typedef_cont_Abs [OF type below adm])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   206
    apply simp_all
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   207
    done
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   208
  have cast_cast_approx:
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   209
    "\<And>i x. cast\<cdot>t\<cdot>(cast\<cdot>(approx i\<cdot>t)\<cdot>x) = cast\<cdot>(approx i\<cdot>t)\<cdot>x"
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   210
    apply (rule cast_fixed)
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   211
    apply (rule subdeflationD)
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   212
    apply (rule approx.below)
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   213
    apply (rule cast_in_deflation)
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   214
    done
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   215
  have approx':
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   216
    "approx = (\<lambda>i. \<Lambda>(x::'a). prj\<cdot>(cast\<cdot>(approx i\<cdot>t)\<cdot>(emb\<cdot>x)))"
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   217
    unfolding approx repdef_approx_def
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   218
    apply (subst cast_cast_approx [symmetric])
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   219
    apply (simp add: prj_beta [symmetric] emb_beta [symmetric])
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   220
    done
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   221
  have emb_in_deflation: "\<And>x::'a. emb\<cdot>x ::: t"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   222
    using type_definition.Rep [OF type]
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   223
    by (simp add: emb_beta)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   224
  have prj_emb: "\<And>x::'a. prj\<cdot>(emb\<cdot>x) = x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   225
    unfolding prj_beta
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   226
    apply (simp add: cast_fixed [OF emb_in_deflation])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   227
    apply (simp add: emb_beta type_definition.Rep_inverse [OF type])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   228
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   229
  have emb_prj: "\<And>y. emb\<cdot>(prj\<cdot>y :: 'a) = cast\<cdot>t\<cdot>y"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   230
    unfolding prj_beta emb_beta
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   231
    by (simp add: type_definition.Abs_inverse [OF type])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   232
  show "ep_pair (emb :: 'a \<rightarrow> udom) prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   233
    apply default
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   234
    apply (simp add: prj_emb)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   235
    apply (simp add: emb_prj cast.below)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   236
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   237
  show "chain (approx :: nat \<Rightarrow> 'a \<rightarrow> 'a)"
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   238
    unfolding approx' by simp
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   239
  show "\<And>x::'a. (\<Squnion>i. approx i\<cdot>x) = x"
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   240
    unfolding approx'
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   241
    apply (simp add: lub_distribs)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   242
    apply (subst cast_fixed [OF emb_in_deflation])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   243
    apply (rule prj_emb)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   244
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   245
  show "\<And>(i::nat) (x::'a). approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x"
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   246
    unfolding approx'
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   247
    apply simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   248
    apply (simp add: emb_prj)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   249
    apply (simp add: cast_cast_approx)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   250
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   251
  show "\<And>i::nat. finite {x::'a. approx i\<cdot>x = x}"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   252
    apply (rule_tac B="(\<lambda>x. prj\<cdot>x) ` {x. cast\<cdot>(approx i\<cdot>t)\<cdot>x = x}"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   253
           in finite_subset)
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   254
    apply (clarsimp simp add: approx')
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   255
    apply (drule_tac f="\<lambda>x. emb\<cdot>x" in arg_cong)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   256
    apply (rule image_eqI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   257
    apply (rule prj_emb [symmetric])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   258
    apply (simp add: emb_prj)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   259
    apply (simp add: cast_cast_approx)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   260
    apply (rule finite_imageI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   261
    apply (simp add: cast_approx_fixed_iff)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   262
    apply (simp add: Collect_conj_eq)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   263
    apply (simp add: finite_fixes_approx)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   264
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   265
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   266
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   267
text {* Restore original typing constraints *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   268
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   269
setup {* Sign.add_const_constraint
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   270
  (@{const_name "approx"}, SOME @{typ "nat \<Rightarrow> 'a::profinite \<rightarrow> 'a"}) *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   271
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   272
setup {* Sign.add_const_constraint
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   273
  (@{const_name emb}, SOME @{typ "'a::rep \<rightarrow> udom"}) *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   274
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   275
setup {* Sign.add_const_constraint
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   276
  (@{const_name prj}, SOME @{typ "udom \<rightarrow> 'a::rep"}) *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   277
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   278
lemma typedef_REP:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   279
  fixes Rep :: "'a::rep \<Rightarrow> udom"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   280
  fixes Abs :: "udom \<Rightarrow> 'a::rep"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   281
  fixes t :: TypeRep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   282
  assumes type: "type_definition Rep Abs {x. x ::: t}"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   283
  assumes below: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   284
  assumes emb: "emb \<equiv> (\<Lambda> x. Rep x)"
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   285
  assumes prj: "prj \<equiv> (\<Lambda> x. Abs (cast\<cdot>t\<cdot>x))"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   286
  shows "REP('a) = t"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   287
proof -
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   288
  have adm: "adm (\<lambda>x. x \<in> {x. x ::: t})"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   289
    by (simp add: adm_in_deflation)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   290
  have emb_beta: "\<And>x. emb\<cdot>x = Rep x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   291
    unfolding emb
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   292
    apply (rule beta_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   293
    apply (rule typedef_cont_Rep [OF type below adm])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   294
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   295
  have prj_beta: "\<And>y. prj\<cdot>y = Abs (cast\<cdot>t\<cdot>y)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   296
    unfolding prj
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   297
    apply (rule beta_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   298
    apply (rule typedef_cont_Abs [OF type below adm])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   299
    apply simp_all
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   300
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   301
  have emb_in_deflation: "\<And>x::'a. emb\<cdot>x ::: t"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   302
    using type_definition.Rep [OF type]
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   303
    by (simp add: emb_beta)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   304
  have prj_emb: "\<And>x::'a. prj\<cdot>(emb\<cdot>x) = x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   305
    unfolding prj_beta
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   306
    apply (simp add: cast_fixed [OF emb_in_deflation])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   307
    apply (simp add: emb_beta type_definition.Rep_inverse [OF type])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   308
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   309
  have emb_prj: "\<And>y. emb\<cdot>(prj\<cdot>y :: 'a) = cast\<cdot>t\<cdot>y"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   310
    unfolding prj_beta emb_beta
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   311
    by (simp add: type_definition.Abs_inverse [OF type])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   312
  show "REP('a) = t"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   313
    apply (rule cast_eq_imp_eq, rule ext_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   314
    apply (simp add: cast_REP emb_prj)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   315
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   316
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   317
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   318
lemma adm_mem_Collect_in_deflation: "adm (\<lambda>x. x \<in> {x. x ::: A})"
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   319
unfolding mem_Collect_eq by (rule adm_in_deflation)
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   320
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   321
use "Tools/repdef.ML"
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   322
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   323
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   324
subsection {* Instances of class @{text rep} *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   325
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   326
subsubsection {* Universal Domain *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   327
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   328
text "The Universal Domain itself is trivially representable."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   329
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   330
instantiation udom :: rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   331
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   332
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   333
definition emb_udom_def [simp]: "emb = (ID :: udom \<rightarrow> udom)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   334
definition prj_udom_def [simp]: "prj = (ID :: udom \<rightarrow> udom)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   335
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   336
instance
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   337
 apply (intro_classes)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   338
 apply (simp_all add: ep_pair.intro)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   339
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   340
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   341
end
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   342
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   343
subsubsection {* Lifted types *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   344
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   345
instantiation lift :: (countable) rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   346
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   347
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   348
definition emb_lift_def:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   349
  "emb = udom_emb oo (FLIFT x. Def (to_nat x))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   350
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   351
definition prj_lift_def:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   352
  "prj = (FLIFT n. if (\<exists>x::'a::countable. n = to_nat x)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   353
                    then Def (THE x::'a. n = to_nat x) else \<bottom>) oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   354
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   355
instance
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   356
 apply (intro_classes, unfold emb_lift_def prj_lift_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   357
 apply (rule ep_pair_comp [OF _ ep_pair_udom])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   358
 apply (rule ep_pair.intro)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   359
  apply (case_tac x, simp, simp)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   360
 apply (case_tac y, simp, clarsimp)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   361
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   362
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   363
end
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   364
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   365
subsubsection {* Representable type constructors *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   366
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   367
text "Functions between representable types are representable."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   368
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   369
instantiation "->" :: (rep, rep) rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   370
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   371
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   372
definition emb_cfun_def: "emb = udom_emb oo cfun_map\<cdot>prj\<cdot>emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   373
definition prj_cfun_def: "prj = cfun_map\<cdot>emb\<cdot>prj oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   374
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   375
instance
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   376
 apply (intro_classes, unfold emb_cfun_def prj_cfun_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   377
 apply (intro ep_pair_comp ep_pair_cfun_map ep_pair_emb_prj ep_pair_udom)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   378
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   379
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   380
end
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   381
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   382
text "Strict products of representable types are representable."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   383
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   384
instantiation "**" :: (rep, rep) rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   385
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   386
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   387
definition emb_sprod_def: "emb = udom_emb oo sprod_map\<cdot>emb\<cdot>emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   388
definition prj_sprod_def: "prj = sprod_map\<cdot>prj\<cdot>prj oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   389
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   390
instance
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   391
 apply (intro_classes, unfold emb_sprod_def prj_sprod_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   392
 apply (intro ep_pair_comp ep_pair_sprod_map ep_pair_emb_prj ep_pair_udom)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   393
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   394
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   395
end
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   396
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   397
text "Strict sums of representable types are representable."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   398
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   399
instantiation "++" :: (rep, rep) rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   400
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   401
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   402
definition emb_ssum_def: "emb = udom_emb oo ssum_map\<cdot>emb\<cdot>emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   403
definition prj_ssum_def: "prj = ssum_map\<cdot>prj\<cdot>prj oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   404
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   405
instance
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   406
 apply (intro_classes, unfold emb_ssum_def prj_ssum_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   407
 apply (intro ep_pair_comp ep_pair_ssum_map ep_pair_emb_prj ep_pair_udom)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   408
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   409
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   410
end
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   411
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   412
text "Up of a representable type is representable."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   413
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   414
instantiation "u" :: (rep) rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   415
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   416
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   417
definition emb_u_def: "emb = udom_emb oo u_map\<cdot>emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   418
definition prj_u_def: "prj = u_map\<cdot>prj oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   419
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   420
instance
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   421
 apply (intro_classes, unfold emb_u_def prj_u_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   422
 apply (intro ep_pair_comp ep_pair_u_map ep_pair_emb_prj ep_pair_udom)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   423
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   424
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   425
end
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   426
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   427
text "Cartesian products of representable types are representable."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   428
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   429
instantiation "*" :: (rep, rep) rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   430
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   431
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   432
definition emb_cprod_def: "emb = udom_emb oo cprod_map\<cdot>emb\<cdot>emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   433
definition prj_cprod_def: "prj = cprod_map\<cdot>prj\<cdot>prj oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   434
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   435
instance
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   436
 apply (intro_classes, unfold emb_cprod_def prj_cprod_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   437
 apply (intro ep_pair_comp ep_pair_cprod_map ep_pair_emb_prj ep_pair_udom)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   438
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   439
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   440
end
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   441
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   442
text "Upper powerdomain of a representable type is representable."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   443
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   444
instantiation upper_pd :: (rep) rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   445
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   446
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   447
definition emb_upper_pd_def: "emb = udom_emb oo upper_map\<cdot>emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   448
definition prj_upper_pd_def: "prj = upper_map\<cdot>prj oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   449
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   450
instance
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   451
 apply (intro_classes, unfold emb_upper_pd_def prj_upper_pd_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   452
 apply (intro ep_pair_comp ep_pair_upper_map ep_pair_emb_prj ep_pair_udom)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   453
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   454
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   455
end
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   456
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   457
text "Lower powerdomain of a representable type is representable."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   458
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   459
instantiation lower_pd :: (rep) rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   460
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   461
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   462
definition emb_lower_pd_def: "emb = udom_emb oo lower_map\<cdot>emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   463
definition prj_lower_pd_def: "prj = lower_map\<cdot>prj oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   464
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   465
instance
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   466
 apply (intro_classes, unfold emb_lower_pd_def prj_lower_pd_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   467
 apply (intro ep_pair_comp ep_pair_lower_map ep_pair_emb_prj ep_pair_udom)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   468
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   469
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   470
end
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   471
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   472
text "Convex powerdomain of a representable type is representable."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   473
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   474
instantiation convex_pd :: (rep) rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   475
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   476
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   477
definition emb_convex_pd_def: "emb = udom_emb oo convex_map\<cdot>emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   478
definition prj_convex_pd_def: "prj = convex_map\<cdot>prj oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   479
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   480
instance
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   481
 apply (intro_classes, unfold emb_convex_pd_def prj_convex_pd_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   482
 apply (intro ep_pair_comp ep_pair_convex_map ep_pair_emb_prj ep_pair_udom)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   483
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   484
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   485
end
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   486
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   487
subsection {* Finite deflation lemmas *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   488
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   489
text "TODO: move these lemmas somewhere else"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   490
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   491
lemma finite_compact_range_imp_finite_range:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   492
  fixes d :: "'a::profinite \<rightarrow> 'b::cpo"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   493
  assumes "finite ((\<lambda>x. d\<cdot>x) ` {x. compact x})"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   494
  shows "finite (range (\<lambda>x. d\<cdot>x))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   495
proof (rule finite_subset [OF _ prems])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   496
  {
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   497
    fix x :: 'a
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   498
    have "range (\<lambda>i. d\<cdot>(approx i\<cdot>x)) \<subseteq> (\<lambda>x. d\<cdot>x) ` {x. compact x}"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   499
      by auto
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   500
    hence "finite (range (\<lambda>i. d\<cdot>(approx i\<cdot>x)))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   501
      using prems by (rule finite_subset)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   502
    hence "finite_chain (\<lambda>i. d\<cdot>(approx i\<cdot>x))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   503
      by (simp add: finite_range_imp_finch)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   504
    hence "\<exists>i. (\<Squnion>i. d\<cdot>(approx i\<cdot>x)) = d\<cdot>(approx i\<cdot>x)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   505
      by (simp add: finite_chain_def maxinch_is_thelub)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   506
    hence "\<exists>i. d\<cdot>x = d\<cdot>(approx i\<cdot>x)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   507
      by (simp add: lub_distribs)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   508
    hence "d\<cdot>x \<in> (\<lambda>x. d\<cdot>x) ` {x. compact x}"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   509
      by auto
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   510
  }
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   511
  thus "range (\<lambda>x. d\<cdot>x) \<subseteq> (\<lambda>x. d\<cdot>x) ` {x. compact x}"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   512
    by clarsimp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   513
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   514
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   515
lemma finite_deflation_upper_map:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   516
  assumes "finite_deflation d" shows "finite_deflation (upper_map\<cdot>d)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   517
proof (intro finite_deflation.intro finite_deflation_axioms.intro)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   518
  interpret d: finite_deflation d by fact
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   519
  have "deflation d" by fact
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   520
  thus "deflation (upper_map\<cdot>d)" by (rule deflation_upper_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   521
  have "finite (range (\<lambda>x. d\<cdot>x))" by (rule d.finite_range)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   522
  hence "finite (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   523
    by (rule finite_vimageI, simp add: inj_on_def Rep_compact_basis_inject)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   524
  hence "finite (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x)))" by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   525
  hence "finite (Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   526
    by (rule finite_vimageI, simp add: inj_on_def Rep_pd_basis_inject)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   527
  hence "finite (upper_principal ` Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   528
  hence "finite ((\<lambda>xs. upper_map\<cdot>d\<cdot>xs) ` range upper_principal)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   529
    apply (rule finite_subset [COMP swap_prems_rl])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   530
    apply (clarsimp, rename_tac t)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   531
    apply (induct_tac t rule: pd_basis_induct)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   532
    apply (simp only: upper_unit_Rep_compact_basis [symmetric] upper_map_unit)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   533
    apply (subgoal_tac "\<exists>b. d\<cdot>(Rep_compact_basis a) = Rep_compact_basis b")
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   534
    apply clarsimp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   535
    apply (rule imageI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   536
    apply (rule vimageI2)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   537
    apply (simp add: Rep_PDUnit)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   538
    apply (rule image_eqI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   539
    apply (erule sym)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   540
    apply simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   541
    apply (rule exI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   542
    apply (rule Abs_compact_basis_inverse [symmetric])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   543
    apply (simp add: d.compact)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   544
    apply (simp only: upper_plus_principal [symmetric] upper_map_plus)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   545
    apply clarsimp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   546
    apply (rule imageI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   547
    apply (rule vimageI2)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   548
    apply (simp add: Rep_PDPlus)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   549
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   550
  moreover have "{xs::'a upper_pd. compact xs} = range upper_principal"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   551
    by (auto dest: upper_pd.compact_imp_principal)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   552
  ultimately have "finite ((\<lambda>xs. upper_map\<cdot>d\<cdot>xs) ` {xs::'a upper_pd. compact xs})"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   553
    by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   554
  hence "finite (range (\<lambda>xs. upper_map\<cdot>d\<cdot>xs))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   555
    by (rule finite_compact_range_imp_finite_range)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   556
  thus "finite {xs. upper_map\<cdot>d\<cdot>xs = xs}"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   557
    by (rule finite_range_imp_finite_fixes)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   558
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   559
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   560
lemma finite_deflation_lower_map:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   561
  assumes "finite_deflation d" shows "finite_deflation (lower_map\<cdot>d)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   562
proof (intro finite_deflation.intro finite_deflation_axioms.intro)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   563
  interpret d: finite_deflation d by fact
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   564
  have "deflation d" by fact
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   565
  thus "deflation (lower_map\<cdot>d)" by (rule deflation_lower_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   566
  have "finite (range (\<lambda>x. d\<cdot>x))" by (rule d.finite_range)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   567
  hence "finite (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   568
    by (rule finite_vimageI, simp add: inj_on_def Rep_compact_basis_inject)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   569
  hence "finite (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x)))" by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   570
  hence "finite (Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   571
    by (rule finite_vimageI, simp add: inj_on_def Rep_pd_basis_inject)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   572
  hence "finite (lower_principal ` Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   573
  hence "finite ((\<lambda>xs. lower_map\<cdot>d\<cdot>xs) ` range lower_principal)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   574
    apply (rule finite_subset [COMP swap_prems_rl])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   575
    apply (clarsimp, rename_tac t)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   576
    apply (induct_tac t rule: pd_basis_induct)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   577
    apply (simp only: lower_unit_Rep_compact_basis [symmetric] lower_map_unit)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   578
    apply (subgoal_tac "\<exists>b. d\<cdot>(Rep_compact_basis a) = Rep_compact_basis b")
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   579
    apply clarsimp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   580
    apply (rule imageI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   581
    apply (rule vimageI2)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   582
    apply (simp add: Rep_PDUnit)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   583
    apply (rule image_eqI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   584
    apply (erule sym)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   585
    apply simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   586
    apply (rule exI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   587
    apply (rule Abs_compact_basis_inverse [symmetric])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   588
    apply (simp add: d.compact)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   589
    apply (simp only: lower_plus_principal [symmetric] lower_map_plus)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   590
    apply clarsimp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   591
    apply (rule imageI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   592
    apply (rule vimageI2)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   593
    apply (simp add: Rep_PDPlus)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   594
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   595
  moreover have "{xs::'a lower_pd. compact xs} = range lower_principal"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   596
    by (auto dest: lower_pd.compact_imp_principal)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   597
  ultimately have "finite ((\<lambda>xs. lower_map\<cdot>d\<cdot>xs) ` {xs::'a lower_pd. compact xs})"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   598
    by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   599
  hence "finite (range (\<lambda>xs. lower_map\<cdot>d\<cdot>xs))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   600
    by (rule finite_compact_range_imp_finite_range)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   601
  thus "finite {xs. lower_map\<cdot>d\<cdot>xs = xs}"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   602
    by (rule finite_range_imp_finite_fixes)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   603
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   604
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   605
lemma finite_deflation_convex_map:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   606
  assumes "finite_deflation d" shows "finite_deflation (convex_map\<cdot>d)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   607
proof (intro finite_deflation.intro finite_deflation_axioms.intro)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   608
  interpret d: finite_deflation d by fact
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   609
  have "deflation d" by fact
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   610
  thus "deflation (convex_map\<cdot>d)" by (rule deflation_convex_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   611
  have "finite (range (\<lambda>x. d\<cdot>x))" by (rule d.finite_range)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   612
  hence "finite (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   613
    by (rule finite_vimageI, simp add: inj_on_def Rep_compact_basis_inject)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   614
  hence "finite (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x)))" by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   615
  hence "finite (Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   616
    by (rule finite_vimageI, simp add: inj_on_def Rep_pd_basis_inject)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   617
  hence "finite (convex_principal ` Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   618
  hence "finite ((\<lambda>xs. convex_map\<cdot>d\<cdot>xs) ` range convex_principal)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   619
    apply (rule finite_subset [COMP swap_prems_rl])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   620
    apply (clarsimp, rename_tac t)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   621
    apply (induct_tac t rule: pd_basis_induct)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   622
    apply (simp only: convex_unit_Rep_compact_basis [symmetric] convex_map_unit)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   623
    apply (subgoal_tac "\<exists>b. d\<cdot>(Rep_compact_basis a) = Rep_compact_basis b")
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   624
    apply clarsimp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   625
    apply (rule imageI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   626
    apply (rule vimageI2)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   627
    apply (simp add: Rep_PDUnit)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   628
    apply (rule image_eqI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   629
    apply (erule sym)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   630
    apply simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   631
    apply (rule exI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   632
    apply (rule Abs_compact_basis_inverse [symmetric])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   633
    apply (simp add: d.compact)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   634
    apply (simp only: convex_plus_principal [symmetric] convex_map_plus)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   635
    apply clarsimp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   636
    apply (rule imageI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   637
    apply (rule vimageI2)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   638
    apply (simp add: Rep_PDPlus)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   639
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   640
  moreover have "{xs::'a convex_pd. compact xs} = range convex_principal"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   641
    by (auto dest: convex_pd.compact_imp_principal)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   642
  ultimately have "finite ((\<lambda>xs. convex_map\<cdot>d\<cdot>xs) ` {xs::'a convex_pd. compact xs})"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   643
    by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   644
  hence "finite (range (\<lambda>xs. convex_map\<cdot>d\<cdot>xs))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   645
    by (rule finite_compact_range_imp_finite_range)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   646
  thus "finite {xs. convex_map\<cdot>d\<cdot>xs = xs}"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   647
    by (rule finite_range_imp_finite_fixes)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   648
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   649
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   650
subsection {* Type combinators *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   651
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   652
definition
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   653
  TypeRep_fun1 ::
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   654
    "((udom \<rightarrow> udom) \<rightarrow> ('a \<rightarrow> 'a))
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   655
      \<Rightarrow> (TypeRep \<rightarrow> TypeRep)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   656
where
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   657
  "TypeRep_fun1 f =
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   658
    alg_defl.basis_fun (\<lambda>a.
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   659
      alg_defl_principal (
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   660
        Abs_fin_defl (udom_emb oo f\<cdot>(Rep_fin_defl a) oo udom_prj)))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   661
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   662
definition
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   663
  TypeRep_fun2 ::
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   664
    "((udom \<rightarrow> udom) \<rightarrow> (udom \<rightarrow> udom) \<rightarrow> ('a \<rightarrow> 'a))
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   665
      \<Rightarrow> (TypeRep \<rightarrow> TypeRep \<rightarrow> TypeRep)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   666
where
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   667
  "TypeRep_fun2 f =
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   668
    alg_defl.basis_fun (\<lambda>a.
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   669
      alg_defl.basis_fun (\<lambda>b.
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   670
        alg_defl_principal (
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   671
          Abs_fin_defl (udom_emb oo
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   672
            f\<cdot>(Rep_fin_defl a)\<cdot>(Rep_fin_defl b) oo udom_prj))))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   673
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   674
definition "one_typ = REP(one)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   675
definition "tr_typ = REP(tr)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   676
definition "cfun_typ = TypeRep_fun2 cfun_map"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   677
definition "ssum_typ = TypeRep_fun2 ssum_map"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   678
definition "sprod_typ = TypeRep_fun2 sprod_map"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   679
definition "cprod_typ = TypeRep_fun2 cprod_map"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   680
definition "u_typ = TypeRep_fun1 u_map"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   681
definition "upper_typ = TypeRep_fun1 upper_map"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   682
definition "lower_typ = TypeRep_fun1 lower_map"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   683
definition "convex_typ = TypeRep_fun1 convex_map"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   684
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   685
lemma Rep_fin_defl_mono: "a \<sqsubseteq> b \<Longrightarrow> Rep_fin_defl a \<sqsubseteq> Rep_fin_defl b"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   686
unfolding below_fin_defl_def .
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   687
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   688
lemma cast_TypeRep_fun1:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   689
  assumes f: "\<And>a. finite_deflation a \<Longrightarrow> finite_deflation (f\<cdot>a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   690
  shows "cast\<cdot>(TypeRep_fun1 f\<cdot>A) = udom_emb oo f\<cdot>(cast\<cdot>A) oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   691
proof -
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   692
  have 1: "\<And>a. finite_deflation (udom_emb oo f\<cdot>(Rep_fin_defl a) oo udom_prj)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   693
    apply (rule ep_pair.finite_deflation_e_d_p [OF ep_pair_udom])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   694
    apply (rule f, rule finite_deflation_Rep_fin_defl)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   695
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   696
  show ?thesis
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   697
    by (induct A rule: alg_defl.principal_induct, simp)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   698
       (simp only: TypeRep_fun1_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   699
                   alg_defl.basis_fun_principal
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   700
                   alg_defl.basis_fun_mono
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   701
                   alg_defl.principal_mono
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   702
                   Abs_fin_defl_mono [OF 1 1]
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   703
                   monofun_cfun below_refl
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   704
                   Rep_fin_defl_mono
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   705
                   cast_alg_defl_principal
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   706
                   Abs_fin_defl_inverse [unfolded mem_Collect_eq, OF 1])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   707
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   708
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   709
lemma cast_TypeRep_fun2:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   710
  assumes f: "\<And>a b. finite_deflation a \<Longrightarrow> finite_deflation b \<Longrightarrow>
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   711
                finite_deflation (f\<cdot>a\<cdot>b)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   712
  shows "cast\<cdot>(TypeRep_fun2 f\<cdot>A\<cdot>B) = udom_emb oo f\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   713
proof -
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   714
  have 1: "\<And>a b. finite_deflation
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   715
           (udom_emb oo f\<cdot>(Rep_fin_defl a)\<cdot>(Rep_fin_defl b) oo udom_prj)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   716
    apply (rule ep_pair.finite_deflation_e_d_p [OF ep_pair_udom])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   717
    apply (rule f, (rule finite_deflation_Rep_fin_defl)+)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   718
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   719
  show ?thesis
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   720
    by (induct A B rule: alg_defl.principal_induct2, simp, simp)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   721
       (simp only: TypeRep_fun2_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   722
                   alg_defl.basis_fun_principal
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   723
                   alg_defl.basis_fun_mono
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   724
                   alg_defl.principal_mono
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   725
                   Abs_fin_defl_mono [OF 1 1]
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   726
                   monofun_cfun below_refl
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   727
                   Rep_fin_defl_mono
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   728
                   cast_alg_defl_principal
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   729
                   Abs_fin_defl_inverse [unfolded mem_Collect_eq, OF 1])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   730
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   731
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   732
lemma cast_cfun_typ:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   733
  "cast\<cdot>(cfun_typ\<cdot>A\<cdot>B) = udom_emb oo cfun_map\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   734
unfolding cfun_typ_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   735
apply (rule cast_TypeRep_fun2)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   736
apply (erule (1) finite_deflation_cfun_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   737
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   738
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   739
lemma cast_ssum_typ:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   740
  "cast\<cdot>(ssum_typ\<cdot>A\<cdot>B) = udom_emb oo ssum_map\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   741
unfolding ssum_typ_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   742
apply (rule cast_TypeRep_fun2)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   743
apply (erule (1) finite_deflation_ssum_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   744
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   745
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   746
lemma cast_sprod_typ:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   747
  "cast\<cdot>(sprod_typ\<cdot>A\<cdot>B) = udom_emb oo sprod_map\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   748
unfolding sprod_typ_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   749
apply (rule cast_TypeRep_fun2)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   750
apply (erule (1) finite_deflation_sprod_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   751
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   752
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   753
lemma cast_cprod_typ:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   754
  "cast\<cdot>(cprod_typ\<cdot>A\<cdot>B) = udom_emb oo cprod_map\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   755
unfolding cprod_typ_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   756
apply (rule cast_TypeRep_fun2)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   757
apply (erule (1) finite_deflation_cprod_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   758
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   759
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   760
lemma cast_u_typ:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   761
  "cast\<cdot>(u_typ\<cdot>A) = udom_emb oo u_map\<cdot>(cast\<cdot>A) oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   762
unfolding u_typ_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   763
apply (rule cast_TypeRep_fun1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   764
apply (erule finite_deflation_u_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   765
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   766
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   767
lemma cast_upper_typ:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   768
  "cast\<cdot>(upper_typ\<cdot>A) = udom_emb oo upper_map\<cdot>(cast\<cdot>A) oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   769
unfolding upper_typ_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   770
apply (rule cast_TypeRep_fun1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   771
apply (erule finite_deflation_upper_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   772
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   773
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   774
lemma cast_lower_typ:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   775
  "cast\<cdot>(lower_typ\<cdot>A) = udom_emb oo lower_map\<cdot>(cast\<cdot>A) oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   776
unfolding lower_typ_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   777
apply (rule cast_TypeRep_fun1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   778
apply (erule finite_deflation_lower_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   779
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   780
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   781
lemma cast_convex_typ:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   782
  "cast\<cdot>(convex_typ\<cdot>A) = udom_emb oo convex_map\<cdot>(cast\<cdot>A) oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   783
unfolding convex_typ_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   784
apply (rule cast_TypeRep_fun1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   785
apply (erule finite_deflation_convex_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   786
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   787
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   788
text {* REP of type constructor = type combinator *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   789
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   790
lemma REP_one: "REP(one) = one_typ"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   791
by (simp only: one_typ_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   792
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   793
lemma REP_tr: "REP(tr) = tr_typ"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   794
by (simp only: tr_typ_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   795
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   796
lemma REP_cfun: "REP('a \<rightarrow> 'b) = cfun_typ\<cdot>REP('a)\<cdot>REP('b)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   797
apply (rule cast_eq_imp_eq, rule ext_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   798
apply (simp add: cast_REP cast_cfun_typ)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   799
apply (simp add: cfun_map_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   800
apply (simp only: prj_cfun_def emb_cfun_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   801
apply (simp add: expand_cfun_eq ep_pair.e_eq_iff [OF ep_pair_udom])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   802
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   803
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   804
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   805
lemma REP_ssum: "REP('a \<oplus> 'b) = ssum_typ\<cdot>REP('a)\<cdot>REP('b)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   806
apply (rule cast_eq_imp_eq, rule ext_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   807
apply (simp add: cast_REP cast_ssum_typ)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   808
apply (simp add: prj_ssum_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   809
apply (simp add: emb_ssum_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   810
apply (simp add: ssum_map_map cfcomp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   811
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   812
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   813
lemma REP_sprod: "REP('a \<otimes> 'b) = sprod_typ\<cdot>REP('a)\<cdot>REP('b)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   814
apply (rule cast_eq_imp_eq, rule ext_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   815
apply (simp add: cast_REP cast_sprod_typ)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   816
apply (simp add: prj_sprod_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   817
apply (simp add: emb_sprod_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   818
apply (simp add: sprod_map_map cfcomp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   819
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   820
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   821
lemma REP_cprod: "REP('a \<times> 'b) = cprod_typ\<cdot>REP('a)\<cdot>REP('b)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   822
apply (rule cast_eq_imp_eq, rule ext_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   823
apply (simp add: cast_REP cast_cprod_typ)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   824
apply (simp add: prj_cprod_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   825
apply (simp add: emb_cprod_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   826
apply (simp add: cprod_map_map cfcomp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   827
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   828
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   829
lemma REP_up: "REP('a u) = u_typ\<cdot>REP('a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   830
apply (rule cast_eq_imp_eq, rule ext_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   831
apply (simp add: cast_REP cast_u_typ)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   832
apply (simp add: prj_u_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   833
apply (simp add: emb_u_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   834
apply (simp add: u_map_map cfcomp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   835
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   836
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   837
lemma REP_upper: "REP('a upper_pd) = upper_typ\<cdot>REP('a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   838
apply (rule cast_eq_imp_eq, rule ext_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   839
apply (simp add: cast_REP cast_upper_typ)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   840
apply (simp add: prj_upper_pd_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   841
apply (simp add: emb_upper_pd_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   842
apply (simp add: upper_map_map cfcomp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   843
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   844
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   845
lemma REP_lower: "REP('a lower_pd) = lower_typ\<cdot>REP('a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   846
apply (rule cast_eq_imp_eq, rule ext_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   847
apply (simp add: cast_REP cast_lower_typ)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   848
apply (simp add: prj_lower_pd_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   849
apply (simp add: emb_lower_pd_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   850
apply (simp add: lower_map_map cfcomp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   851
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   852
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   853
lemma REP_convex: "REP('a convex_pd) = convex_typ\<cdot>REP('a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   854
apply (rule cast_eq_imp_eq, rule ext_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   855
apply (simp add: cast_REP cast_convex_typ)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   856
apply (simp add: prj_convex_pd_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   857
apply (simp add: emb_convex_pd_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   858
apply (simp add: convex_map_map cfcomp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   859
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   860
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   861
lemmas REP_simps =
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   862
  REP_one
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   863
  REP_tr
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   864
  REP_cfun
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   865
  REP_ssum
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   866
  REP_sprod
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   867
  REP_cprod
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   868
  REP_up
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   869
  REP_upper
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   870
  REP_lower
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   871
  REP_convex
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   872
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   873
subsection {* Isomorphic deflations *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   874
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   875
definition
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   876
  isodefl :: "('a::rep \<rightarrow> 'a) \<Rightarrow> udom alg_defl \<Rightarrow> bool"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   877
where
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   878
  "isodefl d t \<longleftrightarrow> cast\<cdot>t = emb oo d oo prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   879
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   880
lemma isodeflI: "(\<And>x. cast\<cdot>t\<cdot>x = emb\<cdot>(d\<cdot>(prj\<cdot>x))) \<Longrightarrow> isodefl d t"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   881
unfolding isodefl_def by (simp add: ext_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   882
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   883
lemma cast_isodefl: "isodefl d t \<Longrightarrow> cast\<cdot>t = (\<Lambda> x. emb\<cdot>(d\<cdot>(prj\<cdot>x)))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   884
unfolding isodefl_def by (simp add: ext_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   885
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   886
lemma isodefl_strict: "isodefl d t \<Longrightarrow> d\<cdot>\<bottom> = \<bottom>"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   887
unfolding isodefl_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   888
by (drule cfun_fun_cong [where x="\<bottom>"], simp)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   889
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   890
lemma isodefl_imp_deflation:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   891
  fixes d :: "'a::rep \<rightarrow> 'a"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   892
  assumes "isodefl d t" shows "deflation d"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   893
proof
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   894
  note prems [unfolded isodefl_def, simp]
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   895
  fix x :: 'a
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   896
  show "d\<cdot>(d\<cdot>x) = d\<cdot>x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   897
    using cast.idem [of t "emb\<cdot>x"] by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   898
  show "d\<cdot>x \<sqsubseteq> x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   899
    using cast.below [of t "emb\<cdot>x"] by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   900
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   901
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   902
lemma isodefl_ID_REP: "isodefl (ID :: 'a \<rightarrow> 'a) REP('a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   903
unfolding isodefl_def by (simp add: cast_REP)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   904
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   905
lemma isodefl_REP_imp_ID: "isodefl (d :: 'a \<rightarrow> 'a) REP('a) \<Longrightarrow> d = ID"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   906
unfolding isodefl_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   907
apply (simp add: cast_REP)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   908
apply (simp add: expand_cfun_eq)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   909
apply (rule allI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   910
apply (drule_tac x="emb\<cdot>x" in spec)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   911
apply simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   912
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   913
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   914
lemma isodefl_bottom: "isodefl \<bottom> \<bottom>"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   915
unfolding isodefl_def by (simp add: expand_cfun_eq)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   916
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   917
lemma adm_isodefl:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   918
  "cont f \<Longrightarrow> cont g \<Longrightarrow> adm (\<lambda>x. isodefl (f x) (g x))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   919
unfolding isodefl_def by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   920
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   921
lemma isodefl_lub:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   922
  assumes "chain d" and "chain t"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   923
  assumes "\<And>i. isodefl (d i) (t i)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   924
  shows "isodefl (\<Squnion>i. d i) (\<Squnion>i. t i)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   925
using prems unfolding isodefl_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   926
by (simp add: contlub_cfun_arg contlub_cfun_fun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   927
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   928
lemma isodefl_fix:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   929
  assumes "\<And>d t. isodefl d t \<Longrightarrow> isodefl (f\<cdot>d) (g\<cdot>t)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   930
  shows "isodefl (fix\<cdot>f) (fix\<cdot>g)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   931
unfolding fix_def2
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   932
apply (rule isodefl_lub, simp, simp)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   933
apply (induct_tac i)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   934
apply (simp add: isodefl_bottom)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   935
apply (simp add: prems)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   936
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   937
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   938
lemma isodefl_coerce:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   939
  fixes d :: "'a \<rightarrow> 'a"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   940
  assumes REP: "REP('b) = REP('a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   941
  shows "isodefl d t \<Longrightarrow> isodefl (coerce oo d oo coerce :: 'b \<rightarrow> 'b) t"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   942
unfolding isodefl_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   943
apply (simp add: expand_cfun_eq)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   944
apply (simp add: emb_coerce coerce_prj REP)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   945
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   946
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   947
lemma isodefl_cfun:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   948
  "isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow>
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   949
    isodefl (cfun_map\<cdot>d1\<cdot>d2) (cfun_typ\<cdot>t1\<cdot>t2)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   950
apply (rule isodeflI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   951
apply (simp add: cast_cfun_typ cast_isodefl)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   952
apply (simp add: emb_cfun_def prj_cfun_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   953
apply (simp add: cfun_map_map cfcomp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   954
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   955
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   956
lemma isodefl_ssum:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   957
  "isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow>
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   958
    isodefl (ssum_map\<cdot>d1\<cdot>d2) (ssum_typ\<cdot>t1\<cdot>t2)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   959
apply (rule isodeflI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   960
apply (simp add: cast_ssum_typ cast_isodefl)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   961
apply (simp add: emb_ssum_def prj_ssum_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   962
apply (simp add: ssum_map_map isodefl_strict)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   963
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   964
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   965
lemma isodefl_sprod:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   966
  "isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow>
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   967
    isodefl (sprod_map\<cdot>d1\<cdot>d2) (sprod_typ\<cdot>t1\<cdot>t2)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   968
apply (rule isodeflI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   969
apply (simp add: cast_sprod_typ cast_isodefl)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   970
apply (simp add: emb_sprod_def prj_sprod_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   971
apply (simp add: sprod_map_map isodefl_strict)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   972
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   973
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   974
lemma isodefl_u:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   975
  "isodefl d t \<Longrightarrow> isodefl (u_map\<cdot>d) (u_typ\<cdot>t)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   976
apply (rule isodeflI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   977
apply (simp add: cast_u_typ cast_isodefl)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   978
apply (simp add: emb_u_def prj_u_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   979
apply (simp add: u_map_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   980
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   981
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   982
lemma isodefl_one: "isodefl (ID :: one \<rightarrow> one) one_typ"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   983
unfolding one_typ_def by (rule isodefl_ID_REP)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   984
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   985
lemma isodefl_tr: "isodefl (ID :: tr \<rightarrow> tr) tr_typ"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   986
unfolding tr_typ_def by (rule isodefl_ID_REP)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   987
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   988
lemma isodefl_upper:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   989
  "isodefl d t \<Longrightarrow> isodefl (upper_map\<cdot>d) (upper_typ\<cdot>t)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   990
apply (rule isodeflI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   991
apply (simp add: cast_upper_typ cast_isodefl)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   992
apply (simp add: emb_upper_pd_def prj_upper_pd_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   993
apply (simp add: upper_map_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   994
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   995
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   996
lemma isodefl_lower:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   997
  "isodefl d t \<Longrightarrow> isodefl (lower_map\<cdot>d) (lower_typ\<cdot>t)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   998
apply (rule isodeflI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   999
apply (simp add: cast_lower_typ cast_isodefl)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
  1000
apply (simp add: emb_lower_pd_def prj_lower_pd_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
  1001
apply (simp add: lower_map_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
  1002
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
  1003
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
  1004
lemma isodefl_convex:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
  1005
  "isodefl d t \<Longrightarrow> isodefl (convex_map\<cdot>d) (convex_typ\<cdot>t)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
  1006
apply (rule isodeflI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
  1007
apply (simp add: cast_convex_typ cast_isodefl)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
  1008
apply (simp add: emb_convex_pd_def prj_convex_pd_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
  1009
apply (simp add: convex_map_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
  1010
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
  1011
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
  1012
end