src/HOL/HOLCF/Domain.thy
author wenzelm
Thu, 14 Mar 2019 16:55:06 +0100
changeset 69913 ca515cf61651
parent 69605 a96320074298
permissions -rw-r--r--
more specific keyword kinds;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42151
4da4fc77664b tuned headers;
wenzelm
parents: 41529
diff changeset
     1
(*  Title:      HOL/HOLCF/Domain.thy
15741
29a78517543f New file for theorems used by the domain package
huffman
parents:
diff changeset
     2
    Author:     Brian Huffman
29a78517543f New file for theorems used by the domain package
huffman
parents:
diff changeset
     3
*)
29a78517543f New file for theorems used by the domain package
huffman
parents:
diff changeset
     4
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
     5
section \<open>Domain package\<close>
15741
29a78517543f New file for theorems used by the domain package
huffman
parents:
diff changeset
     6
29a78517543f New file for theorems used by the domain package
huffman
parents:
diff changeset
     7
theory Domain
41285
efd23c1d9886 renamed Bifinite.thy to Representable.thy
huffman
parents: 40834
diff changeset
     8
imports Representable Domain_Aux
46950
d0181abdbdac declare command keywords via theory header, including strict checking outside Pure;
wenzelm
parents: 46947
diff changeset
     9
keywords
63432
wenzelm
parents: 62175
diff changeset
    10
  "lazy" "unsafe" and
69913
ca515cf61651 more specific keyword kinds;
wenzelm
parents: 69605
diff changeset
    11
  "domaindef" "domain" :: thy_defn and
ca515cf61651 more specific keyword kinds;
wenzelm
parents: 69605
diff changeset
    12
  "domain_isomorphism" :: thy_decl
15741
29a78517543f New file for theorems used by the domain package
huffman
parents:
diff changeset
    13
begin
29a78517543f New file for theorems used by the domain package
huffman
parents:
diff changeset
    14
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    15
default_sort "domain"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    16
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
    17
subsection \<open>Representations of types\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    18
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    19
lemma emb_prj: "emb\<cdot>((prj\<cdot>x)::'a) = cast\<cdot>DEFL('a)\<cdot>x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    20
by (simp add: cast_DEFL)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    21
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    22
lemma emb_prj_emb:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    23
  fixes x :: "'a"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    24
  assumes "DEFL('a) \<sqsubseteq> DEFL('b)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    25
  shows "emb\<cdot>(prj\<cdot>(emb\<cdot>x) :: 'b) = emb\<cdot>x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    26
unfolding emb_prj
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    27
apply (rule cast.belowD)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    28
apply (rule monofun_cfun_arg [OF assms])
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    29
apply (simp add: cast_DEFL)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    30
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    31
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    32
lemma prj_emb_prj:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    33
  assumes "DEFL('a) \<sqsubseteq> DEFL('b)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    34
  shows "prj\<cdot>(emb\<cdot>(prj\<cdot>x :: 'b)) = (prj\<cdot>x :: 'a)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    35
 apply (rule emb_eq_iff [THEN iffD1])
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    36
 apply (simp only: emb_prj)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    37
 apply (rule deflation_below_comp1)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    38
   apply (rule deflation_cast)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    39
  apply (rule deflation_cast)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    40
 apply (rule monofun_cfun_arg [OF assms])
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    41
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    42
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
    43
text \<open>Isomorphism lemmas used internally by the domain package:\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    44
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    45
lemma domain_abs_iso:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    46
  fixes abs and rep
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    47
  assumes DEFL: "DEFL('b) = DEFL('a)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    48
  assumes abs_def: "(abs :: 'a \<rightarrow> 'b) \<equiv> prj oo emb"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    49
  assumes rep_def: "(rep :: 'b \<rightarrow> 'a) \<equiv> prj oo emb"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    50
  shows "rep\<cdot>(abs\<cdot>x) = x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    51
unfolding abs_def rep_def
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    52
by (simp add: emb_prj_emb DEFL)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    53
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    54
lemma domain_rep_iso:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    55
  fixes abs and rep
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    56
  assumes DEFL: "DEFL('b) = DEFL('a)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    57
  assumes abs_def: "(abs :: 'a \<rightarrow> 'b) \<equiv> prj oo emb"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    58
  assumes rep_def: "(rep :: 'b \<rightarrow> 'a) \<equiv> prj oo emb"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    59
  shows "abs\<cdot>(rep\<cdot>x) = x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    60
