src/HOLCF/Adm.thy
author huffman
Tue Oct 12 07:46:44 2010 -0700 (2010-10-12)
changeset 40007 bb04a995bbd3
parent 39969 0b8e19f588a4
child 40430 483a4876e428
permissions -rw-r--r--
cleaned up Adm.thy
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@40007
    51
lemma adm_const [simp]: "adm (\<lambda>x. t)"
huffman@17814
    52
by (rule admI, simp)
huffman@16056
    53
huffman@40007
    54
lemma adm_conj [simp]:
huffman@40007
    55
  "\<lbrakk>adm (\<lambda>x. P x); adm (\<lambda>x. Q x)\<rbrakk> \<Longrightarrow> adm (\<lambda>x. P x \<and> Q x)"
huffman@25925
    56
by (fast intro: admI elim: admD)
huffman@16056
    57
huffman@40007
    58
lemma adm_all [simp]:
huffman@40007
    59
  "(\<And>y. adm (\<lambda>x. P x y)) \<Longrightarrow> adm (\<lambda>x. \<forall>y. P x y)"
huffman@16056
    60
by (fast intro: admI elim: admD)
huffman@16056
    61
huffman@40007
    62
lemma adm_ball [simp]:
huffman@40007
    63
  "(\<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
    64
by (fast intro: admI elim: admD)
huffman@17586
    65
huffman@40007
    66
text {* Admissibility for disjunction is hard to prove. It requires 2 lemmas. *}
huffman@17814
    67
huffman@40007
    68
lemma adm_disj_lemma1:
huffman@40007
    69
  assumes adm: "adm P"
huffman@40007
    70
  assumes chain: "chain Y"
huffman@40007
    71
  assumes P: "\<forall>i. \<exists>j\<ge>i. P (Y j)"
huffman@40007
    72
  shows "P (\<Squnion>i. Y i)"
huffman@40007
    73
proof -
huffman@40007
    74
  def f \<equiv> "\<lambda>i. LEAST j. i \<le> j \<and> P (Y j)"
huffman@40007
    75
  have chain': "chain (\<lambda>i. Y (f i))"
huffman@40007
    76
    unfolding f_def
huffman@40007
    77
    apply (rule chainI)
huffman@40007
    78
    apply (rule chain_mono [OF chain])
huffman@40007
    79
    apply (rule Least_le)
huffman@40007
    80
    apply (rule LeastI2_ex)
huffman@40007
    81
    apply (simp_all add: P)
huffman@40007
    82
    done
huffman@40007
    83
  have f1: "\<And>i. i \<le> f i" and f2: "\<And>i. P (Y (f i))"
huffman@40007
    84
    using LeastI_ex [OF P [rule_format]] by (simp_all add: f_def)
huffman@40007
    85
  have lub_eq: "(\<Squnion>i. Y i) = (\<Squnion>i. Y (f i))"
huffman@40007
    86
    apply (rule below_antisym)
