src/HOLCF/Domain_Aux.thy
author wenzelm
Wed, 03 Nov 2010 21:53:56 +0100
changeset 40335 3e4bb6e7c3ca
parent 40327 1dfdbd66093a
child 40502 8e92772bc0e8
permissions -rw-r--r--
feeder: treat header as escaped utf8 to allow initial ML text to refer to non-ASCII file/directory names (e.g. "Documents/" on Chinese Ubuntu);
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35652
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
     1
(*  Title:      HOLCF/Domain_Aux.thy
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
     2
    Author:     Brian Huffman
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
     3
*)
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
     4
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
     5
header {* Domain package support *}
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
     6
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
     7
theory Domain_Aux
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
     8
imports Ssum Sprod Fixrec
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
     9
uses
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
    10
  ("Tools/Domain/domain_take_proofs.ML")
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
    11
begin
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
    12
35653
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    13
subsection {* Continuous isomorphisms *}
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    14
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    15
text {* A locale for continuous isomorphisms *}
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    16
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    17
locale iso =
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    18
  fixes abs :: "'a \<rightarrow> 'b"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    19
  fixes rep :: "'b \<rightarrow> 'a"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    20
  assumes abs_iso [simp]: "rep\<cdot>(abs\<cdot>x) = x"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    21
  assumes rep_iso [simp]: "abs\<cdot>(rep\<cdot>y) = y"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    22
begin
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    23
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    24
lemma swap: "iso rep abs"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    25
  by (rule iso.intro [OF rep_iso abs_iso])
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    26
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    27
lemma abs_below: "(abs\<cdot>x \<sqsubseteq> abs\<cdot>y) = (x \<sqsubseteq> y)"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    28
proof
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    29
  assume "abs\<cdot>x \<sqsubseteq> abs\<cdot>y"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    30
  then have "rep\<cdot>(abs\<cdot>x) \<sqsubseteq> rep\<cdot>(abs\<cdot>y)" by (rule monofun_cfun_arg)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    31
  then show "x \<sqsubseteq> y" by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    32
next
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    33
  assume "x \<sqsubseteq> y"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    34
  then show "abs\<cdot>x \<sqsubseteq> abs\<cdot>y" by (rule monofun_cfun_arg)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    35
qed
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    36
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    37
lemma rep_below: "(rep\<cdot>x \<sqsubseteq> rep\<cdot>y) = (x \<sqsubseteq> y)"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    38
  by (rule iso.abs_below [OF swap])
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    39
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    40
lemma abs_eq: "(abs\<cdot>x = abs\<cdot>y) = (x = y)"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    41
  by (simp add: po_eq_conv abs_below)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    42
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    43
lemma rep_eq: "(rep\<cdot>x = rep\<cdot>y) = (x = y)"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    44
  by (rule iso.abs_eq [OF swap])
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    45
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    46
lemma abs_strict: "abs\<cdot>\<bottom> = \<bottom>"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    47
proof -
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    48
  have "\<bottom> \<sqsubseteq> rep\<cdot>\<bottom>" ..
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    49
  then have "abs\<cdot>\<bottom> \<sqsubseteq> abs\<cdot>(rep\<cdot>\<bottom>)" by (rule monofun_cfun_arg)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    50
  then have "abs\<cdot>\<bottom> \<sqsubseteq> \<bottom>" by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    51
  then show ?thesis by (rule UU_I)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    52
