src/HOLCF/Adm.thy
author huffman
Mon Oct 04 06:58:37 2010 -0700 (2010-10-04)
changeset 39969 0b8e19f588a4
parent 36452 d37c6eed8117
child 40007 bb04a995bbd3
permissions -rw-r--r--
new lemmas about lub
huffman@16056
     1
(*  Title:      HOLCF/Adm.thy
huffman@25895
     2
    Author:     Franz Regensburger and Brian Huffman
huffman@16056
     3
*)
huffman@16056
     4
huffman@17814
     5
header {* Admissibility and compactness *}
huffman@16056
     6
huffman@16056
     7
theory Adm
huffman@27181
     8
imports Cont
huffman@16056
     9
begin
huffman@16056
    10
wenzelm@36452
    11
default_sort cpo
huffman@16056
    12
huffman@16056
    13
subsection {* Definitions *}
huffman@16056
    14
wenzelm@25131
    15
definition
wenzelm@25131
    16
  adm :: "('a::cpo \<Rightarrow> bool) \<Rightarrow> bool" where
wenzelm@25131
    17
  "adm P = (\<forall>Y. chain Y \<longrightarrow> (\<forall>i. P (Y i)) \<longrightarrow> P (\<Squnion>i. Y i))"
huffman@16056
    18
huffman@16056
    19
lemma admI:
huffman@16623
    20
   "(\<And>Y. \<lbrakk>chain Y; \<forall>i. P (Y i)\<rbrakk> \<Longrightarrow> P (\<Squnion>i. Y i)) \<Longrightarrow> adm P"
huffman@25895
    21
unfolding adm_def by fast
huffman@25895
    22
huffman@25925
    23
lemma admD: "\<lbrakk>adm P; chain Y; \<And>i. P (Y i)\<rbrakk> \<Longrightarrow> P (\<Squnion>i. Y i)"
huffman@25895
    24
unfolding adm_def by fast
huffman@16056
    25
huffman@27181
    26
lemma admD2: "\<lbrakk>adm (\<lambda>x. \<not> P x); chain Y; P (\<Squnion>i. Y i)\<rbrakk> \<Longrightarrow> \<exists>i. P (Y i)"
huffman@27181
    27
unfolding adm_def by fast
huffman@27181
    28
huffman@16565
    29
lemma triv_admI: "\<forall>x. P x \<Longrightarrow> adm P"
huffman@17814
    30
by (rule admI, erule spec)
huffman@16056
    31
huffman@16623
    32
text {* improved admissibility introduction *}
huffman@16623
    33
huffman@16623
    34
lemma admI2:
huffman@16623
    35
  "(\<And>Y. \<lbrakk>chain Y; \<forall>i. P (Y i); \<forall>i. \<exists>j>i. Y i \<noteq> Y j \<and> Y i \<sqsubseteq> Y j\<rbrakk> 
huffman@16623
    36
    \<Longrightarrow> P (\<Squnion>i. Y i)) \<Longrightarrow> adm P"
huffman@16623
    37
apply (rule admI)
huffman@16623
    38
apply (erule (1) increasing_chain_adm_lemma)
huffman@16623
    39
apply fast
huffman@16623
    40
done
huffman@16623
    41
huffman@16623
    42
subsection {* Admissibility on chain-finite types *}
huffman@16623
    43
huffman@16056
    44
text {* for chain-finite (easy) types every formula is admissible *}
huffman@16056
    45
huffman@25921
    46
lemma adm_chfin: "adm (P::'a::chfin \<Rightarrow> bool)"
huffman@25921
    47
by (rule admI, frule chfin, auto simp add: maxinch_is_thelub)
huffman@16056
    48
huffman@16623
    49
subsection {* Admissibility of special formulae and propagation *}
huffman@16056
    50
huffman@17814
    51
lemma adm_not_free: "adm (\<lambda>x. t)"
huffman@17814
    52
by (rule admI, simp)
huffman@16056
    53
huffman@16565
    54
lemma adm_conj: "\<lbrakk>adm P; adm Q\<rbrakk> \<Longrightarrow> adm (\<lambda>x. P x \<and> Q x)"
huffman@25925
    55
by (fast intro: admI elim: admD)
huffman@16056
    56
huffman@27290
    57