huffman@40007
    87
    apply (rule lub_mono [OF chain chain'])
huffman@40007
    88
    apply (rule chain_mono [OF chain f1])
huffman@40007
    89
    apply (rule lub_range_mono [OF _ chain chain'])
huffman@40007
    90
    apply clarsimp
huffman@40007
    91
    done
huffman@40007
    92
  show "P (\<Squnion>i. Y i)"
huffman@40007
    93
    unfolding lub_eq using adm chain' f2 by (rule admD)
huffman@40007
    94
qed
huffman@16056
    95
huffman@40007
    96
lemma adm_disj_lemma2:
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@40007
   104
lemma adm_disj [simp]:
huffman@40007
   105
  "\<lbrakk>adm (\<lambda>x. P x); adm (\<lambda>x. Q x)\<rbrakk> \<Longrightarrow> adm (\<lambda>x. P x \<or> Q x)"
huffman@16056
   106
apply (rule admI)
huffman@40007
   107
apply (erule adm_disj_lemma2 [THEN disjE])
huffman@40007
   108
apply (erule (2) adm_disj_lemma1 [THEN disjI1])
huffman@40007
   109
apply (erule (2) adm_disj_lemma1 [THEN disjI2])
huffman@16056
   110
done
huffman@16056
   111
huffman@40007
   112
lemma adm_imp [simp]:
huffman@40007
   113
  "\<lbrakk>adm (\<lambda>x. \<not> P x); adm (\<lambda>x. Q x)\<rbrakk> \<Longrightarrow> adm (\<lambda>x. P x \<longrightarrow> Q x)"
huffman@16056
   114
by (subst imp_conv_disj, rule adm_disj)
huffman@16056
   115
huffman@40007
   116
lemma adm_iff [simp]:
huffman@16565
   117
  "\<lbrakk>adm (\<lambda>x. P x \<longrightarrow> Q x); adm (\<lambda>x. Q x \<longrightarrow> P x)\<rbrakk>  
huffman@16565
   118
    \<Longrightarrow> adm (\<lambda>x. P x = Q x)"
huffman@16056
   119
by (subst iff_conv_conj_imp, rule adm_conj)
huffman@16056
   120
huffman@17814
   121
text {* admissibility and continuity *}
huffman@17814
   122
huffman@40007
   123
lemma adm_below [simp]:
huffman@40007
   124
  "\<lbrakk>cont (\<lambda>x. u x); cont (\<lambda>x. v x)\<rbrakk> \<Longrightarrow> adm (\<lambda>x. u x \<sqsubseteq> v x)"
huffman@17814
   125
apply (rule admI)
huffman@17814
   126
apply (simp add: cont2contlubE)
huffman@17814
   127
apply (rule lub_mono)
huffman@17814
   128
apply (erule (1) ch2ch_cont)
huffman@17814
   129
apply (erule (1) ch2ch_cont)
huffman@25923
   130
apply (erule spec)
huffman@17814
   131
done
huffman@17814
   132
huffman@40007
   133
lemma adm_eq [simp]:
huffman@40007
   134
  "\<lbrakk>cont (\<lambda>x. u x); cont (\<lambda>x. v x)\<rbrakk> \<Longrightarrow> adm (\<lambda>x. u x = v x)"
huffman@40007
   135
by (simp add: po_eq_conv)
huffman@17814
   136
huffman@40007
   137
lemma adm_subst: "\<lbrakk>cont (\<lambda>x. t x); 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@40007
   145
lemma adm_not_below [simp]: "cont (\<lambda>x. t x) \<Longrightarrow> adm (\<lambda>x. \<not> t x \<sqsubseteq> u)"
huffman@40007
   146
by (rule admI, simp add: cont2contlubE ch2ch_cont lub_below_iff)
huffman@17814
   147
huffman@25880
   148
subsection {* Compactness *}
huffman@25880
   149
huffman@25880
   150
definition
huffman@25880
   151
  compact :: "'a::cpo \<Rightarrow> bool" where
huffman@25880
   152
  "compact k = adm (\<lambda>x. \<not> k \<sqsubseteq> x)"
huffman@25880
   153
huffman@25880
   154
lemma compactI: "adm (\<lambda>x. \<not> k \<sqsubseteq> x) \<Longrightarrow> compact k"
huffman@25880
   155
unfolding compact_def .
huffman@25880
   156
huffman@25880
   157
lemma compactD: "compact k \<Longrightarrow> adm (\<lambda>x. \<not> k \<sqsubseteq> x)"
huffman@25880
   158
unfolding compact_def .
huffman@25880
   159
huffman@25880
   160
lemma compactI2:
huffman@27413
   161
  "(\<And>Y. \<lbrakk>chain Y; x \<sqsubseteq> (\<Squnion>i. Y i)\<rbrakk> \<Longrightarrow> \<exists>i. x \<sqsubseteq> Y i) \<Longrightarrow> compact x"
huffman@25880
   162
unfolding compact_def adm_def by fast
huffman@25880
   163
huffman@25880
   164
lemma compactD2:
huffman@27413
   165
  "\<lbrakk>compact x; chain Y; x \<sqsubseteq> (\<Squnion>i. Y i)\<rbrakk> \<Longrightarrow> \<exists>i. x \<sqsubseteq> Y i"
huffman@25880
   166
unfolding compact_def adm_def by fast
huffman@25880
   167
huffman@39969
   168
lemma compact_below_lub_iff:
huffman@39969
   169
  "\<lbrakk>compact x; chain Y\<rbrakk> \<Longrightarrow> x \<sqsubseteq> (\<Squnion>i. Y i) \<longleftrightarrow> (\<exists>i. x \<sqsubseteq> Y i)"
huffman@39969
   170
by (fast intro: compactD2 elim: below_trans is_ub_thelub)
huffman@39969
   171
huffman@25880
   172
lemma compact_chfin [simp]: "compact (x::'a::chfin)"
huffman@25880
   173
by (rule compactI [OF adm_chfin])
huffman@25880
   174
huffman@25880
   175
lemma compact_imp_max_in_chain:
huffman@25880
   176
  "\<lbrakk>chain Y; compact (\<Squnion>i. Y i)\<rbrakk> \<Longrightarrow> \<exists>i. max_in_chain i Y"
huffman@25880
   177
apply (drule (1) compactD2, simp)
huffman@25880
   178
apply (erule exE, rule_tac x=i in exI)
huffman@25880
   179
apply (rule max_in_chainI)
huffman@31076
   180
apply (rule below_antisym)
huffman@25922
   181
apply (erule (1) chain_mono)
huffman@31076
   182
apply (erule (1) below_trans [OF is_ub_thelub])
huffman@25880
   183
done
huffman@25880
   184
huffman@17814
   185
text {* admissibility and compactness *}
huffman@17814
   186
huffman@40007
   187
lemma adm_compact_not_below [simp]:
huffman@40007
   188
  "\<lbrakk>compact k; cont (\<lambda>x. t x)\<rbrakk> \<Longrightarrow> adm (\<lambda>x. \<not> k \<sqsubseteq> t x)"
huffman@25880
   189
unfolding compact_def by (rule adm_subst)
huffman@16056
   190
huffman@40007
   191
lemma adm_neq_compact [simp]:
huffman@40007
   192
  "\<lbrakk>compact k; cont (\<lambda>x. t x)\<rbrakk> \<Longrightarrow> adm (\<lambda>x. t x \<noteq> k)"
huffman@40007
   193
by (simp add: po_eq_conv)
huffman@17814
   194
huffman@40007
   195
lemma adm_compact_neq [simp]:
huffman@40007
   196
  "\<lbrakk>compact k; cont (\<lambda>x. t x)\<rbrakk> \<Longrightarrow> adm (\<lambda>x. k \<noteq> t x)"
huffman@40007
   197
by (simp add: po_eq_conv)
huffman@17814
   198
huffman@17814
   199
lemma compact_UU [simp, intro]: "compact \<bottom>"
huffman@40007
   200
by (rule compactI, simp)
huffman@17814
   201
huffman@25802
   202
text {* Any upward-closed predicate is admissible. *}
huffman@25802
   203
huffman@25802
   204
lemma adm_upward:
huffman@25802
   205
  assumes P: "\<And>x y. \<lbrakk>P x; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> P y"
huffman@25802
   206
  shows "adm P"
huffman@25802
   207
by (rule admI, drule spec, erule P, erule is_ub_thelub)
huffman@25802
   208
huffman@40007
   209
lemmas adm_lemmas =
huffman@40007
   210
  adm_const adm_conj adm_all adm_ball adm_disj adm_imp adm_iff
huffman@31076
   211
  adm_below adm_eq adm_not_below
huffman@40007
   212
  adm_compact_not_below adm_compact_neq adm_neq_compact
huffman@16056
   213
huffman@16056
   214
end