qed
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    53
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    54
lemma rep_strict: "rep\<cdot>\<bottom> = \<bottom>"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    55
  by (rule iso.abs_strict [OF swap])
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    56
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    57
lemma abs_defin': "abs\<cdot>x = \<bottom> \<Longrightarrow> x = \<bottom>"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    58
proof -
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    59
  have "x = rep\<cdot>(abs\<cdot>x)" by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    60
  also assume "abs\<cdot>x = \<bottom>"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    61
  also note rep_strict
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    62
  finally show "x = \<bottom>" .
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    63
qed
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    64
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    65
lemma rep_defin': "rep\<cdot>z = \<bottom> \<Longrightarrow> z = \<bottom>"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    66
  by (rule iso.abs_defin' [OF swap])
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    67
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    68
lemma abs_defined: "z \<noteq> \<bottom> \<Longrightarrow> abs\<cdot>z \<noteq> \<bottom>"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    69
  by (erule contrapos_nn, erule abs_defin')
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    70
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    71
lemma rep_defined: "z \<noteq> \<bottom> \<Longrightarrow> rep\<cdot>z \<noteq> \<bottom>"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    72
  by (rule iso.abs_defined [OF iso.swap]) (rule iso_axioms)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    73
40321
d065b195ec89 rename lemmas *_defined_iff and *_strict_iff to *_bottom_iff
huffman
parents: 40216
diff changeset
    74
lemma abs_bottom_iff: "(abs\<cdot>x = \<bottom>) = (x = \<bottom>)"
35653
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    75
  by (auto elim: abs_defin' intro: abs_strict)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    76
40321
d065b195ec89 rename lemmas *_defined_iff and *_strict_iff to *_bottom_iff
huffman
parents: 40216
diff changeset
    77
lemma rep_bottom_iff: "(rep\<cdot>x = \<bottom>) = (x = \<bottom>)"
d065b195ec89 rename lemmas *_defined_iff and *_strict_iff to *_bottom_iff
huffman
parents: 40216
diff changeset
    78
  by (rule iso.abs_bottom_iff [OF iso.swap]) (rule iso_axioms)
35653
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    79
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    80
lemma casedist_rule: "rep\<cdot>x = \<bottom> \<or> P \<Longrightarrow> x = \<bottom> \<or> P"
40321
d065b195ec89 rename lemmas *_defined_iff and *_strict_iff to *_bottom_iff
huffman
parents: 40216
diff changeset
    81
  by (simp add: rep_bottom_iff)
35653
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    82
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    83
lemma compact_abs_rev: "compact (abs\<cdot>x) \<Longrightarrow> compact x"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    84
proof (unfold compact_def)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    85
  assume "adm (\<lambda>y. \<not> abs\<cdot>x \<sqsubseteq> y)"
40327
1dfdbd66093a renamed {Rep,Abs}_CFun to {Rep,Abs}_cfun
huffman
parents: 40321
diff changeset
    86
  with cont_Rep_cfun2
35653
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    87
  have "adm (\<lambda>y. \<not> abs\<cdot>x \<sqsubseteq> abs\<cdot>y)" by (rule adm_subst)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    88
  then show "adm (\<lambda>y. \<not> x \<sqsubseteq> y)" using abs_below by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    89
qed
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    90
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    91
lemma compact_rep_rev: "compact (rep\<cdot>x) \<Longrightarrow> compact x"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    92
  by (rule iso.compact_abs_rev [OF iso.swap]) (rule iso_axioms)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    93
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    94
lemma compact_abs: "compact x \<Longrightarrow> compact (abs\<cdot>x)"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    95
  by (rule compact_rep_rev) simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    96
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    97
lemma compact_rep: "compact x \<Longrightarrow> compact (rep\<cdot>x)"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    98
  by (rule iso.compact_abs [OF iso.swap]) (rule iso_axioms)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
    99
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   100
lemma iso_swap: "(x = abs\<cdot>y) = (rep\<cdot>x = y)"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   101
proof
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   102
  assume "x = abs\<cdot>y"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   103
  then have "rep\<cdot>x = rep\<cdot>(abs\<cdot>y)" by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   104
  then show "rep\<cdot>x = y" by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   105
next
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   106
  assume "rep\<cdot>x = y"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   107
  then have "abs\<cdot>(rep\<cdot>x) = abs\<cdot>y" by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   108
  then show "x = abs\<cdot>y" by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   109
qed
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   110
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   111
end
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   112
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   113
35652
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   114
subsection {* Proofs about take functions *}
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   115
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   116
text {*
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   117
  This section contains lemmas that are used in a module that supports
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   118
  the domain isomorphism package; the module contains proofs related
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   119
  to take functions and the finiteness predicate.
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   120
*}
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   121
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   122
lemma deflation_abs_rep:
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   123
  fixes abs and rep and d
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   124
  assumes abs_iso: "\<And>x. rep\<cdot>(abs\<cdot>x) = x"
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   125
  assumes rep_iso: "\<And>y. abs\<cdot>(rep\<cdot>y) = y"
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   126
  shows "deflation d \<Longrightarrow> deflation (abs oo d oo rep)"
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   127
by (rule ep_pair.deflation_e_d_p) (simp add: ep_pair.intro assms)
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   128
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   129
lemma deflation_chain_min:
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   130
  assumes chain: "chain d"
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   131
  assumes defl: "\<And>n. deflation (d n)"
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   132
  shows "d m\<cdot>(d n\<cdot>x) = d (min m n)\<cdot>x"
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   133
proof (rule linorder_le_cases)
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   134
  assume "m \<le> n"
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   135
  with chain have "d m \<sqsubseteq> d n" by (rule chain_mono)
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   136
  then have "d m\<cdot>(d n\<cdot>x) = d m\<cdot>x"
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   137
    by (rule deflation_below_comp1 [OF defl defl])
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   138
  moreover from `m \<le> n` have "min m n = m" by simp
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   139
  ultimately show ?thesis by simp
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   140
next
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   141
  assume "n \<le> m"
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   142
  with chain have "d n \<sqsubseteq> d m" by (rule chain_mono)
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   143
  then have "d m\<cdot>(d n\<cdot>x) = d n\<cdot>x"
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   144
    by (rule deflation_below_comp2 [OF defl defl])
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   145
  moreover from `n \<le> m` have "min m n = n" by simp
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   146
  ultimately show ?thesis by simp
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   147
qed
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   148
35653
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   149
lemma lub_ID_take_lemma:
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   150
  assumes "chain t" and "(\<Squnion>n. t n) = ID"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   151
  assumes "\<And>n. t n\<cdot>x = t n\<cdot>y" shows "x = y"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   152
proof -
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   153
  have "(\<Squnion>n. t n\<cdot>x) = (\<Squnion>n. t n\<cdot>y)"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   154
    using assms(3) by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   155
  then have "(\<Squnion>n. t n)\<cdot>x = (\<Squnion>n. t n)\<cdot>y"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   156
    using assms(1) by (simp add: lub_distribs)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   157
  then show "x = y"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   158
    using assms(2) by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   159
qed
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   160
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   161
lemma lub_ID_reach:
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   162
  assumes "chain t" and "(\<Squnion>n. t n) = ID"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   163
  shows "(\<Squnion>n. t n\<cdot>x) = x"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   164
using assms by (simp add: lub_distribs)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   165
35655
e8e4af6da819 generate take_induct lemmas
huffman
parents: 35653
diff changeset
   166
lemma lub_ID_take_induct:
e8e4af6da819 generate take_induct lemmas
huffman
parents: 35653
diff changeset
   167
  assumes "chain t" and "(\<Squnion>n. t n) = ID"
e8e4af6da819 generate take_induct lemmas
huffman
parents: 35653
diff changeset
   168
  assumes "adm P" and "\<And>n. P (t n\<cdot>x)" shows "P x"
e8e4af6da819 generate take_induct lemmas
huffman
parents: 35653
diff changeset
   169
proof -
e8e4af6da819 generate take_induct lemmas
huffman
parents: 35653
diff changeset
   170
  from `chain t` have "chain (\<lambda>n. t n\<cdot>x)" by simp
e8e4af6da819 generate take_induct lemmas
huffman
parents: 35653
diff changeset
   171
  from `adm P` this `\<And>n. P (t n\<cdot>x)` have "P (\<Squnion>n. t n\<cdot>x)" by (rule admD)
e8e4af6da819 generate take_induct lemmas
huffman
parents: 35653
diff changeset
   172
  with `chain t` `(\<Squnion>n. t n) = ID` show "P x" by (simp add: lub_distribs)
e8e4af6da819 generate take_induct lemmas
huffman
parents: 35653
diff changeset
   173
qed
e8e4af6da819 generate take_induct lemmas
huffman
parents: 35653
diff changeset
   174
35653
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   175
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   176
subsection {* Finiteness *}
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   177
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   178
text {*
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   179
  Let a ``decisive'' function be a deflation that maps every input to
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   180
  either itself or bottom.  Then if a domain's take functions are all
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   181
  decisive, then all values in the domain are finite.
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   182
*}
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   183
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   184
definition
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   185
  decisive :: "('a::pcpo \<rightarrow> 'a) \<Rightarrow> bool"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   186
where
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   187
  "decisive d \<longleftrightarrow> (\<forall>x. d\<cdot>x = x \<or> d\<cdot>x = \<bottom>)"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   188
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   189
lemma decisiveI: "(\<And>x. d\<cdot>x = x \<or> d\<cdot>x = \<bottom>) \<Longrightarrow> decisive d"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   190
  unfolding decisive_def by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   191
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   192
lemma decisive_cases:
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   193
  assumes "decisive d" obtains "d\<cdot>x = x" | "d\<cdot>x = \<bottom>"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   194
using assms unfolding decisive_def by auto
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   195
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   196
lemma decisive_bottom: "decisive \<bottom>"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   197
  unfolding decisive_def by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   198
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   199
lemma decisive_ID: "decisive ID"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   200
  unfolding decisive_def by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   201
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   202
lemma decisive_ssum_map:
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   203
  assumes f: "decisive f"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   204
  assumes g: "decisive g"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   205
  shows "decisive (ssum_map\<cdot>f\<cdot>g)"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   206
apply (rule decisiveI, rename_tac s)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   207
apply (case_tac s, simp_all)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   208
apply (rule_tac x=x in decisive_cases [OF f], simp_all)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   209
apply (rule_tac x=y in decisive_cases [OF g], simp_all)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   210
done
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   211
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   212
lemma decisive_sprod_map:
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   213
  assumes f: "decisive f"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   214
  assumes g: "decisive g"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   215
  shows "decisive (sprod_map\<cdot>f\<cdot>g)"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   216
apply (rule decisiveI, rename_tac s)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   217
apply (case_tac s, simp_all)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   218
apply (rule_tac x=x in decisive_cases [OF f], simp_all)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   219
apply (rule_tac x=y in decisive_cases [OF g], simp_all)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   220
done
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   221
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   222
lemma decisive_abs_rep:
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   223
  fixes abs rep
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   224
  assumes iso: "iso abs rep"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   225
  assumes d: "decisive d"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   226
  shows "decisive (abs oo d oo rep)"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   227
apply (rule decisiveI)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   228
apply (rule_tac x="rep\<cdot>x" in decisive_cases [OF d])
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   229
apply (simp add: iso.rep_iso [OF iso])
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   230
apply (simp add: iso.abs_strict [OF iso])
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   231
done
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   232
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   233
lemma lub_ID_finite:
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   234
  assumes chain: "chain d"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   235
  assumes lub: "(\<Squnion>n. d n) = ID"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   236
  assumes decisive: "\<And>n. decisive (d n)"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   237
  shows "\<exists>n. d n\<cdot>x = x"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   238
proof -
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   239
  have 1: "chain (\<lambda>n. d n\<cdot>x)" using chain by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   240
  have 2: "(\<Squnion>n. d n\<cdot>x) = x" using chain lub by (rule lub_ID_reach)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   241
  have "\<forall>n. d n\<cdot>x = x \<or> d n\<cdot>x = \<bottom>"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   242
    using decisive unfolding decisive_def by simp
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   243
  hence "range (\<lambda>n. d n\<cdot>x) \<subseteq> {x, \<bottom>}"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   244
    by auto
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   245
  hence "finite (range (\<lambda>n. d n\<cdot>x))"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   246
    by (rule finite_subset, simp)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   247
  with 1 have "finite_chain (\<lambda>n. d n\<cdot>x)"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   248
    by (rule finite_range_imp_finch)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   249
  then have "\<exists>n. (\<Squnion>n. d n\<cdot>x) = d n\<cdot>x"
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   250
    unfolding finite_chain_def by (auto simp add: maxinch_is_thelub)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   251
  with 2 show "\<exists>n. d n\<cdot>x = x" by (auto elim: sym)
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   252
qed
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   253
35655
e8e4af6da819 generate take_induct lemmas
huffman
parents: 35653
diff changeset
   254
lemma lub_ID_finite_take_induct:
e8e4af6da819 generate take_induct lemmas
huffman
parents: 35653
diff changeset
   255
  assumes "chain d" and "(\<Squnion>n. d n) = ID" and "\<And>n. decisive (d n)"
e8e4af6da819 generate take_induct lemmas
huffman
parents: 35653
diff changeset
   256
  shows "(\<And>n. P (d n\<cdot>x)) \<Longrightarrow> P x"
e8e4af6da819 generate take_induct lemmas
huffman
parents: 35653
diff changeset
   257
using lub_ID_finite [OF assms] by metis
e8e4af6da819 generate take_induct lemmas
huffman
parents: 35653
diff changeset
   258
35653
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   259
subsection {* ML setup *}
f87132febfac move lemmas from Domain.thy to Domain_Aux.thy
huffman
parents: 35652
diff changeset
   260
35652
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   261
use "Tools/Domain/domain_take_proofs.ML"
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   262
40216
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 35655
diff changeset
   263
setup Domain_Take_Proofs.setup
366309dfaf60 use Named_Thms instead of Theory_Data for some domain package theorems
huffman
parents: 35655
diff changeset
   264
35652
05ca920cd94b move take-proofs stuff into new theory Domain_Aux.thy
huffman
parents:
diff changeset
   265
end