unfolding abs_def rep_def
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    61
by (simp add: emb_prj_emb DEFL)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    62
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
    63
subsection \<open>Deflations as sets\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    64
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41285
diff changeset
    65
definition defl_set :: "'a::bifinite defl \<Rightarrow> 'a set"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    66
where "defl_set A = {x. cast\<cdot>A\<cdot>x = x}"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    67
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    68
lemma adm_defl_set: "adm (\<lambda>x. x \<in> defl_set A)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    69
unfolding defl_set_def by simp
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    70
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    71
lemma defl_set_bottom: "\<bottom> \<in> defl_set A"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    72
unfolding defl_set_def by simp
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    73
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    74
lemma defl_set_cast [simp]: "cast\<cdot>A\<cdot>x \<in> defl_set A"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    75
unfolding defl_set_def by simp
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    76
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    77
lemma defl_set_subset_iff: "defl_set A \<subseteq> defl_set B \<longleftrightarrow> A \<sqsubseteq> B"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    78
apply (simp add: defl_set_def subset_eq cast_below_cast [symmetric])
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    79
apply (auto simp add: cast.belowI cast.belowD)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    80
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    81
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
    82
subsection \<open>Proving a subtype is representable\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    83
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
    84
text \<open>Temporarily relax type constraints.\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    85
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
    86
