src/HOL/HOLCF/FOCUS/Stream_adm.thy
author hoelzl
Tue Jul 19 14:35:44 2011 +0200 (2011-07-19)
changeset 43919 a7e4fb1a0502
parent 42151 4da4fc77664b
child 43921 e8511be08ddd
permissions -rw-r--r--
rename Nat_Infinity (inat) to Extended_Nat (enat)
wenzelm@42151
     1
(*  Title:      HOL/HOLCF/FOCUS/Stream_adm.thy
wenzelm@17293
     2
    Author:     David von Oheimb, TU Muenchen
oheimb@11350
     3
*)
oheimb@11350
     4
wenzelm@17293
     5
header {* Admissibility for streams *}
oheimb@11350
     6
wenzelm@17293
     7
theory Stream_adm
wenzelm@41413
     8
imports "~~/src/HOL/HOLCF/Library/Stream" "~~/src/HOL/Library/Continuity"
wenzelm@17293
     9
begin
oheimb@11350
    10
wenzelm@19763
    11
definition
wenzelm@21404
    12
  stream_monoP  :: "(('a stream) set \<Rightarrow> ('a stream) set) \<Rightarrow> bool" where
wenzelm@19763
    13
  "stream_monoP F = (\<exists>Q i. \<forall>P s. Fin i \<le> #s \<longrightarrow>
wenzelm@19763
    14
                    (s \<in> F P) = (stream_take i\<cdot>s \<in> Q \<and> iterate i\<cdot>rt\<cdot>s \<in> P))"
wenzelm@17293
    15
wenzelm@21404
    16
definition
wenzelm@21404
    17
  stream_antiP  :: "(('a stream) set \<Rightarrow> ('a stream) set) \<Rightarrow> bool" where
wenzelm@19763
    18
  "stream_antiP F = (\<forall>P x. \<exists>Q i.
wenzelm@17293
    19
                (#x  < Fin i \<longrightarrow> (\<forall>y. x \<sqsubseteq> y \<longrightarrow> y \<in> F P \<longrightarrow> x \<in> F P)) \<and>
wenzelm@17293
    20
                (Fin i <= #x \<longrightarrow> (\<forall>y. x \<sqsubseteq> y \<longrightarrow>
wenzelm@19763
    21
                (y \<in> F P) = (stream_take i\<cdot>y \<in> Q \<and> iterate i\<cdot>rt\<cdot>y \<in> P))))"
wenzelm@17293
    22
wenzelm@21404
    23
definition
wenzelm@21404
    24
  antitonP :: "'a set => bool" where
wenzelm@19763
    25
  "antitonP P = (\<forall>x y. x \<sqsubseteq> y \<longrightarrow> y\<in>P \<longrightarrow> x\<in>P)"
wenzelm@17293
    26
wenzelm@17293
    27
huffman@19759
    28
(* ----------------------------------------------------------------------- *)
huffman@19759
    29
huffman@19759
    30
section "admissibility"
huffman@19759
    31
huffman@40430
    32
lemma infinite_chain_adm_lemma:
huffman@40430
    33
  "\<lbrakk>Porder.chain Y; \<forall>i. P (Y i);  
huffman@40430
    34
    \<And>Y. \<lbrakk>Porder.chain Y; \<forall>i. P (Y i); \<not> finite_chain Y\<rbrakk> \<Longrightarrow> P (\<Squnion>i. Y i)\<rbrakk>
huffman@40430
    35
      \<Longrightarrow> P (\<Squnion>i. Y i)"
huffman@40430
    36
apply (case_tac "finite_chain Y")
huffman@40430
    37
prefer 2 apply fast
huffman@40430
    38
apply (unfold finite_chain_def)
huffman@40430
    39
apply safe
huffman@40771
    40
apply (erule lub_finch1 [THEN lub_eqI, THEN ssubst])
huffman@40430
    41
apply assumption
huffman@40430
    42
apply (erule spec)
huffman@40430
    43
done
huffman@40430
    44
huffman@40430
    45
