src/HOLCF/Representable.thy
author huffman
Fri, 05 Mar 2010 14:05:25 -0800
changeset 35596 49a02dab35ed
parent 35595 1785d387627a
child 35652 05ca920cd94b
permissions -rw-r--r--
add comment
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
35473
c4d3d65856dd move some powerdomain stuff into a new file
huffman
parents: 33809
diff changeset
     8
imports Algebraic Universal Ssum Sprod One Fixrec
33794
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
     9
uses
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
    10
  ("Tools/repdef.ML")
35514
a2cfa413eaab move take-related definitions and proofs to new module; simplify map_of_typ functions
huffman
parents: 35490
diff changeset
    11
  ("Tools/Domain/domain_take_proofs.ML")
33794
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
    12
  ("Tools/Domain/domain_isomorphism.ML")
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    13
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    14
35595
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    15
subsection {* Preliminaries: Take proofs *}
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    16
35596
49a02dab35ed add comment
huffman
parents: 35595
diff changeset
    17
text {*
49a02dab35ed add comment
huffman
parents: 35595
diff changeset
    18
  This section contains lemmas that are used in a module that supports
49a02dab35ed add comment
huffman
parents: 35595
diff changeset
    19
  the domain isomorphism package; the module contains proofs related
49a02dab35ed add comment
huffman
parents: 35595
diff changeset
    20
  to take functions and the finiteness predicate.
49a02dab35ed add comment
huffman
parents: 35595
diff changeset
    21
*}
49a02dab35ed add comment
huffman
parents: 35595
diff changeset
    22
