src/HOL/HOLCF/Domain.thy
author haftmann
Thu, 19 Jun 2025 17:15:40 +0200
changeset 82734 89347c0cc6a3
parent 81583 b6df83045178
permissions -rw-r--r--
treat map_filter similar to list_all, list_ex, list_ex1
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
81573
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
     8
imports Representable Map_Functions Fixrec
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
81573
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    15
subsection \<open>Continuous isomorphisms\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    16
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    17
text \<open>A locale for continuous isomorphisms\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    18
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    19
locale iso =
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
    20
  fixes abs :: "'a::pcpo \<rightarrow> 'b::pcpo"
81573
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    21
  fixes rep :: "'b \<rightarrow> 'a"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    22
  assumes abs_iso [simp]: "rep\<cdot>(abs\<cdot>x) = x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    23
  assumes rep_iso [simp]: "abs\<cdot>(rep\<cdot>y) = y"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    24
begin
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    25
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    26
lemma swap: "iso rep abs"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    27
  by (rule iso.intro [OF rep_iso abs_iso])
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    28
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    29
lemma abs_below: "(abs\<cdot>x \<sqsubseteq> abs\<cdot>y) = (x \<sqsubseteq> y)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    30
proof
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    31
  assume "abs\<cdot>x \<sqsubseteq> abs\<cdot>y"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    32
  then have "rep\<cdot>(abs\<cdot>x) \<sqsubseteq> rep\<cdot>(abs\<cdot>y)" by (rule monofun_cfun_arg)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    33
  then show "x \<sqsubseteq> y" by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    34
next
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    35
  assume "x \<sqsubseteq> y"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    36
  then show "abs\<cdot>x \<sqsubseteq> abs\<cdot>y" by (rule monofun_cfun_arg)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    37
qed
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    38
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    39
lemma rep_below: "(rep\<cdot>x \<sqsubseteq> rep\<cdot>y) = (x \<sqsubseteq> y)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    40
  by (rule iso.abs_below [OF swap])
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    41
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    42
lemma abs_eq: "(abs\<cdot>x = abs\<cdot>y) = (x = y)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    43
  by (simp add: po_eq_conv abs_below)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    44
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    45
lemma rep_eq: "(rep\<cdot>x = rep\<cdot>y) = (x = y)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    46
  by (rule iso.abs_eq [OF swap])
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    47
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    48
lemma abs_strict: "abs\<cdot>\<bottom> = \<bottom>"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    49
proof -
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    50
  have "\<bottom> \<sqsubseteq> rep\<cdot>\<bottom>" ..
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    51
  then have "abs\<cdot>\<bottom> \<sqsubseteq> abs\<cdot>(rep\<cdot>\<bottom>)" by (rule monofun_cfun_arg)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    52
  then have "abs\<cdot>\<bottom> \<sqsubseteq> \<bottom>" by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    53
  then show ?thesis by (rule bottomI)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    54