lemma increasing_chain_adm_lemma:
huffman@40430
    46
  "\<lbrakk>Porder.chain Y;  \<forall>i. P (Y i); \<And>Y. \<lbrakk>Porder.chain Y; \<forall>i. P (Y i);
huffman@40430
    47
    \<forall>i. \<exists>j>i. Y i \<noteq> Y j \<and> Y i \<sqsubseteq> Y j\<rbrakk> \<Longrightarrow> P (\<Squnion>i. Y i)\<rbrakk>
huffman@40430
    48
      \<Longrightarrow> P (\<Squnion>i. Y i)"
huffman@40430
    49
apply (erule infinite_chain_adm_lemma)
huffman@40430
    50
apply assumption
huffman@40430
    51
apply (erule thin_rl)
huffman@40430
    52
apply (unfold finite_chain_def)
huffman@40430
    53
apply (unfold max_in_chain_def)
huffman@40430
    54
apply (fast dest: le_imp_less_or_eq elim: chain_mono_less)
huffman@40430
    55
done
huffman@40430
    56
huffman@19759
    57
lemma flatstream_adm_lemma:
wenzelm@26451
    58
  assumes 1: "Porder.chain Y"
huffman@19759
    59
  assumes 2: "!i. P (Y i)"
wenzelm@26451
    60
  assumes 3: "(!!Y. [| Porder.chain Y; !i. P (Y i); !k. ? j. Fin k < #((Y j)::'a::flat stream)|]
huffman@27413
    61
  ==> P(LUB i. Y i))"
huffman@27413
    62
  shows "P(LUB i. Y i)"
berghofe@26838
    63
apply (rule increasing_chain_adm_lemma [of _ P, OF 1 2])
huffman@19759
    64
apply (erule 3, assumption)
huffman@19759
    65
apply (erule thin_rl)
huffman@19759
    66
apply (rule allI)
huffman@19759
    67
apply (case_tac "!j. stream_finite (Y j)")
huffman@19759
    68
apply ( rule chain_incr)
huffman@19759
    69
apply ( rule allI)
huffman@19759
    70
apply ( drule spec)
huffman@19759
    71
apply ( safe)
huffman@19759
    72
apply ( rule exI)
huffman@19759
    73
apply ( rule slen_strict_mono)
huffman@19759
    74
apply (   erule spec)
huffman@19759
    75
apply (  assumption)
huffman@19759
    76
apply ( assumption)
hoelzl@43919
    77
apply (metis enat_ord_code(4) slen_infinite)
huffman@19759
    78
done
huffman@19759
    79
huffman@19759
    80
(* should be without reference to stream length? *)
wenzelm@26451
    81
lemma flatstream_admI: "[|(!!Y. [| Porder.chain Y; !i. P (Y i); 
huffman@27413
    82
 !k. ? j. Fin k < #((Y j)::'a::flat stream)|] ==> P(LUB i. Y i))|]==> adm P"
huffman@19759
    83
apply (unfold adm_def)
huffman@19759
    84
apply (intro strip)
huffman@19759
    85
apply (erule (1) flatstream_adm_lemma)
huffman@19759
    86
apply (fast)
huffman@19759
    87
done
huffman@19759
    88
huffman@19759
    89
huffman@19759
    90
(* context (theory "Nat_InFinity");*)
huffman@19759
    91
lemma ile_lemma: "Fin (i + j) <= x ==> Fin i <= x"
haftmann@27101
    92
  by (rule order_trans) auto
huffman@19759
    93
huffman@19759
    94
lemma stream_monoP2I:
huffman@19759
    95
"!!X. stream_monoP F ==> !i. ? l. !x y. 
huffman@19759
    96
  Fin l <= #x --> (x::'a::flat stream) << y --> x:down_iterate F i --> y:down_iterate F i"
huffman@19759
    97
apply (unfold stream_monoP_def)
huffman@19759
    98
apply (safe)
huffman@19759
    99
apply (rule_tac x="i*ia" in exI)
huffman@19759
   100
apply (induct_tac "ia")
huffman@19759
   101
apply ( simp)
huffman@19759
   102
apply (simp)
huffman@19759
   103