35595
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    23
lemma deflation_abs_rep:
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    24
  fixes abs and rep and d
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    25
  assumes abs_iso: "\<And>x. rep\<cdot>(abs\<cdot>x) = x"
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    26
  assumes rep_iso: "\<And>y. abs\<cdot>(rep\<cdot>y) = y"
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    27
  shows "deflation d \<Longrightarrow> deflation (abs oo d oo rep)"
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    28
by (rule ep_pair.deflation_e_d_p) (simp add: ep_pair.intro assms)
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    29
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    30
lemma deflation_chain_min:
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    31
  assumes chain: "chain d"
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    32
  assumes defl: "\<And>n. deflation (d n)"
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    33
  shows "d m\<cdot>(d n\<cdot>x) = d (min m n)\<cdot>x"
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    34
proof (rule linorder_le_cases)
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    35
  assume "m \<le> n"
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    36
  with chain have "d m \<sqsubseteq> d n" by (rule chain_mono)
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    37
  then have "d m\<cdot>(d n\<cdot>x) = d m\<cdot>x"
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    38
    by (rule deflation_below_comp1 [OF defl defl])
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    39
  moreover from `m \<le> n` have "min m n = m" by simp
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    40
  ultimately show ?thesis by simp
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    41
next
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    42
  assume "n \<le> m"
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    43
  with chain have "d n \<sqsubseteq> d m" by (rule chain_mono)
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    44
  then have "d m\<cdot>(d n\<cdot>x) = d n\<cdot>x"
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    45
    by (rule deflation_below_comp2 [OF defl defl])
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    46
  moreover from `n \<le> m` have "min m n = n" by simp
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    47
  ultimately show ?thesis by simp
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    48
qed
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    49
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    50
use "Tools/Domain/domain_take_proofs.ML"
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    51
1785d387627a move take_proofs-related stuff to a new section
huffman
parents: 35563
diff changeset
    52
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    53
subsection {* Class of representable types *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    54
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    55
text "Overloaded embedding and projection functions between
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    56
      a representable type and the universal domain."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    57
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    58
class rep = bifinite +
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    59
  fixes emb :: "'a::pcpo \<rightarrow> udom"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    60
  fixes prj :: "udom \<rightarrow> 'a::pcpo"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    61
  assumes ep_pair_emb_prj: "ep_pair emb prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    62
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    63
interpretation rep!:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    64
  pcpo_ep_pair
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    65
    "emb :: 'a::rep \<rightarrow> udom"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    66
    "prj :: udom \<rightarrow> 'a::rep"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    67
  unfolding pcpo_ep_pair_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    68
  by (rule ep_pair_emb_prj)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    69
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    70
lemmas emb_inverse = rep.e_inverse
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    71
lemmas emb_prj_below = rep.e_p_below
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    72
lemmas emb_eq_iff = rep.e_eq_iff
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    73
lemmas emb_strict = rep.e_strict
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    74
lemmas prj_strict = rep.p_strict
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    75
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    76
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    77
subsection {* Making @{term rep} the default class *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    78
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    79
text {*
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    80
  From now on, free type variables are assumed to be in class
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    81
  @{term rep}, unless specified otherwise.
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    82
*}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    83
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    84
defaultsort rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    85
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    86
subsection {* Representations of types *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    87
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    88
text "A TypeRep is an algebraic deflation over the universe of values."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    89
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    90
types TypeRep = "udom alg_defl"
35431
8758fe1fc9f8 cleanup type translations;
wenzelm
parents: 33809
diff changeset
    91
translations (type) "TypeRep" \<leftharpoondown> (type) "udom alg_defl"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    92
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    93
definition
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    94
  Rep_of :: "'a::rep itself \<Rightarrow> TypeRep"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    95
where
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    96
  "Rep_of TYPE('a::rep) =
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    97
    (\<Squnion>i. alg_defl_principal (Abs_fin_defl
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    98
      (emb oo (approx i :: 'a \<rightarrow> 'a) oo prj)))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
    99
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   100
syntax "_REP" :: "type \<Rightarrow> TypeRep"  ("(1REP/(1'(_')))")
35431
8758fe1fc9f8 cleanup type translations;
wenzelm
parents: 33809
diff changeset
   101
translations "REP('t)" \<rightleftharpoons> "CONST Rep_of TYPE('t)"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   102
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   103
lemma cast_REP:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   104
  "cast\<cdot>REP('a::rep) = (emb::'a \<rightarrow> udom) oo (prj::udom \<rightarrow> 'a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   105
proof -
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   106
  let ?a = "\<lambda>i. emb oo approx i oo (prj::udom \<rightarrow> 'a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   107
  have a: "\<And>i. finite_deflation (?a i)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   108
    apply (rule rep.finite_deflation_e_d_p)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   109
    apply (rule finite_deflation_approx)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   110
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   111
  show ?thesis
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   112
    unfolding Rep_of_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   113
    apply (subst contlub_cfun_arg)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   114
    apply (rule chainI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   115
    apply (rule alg_defl.principal_mono)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   116
    apply (rule Abs_fin_defl_mono [OF a a])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   117
    apply (rule chainE, simp)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   118
    apply (subst cast_alg_defl_principal)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   119
    apply (simp add: Abs_fin_defl_inverse a)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   120
    apply (simp add: expand_cfun_eq lub_distribs)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   121
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   122
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   123
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   124
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
   125
by (simp add: cast_REP)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   126
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   127
lemma in_REP_iff:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   128
  "x ::: REP('a::rep) \<longleftrightarrow> emb\<cdot>((prj\<cdot>x)::'a) = x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   129
by (simp add: in_deflation_def cast_REP)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   130
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   131
lemma prj_inverse:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   132
  "x ::: REP('a::rep) \<Longrightarrow> emb\<cdot>((prj\<cdot>x)::'a) = x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   133
by (simp only: in_REP_iff)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   134
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   135
lemma emb_in_REP [simp]:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   136
  "emb\<cdot>(x::'a::rep) ::: REP('a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   137
by (simp add: in_REP_iff)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   138
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   139
subsection {* Coerce operator *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   140
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   141
definition coerce :: "'a \<rightarrow> 'b"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   142
where "coerce = prj oo emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   143
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   144
lemma beta_coerce: "coerce\<cdot>x = prj\<cdot>(emb\<cdot>x)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   145
by (simp add: coerce_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   146
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   147
lemma prj_emb: "prj\<cdot>(emb\<cdot>x) = coerce\<cdot>x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   148
by (simp add: coerce_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   149
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   150
lemma coerce_strict [simp]: "coerce\<cdot>\<bottom> = \<bottom>"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   151
by (simp add: coerce_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   152
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   153
lemma coerce_eq_ID [simp]: "(coerce :: 'a \<rightarrow> 'a) = ID"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   154
by (rule ext_cfun, simp add: beta_coerce)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   155
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   156
lemma emb_coerce:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   157
  "REP('a) \<sqsubseteq> REP('b)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   158
   \<Longrightarrow> emb\<cdot>((coerce::'a \<rightarrow> 'b)\<cdot>x) = emb\<cdot>x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   159
 apply (simp add: beta_coerce)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   160
 apply (rule prj_inverse)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   161
 apply (erule subdeflationD)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   162
 apply (rule emb_in_REP)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   163
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   164
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   165
lemma coerce_prj:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   166
  "REP('a) \<sqsubseteq> REP('b)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   167
   \<Longrightarrow> (coerce::'b \<rightarrow> 'a)\<cdot>(prj\<cdot>x) = prj\<cdot>x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   168
 apply (simp add: coerce_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   169
 apply (rule emb_eq_iff [THEN iffD1])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   170
 apply (simp only: emb_prj)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   171
 apply (rule deflation_below_comp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   172
   apply (rule deflation_cast)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   173
  apply (rule deflation_cast)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   174
 apply (erule monofun_cfun_arg)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   175
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   176
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   177
lemma coerce_coerce [simp]:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   178
  "REP('a) \<sqsubseteq> REP('b)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   179
   \<Longrightarrow> coerce\<cdot>((coerce::'a \<rightarrow> 'b)\<cdot>x) = coerce\<cdot>x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   180
by (simp add: beta_coerce prj_inverse subdeflationD)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   181
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   182
lemma coerce_inverse:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   183
  "emb\<cdot>(x::'a) ::: REP('b) \<Longrightarrow> coerce\<cdot>(coerce\<cdot>x :: 'b) = x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   184
by (simp only: beta_coerce prj_inverse emb_inverse)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   185
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   186
lemma coerce_type:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   187
  "REP('a) \<sqsubseteq> REP('b)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   188
   \<Longrightarrow> emb\<cdot>((coerce::'a \<rightarrow> 'b)\<cdot>x) ::: REP('a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   189
by (simp add: beta_coerce prj_inverse subdeflationD)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   190
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   191
lemma ep_pair_coerce:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   192
  "REP('a) \<sqsubseteq> REP('b)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   193
   \<Longrightarrow> ep_pair (coerce::'a \<rightarrow> 'b) (coerce::'b \<rightarrow> 'a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   194
 apply (rule ep_pair.intro)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   195
  apply simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   196
 apply (simp only: beta_coerce)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   197
 apply (rule below_trans)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   198
  apply (rule monofun_cfun_arg)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   199
  apply (rule emb_prj_below)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   200
 apply simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   201
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   202
33779
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   203
text {* Isomorphism lemmas used internally by the domain package: *}
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   204
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   205
lemma domain_abs_iso:
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   206
  fixes abs and rep
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   207
  assumes REP: "REP('b) = REP('a)"
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   208
  assumes abs_def: "abs \<equiv> (coerce :: 'a \<rightarrow> 'b)"
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   209
  assumes rep_def: "rep \<equiv> (coerce :: 'b \<rightarrow> 'a)"
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   210
  shows "rep\<cdot>(abs\<cdot>x) = x"
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   211
unfolding abs_def rep_def by (simp add: REP)
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   212
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   213
lemma domain_rep_iso:
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   214
  fixes abs and rep
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   215
  assumes REP: "REP('b) = REP('a)"
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   216
  assumes abs_def: "abs \<equiv> (coerce :: 'a \<rightarrow> 'b)"
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   217
  assumes rep_def: "rep \<equiv> (coerce :: 'b \<rightarrow> 'a)"
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   218
  shows "abs\<cdot>(rep\<cdot>x) = x"
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   219
unfolding abs_def rep_def by (simp add: REP [symmetric])
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   220
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   221
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   222
subsection {* Proving a subtype is representable *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   223
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   224
text {*
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   225
  Temporarily relax type constraints for @{term "approx"},
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   226
  @{term emb}, and @{term prj}.
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   227
*}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   228
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   229
setup {* Sign.add_const_constraint
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   230
  (@{const_name "approx"}, SOME @{typ "nat \<Rightarrow> 'a::cpo \<rightarrow> 'a"}) *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   231
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   232
setup {* Sign.add_const_constraint
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   233
  (@{const_name emb}, SOME @{typ "'a::pcpo \<rightarrow> udom"}) *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   234
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   235
setup {* Sign.add_const_constraint
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   236
  (@{const_name prj}, SOME @{typ "udom \<rightarrow> 'a::pcpo"}) *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   237
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   238
definition
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   239
  repdef_approx ::
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   240
    "('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
   241
where
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   242
  "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
   243
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   244
lemma typedef_rep_class:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   245
  fixes Rep :: "'a::pcpo \<Rightarrow> udom"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   246
  fixes Abs :: "udom \<Rightarrow> 'a::pcpo"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   247
  fixes t :: TypeRep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   248
  assumes type: "type_definition Rep Abs {x. x ::: t}"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   249
  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
   250
  assumes emb: "emb \<equiv> (\<Lambda> x. Rep x)"
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   251
  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
   252
  assumes approx: "(approx :: nat \<Rightarrow> 'a \<rightarrow> 'a) \<equiv> repdef_approx Rep Abs t"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   253
  shows "OFCLASS('a, rep_class)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   254
proof
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   255
  have adm: "adm (\<lambda>x. x \<in> {x. x ::: t})"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   256
    by (simp add: adm_in_deflation)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   257
  have emb_beta: "\<And>x. emb\<cdot>x = Rep x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   258
    unfolding emb
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   259
    apply (rule beta_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   260
    apply (rule typedef_cont_Rep [OF type below adm])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   261
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   262
  have prj_beta: "\<And>y. prj\<cdot>y = Abs (cast\<cdot>t\<cdot>y)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   263
    unfolding prj
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   264
    apply (rule beta_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   265
    apply (rule typedef_cont_Abs [OF type below adm])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   266
    apply simp_all
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   267
    done
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   268
  have cast_cast_approx:
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   269
    "\<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
   270
    apply (rule cast_fixed)
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   271
    apply (rule subdeflationD)
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   272
    apply (rule approx.below)
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   273
    apply (rule cast_in_deflation)
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   274
    done
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   275
  have approx':
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   276
    "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
   277
    unfolding approx repdef_approx_def
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   278
    apply (subst cast_cast_approx [symmetric])
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   279
    apply (simp add: prj_beta [symmetric] emb_beta [symmetric])
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   280
    done
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   281
  have emb_in_deflation: "\<And>x::'a. emb\<cdot>x ::: t"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   282
    using type_definition.Rep [OF type]
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   283
    by (simp add: emb_beta)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   284
  have prj_emb: "\<And>x::'a. prj\<cdot>(emb\<cdot>x) = x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   285
    unfolding prj_beta
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   286
    apply (simp add: cast_fixed [OF emb_in_deflation])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   287
    apply (simp add: emb_beta type_definition.Rep_inverse [OF type])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   288
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   289
  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
   290
    unfolding prj_beta emb_beta
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   291
    by (simp add: type_definition.Abs_inverse [OF type])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   292
  show "ep_pair (emb :: 'a \<rightarrow> udom) prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   293
    apply default
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   294
    apply (simp add: prj_emb)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   295
    apply (simp add: emb_prj cast.below)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   296
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   297
  show "chain (approx :: nat \<Rightarrow> 'a \<rightarrow> 'a)"
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   298
    unfolding approx' by simp
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   299
  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
   300
    unfolding approx'
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   301
    apply (simp add: lub_distribs)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   302
    apply (subst cast_fixed [OF emb_in_deflation])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   303
    apply (rule prj_emb)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   304
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   305
  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
   306
    unfolding approx'
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   307
    apply simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   308
    apply (simp add: emb_prj)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   309
    apply (simp add: cast_cast_approx)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   310
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   311
  show "\<And>i::nat. finite {x::'a. approx i\<cdot>x = x}"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   312
    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
   313
           in finite_subset)
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   314
    apply (clarsimp simp add: approx')
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   315
    apply (drule_tac f="\<lambda>x. emb\<cdot>x" in arg_cong)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   316
    apply (rule image_eqI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   317
    apply (rule prj_emb [symmetric])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   318
    apply (simp add: emb_prj)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   319
    apply (simp add: cast_cast_approx)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   320
    apply (rule finite_imageI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   321
    apply (simp add: cast_approx_fixed_iff)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   322
    apply (simp add: Collect_conj_eq)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   323
    apply (simp add: finite_fixes_approx)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   324
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   325
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   326
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   327
text {* Restore original typing constraints *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   328
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   329
setup {* Sign.add_const_constraint
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   330
  (@{const_name "approx"}, SOME @{typ "nat \<Rightarrow> 'a::profinite \<rightarrow> 'a"}) *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   331
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   332
setup {* Sign.add_const_constraint
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   333
  (@{const_name emb}, SOME @{typ "'a::rep \<rightarrow> udom"}) *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   334
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   335
setup {* Sign.add_const_constraint
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   336
  (@{const_name prj}, SOME @{typ "udom \<rightarrow> 'a::rep"}) *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   337
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   338
lemma typedef_REP:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   339
  fixes Rep :: "'a::rep \<Rightarrow> udom"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   340
  fixes Abs :: "udom \<Rightarrow> 'a::rep"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   341
  fixes t :: TypeRep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   342
  assumes type: "type_definition Rep Abs {x. x ::: t}"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   343
  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
   344
  assumes emb: "emb \<equiv> (\<Lambda> x. Rep x)"
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   345
  assumes prj: "prj \<equiv> (\<Lambda> x. Abs (cast\<cdot>t\<cdot>x))"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   346
  shows "REP('a) = t"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   347
proof -
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   348
  have adm: "adm (\<lambda>x. x \<in> {x. x ::: t})"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   349
    by (simp add: adm_in_deflation)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   350
  have emb_beta: "\<And>x. emb\<cdot>x = Rep x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   351
    unfolding emb
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   352
    apply (rule beta_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   353
    apply (rule typedef_cont_Rep [OF type below adm])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   354
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   355
  have prj_beta: "\<And>y. prj\<cdot>y = Abs (cast\<cdot>t\<cdot>y)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   356
    unfolding prj
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   357
    apply (rule beta_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   358
    apply (rule typedef_cont_Abs [OF type below adm])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   359
    apply simp_all
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   360
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   361
  have emb_in_deflation: "\<And>x::'a. emb\<cdot>x ::: t"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   362
    using type_definition.Rep [OF type]
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   363
    by (simp add: emb_beta)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   364
  have prj_emb: "\<And>x::'a. prj\<cdot>(emb\<cdot>x) = x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   365
    unfolding prj_beta
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   366
    apply (simp add: cast_fixed [OF emb_in_deflation])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   367
    apply (simp add: emb_beta type_definition.Rep_inverse [OF type])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   368
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   369
  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
   370
    unfolding prj_beta emb_beta
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   371
    by (simp add: type_definition.Abs_inverse [OF type])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   372
  show "REP('a) = t"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   373
    apply (rule cast_eq_imp_eq, rule ext_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   374
    apply (simp add: cast_REP emb_prj)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   375
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   376
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   377
33679
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   378
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
   379
unfolding mem_Collect_eq by (rule adm_in_deflation)
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   380
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   381
use "Tools/repdef.ML"
331712879666 automate definition of representable domains from algebraic deflations
huffman
parents: 33589
diff changeset
   382
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   383
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   384
subsection {* Instances of class @{text rep} *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   385
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   386
subsubsection {* Universal Domain *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   387
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   388
text "The Universal Domain itself is trivially representable."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   389
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   390
instantiation udom :: rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   391
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   392
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   393
definition emb_udom_def [simp]: "emb = (ID :: udom \<rightarrow> udom)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   394
definition prj_udom_def [simp]: "prj = (ID :: udom \<rightarrow> udom)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   395
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   396
instance
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   397
 apply (intro_classes)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   398
 apply (simp_all add: ep_pair.intro)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   399
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   400
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   401
end
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   402
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   403
subsubsection {* Lifted types *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   404
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   405
instantiation lift :: (countable) rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   406
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   407
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   408
definition emb_lift_def:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   409
  "emb = udom_emb oo (FLIFT x. Def (to_nat x))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   410
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   411
definition prj_lift_def:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   412
  "prj = (FLIFT n. if (\<exists>x::'a::countable. n = to_nat x)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   413
                    then Def (THE x::'a. n = to_nat x) else \<bottom>) oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   414
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   415
instance
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   416
 apply (intro_classes, unfold emb_lift_def prj_lift_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   417
 apply (rule ep_pair_comp [OF _ ep_pair_udom])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   418
 apply (rule ep_pair.intro)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   419
  apply (case_tac x, simp, simp)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   420
 apply (case_tac y, simp, clarsimp)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   421
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   422
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   423
end
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   424
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   425
subsubsection {* Representable type constructors *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   426
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   427
text "Functions between representable types are representable."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   428
35525
fa231b86cb1e proper names for types cfun, sprod, ssum
huffman
parents: 35514
diff changeset
   429
instantiation cfun :: (rep, rep) rep
33588
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_cfun_def: "emb = udom_emb oo cfun_map\<cdot>prj\<cdot>emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   433
definition prj_cfun_def: "prj = cfun_map\<cdot>emb\<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_cfun_def prj_cfun_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   437
 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
   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 "Strict products of representable types are representable."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   443
35525
fa231b86cb1e proper names for types cfun, sprod, ssum
huffman
parents: 35514
diff changeset
   444
instantiation sprod :: (rep, rep) rep
33588
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_sprod_def: "emb = udom_emb oo sprod_map\<cdot>emb\<cdot>emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   448
definition prj_sprod_def: "prj = sprod_map\<cdot>prj\<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_sprod_def prj_sprod_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   452
 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
   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 "Strict sums of representable types are representable."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   458
35525
fa231b86cb1e proper names for types cfun, sprod, ssum
huffman
parents: 35514
diff changeset
   459
instantiation ssum :: (rep, rep) rep
33588
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_ssum_def: "emb = udom_emb oo ssum_map\<cdot>emb\<cdot>emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   463
definition prj_ssum_def: "prj = ssum_map\<cdot>prj\<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_ssum_def prj_ssum_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   467
 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
   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 "Up 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 "u" :: (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_u_def: "emb = udom_emb oo u_map\<cdot>emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   478
definition prj_u_def: "prj = u_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_u_def prj_u_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   482
 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
   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
text "Cartesian products of representable types are representable."
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   488
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   489
instantiation "*" :: (rep, rep) rep
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   490
begin
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   491
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   492
definition emb_cprod_def: "emb = udom_emb oo cprod_map\<cdot>emb\<cdot>emb"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   493
definition prj_cprod_def: "prj = cprod_map\<cdot>prj\<cdot>prj oo udom_prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   494
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   495
instance
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   496
 apply (intro_classes, unfold emb_cprod_def prj_cprod_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   497
 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
   498
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   499
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   500
end
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   501
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   502
subsection {* Type combinators *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   503
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   504
definition
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   505
  TypeRep_fun1 ::
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   506
    "((udom \<rightarrow> udom) \<rightarrow> ('a \<rightarrow> 'a))
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   507
      \<Rightarrow> (TypeRep \<rightarrow> TypeRep)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   508
where
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   509
  "TypeRep_fun1 f =
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   510
    alg_defl.basis_fun (\<lambda>a.
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   511
      alg_defl_principal (
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   512
        Abs_fin_defl (udom_emb oo f\<cdot>(Rep_fin_defl a) oo udom_prj)))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   513
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   514
definition
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   515
  TypeRep_fun2 ::
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   516
    "((udom \<rightarrow> udom) \<rightarrow> (udom \<rightarrow> udom) \<rightarrow> ('a \<rightarrow> 'a))
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   517
      \<Rightarrow> (TypeRep \<rightarrow> TypeRep \<rightarrow> TypeRep)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   518
where
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   519
  "TypeRep_fun2 f =
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   520
    alg_defl.basis_fun (\<lambda>a.
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   521
      alg_defl.basis_fun (\<lambda>b.
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   522
        alg_defl_principal (
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   523
          Abs_fin_defl (udom_emb oo
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   524
            f\<cdot>(Rep_fin_defl a)\<cdot>(Rep_fin_defl b) oo udom_prj))))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   525
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   526
definition "cfun_defl = TypeRep_fun2 cfun_map"
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   527
definition "ssum_defl = TypeRep_fun2 ssum_map"
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   528
definition "sprod_defl = TypeRep_fun2 sprod_map"
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   529
definition "cprod_defl = TypeRep_fun2 cprod_map"
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   530
definition "u_defl = TypeRep_fun1 u_map"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   531
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   532
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
   533
unfolding below_fin_defl_def .
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   534
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   535
lemma cast_TypeRep_fun1:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   536
  assumes f: "\<And>a. finite_deflation a \<Longrightarrow> finite_deflation (f\<cdot>a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   537
  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
   538
proof -
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   539
  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
   540
    apply (rule ep_pair.finite_deflation_e_d_p [OF ep_pair_udom])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   541
    apply (rule f, rule finite_deflation_Rep_fin_defl)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   542
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   543
  show ?thesis
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   544
    by (induct A rule: alg_defl.principal_induct, simp)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   545
       (simp only: TypeRep_fun1_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   546
                   alg_defl.basis_fun_principal
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   547
                   alg_defl.basis_fun_mono
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   548
                   alg_defl.principal_mono
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   549
                   Abs_fin_defl_mono [OF 1 1]
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   550
                   monofun_cfun below_refl
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   551
                   Rep_fin_defl_mono
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   552
                   cast_alg_defl_principal
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   553
                   Abs_fin_defl_inverse [unfolded mem_Collect_eq, OF 1])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   554
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   555
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   556
lemma cast_TypeRep_fun2:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   557
  assumes f: "\<And>a b. finite_deflation a \<Longrightarrow> finite_deflation b \<Longrightarrow>
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   558
                finite_deflation (f\<cdot>a\<cdot>b)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   559
  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
   560
proof -
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   561
  have 1: "\<And>a b. finite_deflation
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   562
           (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
   563
    apply (rule ep_pair.finite_deflation_e_d_p [OF ep_pair_udom])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   564
    apply (rule f, (rule finite_deflation_Rep_fin_defl)+)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   565
    done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   566
  show ?thesis
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   567
    by (induct A B rule: alg_defl.principal_induct2, simp, simp)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   568
       (simp only: TypeRep_fun2_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   569
                   alg_defl.basis_fun_principal
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   570
                   alg_defl.basis_fun_mono
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   571
                   alg_defl.principal_mono
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   572
                   Abs_fin_defl_mono [OF 1 1]
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   573
                   monofun_cfun below_refl
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   574
                   Rep_fin_defl_mono
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   575
                   cast_alg_defl_principal
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   576
                   Abs_fin_defl_inverse [unfolded mem_Collect_eq, OF 1])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   577
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   578
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   579
lemma cast_cfun_defl:
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   580
  "cast\<cdot>(cfun_defl\<cdot>A\<cdot>B) = udom_emb oo cfun_map\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj"
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   581
unfolding cfun_defl_def
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   582
apply (rule cast_TypeRep_fun2)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   583
apply (erule (1) finite_deflation_cfun_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   584
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   585
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   586
lemma cast_ssum_defl:
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   587
  "cast\<cdot>(ssum_defl\<cdot>A\<cdot>B) = udom_emb oo ssum_map\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj"
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   588
unfolding ssum_defl_def
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   589
apply (rule cast_TypeRep_fun2)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   590
apply (erule (1) finite_deflation_ssum_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   591
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   592
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   593
lemma cast_sprod_defl:
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   594
  "cast\<cdot>(sprod_defl\<cdot>A\<cdot>B) = udom_emb oo sprod_map\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj"
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   595
unfolding sprod_defl_def
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   596
apply (rule cast_TypeRep_fun2)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   597
apply (erule (1) finite_deflation_sprod_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   598
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   599
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   600
lemma cast_cprod_defl:
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   601
  "cast\<cdot>(cprod_defl\<cdot>A\<cdot>B) = udom_emb oo cprod_map\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj"
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   602
unfolding cprod_defl_def
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   603
apply (rule cast_TypeRep_fun2)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   604
apply (erule (1) finite_deflation_cprod_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   605
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   606
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   607
lemma cast_u_defl:
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   608
  "cast\<cdot>(u_defl\<cdot>A) = udom_emb oo u_map\<cdot>(cast\<cdot>A) oo udom_prj"
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   609
unfolding u_defl_def
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   610
apply (rule cast_TypeRep_fun1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   611
apply (erule finite_deflation_u_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   612
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   613
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   614
text {* REP of type constructor = type combinator *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   615
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   616
lemma REP_cfun: "REP('a \<rightarrow> 'b) = cfun_defl\<cdot>REP('a)\<cdot>REP('b)"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   617
apply (rule cast_eq_imp_eq, rule ext_cfun)
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   618
apply (simp add: cast_REP cast_cfun_defl)
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   619
apply (simp add: cfun_map_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   620
apply (simp only: prj_cfun_def emb_cfun_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   621
apply (simp add: expand_cfun_eq ep_pair.e_eq_iff [OF ep_pair_udom])
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   622
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   623
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   624
lemma REP_ssum: "REP('a \<oplus> 'b) = ssum_defl\<cdot>REP('a)\<cdot>REP('b)"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   625
apply (rule cast_eq_imp_eq, rule ext_cfun)
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   626
apply (simp add: cast_REP cast_ssum_defl)
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   627
apply (simp add: prj_ssum_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   628
apply (simp add: emb_ssum_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   629
apply (simp add: ssum_map_map cfcomp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   630
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   631
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   632
lemma REP_sprod: "REP('a \<otimes> 'b) = sprod_defl\<cdot>REP('a)\<cdot>REP('b)"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   633
apply (rule cast_eq_imp_eq, rule ext_cfun)
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   634
apply (simp add: cast_REP cast_sprod_defl)
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   635
apply (simp add: prj_sprod_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   636
apply (simp add: emb_sprod_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   637
apply (simp add: sprod_map_map cfcomp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   638
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   639
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   640
lemma REP_cprod: "REP('a \<times> 'b) = cprod_defl\<cdot>REP('a)\<cdot>REP('b)"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   641
apply (rule cast_eq_imp_eq, rule ext_cfun)
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   642
apply (simp add: cast_REP cast_cprod_defl)
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   643
apply (simp add: prj_cprod_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   644
apply (simp add: emb_cprod_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   645
apply (simp add: cprod_map_map cfcomp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   646
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   647
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   648
lemma REP_up: "REP('a u) = u_defl\<cdot>REP('a)"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   649
apply (rule cast_eq_imp_eq, rule ext_cfun)
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   650
apply (simp add: cast_REP cast_u_defl)
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   651
apply (simp add: prj_u_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   652
apply (simp add: emb_u_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   653
apply (simp add: u_map_map cfcomp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   654
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   655
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   656
lemmas REP_simps =
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   657
  REP_cfun
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   658
  REP_ssum
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   659
  REP_sprod
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   660
  REP_cprod
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   661
  REP_up
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   662
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   663
subsection {* Isomorphic deflations *}
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   664
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   665
definition
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   666
  isodefl :: "('a::rep \<rightarrow> 'a) \<Rightarrow> udom alg_defl \<Rightarrow> bool"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   667
where
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   668
  "isodefl d t \<longleftrightarrow> cast\<cdot>t = emb oo d oo prj"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   669
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   670
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
   671
unfolding isodefl_def by (simp add: ext_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   672
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   673
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
   674
unfolding isodefl_def by (simp add: ext_cfun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   675
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   676
lemma isodefl_strict: "isodefl d t \<Longrightarrow> d\<cdot>\<bottom> = \<bottom>"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   677
unfolding isodefl_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   678
by (drule cfun_fun_cong [where x="\<bottom>"], simp)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   679
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   680
lemma isodefl_imp_deflation:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   681
  fixes d :: "'a::rep \<rightarrow> 'a"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   682
  assumes "isodefl d t" shows "deflation d"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   683
proof
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   684
  note prems [unfolded isodefl_def, simp]
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   685
  fix x :: 'a
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   686
  show "d\<cdot>(d\<cdot>x) = d\<cdot>x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   687
    using cast.idem [of t "emb\<cdot>x"] by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   688
  show "d\<cdot>x \<sqsubseteq> x"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   689
    using cast.below [of t "emb\<cdot>x"] by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   690
qed
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   691
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   692
lemma isodefl_ID_REP: "isodefl (ID :: 'a \<rightarrow> 'a) REP('a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   693
unfolding isodefl_def by (simp add: cast_REP)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   694
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   695
lemma isodefl_REP_imp_ID: "isodefl (d :: 'a \<rightarrow> 'a) REP('a) \<Longrightarrow> d = ID"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   696
unfolding isodefl_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   697
apply (simp add: cast_REP)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   698
apply (simp add: expand_cfun_eq)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   699
apply (rule allI)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   700
apply (drule_tac x="emb\<cdot>x" in spec)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   701
apply simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   702
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   703
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   704
lemma isodefl_bottom: "isodefl \<bottom> \<bottom>"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   705
unfolding isodefl_def by (simp add: expand_cfun_eq)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   706
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   707
lemma adm_isodefl:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   708
  "cont f \<Longrightarrow> cont g \<Longrightarrow> adm (\<lambda>x. isodefl (f x) (g x))"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   709
unfolding isodefl_def by simp
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   710
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   711
lemma isodefl_lub:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   712
  assumes "chain d" and "chain t"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   713
  assumes "\<And>i. isodefl (d i) (t i)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   714
  shows "isodefl (\<Squnion>i. d i) (\<Squnion>i. t i)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   715
using prems unfolding isodefl_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   716
by (simp add: contlub_cfun_arg contlub_cfun_fun)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   717
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   718
lemma isodefl_fix:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   719
  assumes "\<And>d t. isodefl d t \<Longrightarrow> isodefl (f\<cdot>d) (g\<cdot>t)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   720
  shows "isodefl (fix\<cdot>f) (fix\<cdot>g)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   721
unfolding fix_def2
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   722
apply (rule isodefl_lub, simp, simp)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   723
apply (induct_tac i)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   724
apply (simp add: isodefl_bottom)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   725
apply (simp add: prems)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   726
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   727
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   728
lemma isodefl_coerce:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   729
  fixes d :: "'a \<rightarrow> 'a"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   730
  assumes REP: "REP('b) = REP('a)"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   731
  shows "isodefl d t \<Longrightarrow> isodefl (coerce oo d oo coerce :: 'b \<rightarrow> 'b) t"
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   732
unfolding isodefl_def
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   733
apply (simp add: expand_cfun_eq)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   734
apply (simp add: emb_coerce coerce_prj REP)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   735
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   736
33779
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   737
lemma isodefl_abs_rep:
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   738
  fixes abs and rep and d
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   739
  assumes REP: "REP('b) = REP('a)"
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   740
  assumes abs_def: "abs \<equiv> (coerce :: 'a \<rightarrow> 'b)"
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   741
  assumes rep_def: "rep \<equiv> (coerce :: 'b \<rightarrow> 'a)"
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   742
  shows "isodefl d t \<Longrightarrow> isodefl (abs oo d oo rep) t"
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   743
unfolding abs_def rep_def using REP by (rule isodefl_coerce)
b8efeea2cebd remove one_typ and tr_typ; add abs/rep lemmas
huffman
parents: 33679
diff changeset
   744
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   745
lemma isodefl_cfun:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   746
  "isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow>
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   747
    isodefl (cfun_map\<cdot>d1\<cdot>d2) (cfun_defl\<cdot>t1\<cdot>t2)"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   748
apply (rule isodeflI)
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   749
apply (simp add: cast_cfun_defl cast_isodefl)
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   750
apply (simp add: emb_cfun_def prj_cfun_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   751
apply (simp add: cfun_map_map cfcomp1)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   752
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   753
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   754
lemma isodefl_ssum:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   755
  "isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow>
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   756
    isodefl (ssum_map\<cdot>d1\<cdot>d2) (ssum_defl\<cdot>t1\<cdot>t2)"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   757
apply (rule isodeflI)
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   758
apply (simp add: cast_ssum_defl cast_isodefl)
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   759
apply (simp add: emb_ssum_def prj_ssum_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   760
apply (simp add: ssum_map_map isodefl_strict)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   761
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   762
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   763
lemma isodefl_sprod:
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   764
  "isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow>
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   765
    isodefl (sprod_map\<cdot>d1\<cdot>d2) (sprod_defl\<cdot>t1\<cdot>t2)"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   766
apply (rule isodeflI)
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   767
apply (simp add: cast_sprod_defl cast_isodefl)
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   768
apply (simp add: emb_sprod_def prj_sprod_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   769
apply (simp add: sprod_map_map isodefl_strict)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   770
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   771
33786
d280c5ebd7d7 add lemma isodefl_cprod
huffman
parents: 33784
diff changeset
   772
lemma isodefl_cprod:
d280c5ebd7d7 add lemma isodefl_cprod
huffman
parents: 33784
diff changeset
   773
  "isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow>
d280c5ebd7d7 add lemma isodefl_cprod
huffman
parents: 33784
diff changeset
   774
    isodefl (cprod_map\<cdot>d1\<cdot>d2) (cprod_defl\<cdot>t1\<cdot>t2)"
d280c5ebd7d7 add lemma isodefl_cprod
huffman
parents: 33784
diff changeset
   775
apply (rule isodeflI)
d280c5ebd7d7 add lemma isodefl_cprod
huffman
parents: 33784
diff changeset
   776
apply (simp add: cast_cprod_defl cast_isodefl)
d280c5ebd7d7 add lemma isodefl_cprod
huffman
parents: 33784
diff changeset
   777
apply (simp add: emb_cprod_def prj_cprod_def)
d280c5ebd7d7 add lemma isodefl_cprod
huffman
parents: 33784
diff changeset
   778
apply (simp add: cprod_map_map cfcomp1)
d280c5ebd7d7 add lemma isodefl_cprod
huffman
parents: 33784
diff changeset
   779
done
d280c5ebd7d7 add lemma isodefl_cprod
huffman
parents: 33784
diff changeset
   780
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   781
lemma isodefl_u:
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   782
  "isodefl d t \<Longrightarrow> isodefl (u_map\<cdot>d) (u_defl\<cdot>t)"
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   783
apply (rule isodeflI)
33784
7e434813752f change naming convention for deflation combinators
huffman
parents: 33779
diff changeset
   784
apply (simp add: cast_u_defl cast_isodefl)
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   785
apply (simp add: emb_u_def prj_u_def)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   786
apply (simp add: u_map_map)
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   787
done
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   788
33794
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
   789
subsection {* Constructing Domain Isomorphisms *}
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
   790
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
   791
use "Tools/Domain/domain_isomorphism.ML"
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
   792
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
   793
setup {*
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
   794
  fold Domain_Isomorphism.add_type_constructor
35525
fa231b86cb1e proper names for types cfun, sprod, ssum
huffman
parents: 35514
diff changeset
   795
    [(@{type_name cfun}, @{term cfun_defl}, @{const_name cfun_map}, @{thm REP_cfun},
35479
dffffe36344a store deflation thms for map functions in theory data
huffman
parents: 35475
diff changeset
   796
        @{thm isodefl_cfun}, @{thm cfun_map_ID}, @{thm deflation_cfun_map}),
33794
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
   797
35525
fa231b86cb1e proper names for types cfun, sprod, ssum
huffman
parents: 35514
diff changeset
   798
     (@{type_name ssum}, @{term ssum_defl}, @{const_name ssum_map}, @{thm REP_ssum},
35479
dffffe36344a store deflation thms for map functions in theory data
huffman
parents: 35475
diff changeset
   799
        @{thm isodefl_ssum}, @{thm ssum_map_ID}, @{thm deflation_ssum_map}),
33794
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
   800
35525
fa231b86cb1e proper names for types cfun, sprod, ssum
huffman
parents: 35514
diff changeset
   801
     (@{type_name sprod}, @{term sprod_defl}, @{const_name sprod_map}, @{thm REP_sprod},
35479
dffffe36344a store deflation thms for map functions in theory data
huffman
parents: 35475
diff changeset
   802
        @{thm isodefl_sprod}, @{thm sprod_map_ID}, @{thm deflation_sprod_map}),
33794
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
   803
35479
dffffe36344a store deflation thms for map functions in theory data
huffman
parents: 35475
diff changeset
   804
     (@{type_name "*"}, @{term cprod_defl}, @{const_name cprod_map}, @{thm REP_cprod},
dffffe36344a store deflation thms for map functions in theory data
huffman
parents: 35475
diff changeset
   805
        @{thm isodefl_cprod}, @{thm cprod_map_ID}, @{thm deflation_cprod_map}),
33794
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
   806
35479
dffffe36344a store deflation thms for map functions in theory data
huffman
parents: 35475
diff changeset
   807
     (@{type_name "u"}, @{term u_defl}, @{const_name u_map}, @{thm REP_up},
dffffe36344a store deflation thms for map functions in theory data
huffman
parents: 35475
diff changeset
   808
        @{thm isodefl_u}, @{thm u_map_ID}, @{thm deflation_u_map})]
33794
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
   809
*}
364bc92ba081 set up domain_isomorphism package in Representable.thy
huffman
parents: 33786
diff changeset
   810
33588
ea9becc59636 theory of representable cpos
huffman
parents:
diff changeset
   811
end