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