apply (intro strip)
huffman@19759
   104
apply (erule allE, erule all_dupE, drule mp, erule ile_lemma)
huffman@19759
   105
apply (drule_tac P="%x. x" in subst, assumption)
huffman@19759
   106
apply (erule allE, drule mp, rule ile_lemma) back
haftmann@27101
   107
apply ( erule order_trans)
huffman@19759
   108
apply ( erule slen_mono)
huffman@19759
   109
apply (erule ssubst)
huffman@19759
   110
apply (safe)
huffman@19759
   111
apply ( erule (2) ile_lemma [THEN slen_take_lemma3, THEN subst])
huffman@19759
   112
apply (erule allE)
huffman@19759
   113
apply (drule mp)
huffman@19759
   114
apply ( erule slen_rt_mult)
huffman@19759
   115
apply (erule allE)
huffman@19759
   116
apply (drule mp)
huffman@19759
   117
apply (erule monofun_rt_mult)
huffman@19759
   118
apply (drule (1) mp)
huffman@19759
   119
apply (assumption)
huffman@19759
   120
done
huffman@19759
   121
huffman@19759
   122
lemma stream_monoP2_gfp_admI: "[| !i. ? l. !x y. 
huffman@19759
   123
 Fin l <= #x --> (x::'a::flat stream) << y --> x:down_iterate F i --> y:down_iterate F i;
huffman@19759
   124
    down_cont F |] ==> adm (%x. x:gfp F)"
huffman@19759
   125
apply (erule INTER_down_iterate_is_gfp [THEN ssubst]) (* cont *)
huffman@19759
   126
apply (simp (no_asm))
huffman@19759
   127
apply (rule adm_lemmas)
huffman@19759
   128
apply (rule flatstream_admI)
huffman@19759
   129
apply (erule allE)
huffman@19759
   130
apply (erule exE)
huffman@19759
   131
apply (erule allE, erule exE)
huffman@19759
   132
apply (erule allE, erule allE, drule mp) (* stream_monoP *)
huffman@19759
   133
apply ( drule ileI1)
haftmann@27101
   134
apply ( drule order_trans)
huffman@19759
   135
apply (  rule ile_iSuc)
huffman@19759
   136
apply ( drule iSuc_ile_mono [THEN iffD1])
huffman@19759
   137
apply ( assumption)
huffman@19759
   138
apply (drule mp)
huffman@19759
   139
apply ( erule is_ub_thelub)
huffman@19759
   140
apply (fast)
huffman@19759
   141
done
huffman@19759
   142
huffman@19759
   143
lemmas fstream_gfp_admI = stream_monoP2I [THEN stream_monoP2_gfp_admI]
huffman@19759
   144
huffman@19759
   145
lemma stream_antiP2I:
huffman@19759
   146
"!!X. [|stream_antiP (F::(('a::flat stream)set => ('a stream set)))|]
huffman@19759
   147
  ==> !i x y. x << y --> y:down_iterate F i --> x:down_iterate F i"
huffman@19759
   148
apply (unfold stream_antiP_def)
huffman@19759
   149
apply (rule allI)
huffman@19759
   150
apply (induct_tac "i")
huffman@19759
   151
apply ( simp)
huffman@19759
   152
apply (simp)
huffman@19759
   153
apply (intro strip)
huffman@19759
   154
apply (erule allE, erule all_dupE, erule exE, erule exE)
huffman@19759
   155
apply (erule conjE)
huffman@19759
   156
apply (case_tac "#x < Fin i")
huffman@19759
   157
apply ( fast)
huffman@26102
   158
apply (unfold linorder_not_less)
huffman@19759
   159
apply (drule (1) mp)
huffman@40431
   160
apply (erule all_dupE, drule mp, rule below_refl)
huffman@19759
   161
apply (erule ssubst)
huffman@19759
   162
apply (erule allE, drule (1) mp)
huffman@19759
   163
apply (drule_tac P="%x. x" in subst, assumption)
huffman@19759
   164
apply (erule conjE, rule conjI)
huffman@19759
   165