qed
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    55
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    56
lemma rep_strict: "rep\<cdot>\<bottom> = \<bottom>"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    57
  by (rule iso.abs_strict [OF swap])
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    58
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    59
lemma abs_defin': "abs\<cdot>x = \<bottom> \<Longrightarrow> x = \<bottom>"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    60
proof -
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    61
  have "x = rep\<cdot>(abs\<cdot>x)" by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    62
  also assume "abs\<cdot>x = \<bottom>"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    63
  also note rep_strict
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    64
  finally show "x = \<bottom>" .
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    65
qed
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    66
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    67
lemma rep_defin': "rep\<cdot>z = \<bottom> \<Longrightarrow> z = \<bottom>"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    68
  by (rule iso.abs_defin' [OF swap])
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    69
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    70
lemma abs_defined: "z \<noteq> \<bottom> \<Longrightarrow> abs\<cdot>z \<noteq> \<bottom>"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    71
  by (erule contrapos_nn, erule abs_defin')
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    72
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    73
lemma rep_defined: "z \<noteq> \<bottom> \<Longrightarrow> rep\<cdot>z \<noteq> \<bottom>"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    74
  by (rule iso.abs_defined [OF iso.swap]) (rule iso_axioms)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    75
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    76
lemma abs_bottom_iff: "(abs\<cdot>x = \<bottom>) = (x = \<bottom>)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    77
  by (auto elim: abs_defin' intro: abs_strict)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    78
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    79
lemma rep_bottom_iff: "(rep\<cdot>x = \<bottom>) = (x = \<bottom>)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    80
  by (rule iso.abs_bottom_iff [OF iso.swap]) (rule iso_axioms)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    81
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    82
lemma casedist_rule: "rep\<cdot>x = \<bottom> \<or> P \<Longrightarrow> x = \<bottom> \<or> P"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    83
  by (simp add: rep_bottom_iff)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    84
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    85
lemma compact_abs_rev: "compact (abs\<cdot>x) \<Longrightarrow> compact x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    86
proof (unfold compact_def)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    87
  assume "adm (\<lambda>y. abs\<cdot>x \<notsqsubseteq> y)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    88
  with cont_Rep_cfun2
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    89
  have "adm (\<lambda>y. abs\<cdot>x \<notsqsubseteq> abs\<cdot>y)" by (rule adm_subst)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    90
  then show "adm (\<lambda>y. x \<notsqsubseteq> y)" using abs_below by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    91
qed
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    92
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    93
lemma compact_rep_rev: "compact (rep\<cdot>x) \<Longrightarrow> compact x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    94
  by (rule iso.compact_abs_rev [OF iso.swap]) (rule iso_axioms)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    95
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    96
lemma compact_abs: "compact x \<Longrightarrow> compact (abs\<cdot>x)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    97
  by (rule compact_rep_rev) simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    98
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
    99
lemma compact_rep: "compact x \<Longrightarrow> compact (rep\<cdot>x)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   100
  by (rule iso.compact_abs [OF iso.swap]) (rule iso_axioms)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   101
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   102
lemma iso_swap: "(x = abs\<cdot>y) = (rep\<cdot>x = y)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   103
proof
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   104
  assume "x = abs\<cdot>y"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   105
  then have "rep\<cdot>x = rep\<cdot>(abs\<cdot>y)" by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   106
  then show "rep\<cdot>x = y" by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   107
next
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   108
  assume "rep\<cdot>x = y"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   109
  then have "abs\<cdot>(rep\<cdot>x) = abs\<cdot>y" by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   110
  then show "x = abs\<cdot>y" by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   111
qed
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   112
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   113
end
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   114
81577
a712bf5ccab0 tuned whitespace;
wenzelm
parents: 81573
diff changeset
   115
81573
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   116
subsection \<open>Proofs about take functions\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   117
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   118
text \<open>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   119
  This section contains lemmas that are used in a module that supports
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   120
  the domain isomorphism package; the module contains proofs related
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   121
  to take functions and the finiteness predicate.
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   122
\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   123
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   124
lemma deflation_abs_rep:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   125
  fixes abs and rep and d
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   126
  assumes abs_iso: "\<And>x. rep\<cdot>(abs\<cdot>x) = x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   127
  assumes rep_iso: "\<And>y. abs\<cdot>(rep\<cdot>y) = y"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   128
  shows "deflation d \<Longrightarrow> deflation (abs oo d oo rep)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   129
by (rule ep_pair.deflation_e_d_p) (simp add: ep_pair.intro assms)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   130
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   131
lemma deflation_chain_min:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   132
  assumes chain: "chain d"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   133
  assumes defl: "\<And>n. deflation (d n)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   134
  shows "d m\<cdot>(d n\<cdot>x) = d (min m n)\<cdot>x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   135
proof (rule linorder_le_cases)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   136
  assume "m \<le> n"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   137
  with chain have "d m \<sqsubseteq> d n" by (rule chain_mono)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   138
  then have "d m\<cdot>(d n\<cdot>x) = d m\<cdot>x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   139
    by (rule deflation_below_comp1 [OF defl defl])
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   140
  moreover from \<open>m \<le> n\<close> have "min m n = m" by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   141
  ultimately show ?thesis by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   142
next
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   143
  assume "n \<le> m"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   144
  with chain have "d n \<sqsubseteq> d m" by (rule chain_mono)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   145
  then have "d m\<cdot>(d n\<cdot>x) = d n\<cdot>x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   146
    by (rule deflation_below_comp2 [OF defl defl])
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   147
  moreover from \<open>n \<le> m\<close> have "min m n = n" by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   148
  ultimately show ?thesis by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   149
qed
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   150
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   151
lemma lub_ID_take_lemma:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   152
  assumes "chain t" and "(\<Squnion>n. t n) = ID"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   153
  assumes "\<And>n. t n\<cdot>x = t n\<cdot>y" shows "x = y"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   154
proof -
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   155
  have "(\<Squnion>n. t n\<cdot>x) = (\<Squnion>n. t n\<cdot>y)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   156
    using assms(3) by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   157
  then have "(\<Squnion>n. t n)\<cdot>x = (\<Squnion>n. t n)\<cdot>y"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   158
    using assms(1) by (simp add: lub_distribs)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   159
  then show "x = y"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   160
    using assms(2) by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   161
qed
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   162
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   163
lemma lub_ID_reach:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   164
  assumes "chain t" and "(\<Squnion>n. t n) = ID"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   165
  shows "(\<Squnion>n. t n\<cdot>x) = x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   166
using assms by (simp add: lub_distribs)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   167
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   168
lemma lub_ID_take_induct:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   169
  assumes "chain t" and "(\<Squnion>n. t n) = ID"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   170
  assumes "adm P" and "\<And>n. P (t n\<cdot>x)" shows "P x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   171
proof -
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   172
  from \<open>chain t\<close> have "chain (\<lambda>n. t n\<cdot>x)" by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   173
  from \<open>adm P\<close> this \<open>\<And>n. P (t n\<cdot>x)\<close> have "P (\<Squnion>n. t n\<cdot>x)" by (rule admD)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   174
  with \<open>chain t\<close> \<open>(\<Squnion>n. t n) = ID\<close> show "P x" by (simp add: lub_distribs)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   175
qed
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   176
81577
a712bf5ccab0 tuned whitespace;
wenzelm
parents: 81573
diff changeset
   177
81573
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   178
subsection \<open>Finiteness\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   179
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   180
text \<open>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   181
  Let a ``decisive'' function be a deflation that maps every input to
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   182
  either itself or bottom.  Then if a domain's take functions are all
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   183
  decisive, then all values in the domain are finite.
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   184
\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   185
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   186
definition
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   187
  decisive :: "('a::pcpo \<rightarrow> 'a) \<Rightarrow> bool"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   188
where
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   189
  "decisive d \<longleftrightarrow> (\<forall>x. d\<cdot>x = x \<or> d\<cdot>x = \<bottom>)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   190
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   191
lemma decisiveI: "(\<And>x. d\<cdot>x = x \<or> d\<cdot>x = \<bottom>) \<Longrightarrow> decisive d"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   192
  unfolding decisive_def by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   193
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   194
lemma decisive_cases:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   195
  assumes "decisive d" obtains "d\<cdot>x = x" | "d\<cdot>x = \<bottom>"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   196
using assms unfolding decisive_def by auto
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   197
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   198
lemma decisive_bottom: "decisive \<bottom>"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   199
  unfolding decisive_def by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   200
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   201
lemma decisive_ID: "decisive ID"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   202
  unfolding decisive_def by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   203
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   204
lemma decisive_ssum_map:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   205
  assumes f: "decisive f"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   206
  assumes g: "decisive g"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   207
  shows "decisive (ssum_map\<cdot>f\<cdot>g)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   208
  apply (rule decisiveI)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   209
  subgoal for s
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   210
    apply (cases s, simp_all)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   211
     apply (rule_tac x=x in decisive_cases [OF f], simp_all)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   212
    apply (rule_tac x=y in decisive_cases [OF g], simp_all)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   213
    done
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   214
  done
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   215
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   216
lemma decisive_sprod_map:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   217
  assumes f: "decisive f"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   218
  assumes g: "decisive g"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   219
  shows "decisive (sprod_map\<cdot>f\<cdot>g)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   220
  apply (rule decisiveI)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   221
  subgoal for s
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   222
    apply (cases s, simp)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   223
    subgoal for x y
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   224
      apply (rule decisive_cases [OF f, where x = x], simp_all)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   225
      apply (rule decisive_cases [OF g, where x = y], simp_all)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   226
      done
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   227
    done
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   228
  done
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   229
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   230
lemma decisive_abs_rep:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   231
  fixes abs rep
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   232
  assumes iso: "iso abs rep"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   233
  assumes d: "decisive d"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   234
  shows "decisive (abs oo d oo rep)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   235
  apply (rule decisiveI)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   236
  subgoal for s
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   237
    apply (rule decisive_cases [OF d, where x="rep\<cdot>s"])
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   238
     apply (simp add: iso.rep_iso [OF iso])
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   239
    apply (simp add: iso.abs_strict [OF iso])
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   240
    done
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   241
  done
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   242
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   243
lemma lub_ID_finite:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   244
  assumes chain: "chain d"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   245
  assumes lub: "(\<Squnion>n. d n) = ID"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   246
  assumes decisive: "\<And>n. decisive (d n)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   247
  shows "\<exists>n. d n\<cdot>x = x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   248
proof -
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   249
  have 1: "chain (\<lambda>n. d n\<cdot>x)" using chain by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   250
  have 2: "(\<Squnion>n. d n\<cdot>x) = x" using chain lub by (rule lub_ID_reach)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   251
  have "\<forall>n. d n\<cdot>x = x \<or> d n\<cdot>x = \<bottom>"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   252
    using decisive unfolding decisive_def by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   253
  hence "range (\<lambda>n. d n\<cdot>x) \<subseteq> {x, \<bottom>}"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   254
    by auto
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   255
  hence "finite (range (\<lambda>n. d n\<cdot>x))"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   256
    by (rule finite_subset, simp)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   257
  with 1 have "finite_chain (\<lambda>n. d n\<cdot>x)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   258
    by (rule finite_range_imp_finch)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   259
  then have "\<exists>n. (\<Squnion>n. d n\<cdot>x) = d n\<cdot>x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   260
    unfolding finite_chain_def by (auto simp add: maxinch_is_thelub)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   261
  with 2 show "\<exists>n. d n\<cdot>x = x" by (auto elim: sym)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   262
qed
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   263
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   264
lemma lub_ID_finite_take_induct:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   265
  assumes "chain d" and "(\<Squnion>n. d n) = ID" and "\<And>n. decisive (d n)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   266
  shows "(\<And>n. P (d n\<cdot>x)) \<Longrightarrow> P x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   267
using lub_ID_finite [OF assms] by metis
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   268
81577
a712bf5ccab0 tuned whitespace;
wenzelm
parents: 81573
diff changeset
   269
81573
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   270
subsection \<open>Proofs about constructor functions\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   271
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   272
text \<open>Lemmas for proving nchotomy rule:\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   273
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   274
lemma ex_one_bottom_iff:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   275
  "(\<exists>x. P x \<and> x \<noteq> \<bottom>) = P ONE"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   276
by simp
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   277
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   278
lemma ex_up_bottom_iff:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   279
  "(\<exists>x. P x \<and> x \<noteq> \<bottom>) = (\<exists>x. P (up\<cdot>x))"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   280
by (safe, case_tac x, auto)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   281
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   282
lemma ex_sprod_bottom_iff:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   283
 "(\<exists>y. P y \<and> y \<noteq> \<bottom>) =
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   284
  (\<exists>x y. (P (:x, y:) \<and> x \<noteq> \<bottom>) \<and> y \<noteq> \<bottom>)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   285
by (safe, case_tac y, auto)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   286
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   287
lemma ex_sprod_up_bottom_iff:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   288
 "(\<exists>y. P y \<and> y \<noteq> \<bottom>) =
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   289
  (\<exists>x y. P (:up\<cdot>x, y:) \<and> y \<noteq> \<bottom>)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   290
by (safe, case_tac y, simp, case_tac x, auto)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   291
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   292
lemma ex_ssum_bottom_iff:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   293
 "(\<exists>x. P x \<and> x \<noteq> \<bottom>) =
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   294
 ((\<exists>x. P (sinl\<cdot>x) \<and> x \<noteq> \<bottom>) \<or>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   295
  (\<exists>x. P (sinr\<cdot>x) \<and> x \<noteq> \<bottom>))"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   296
by (safe, case_tac x, auto)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   297
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   298
lemma exh_start: "p = \<bottom> \<or> (\<exists>x. p = x \<and> x \<noteq> \<bottom>)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   299
  by auto
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   300
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   301
lemmas ex_bottom_iffs =
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   302
   ex_ssum_bottom_iff
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   303
   ex_sprod_up_bottom_iff
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   304
   ex_sprod_bottom_iff
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   305
   ex_up_bottom_iff
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   306
   ex_one_bottom_iff
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   307
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   308
text \<open>Rules for turning nchotomy into exhaust:\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   309
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   310
lemma exh_casedist0: "\<lbrakk>R; R \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" (* like make_elim *)
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   311
  by auto
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   312
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   313
lemma exh_casedist1: "((P \<or> Q \<Longrightarrow> R) \<Longrightarrow> S) \<equiv> (\<lbrakk>P \<Longrightarrow> R; Q \<Longrightarrow> R\<rbrakk> \<Longrightarrow> S)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   314
  by rule auto
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   315
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   316
lemma exh_casedist2: "(\<exists>x. P x \<Longrightarrow> Q) \<equiv> (\<And>x. P x \<Longrightarrow> Q)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   317
  by rule auto
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   318
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   319
lemma exh_casedist3: "(P \<and> Q \<Longrightarrow> R) \<equiv> (P \<Longrightarrow> Q \<Longrightarrow> R)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   320
  by rule auto
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   321
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   322
lemmas exh_casedists = exh_casedist1 exh_casedist2 exh_casedist3
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   323
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   324
text \<open>Rules for proving constructor properties\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   325
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   326
lemmas con_strict_rules =
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   327
  sinl_strict sinr_strict spair_strict1 spair_strict2
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   328
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   329
lemmas con_bottom_iff_rules =
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   330
  sinl_bottom_iff sinr_bottom_iff spair_bottom_iff up_defined ONE_defined
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   331
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   332
lemmas con_below_iff_rules =
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   333
  sinl_below sinr_below sinl_below_sinr sinr_below_sinl con_bottom_iff_rules
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   334
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   335
lemmas con_eq_iff_rules =
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   336
  sinl_eq sinr_eq sinl_eq_sinr sinr_eq_sinl con_bottom_iff_rules
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   337
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   338
lemmas sel_strict_rules =
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   339
  cfcomp2 sscase1 sfst_strict ssnd_strict fup1
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   340
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   341
lemma sel_app_extra_rules:
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   342
  "sscase\<cdot>ID\<cdot>\<bottom>\<cdot>(sinr\<cdot>x) = \<bottom>"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   343
  "sscase\<cdot>ID\<cdot>\<bottom>\<cdot>(sinl\<cdot>x) = x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   344
  "sscase\<cdot>\<bottom>\<cdot>ID\<cdot>(sinl\<cdot>x) = \<bottom>"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   345
  "sscase\<cdot>\<bottom>\<cdot>ID\<cdot>(sinr\<cdot>x) = x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   346
  "fup\<cdot>ID\<cdot>(up\<cdot>x) = x"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   347
by (cases "x = \<bottom>", simp, simp)+
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   348
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   349
lemmas sel_app_rules =
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   350
  sel_strict_rules sel_app_extra_rules
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   351
  ssnd_spair sfst_spair up_defined spair_defined
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   352
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   353
lemmas sel_bottom_iff_rules =
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   354
  cfcomp2 sfst_bottom_iff ssnd_bottom_iff
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   355
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   356
lemmas take_con_rules =
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   357
  ssum_map_sinl' ssum_map_sinr' sprod_map_spair' u_map_up
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   358
  deflation_strict deflation_ID ID1 cfcomp2
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   359
81577
a712bf5ccab0 tuned whitespace;
wenzelm
parents: 81573
diff changeset
   360
81573
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   361
subsection \<open>ML setup\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   362
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   363
named_theorems domain_deflation "theorems like deflation a ==> deflation (foo_map$a)"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   364
  and domain_map_ID "theorems like foo_map$ID = ID"
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   365
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   366
ML_file \<open>Tools/Domain/domain_take_proofs.ML\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   367
ML_file \<open>Tools/cont_consts.ML\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   368
ML_file \<open>Tools/cont_proc.ML\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   369
simproc_setup cont ("cont f") = \<open>K ContProc.cont_proc\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   370
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   371
ML_file \<open>Tools/Domain/domain_constructors.ML\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   372
ML_file \<open>Tools/Domain/domain_induction.ML\<close>
972fecd8907a fewer theories (in contrast to 05ca920cd94b);
wenzelm
parents: 69913
diff changeset
   373
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   374
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   375
subsection \<open>Representations of types\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   376
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   377
lemma emb_prj: "emb\<cdot>((prj\<cdot>x)::'a::domain) = cast\<cdot>DEFL('a)\<cdot>x"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   378
by (simp add: cast_DEFL)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   379
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   380
lemma emb_prj_emb:
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   381
  fixes x :: "'a::domain"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   382
  assumes "DEFL('a) \<sqsubseteq> DEFL('b)"
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   383
  shows "emb\<cdot>(prj\<cdot>(emb\<cdot>x) :: 'b::domain) = emb\<cdot>x"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   384
unfolding emb_prj
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   385
apply (rule cast.belowD)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   386
apply (rule monofun_cfun_arg [OF assms])
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   387
apply (simp add: cast_DEFL)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   388
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   389
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   390
lemma prj_emb_prj:
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   391
  assumes "DEFL('a::domain) \<sqsubseteq> DEFL('b::domain)"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   392
  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
   393
 apply (rule emb_eq_iff [THEN iffD1])
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   394
 apply (simp only: emb_prj)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   395
 apply (rule deflation_below_comp1)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   396
   apply (rule deflation_cast)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   397
  apply (rule deflation_cast)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   398
 apply (rule monofun_cfun_arg [OF assms])
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   399
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   400
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   401
text \<open>Isomorphism lemmas used internally by the domain package:\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   402
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   403
lemma domain_abs_iso:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   404
  fixes abs and rep
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   405
  assumes DEFL: "DEFL('b::domain) = DEFL('a::domain)"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   406
  assumes abs_def: "(abs :: 'a \<rightarrow> 'b) \<equiv> prj oo emb"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   407
  assumes rep_def: "(rep :: 'b \<rightarrow> 'a) \<equiv> prj oo emb"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   408
  shows "rep\<cdot>(abs\<cdot>x) = x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   409
unfolding abs_def rep_def
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   410
by (simp add: emb_prj_emb DEFL)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   411
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   412
lemma domain_rep_iso:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   413
  fixes abs and rep
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   414
  assumes DEFL: "DEFL('b::domain) = DEFL('a::domain)"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   415
  assumes abs_def: "(abs :: 'a \<rightarrow> 'b) \<equiv> prj oo emb"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   416
  assumes rep_def: "(rep :: 'b \<rightarrow> 'a) \<equiv> prj oo emb"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   417
  shows "abs\<cdot>(rep\<cdot>x) = x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   418
unfolding abs_def rep_def
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   419
by (simp add: emb_prj_emb DEFL)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   420
81577
a712bf5ccab0 tuned whitespace;
wenzelm
parents: 81573
diff changeset
   421
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   422
subsection \<open>Deflations as sets\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   423
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41285
diff changeset
   424
definition defl_set :: "'a::bifinite defl \<Rightarrow> 'a set"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   425
where "defl_set A = {x. cast\<cdot>A\<cdot>x = x}"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   426
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   427
lemma adm_defl_set: "adm (\<lambda>x. x \<in> defl_set A)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   428
unfolding defl_set_def by simp
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   429
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   430
lemma defl_set_bottom: "\<bottom> \<in> defl_set A"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   431
unfolding defl_set_def by simp
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   432
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   433
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
   434
unfolding defl_set_def by simp
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   435
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   436
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
   437
apply (simp add: defl_set_def subset_eq cast_below_cast [symmetric])
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   438
apply (auto simp add: cast.belowI cast.belowD)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   439
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   440
81577
a712bf5ccab0 tuned whitespace;
wenzelm
parents: 81573
diff changeset
   441
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   442
subsection \<open>Proving a subtype is representable\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   443
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   444
text \<open>Temporarily relax type constraints.\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   445
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   446
setup \<open>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   447
  fold Sign.add_const_constraint
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
   448
  [ (\<^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
   449
  , (\<^const_name>\<open>emb\<close>, SOME \<^typ>\<open>'a::pcpo \<rightarrow> udom\<close>)
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
   450
  , (\<^const_name>\<open>prj\<close>, SOME \<^typ>\<open>udom \<rightarrow> 'a::pcpo\<close>)
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
   451
  , (\<^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
   452
  , (\<^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
   453
  , (\<^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
   454
\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   455
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   456
lemma typedef_domain_class:
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   457
  fixes Rep :: "'a::pcpo \<Rightarrow> udom"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   458
  fixes Abs :: "udom \<Rightarrow> 'a::pcpo"
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41285
diff changeset
   459
  fixes t :: "udom defl"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   460
  assumes type: "type_definition Rep Abs (defl_set t)"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 63432
diff changeset
   461
  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
   462
  assumes emb: "emb \<equiv> (\<Lambda> x. Rep x)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   463
  assumes prj: "prj \<equiv> (\<Lambda> x. Abs (cast\<cdot>t\<cdot>x))"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   464
  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
   465
  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
   466
  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
   467
  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
   468
  shows "OFCLASS('a, domain_class)"
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   469
proof
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   470
  have emb_beta: "\<And>x. emb\<cdot>x = Rep x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   471
    unfolding emb
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   472
    apply (rule beta_cfun)
40834
a1249aeff5b6 change cpodef-generated cont_Rep rules to cont2cont format
huffman
parents: 40830
diff changeset
   473
    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
   474
    done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   475
  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
   476
    unfolding prj
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   477
    apply (rule beta_cfun)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   478
    apply (rule typedef_cont_Abs [OF type below adm_defl_set])
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   479
    apply simp_all
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   480
    done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   481
  have prj_emb: "\<And>x::'a. prj\<cdot>(emb\<cdot>x) = x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   482
    using type_definition.Rep [OF type]
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   483
    unfolding prj_beta emb_beta defl_set_def
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   484
    by (simp add: type_definition.Rep_inverse [OF type])
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   485
  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
   486
    unfolding prj_beta emb_beta
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   487
    by (simp add: type_definition.Abs_inverse [OF type])
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   488
  show "ep_pair (emb :: 'a \<rightarrow> udom) prj"
61169
4de9ff3ea29a tuned proofs -- less legacy;
wenzelm
parents: 60753
diff changeset
   489
    apply standard
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   490
    apply (simp add: prj_emb)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   491
    apply (simp add: emb_prj cast.below)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   492
    done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   493
  show "cast\<cdot>DEFL('a) = emb oo (prj :: udom \<rightarrow> 'a)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   494
    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
   495
qed (simp_all only: liftemb liftprj liftdefl)
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   496
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   497
lemma typedef_DEFL:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   498
  assumes "defl \<equiv> (\<lambda>a::'a::pcpo itself. t)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   499
  shows "DEFL('a::pcpo) = t"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   500
unfolding assms ..
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   501
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   502
text \<open>Restore original typing constraints.\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   503
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   504
setup \<open>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   505
  fold Sign.add_const_constraint
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
   506
   [(\<^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
   507
    (\<^const_name>\<open>emb\<close>, SOME \<^typ>\<open>'a::domain \<rightarrow> udom\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
   508
    (\<^const_name>\<open>prj\<close>, SOME \<^typ>\<open>udom \<rightarrow> 'a::domain\<close>),
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68357
diff changeset
   509
    (\<^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
   510
    (\<^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
   511
    (\<^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
   512
\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   513
69605
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 69597
diff changeset
   514
ML_file \<open>Tools/domaindef.ML\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   515
81577
a712bf5ccab0 tuned whitespace;
wenzelm
parents: 81573
diff changeset
   516
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   517
subsection \<open>Isomorphic deflations\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   518
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   519
definition isodefl :: "('a::domain \<rightarrow> 'a) \<Rightarrow> udom defl \<Rightarrow> bool"
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   520
  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
   521
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   522
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
   523
  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
   524
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   525
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
   526
unfolding isodefl_def by (simp add: cfun_eqI)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   527
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   528
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
   529
unfolding isodefl_def by (simp add: cfun_eqI)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   530
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   531
lemma isodefl_strict: "isodefl d t \<Longrightarrow> d\<cdot>\<bottom> = \<bottom>"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   532
unfolding isodefl_def
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   533
by (drule cfun_fun_cong [where x="\<bottom>"], simp)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   534
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   535
lemma isodefl_imp_deflation:
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   536
  fixes d :: "'a::domain \<rightarrow> 'a"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   537
  assumes "isodefl d t" shows "deflation d"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   538
proof
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   539
  note assms [unfolded isodefl_def, simp]
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   540
  fix x :: 'a
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   541
  show "d\<cdot>(d\<cdot>x) = d\<cdot>x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   542
    using cast.idem [of t "emb\<cdot>x"] by simp
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   543
  show "d\<cdot>x \<sqsubseteq> x"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   544
    using cast.below [of t "emb\<cdot>x"] by simp
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   545
qed
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   546
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   547
lemma isodefl_ID_DEFL: "isodefl (ID :: 'a \<rightarrow> 'a) DEFL('a::domain)"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   548
unfolding isodefl_def by (simp add: cast_DEFL)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   549
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   550
lemma isodefl_LIFTDEFL:
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   551
  "isodefl' (ID :: 'a \<rightarrow> 'a) LIFTDEFL('a::predomain)"
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   552
unfolding isodefl'_def by (simp add: cast_liftdefl u_map_ID)
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   553
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   554
lemma isodefl_DEFL_imp_ID: "isodefl (d :: 'a \<rightarrow> 'a) DEFL('a::domain) \<Longrightarrow> d = ID"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   555
unfolding isodefl_def
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   556
apply (simp add: cast_DEFL)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   557
apply (simp add: cfun_eq_iff)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   558
apply (rule allI)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   559
apply (drule_tac x="emb\<cdot>x" in spec)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   560
apply simp
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   561
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   562
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   563
lemma isodefl_bottom: "isodefl \<bottom> \<bottom>"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   564
unfolding isodefl_def by (simp add: cfun_eq_iff)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   565
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   566
lemma adm_isodefl:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   567
  "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
   568
unfolding isodefl_def by simp
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   569
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   570
lemma isodefl_lub:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   571
  assumes "chain d" and "chain t"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   572
  assumes "\<And>i. isodefl (d i) (t i)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   573
  shows "isodefl (\<Squnion>i. d i) (\<Squnion>i. t i)"
41529
ba60efa2fd08 eliminated global prems;
wenzelm
parents: 41437
diff changeset
   574
using assms unfolding isodefl_def
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   575
by (simp add: contlub_cfun_arg contlub_cfun_fun)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   576
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   577
lemma isodefl_fix:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   578
  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
   579
  shows "isodefl (fix\<cdot>f) (fix\<cdot>g)"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   580
unfolding fix_def2
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   581
apply (rule isodefl_lub, simp, simp)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   582
apply (induct_tac i)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   583
apply (simp add: isodefl_bottom)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   584
apply (simp add: assms)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   585
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   586
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   587
lemma isodefl_abs_rep:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   588
  fixes abs and rep and d
81583
b6df83045178 clarified default_sort: "cpo" for bootstrap, "domain" for main HOLCF;
wenzelm
parents: 81577
diff changeset
   589
  assumes DEFL: "DEFL('b::domain) = DEFL('a::domain)"
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   590
  assumes abs_def: "(abs :: 'a \<rightarrow> 'b) \<equiv> prj oo emb"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   591
  assumes rep_def: "(rep :: 'b \<rightarrow> 'a) \<equiv> prj oo emb"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   592
  shows "isodefl d t \<Longrightarrow> isodefl (abs oo d oo rep) t"
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   593
unfolding isodefl_def
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   594
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
   595
41436
480978f80eae rename constant pdefl to liftdefl_of
huffman
parents: 41297
diff changeset
   596
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
   597
unfolding isodefl_def isodefl'_def
41436
480978f80eae rename constant pdefl to liftdefl_of
huffman
parents: 41297
diff changeset
   598
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
   599
40592
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   600
lemma isodefl_sfun:
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   601
  "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
   602
    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
   603
apply (rule isodeflI)
40592
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   604
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
   605
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
   606
apply (simp add: sfun_map_map isodefl_strict)
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   607
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   608
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   609
lemma isodefl_ssum:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   610
  "isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow>
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   611
    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
   612
apply (rule isodeflI)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   613
apply (simp add: cast_ssum_defl cast_isodefl)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   614
apply (simp add: emb_ssum_def prj_ssum_def)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   615
apply (simp add: ssum_map_map isodefl_strict)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   616
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   617
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   618
lemma isodefl_sprod:
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   619
  "isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow>
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   620
    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
   621
apply (rule isodeflI)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   622
apply (simp add: cast_sprod_defl cast_isodefl)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   623
apply (simp add: emb_sprod_def prj_sprod_def)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   624
apply (simp add: sprod_map_map isodefl_strict)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   625
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   626
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   627
lemma isodefl_prod:
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   628
  "isodefl d1 t1 \<Longrightarrow> isodefl d2 t2 \<Longrightarrow>
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   629
    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
   630
apply (rule isodeflI)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   631
apply (simp add: cast_prod_defl cast_isodefl)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   632
apply (simp add: emb_prod_def prj_prod_def)
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   633
apply (simp add: prod_map_map cfcomp1)
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   634
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   635
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   636
lemma isodefl_u:
41437
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   637
  "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
   638
apply (rule isodeflI)
41437
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   639
apply (simp add: cast_u_defl cast_isodefl)
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   640
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
   641
done
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   642
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   643
lemma isodefl_u_liftdefl:
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   644
  "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
   645
apply (rule isodeflI)
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   646
apply (simp add: cast_u_liftdefl isodefl'_def)
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   647
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
   648
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   649
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   650
lemma encode_prod_u_map:
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   651
  "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
   652
    = 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
   653
unfolding encode_prod_u_def decode_prod_u_def
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   654
apply (case_tac x, simp, rename_tac a b)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   655
apply (case_tac a, simp, case_tac b, simp, simp)
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   656
done
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   657
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   658
lemma isodefl_prod_u:
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   659
  assumes "isodefl' d1 t1" and "isodefl' d2 t2"
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   660
  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
   661
using assms unfolding isodefl'_def
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   662
unfolding liftemb_prod_def liftprj_prod_def
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   663
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
   664
40592
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   665
lemma encode_cfun_map:
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   666
  "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
   667
    = 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
   668
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
   669
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
   670
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
   671
done
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   672
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   673
lemma isodefl_cfun:
40830
158d18502378 simplify predomain instances
huffman
parents: 40774
diff changeset
   674
  assumes "isodefl (u_map\<cdot>d1) t1" and "isodefl d2 t2"
158d18502378 simplify predomain instances
huffman
parents: 40774
diff changeset
   675
  shows "isodefl (cfun_map\<cdot>d1\<cdot>d2) (sfun_defl\<cdot>t1\<cdot>t2)"
158d18502378 simplify predomain instances
huffman
parents: 40774
diff changeset
   676
using isodefl_sfun [OF assms] unfolding isodefl_def
158d18502378 simplify predomain instances
huffman
parents: 40774
diff changeset
   677
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
   678
81577
a712bf5ccab0 tuned whitespace;
wenzelm
parents: 81573
diff changeset
   679
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   680
subsection \<open>Setting up the domain package\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   681
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
   682
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
   683
  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
   684
69605
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 69597
diff changeset
   685
ML_file \<open>Tools/Domain/domain_isomorphism.ML\<close>
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 69597
diff changeset
   686
ML_file \<open>Tools/Domain/domain_axioms.ML\<close>
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 69597
diff changeset
   687
ML_file \<open>Tools/Domain/domain.ML\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   688
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   689
lemmas [domain_defl_simps] =
40592
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   690
  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
   691
  liftdefl_eq LIFTDEFL_prod u_liftdefl_liftdefl_of
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   692
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   693
lemmas [domain_map_ID] =
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   694
  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
   695
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   696
lemmas [domain_isodefl] =
40592
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   697
  isodefl_u isodefl_sfun isodefl_ssum isodefl_sprod
41436
480978f80eae rename constant pdefl to liftdefl_of
huffman
parents: 41297
diff changeset
   698
  isodefl_cfun isodefl_prod isodefl_prod_u isodefl'_liftdefl_of
41437
5bc117c382ec rename constant u_defl to u_liftdefl;
huffman
parents: 41436
diff changeset
   699
  isodefl_u_liftdefl
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   700
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   701
lemmas [domain_deflation] =
40592
f432973ce0f6 move strict function type into main HOLCF; instance cfun :: (predomain, domain) domain
huffman
parents: 40575
diff changeset
   702
  deflation_cfun_map deflation_sfun_map deflation_ssum_map
41297
01b2de947cff rename function cprod_map to prod_map
huffman
parents: 41292
diff changeset
   703
  deflation_sprod_map deflation_prod_map deflation_u_map
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   704
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   705
setup \<open>
40737
2037021f034f remove map function names from domain package theory data
huffman
parents: 40592
diff changeset
   706
  fold Domain_Take_Proofs.add_rec_type
68357
6bf71e776226 more symbols;
wenzelm
parents: 67399
diff changeset
   707
    [(\<^type_name>\<open>cfun\<close>, [true, true]),
6bf71e776226 more symbols;
wenzelm
parents: 67399
diff changeset
   708
     (\<^type_name>\<open>sfun\<close>, [true, true]),
6bf71e776226 more symbols;
wenzelm
parents: 67399
diff changeset
   709
     (\<^type_name>\<open>ssum\<close>, [true, true]),
6bf71e776226 more symbols;
wenzelm
parents: 67399
diff changeset
   710
     (\<^type_name>\<open>sprod\<close>, [true, true]),
6bf71e776226 more symbols;
wenzelm
parents: 67399
diff changeset
   711
     (\<^type_name>\<open>prod\<close>, [true, true]),
6bf71e776226 more symbols;
wenzelm
parents: 67399
diff changeset
   712
     (\<^type_name>\<open>u\<close>, [true])]
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   713
\<close>
40504
7c6265ba6d43 merge Representable.thy into Domain.thy
huffman
parents: 40503
diff changeset
   714
15741
29a78517543f New file for theorems used by the domain package
huffman
parents:
diff changeset
   715
end