lemma adm_all: "(\<And>y. adm (\<lambda>x. P x y)) \<Longrightarrow> adm (\<lambda>x. \<forall>y. P x y)"
huffman@16056
    58
by (fast intro: admI elim: admD)
huffman@16056
    59
huffman@27290
    60
lemma adm_ball: "(\<And>y. y \<in> A \<Longrightarrow> adm (\<lambda>x. P x y)) \<Longrightarrow> adm (\<lambda>x. \<forall>y\<in>A. P x y)"
huffman@17586
    61
by (fast intro: admI elim: admD)
huffman@17586
    62
huffman@17814
    63
text {* Admissibility for disjunction is hard to prove. It takes 5 Lemmas *}
huffman@16056
    64
huffman@17814
    65
lemma adm_disj_lemma1: 
huffman@16623
    66
  "\<lbrakk>chain (Y::nat \<Rightarrow> 'a::cpo); \<forall>i. \<exists>j\<ge>i. P (Y j)\<rbrakk>
huffman@17814
    67
    \<Longrightarrow> chain (\<lambda>i. Y (LEAST j. i \<le> j \<and> P (Y j)))"
huffman@16056
    68
apply (rule chainI)
huffman@25922
    69
apply (erule chain_mono)
huffman@16056
    70
apply (rule Least_le)
huffman@17814
    71
apply (rule LeastI2_ex)
huffman@17814
    72
apply simp_all
huffman@16056
    73
done
huffman@16056
    74
huffman@17814
    75
lemmas adm_disj_lemma2 = LeastI_ex [of "\<lambda>j. i \<le> j \<and> P (Y j)", standard]
huffman@17814
    76
huffman@17814
    77
lemma adm_disj_lemma3: 
huffman@16623
    78
  "\<lbrakk>chain (Y::nat \<Rightarrow> 'a::cpo); \<forall>i. \<exists>j\<ge>i. P (Y j)\<rbrakk> \<Longrightarrow> 
huffman@17814
    79
    (\<Squnion>i. Y i) = (\<Squnion>i. Y (LEAST j. i \<le> j \<and> P (Y j)))"
huffman@17814
    80
 apply (frule (1) adm_disj_lemma1)
huffman@31076
    81
 apply (rule below_antisym)
huffman@25923
    82
  apply (rule lub_mono, assumption+)
huffman@25922
    83
  apply (erule chain_mono)
huffman@17814
    84
  apply (simp add: adm_disj_lemma2)
huffman@17814
    85
 apply (rule lub_range_mono, fast, assumption+)
huffman@16056
    86
done
huffman@16056
    87
huffman@17814
    88
lemma adm_disj_lemma4:
huffman@17814
    89
  "\<lbrakk>adm P; chain Y; \<forall>i. \<exists>j\<ge>i. P (Y j)\<rbrakk> \<Longrightarrow> P (\<Squnion>i. Y i)"
huffman@17814
    90
apply (subst adm_disj_lemma3, assumption+)
huffman@17814
    91
apply (erule admD)
huffman@17814
    92
apply (simp add: adm_disj_lemma1)
huffman@17814
    93
apply (simp add: adm_disj_lemma2)
huffman@16056
    94
done
huffman@16056
    95
huffman@17814
    96
lemma adm_disj_lemma5:
huffman@17814
    97
  "\<forall>n::nat. P n \<or> Q n \<Longrightarrow> (\<forall>i. \<exists>j\<ge>i. P j) \<or> (\<forall>i. \<exists>j\<ge>i. Q j)"
huffman@17814
    98
apply (erule contrapos_pp)
huffman@17814
    99
apply (clarsimp, rename_tac a b)
huffman@17814
   100
apply (rule_tac x="max a b" in exI)
huffman@25895
   101
apply simp
huffman@16056
   102
done
huffman@16056
   103
huffman@16623
   104
lemma adm_disj: "\<lbrakk>adm P; adm Q\<rbrakk> \<Longrightarrow> adm (\<lambda>x. P x \<or> Q x)"
huffman@16056
   105
apply (rule admI)
huffman@17814
   106
apply (erule adm_disj_lemma5 [THEN disjE])
huffman@17814
   107
apply (erule (2) adm_disj_lemma4 [THEN disjI1])
huffman@17814
   108
apply (erule (2) adm_disj_lemma4 [THEN disjI2])
huffman@16056
   109
done
huffman@16056
   110
huffman@16565
   111