apply ( erule slen_take_lemma3 [THEN ssubst], assumption)
huffman@19759
   166
apply ( assumption)
huffman@19759
   167
apply (erule allE, erule allE, drule mp, erule monofun_rt_mult)
huffman@19759
   168
apply (drule (1) mp)
huffman@19759
   169
apply (assumption)
huffman@19759
   170
done
huffman@19759
   171
huffman@19759
   172
lemma stream_antiP2_non_gfp_admI:
huffman@19759
   173
"!!X. [|!i x y. x << y --> y:down_iterate F i --> x:down_iterate F i; down_cont F |] 
huffman@19759
   174
  ==> adm (%u. ~ u:gfp F)"
huffman@19759
   175
apply (unfold adm_def)
huffman@19759
   176
apply (simp add: INTER_down_iterate_is_gfp)
huffman@19759
   177
apply (fast dest!: is_ub_thelub)
huffman@19759
   178
done
huffman@19759
   179
huffman@19759
   180
lemmas fstream_non_gfp_admI = stream_antiP2I [THEN stream_antiP2_non_gfp_admI]
huffman@19759
   181
huffman@19759
   182
huffman@19759
   183
huffman@19759
   184
(**new approach for adm********************************************************)
huffman@19759
   185
huffman@19759
   186
section "antitonP"
huffman@19759
   187
huffman@19759
   188
lemma antitonPD: "[| antitonP P; y:P; x<<y |] ==> x:P"
huffman@19759
   189
apply (unfold antitonP_def)
huffman@19759
   190
apply auto
huffman@19759
   191
done
huffman@19759
   192
huffman@19759
   193
lemma antitonPI: "!x y. y:P --> x<<y --> x:P ==> antitonP P"
huffman@19759
   194
apply (unfold antitonP_def)
huffman@19759
   195
apply (fast)
huffman@19759
   196
done
huffman@19759
   197
huffman@19759
   198
lemma antitonP_adm_non_P: "antitonP P ==> adm (%u. u~:P)"
huffman@19759
   199
apply (unfold adm_def)
huffman@19759
   200
apply (auto dest: antitonPD elim: is_ub_thelub)
huffman@19759
   201
done
huffman@19759
   202
huffman@19759
   203
lemma def_gfp_adm_nonP: "P \<equiv> gfp F \<Longrightarrow> {y. \<exists>x::'a::pcpo. y \<sqsubseteq> x \<and> x \<in> P} \<subseteq> F {y. \<exists>x. y \<sqsubseteq> x \<and> x \<in> P} \<Longrightarrow> 
huffman@19759
   204
  adm (\<lambda>u. u\<notin>P)"
huffman@19759
   205
apply (simp)
huffman@19759
   206
apply (rule antitonP_adm_non_P)
huffman@19759
   207
apply (rule antitonPI)
huffman@19759
   208
apply (drule gfp_upperbound)
huffman@19759
   209
apply (fast)
huffman@19759
   210
done
huffman@19759
   211
huffman@19759
   212
lemma adm_set:
huffman@27413
   213
"{\<Squnion>i. Y i |Y. Porder.chain Y & (\<forall>i. Y i \<in> P)} \<subseteq> P \<Longrightarrow> adm (\<lambda>x. x\<in>P)"
huffman@19759
   214
apply (unfold adm_def)
huffman@19759
   215
apply (fast)
huffman@19759
   216
done
huffman@19759
   217
huffman@27413
   218
lemma def_gfp_admI: "P \<equiv> gfp F \<Longrightarrow> {\<Squnion>i. Y i |Y. Porder.chain Y \<and> (\<forall>i. Y i \<in> P)} \<subseteq> 
huffman@27413
   219
  F {\<Squnion>i. Y i |Y. Porder.chain Y \<and> (\<forall>i. Y i \<in> P)} \<Longrightarrow> adm (\<lambda>x. x\<in>P)"
huffman@19759
   220
apply (simp)
huffman@19759
   221
apply (rule adm_set)
huffman@19759
   222
apply (erule gfp_upperbound)
huffman@19759
   223
done
huffman@19759
   224
oheimb@11350
   225
end