setup \<open>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    87
  fold Sign.add_const_constraint
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
    88
  [ (\<^const_name>\<open>defl\<close>, SOME \<^typ>\<open>'a::pcpo itself \<Rightarrow> udom defl\<close>)
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
    89
  , (\<^const_name>\<open>emb\<close>, SOME \<^typ>\<open>'a::pcpo \<rightarrow> udom\<close>)
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
    90
  , (\<^const_name>\<open>prj\<close>, SOME \<^typ>\<open>udom \<rightarrow> 'a::pcpo\<close>)
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
    91
  , (\<^const_name>\<open>liftdefl\<close>, SOME \<^typ>\<open>'a::pcpo itself \<Rightarrow> udom u defl\<close>)
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
    92
  , (\<^const_name>\<open>liftemb\<close>, SOME \<^typ>\<open>'a::pcpo u \<rightarrow> udom u\<close>)
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
    93
  , (\<^const_name>\<open>liftprj\<close>, SOME \<^typ>\<open>udom u \<rightarrow> 'a::pcpo u\<close>) ]
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
    94
\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    95
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
    96
lemma typedef_domain_class:
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    97
  fixes Rep :: "'a::pcpo \<Rightarrow> udom"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
    98
  fixes Abs :: "udom \<Rightarrow> 'a::pcpo"
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41285
diff changeset
    99
  fixes t :: "udom defl"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   100
  assumes type: "type_definition Rep Abs (defl_set t)"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63432
diff changeset
   101
  assumes below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   102
  assumes emb: "emb \<equiv> (\<Lambda> x. Rep x)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   103
  assumes prj: "prj \<equiv> (\<Lambda> x. Abs (cast\<cdot>t\<cdot>x))"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   104
  assumes defl: "defl \<equiv> (\<lambda> a::'a itself. t)"
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   105
  assumes liftemb: "(liftemb :: 'a u \<rightarrow> udom u) \<equiv> u_map\<cdot>emb"
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   106
  assumes liftprj: "(liftprj :: udom u \<rightarrow> 'a u) \<equiv> u_map\<cdot>prj"
41436
480978f80eae rename constant pdefl to liftdefl_of
huffman
parents: 41297
diff changeset
   107
  assumes liftdefl: "(liftdefl :: 'a itself \<Rightarrow> _) \<equiv> (\<lambda>t. liftdefl_of\<cdot>DEFL('a))"
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   108
  shows "OFCLASS('a, domain_class)"
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   109
proof
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   110
  have emb_beta: "\<And>x. emb\<cdot>x = Rep x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   111
    unfolding emb
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   112
    apply (rule beta_cfun)
40834
a1249aeff5b6 change cpodef-generated cont_Rep rules to cont2cont format
huffman
parents: 40830
diff changeset
   113
    apply (rule typedef_cont_Rep [OF type below adm_defl_set cont_id])
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   114
    done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   115
  have prj_beta: "\<And>y. prj\<cdot>y = Abs (cast\<cdot>t\<cdot>y)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   116
    unfolding prj
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   117
    apply (rule beta_cfun)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   118
    apply (rule typedef_cont_Abs [OF type below adm_defl_set])
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   119
    apply simp_all
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   120
    done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   121
  have prj_emb: "\<And>x::'a. prj\<cdot>(emb\<cdot>x) = x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   122
    using type_definition.Rep [OF type]
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   123
    unfolding prj_beta emb_beta defl_set_def
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   124
    by (simp add: type_definition.Rep_inverse [OF type])
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   125
  have emb_prj: "\<And>y. emb\<cdot>(prj\<cdot>y :: 'a) = cast\<cdot>t\<cdot>y"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   126
    unfolding prj_beta emb_beta
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   127
    by (simp add: type_definition.Abs_inverse [OF type])
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   128
  show "ep_pair (emb :: 'a \<rightarrow> udom) prj"
61169
4de9ff3ea29a tuned proofs -- less legacy;
wenzelm
parents: 60753
diff changeset
   129
    apply standard
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   130
    apply (simp add: prj_emb)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   131
    apply (simp add: emb_prj cast.below)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   132
    done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   133
  show "cast\<cdot>DEFL('a) = emb oo (prj :: udom \<rightarrow> 'a)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   134
    by (rule cfun_eqI, simp add: defl emb_prj)
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   135
qed (simp_all only: liftemb liftprj liftdefl)
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   136
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   137
lemma typedef_DEFL:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   138
  assumes "defl \<equiv> (\<lambda>a::'a::pcpo itself. t)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   139
  shows "DEFL('a::pcpo) = t"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   140
unfolding assms ..
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   141
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   142
text \<open>Restore original typing constraints.\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   143
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   144
setup \<open>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   145
  fold Sign.add_const_constraint
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
   146
   [(\<^const_name>\<open>defl\<close>, SOME \<^typ>\<open>'a::domain itself \<Rightarrow> udom defl\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
   147
    (\<^const_name>\<open>emb\<close>, SOME \<^typ>\<open>'a::domain \<rightarrow> udom\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
   148
    (\<^const_name>\<open>prj\<close>, SOME \<^typ>\<open>udom \<rightarrow> 'a::domain\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
   149
    (\<^const_name>\<open>liftdefl\<close>, SOME \<^typ>\<open>'a::predomain itself \<Rightarrow> udom u defl\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
   150
    (\<^const_name>\<open>liftemb\<close>, SOME \<^typ>\<open>'a::predomain u \<rightarrow> udom u\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
   151
    (\<^const_name>\<open>liftprj\<close>, SOME \<^typ>\<open>udom u \<rightarrow> 'a::predomain u\<close>)]
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   152
\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   153
69605
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 69597
diff changeset
   154
ML_file \<open>Tools/domaindef.ML\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   155
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   156
subsection \<open>Isomorphic deflations\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   157
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   158
definition isodefl :: "('a \<rightarrow> 'a) \<Rightarrow> udom defl \<Rightarrow> bool"
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   159
  where "isodefl d t \<longleftrightarrow> cast\<cdot>t = emb oo d oo prj"
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   160
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   161
definition isodefl' :: "('a::predomain \<rightarrow> 'a) \<Rightarrow> udom u defl \<Rightarrow> bool"
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   162
  where "isodefl' d t \<longleftrightarrow> cast\<cdot>t = liftemb oo u_map\<cdot>d oo liftprj"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   163
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   164
lemma isodeflI: "(\<And>x. cast\<cdot>t\<cdot>x = emb\<cdot>(d\<cdot>(prj\<cdot>x))) \<Longrightarrow> isodefl d t"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   165
unfolding isodefl_def by (simp add: cfun_eqI)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   166
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   167
lemma cast_isodefl: "isodefl d t \<Longrightarrow> cast\<cdot>t = (\<Lambda> x. emb\<cdot>(d\<cdot>(prj\<cdot>x)))"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   168
unfolding isodefl_def by (simp add: cfun_eqI)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   169
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   170
lemma isodefl_strict: "isodefl d t \<Longrightarrow> d\<cdot>\<bottom> = \<bottom>"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   171
unfolding isodefl_def
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   172
by (drule cfun_fun_cong [where x="\<bottom>"], simp)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   173
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   174
lemma isodefl_imp_deflation:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   175
  fixes d :: "'a \<rightarrow> 'a"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   176
  assumes "isodefl d t" shows "deflation d"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   177
proof
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   178
  note assms [unfolded isodefl_def, simp]
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   179
  fix x :: 'a
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   180
  show "d\<cdot>(d\<cdot>x) = d\<cdot>x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   181
    using cast.idem [of t "emb\<cdot>x"] by simp
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   182
  show "d\<cdot>x \<sqsubseteq> x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   183
    using cast.below [of t "emb\<cdot>x"] by simp
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   184
qed
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   185
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   186
lemma isodefl_ID_DEFL: "isodefl (ID :: 'a \<rightarrow> 'a) DEFL('a)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   187
unfolding isodefl_def by (simp add: cast_DEFL)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   188
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   189
lemma isodefl_LIFTDEFL:
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   190
  "isodefl' (ID :: 'a \<rightarrow> 'a) LIFTDEFL('a::predomain)"
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   191
unfolding isodefl'_def by (simp add: cast_liftdefl u_map_ID)
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   192
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   193
lemma isodefl_DEFL_imp_ID: "isodefl (d :: 'a \<rightarrow> 'a) DEFL('a) \<Longrightarrow> d = ID"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   194
unfolding isodefl_def
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   195
apply (simp add: cast_DEFL)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   196
apply (simp add: cfun_eq_iff)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   197
apply (rule allI)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   198
apply (drule_tac x="emb\<cdot>x" in spec)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   199
apply simp
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   200
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   201
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   202
lemma isodefl_bottom: "isodefl \<bottom> \<bottom>"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   203
unfolding isodefl_def by (simp add: cfun_eq_iff)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   204
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   205
lemma adm_isodefl:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   206
  "cont f \<Longrightarrow> cont g \<Longrightarrow> adm (\<lambda>x. isodefl (f x) (g x))"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   207
unfolding isodefl_def by simp
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   208
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   209
lemma isodefl_lub:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   210
  assumes "chain d" and "chain t"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   211
  assumes "\<And>i. isodefl (d i) (t i)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   212
  shows "isodefl (\<Squnion>i. d i) (\<Squnion>i. t i)"
41529
ba60efa2fd08 eliminated global prems;
wenzelm
parents: 41437
diff changeset
   213
using assms unfolding isodefl_def
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   214
by (simp add: contlub_cfun_arg contlub_cfun_fun)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   215
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   216
lemma isodefl_fix:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   217
  assumes "\<And>d t. isodefl d t \<Longrightarrow> isodefl (f\<cdot>d) (g\<cdot>t)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   218
  shows "isodefl (fix\<cdot>f) (fix\<cdot>g)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   219
unfolding fix_def2
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   220
apply (rule isodefl_lub, simp, simp)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   221
apply (induct_tac i)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   222
apply (simp add: isodefl_bottom)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   223
apply (simp add: assms)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   224
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   225
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   226
lemma isodefl_abs_rep:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   227
  fixes abs and rep and d
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   228
  assumes DEFL: "DEFL('b) = DEFL('a)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   229
  assumes abs_def: "(abs :: 'a \<rightarrow> 'b) \<equiv> prj oo emb"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   230
  assumes rep_def: "(rep :: 'b \<rightarrow> 'a) \<equiv> prj oo emb"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   231
  shows "isodefl d t \<Longrightarrow> isodefl (abs oo d oo rep) t"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   232
unfolding isodefl_def
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   233
by (simp add: cfun_eq_iff assms prj_emb_prj emb_prj_emb)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   234
41436
480978f80eae rename constant pdefl to liftdefl_of
huffman
parents: 41297
diff changeset
   235
lemma isodefl'_liftdefl_of: "isodefl d t \<Longrightarrow> isodefl' d (liftdefl_of\<cdot>t)"
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   236
unfolding isodefl_def isodefl'_def
41436
480978f80eae rename constant pdefl to liftdefl_of
huffman
parents: 41297
diff changeset
   237
by (simp add: cast_liftdefl_of u_map_oo liftemb_eq liftprj_eq)
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   238
40592
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   239
lemma isodefl_sfun:
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   240
  "isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow>
40592
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   241
    isodefl (sfun_map\<cdot>d1\<cdot>d2) (sfun_defl\<cdot>t1\<cdot>t2)"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   242
apply (rule isodeflI)
40592
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   243
apply (simp add: cast_sfun_defl cast_isodefl)
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   244
apply (simp add: emb_sfun_def prj_sfun_def)
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   245
apply (simp add: sfun_map_map isodefl_strict)
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   246
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   247
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   248
lemma isodefl_ssum:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   249
  "isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow>
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   250
    isodefl (ssum_map\<cdot>d1\<cdot>d2) (ssum_defl\<cdot>t1\<cdot>t2)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   251
apply (rule isodeflI)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   252
apply (simp add: cast_ssum_defl cast_isodefl)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   253
apply (simp add: emb_ssum_def prj_ssum_def)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   254
apply (simp add: ssum_map_map isodefl_strict)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   255
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   256
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   257
lemma isodefl_sprod:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   258
  "isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow>
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   259
    isodefl (sprod_map\<cdot>d1\<cdot>d2) (sprod_defl\<cdot>t1\<cdot>t2)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   260
apply (rule isodeflI)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   261
apply (simp add: cast_sprod_defl cast_isodefl)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   262
apply (simp add: emb_sprod_def prj_sprod_def)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   263
apply (simp add: sprod_map_map isodefl_strict)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   264
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   265
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   266
lemma isodefl_prod:
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   267
  "isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow>
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   268
    isodefl (prod_map\<cdot>d1\<cdot>d2) (prod_defl\<cdot>t1\<cdot>t2)"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   269
apply (rule isodeflI)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   270
apply (simp add: cast_prod_defl cast_isodefl)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   271
apply (simp add: emb_prod_def prj_prod_def)
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   272
apply (simp add: prod_map_map cfcomp1)
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   273
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   274
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   275
lemma isodefl_u:
41437
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   276
  "isodefl d t \<Longrightarrow> isodefl (u_map\<cdot>d) (u_defl\<cdot>t)"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   277
apply (rule isodeflI)
41437
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   278
apply (simp add: cast_u_defl cast_isodefl)
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   279
apply (simp add: emb_u_def prj_u_def liftemb_eq liftprj_eq u_map_map)
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   280
done
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   281
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   282
lemma isodefl_u_liftdefl:
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   283
  "isodefl' d t \<Longrightarrow> isodefl (u_map\<cdot>d) (u_liftdefl\<cdot>t)"
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   284
apply (rule isodeflI)
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   285
apply (simp add: cast_u_liftdefl isodefl'_def)
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   286
apply (simp add: emb_u_def prj_u_def liftemb_eq liftprj_eq)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   287
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   288
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   289
lemma encode_prod_u_map:
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   290
  "encode_prod_u\<cdot>(u_map\<cdot>(prod_map\<cdot>f\<cdot>g)\<cdot>(decode_prod_u\<cdot>x))
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   291
    = sprod_map\<cdot>(u_map\<cdot>f)\<cdot>(u_map\<cdot>g)\<cdot>x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   292
unfolding encode_prod_u_def decode_prod_u_def
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   293
apply (case_tac x, simp, rename_tac a b)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   294
apply (case_tac a, simp, case_tac b, simp, simp)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   295
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   296
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   297
lemma isodefl_prod_u:
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   298
  assumes "isodefl' d1 t1" and "isodefl' d2 t2"
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   299
  shows "isodefl' (prod_map\<cdot>d1\<cdot>d2) (prod_liftdefl\<cdot>t1\<cdot>t2)"
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   300
using assms unfolding isodefl'_def
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   301
unfolding liftemb_prod_def liftprj_prod_def
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   302
by (simp add: cast_prod_liftdefl cfcomp1 encode_prod_u_map sprod_map_map)
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   303
40592
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   304
lemma encode_cfun_map:
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   305
  "encode_cfun\<cdot>(cfun_map\<cdot>f\<cdot>g\<cdot>(decode_cfun\<cdot>x))
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   306
    = sfun_map\<cdot>(u_map\<cdot>f)\<cdot>g\<cdot>x"
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   307
unfolding encode_cfun_def decode_cfun_def
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   308
apply (simp add: sfun_eq_iff cfun_map_def sfun_map_def)
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   309
apply (rule cfun_eqI, rename_tac y, case_tac y, simp_all)
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   310
done
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   311
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   312
lemma isodefl_cfun:
40830
158d18502378 simplify predomain instances
huffman
parents: 40774
diff changeset
   313
  assumes "isodefl (u_map\<cdot>d1) t1" and "isodefl d2 t2"
158d18502378 simplify predomain instances
huffman
parents: 40774
diff changeset
   314
  shows "isodefl (cfun_map\<cdot>d1\<cdot>d2) (sfun_defl\<cdot>t1\<cdot>t2)"
158d18502378 simplify predomain instances
huffman
parents: 40774
diff changeset
   315
using isodefl_sfun [OF assms] unfolding isodefl_def
158d18502378 simplify predomain instances
huffman
parents: 40774
diff changeset
   316
by (simp add: emb_cfun_def prj_cfun_def cfcomp1 encode_cfun_map)
40592
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   317
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   318
subsection \<open>Setting up the domain package\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   319
57945
cacb00a569e0 prefer 'named_theorems' over Named_Thms, with subtle change of semantics due to visual order vs. internal reverse order;
wenzelm
parents: 48891
diff changeset
   320
named_theorems domain_defl_simps "theorems like DEFL('a t) = t_defl$DEFL('a)"
59028
df7476e79558 named_theorems: multiple args;
wenzelm
parents: 58880
diff changeset
   321
  and domain_isodefl "theorems like isodefl d t ==> isodefl (foo_map$d) (foo_defl$t)"
57945
cacb00a569e0 prefer 'named_theorems' over Named_Thms, with subtle change of semantics due to visual order vs. internal reverse order;
wenzelm
parents: 48891
diff changeset
   322
69605
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 69597
diff changeset
   323
ML_file \<open>Tools/Domain/domain_isomorphism.ML\<close>
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 69597
diff changeset
   324
ML_file \<open>Tools/Domain/domain_axioms.ML\<close>
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 69597
diff changeset
   325
ML_file \<open>Tools/Domain/domain.ML\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   326
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   327
lemmas [domain_defl_simps] =
40592
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   328
  DEFL_cfun DEFL_sfun DEFL_ssum DEFL_sprod DEFL_prod DEFL_u
41437
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   329
  liftdefl_eq LIFTDEFL_prod u_liftdefl_liftdefl_of
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   330
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   331
lemmas [domain_map_ID] =
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   332
  cfun_map_ID sfun_map_ID ssum_map_ID sprod_map_ID prod_map_ID u_map_ID
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   333
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   334
lemmas [domain_isodefl] =
40592
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   335
  isodefl_u isodefl_sfun isodefl_ssum isodefl_sprod
41436
480978f80eae rename constant pdefl to liftdefl_of
huffman
parents: 41297
diff changeset
   336
  isodefl_cfun isodefl_prod isodefl_prod_u isodefl'_liftdefl_of
41437
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   337
  isodefl_u_liftdefl
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   338
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   339
lemmas [domain_deflation] =
40592
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   340
  deflation_cfun_map deflation_sfun_map deflation_ssum_map
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   341
  deflation_sprod_map deflation_prod_map deflation_u_map
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   342
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   343
setup \<open>
40737
2037021f034f remove map function names from domain package theory data
huffman
parents: 40592
diff changeset
   344
  fold Domain_Take_Proofs.add_rec_type
68357
6bf71e776226 more symbols;
wenzelm
parents: 67399
diff changeset
   345
    [(\<^type_name>\<open>cfun\<close>, [true, true]),
6bf71e776226 more symbols;
wenzelm
parents: 67399
diff changeset
   346
     (\<^type_name>\<open>sfun\<close>, [true, true]),
6bf71e776226 more symbols;
wenzelm
parents: 67399
diff changeset
   347
     (\<^type_name>\<open>ssum\<close>, [true, true]),
6bf71e776226 more symbols;
wenzelm
parents: 67399
diff changeset
   348
     (\<^type_name>\<open>sprod\<close>, [true, true]),
6bf71e776226 more symbols;
wenzelm
parents: 67399
diff changeset
   349
     (\<^type_name>\<open>prod\<close>, [true, true]),
6bf71e776226 more symbols;
wenzelm
parents: 67399
diff changeset
   350
     (\<^type_name>\<open>u\<close>, [true])]
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   351
\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   352
15741
29a78517543f New file for theorems used by the domain package
huffman
parents:
diff changeset
   353
end