lemma adm_imp: "\<lbrakk>adm (\<lambda>x. \<not> P x); adm Q\<rbrakk> \<Longrightarrow> adm (\<lambda>x. P x \<longrightarrow> Q x)"
huffman@16056
   112
by (subst imp_conv_disj, rule adm_disj)
huffman@16056
   113
huffman@16565
   114
lemma adm_iff:
huffman@16565
   115
  "\<lbrakk>adm (\<lambda>x. P x \<longrightarrow> Q x); adm (\<lambda>x. Q x \<longrightarrow> P x)\<rbrakk>  
huffman@16565
   116
    \<Longrightarrow> adm (\<lambda>x. P x = Q x)"
huffman@16056
   117
by (subst iff_conv_conj_imp, rule adm_conj)
huffman@16056
   118
huffman@16565
   119
lemma adm_not_conj:
huffman@16565
   120
  "\<lbrakk>adm (\<lambda>x. \<not> P x); adm (\<lambda>x. \<not> Q x)\<rbrakk> \<Longrightarrow> adm (\<lambda>x. \<not> (P x \<and> Q x))"
huffman@17814
   121
by (simp add: adm_imp)
huffman@17814
   122
huffman@17814
   123
text {* admissibility and continuity *}
huffman@17814
   124
huffman@31076
   125
lemma adm_below: "\<lbrakk>cont u; cont v\<rbrakk> \<Longrightarrow> adm (\<lambda>x. u x \<sqsubseteq> v x)"
huffman@17814
   126
apply (rule admI)
huffman@17814
   127
apply (simp add: cont2contlubE)
huffman@17814
   128
apply (rule lub_mono)
huffman@17814
   129
apply (erule (1) ch2ch_cont)
huffman@17814
   130
apply (erule (1) ch2ch_cont)
huffman@25923
   131
apply (erule spec)
huffman@17814
   132
done
huffman@17814
   133
huffman@17814
   134
lemma adm_eq: "\<lbrakk>cont u; cont v\<rbrakk> \<Longrightarrow> adm (\<lambda>x. u x = v x)"
huffman@31076
   135
by (simp add: po_eq_conv adm_conj adm_below)
huffman@17814
   136
huffman@17814
   137
lemma adm_subst: "\<lbrakk>cont t; adm P\<rbrakk> \<Longrightarrow> adm (\<lambda>x. P (t x))"
huffman@17814
   138
apply (rule admI)
huffman@17814
   139
apply (simp add: cont2contlubE)
huffman@17814
   140
apply (erule admD)
huffman@17814
   141
apply (erule (1) ch2ch_cont)
huffman@25925
   142
apply (erule spec)
huffman@17814
   143
done
huffman@16056
   144
huffman@31076
   145
lemma adm_not_below: "cont t \<Longrightarrow> adm (\<lambda>x. \<not> t x \<sqsubseteq> u)"
huffman@17814
   146
apply (rule admI)
huffman@17814
   147
apply (drule_tac x=0 in spec)
huffman@17814
   148
apply (erule contrapos_nn)
huffman@31076
   149
apply (erule rev_below_trans)
huffman@25786
   150
apply (erule cont2mono [THEN monofunE])
huffman@17814
   151
apply (erule is_ub_thelub)
huffman@17814
   152
done
huffman@17814
   153
huffman@25880
   154
subsection {* Compactness *}
huffman@25880
   155
huffman@25880
   156
definition
huffman@25880
   157
  compact :: "'a::cpo \<Rightarrow> bool" where
huffman@25880
   158
  "compact k = adm (\<lambda>x. \<not> k \<sqsubseteq> x)"
huffman@25880
   159
huffman@25880
   160
lemma compactI: "adm (\<lambda>x. \<not> k \<sqsubseteq> x) \<Longrightarrow> compact k"
huffman@25880
   161
unfolding compact_def .
huffman@25880
   162
huffman@25880
   163
lemma compactD: "compact k \<Longrightarrow> adm (\<lambda>x. \<not> k \<sqsubseteq> x)"
huffman@25880
   164
unfolding compact_def .
huffman@25880
   165
huffman@25880
   166
lemma compactI2:
huffman@27413
   167
  "(\<And>Y. \<lbrakk>chain Y; x \<sqsubseteq> (\<Squnion>i. Y i)\<rbrakk> \<Longrightarrow> \<exists>i. x \<sqsubseteq> Y i) \<Longrightarrow> compact x"
huffman@25880
   168
unfolding compact_def adm_def by fast
huffman@25880
   169
huffman@25880
   170
lemma compactD2:
huffman@27413
   171
  "\<lbrakk>compact x; chain Y; x \<sqsubseteq> (\<Squnion>i. Y i)\<rbrakk> \<Longrightarrow> \<exists>i. x \<sqsubseteq> Y i"
huffman@25880
   172
unfolding compact_def adm_def by fast
huffman@25880
   173
huffman@39969
   174
lemma compact_below_lub_iff:
huffman@39969
   175
  "\<lbrakk>compact x; chain Y\<rbrakk> \<Longrightarrow> x \<sqsubseteq> (\<Squnion>i. Y i) \<longleftrightarrow> (\<exists>i. x \<sqsubseteq> Y i)"
huffman@39969
   176
by (fast intro: compactD2 elim: below_trans is_ub_thelub)
huffman@39969
   177
huffman@25880
   178
lemma compact_chfin [simp]: "compact (x::'a::chfin)"
huffman@25880
   179
by (rule compactI [OF adm_chfin])
huffman@25880
   180
huffman@25880
   181
lemma compact_imp_max_in_chain:
huffman@25880
   182
  "\<lbrakk>chain Y; compact (\<Squnion>i. Y i)\<rbrakk> \<Longrightarrow> \<exists>i. max_in_chain i Y"
huffman@25880
   183
apply (drule (1) compactD2, simp)
huffman@25880
   184
apply (erule exE, rule_tac x=i in exI)
huffman@25880
   185
apply (rule max_in_chainI)
huffman@31076
   186
apply (rule below_antisym)
huffman@25922
   187
apply (erule (1) chain_mono)
huffman@31076
   188
apply (erule (1) below_trans [OF is_ub_thelub])
huffman@25880
   189
done
huffman@25880
   190
huffman@17814
   191
text {* admissibility and compactness *}
huffman@17814
   192
huffman@31076
   193
lemma adm_compact_not_below: "\<lbrakk>compact k; cont t\<rbrakk> \<Longrightarrow> adm (\<lambda>x. \<not> k \<sqsubseteq> t x)"
huffman@25880
   194
unfolding compact_def by (rule adm_subst)
huffman@16056
   195
huffman@17814
   196
lemma adm_neq_compact: "\<lbrakk>compact k; cont t\<rbrakk> \<Longrightarrow> adm (\<lambda>x. t x \<noteq> k)"
huffman@31076
   197
by (simp add: po_eq_conv adm_imp adm_not_below adm_compact_not_below)
huffman@17814
   198
huffman@17814
   199
lemma adm_compact_neq: "\<lbrakk>compact k; cont t\<rbrakk> \<Longrightarrow> adm (\<lambda>x. k \<noteq> t x)"
huffman@31076
   200
by (simp add: po_eq_conv adm_imp adm_not_below adm_compact_not_below)
huffman@17814
   201
huffman@17814
   202
lemma compact_UU [simp, intro]: "compact \<bottom>"
huffman@17814
   203
by (rule compactI, simp add: adm_not_free)
huffman@17814
   204
huffman@19440
   205
lemma adm_not_UU: "cont t \<Longrightarrow> adm (\<lambda>x. t x \<noteq> \<bottom>)"
huffman@19440
   206
by (simp add: adm_neq_compact)
huffman@17814
   207
huffman@25802
   208
text {* Any upward-closed predicate is admissible. *}
huffman@25802
   209
huffman@25802
   210
lemma adm_upward:
huffman@25802
   211
  assumes P: "\<And>x y. \<lbrakk>P x; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> P y"
huffman@25802
   212
  shows "adm P"
huffman@25802
   213
by (rule admI, drule spec, erule P, erule is_ub_thelub)
huffman@25802
   214
huffman@17814
   215
lemmas adm_lemmas [simp] =
huffman@25895
   216
  adm_not_free adm_conj adm_all adm_ball adm_disj adm_imp adm_iff
huffman@31076
   217
  adm_below adm_eq adm_not_below
huffman@31076
   218
  adm_compact_not_below adm_compact_neq adm_neq_compact adm_not_UU
huffman@16056
   219
huffman@16056
   220
end