src/HOL/UNITY/Project.thy
author haftmann
Fri Jun 11 17:14:02 2010 +0200 (2010-06-11)
changeset 37407 61dd8c145da7
parent 35416 d8d7d1b785af
child 45477 11d9c2768729
permissions -rw-r--r--
declare lex_prod_def [code del]
wenzelm@24147
     1
(*  Title:      HOL/UNITY/Project.thy
paulson@7630
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@7630
     3
    Copyright   1999  University of Cambridge
paulson@7630
     4
wenzelm@32960
     5
Projections of state sets (also of actions and programs).
paulson@7630
     6
wenzelm@32960
     7
Inheritance of GUARANTEES properties under extension.
paulson@7630
     8
*)
paulson@7630
     9
paulson@13798
    10
header{*Projections of State Sets*}
paulson@13798
    11
haftmann@16417
    12
theory Project imports Extend begin
paulson@7826
    13
haftmann@35416
    14
definition projecting :: "['c program => 'c set, 'a*'b => 'c, 
haftmann@35416
    15
                  'a program, 'c program set, 'a program set] => bool" where
paulson@10064
    16
    "projecting C h F X' X ==
paulson@13819
    17
       \<forall>G. extend h F\<squnion>G \<in> X' --> F\<squnion>project h (C G) G \<in> X"
paulson@7826
    18
haftmann@35416
    19
definition extending :: "['c program => 'c set, 'a*'b => 'c, 'a program, 
haftmann@35416
    20
                 'c program set, 'a program set] => bool" where
paulson@10064
    21
    "extending C h F Y' Y ==
paulson@13819
    22
       \<forall>G. extend h F  ok G --> F\<squnion>project h (C G) G \<in> Y
wenzelm@32960
    23
              --> extend h F\<squnion>G \<in> Y'"
paulson@10064
    24
haftmann@35416
    25
definition subset_closed :: "'a set set => bool" where
paulson@13812
    26
    "subset_closed U == \<forall>A \<in> U. Pow A \<subseteq> U"  
paulson@7826
    27
paulson@13790
    28
paulson@13790
    29
lemma (in Extend) project_extend_constrains_I:
paulson@13812
    30
     "F \<in> A co B ==> project h C (extend h F) \<in> A co B"
paulson@13790
    31
apply (auto simp add: extend_act_def project_act_def constrains_def)
paulson@13790
    32
done
paulson@13790
    33
paulson@13790
    34
paulson@13798
    35
subsection{*Safety*}
paulson@13790
    36
paulson@13790
    37
(*used below to prove Join_project_ensures*)
paulson@13798
    38
lemma (in Extend) project_unless [rule_format]:
paulson@13812
    39
     "[| G \<in> stable C;  project h C G \<in> A unless B |]  
paulson@13812
    40
      ==> G \<in> (C \<inter> extend_set h A) unless (extend_set h B)"
paulson@13790
    41
apply (simp add: unless_def project_constrains)
paulson@13790
    42
apply (blast dest: stable_constrains_Int intro: constrains_weaken)
paulson@13790
    43
done
paulson@13790
    44
paulson@13819
    45
(*Generalizes project_constrains to the program F\<squnion>project h C G
paulson@13790
    46
  useful with guarantees reasoning*)
paulson@13790
    47
lemma (in Extend) Join_project_constrains:
paulson@13819
    48
     "(F\<squnion>project h C G \<in> A co B)  =   
paulson@13819
    49
        (extend h F\<squnion>G \<in> (C \<inter> extend_set h A) co (extend_set h B) &   
paulson@13812
    50
         F \<in> A co B)"
paulson@13790
    51
apply (simp (no_asm) add: project_constrains)
paulson@13790
    52
apply (blast intro: extend_constrains [THEN iffD2, THEN constrains_weaken] 
paulson@13790
    53
             dest: constrains_imp_subset)
paulson@13790
    54
done
paulson@13790
    55
paulson@13790
    56
(*The condition is required to prove the left-to-right direction
paulson@13812
    57
  could weaken it to G \<in> (C \<inter> extend_set h A) co C*)
paulson@13790
    58
lemma (in Extend) Join_project_stable: 
paulson@13819
    59
     "extend h F\<squnion>G \<in> stable C  
paulson@13819
    60
      ==> (F\<squnion>project h C G \<in> stable A)  =   
paulson@13819
    61
          (extend h F\<squnion>G \<in> stable (C \<inter> extend_set h A) &   
paulson@13812
    62
           F \<in> stable A)"
paulson@13790
    63
apply (unfold stable_def)
paulson@13790
    64
apply (simp only: Join_project_constrains)
paulson@13790
    65
apply (blast intro: constrains_weaken dest: constrains_Int)
paulson@13790
    66
done
paulson@13790
    67
paulson@13790
    68
(*For using project_guarantees in particular cases*)
paulson@13790
    69
lemma (in Extend) project_constrains_I:
paulson@13819
    70
     "extend h F\<squnion>G \<in> extend_set h A co extend_set h B  
paulson@13819
    71
      ==> F\<squnion>project h C G \<in> A co B"
paulson@13790
    72
apply (simp add: project_constrains extend_constrains)
paulson@13790
    73
apply (blast intro: constrains_weaken dest: constrains_imp_subset)
paulson@13790
    74
done
paulson@13790
    75
paulson@13790
    76
lemma (in Extend) project_increasing_I: 
paulson@13819
    77
     "extend h F\<squnion>G \<in> increasing (func o f)  
paulson@13819
    78
      ==> F\<squnion>project h C G \<in> increasing func"
paulson@13790
    79
apply (unfold increasing_def stable_def)
paulson@13790
    80
apply (simp del: Join_constrains
paulson@13790
    81
            add: project_constrains_I extend_set_eq_Collect)
paulson@13790
    82
done
paulson@13790
    83
paulson@13790
    84
lemma (in Extend) Join_project_increasing:
paulson@13819
    85
     "(F\<squnion>project h UNIV G \<in> increasing func)  =   
paulson@13819
    86
      (extend h F\<squnion>G \<in> increasing (func o f))"
paulson@13790
    87
apply (rule iffI)
paulson@13790
    88
apply (erule_tac [2] project_increasing_I)
paulson@13790
    89
apply (simp del: Join_stable
paulson@13790
    90
            add: increasing_def Join_project_stable)
paulson@13790
    91
apply (auto simp add: extend_set_eq_Collect extend_stable [THEN iffD1])
paulson@13790
    92
done
paulson@13790
    93
paulson@13790
    94
(*The UNIV argument is essential*)
paulson@13790
    95
lemma (in Extend) project_constrains_D:
paulson@13819
    96
     "F\<squnion>project h UNIV G \<in> A co B  
paulson@13819
    97
      ==> extend h F\<squnion>G \<in> extend_set h A co extend_set h B"
paulson@13790
    98
by (simp add: project_constrains extend_constrains)
paulson@13790
    99
paulson@13790
   100
paulson@13798
   101
subsection{*"projecting" and union/intersection (no converses)*}
paulson@13790
   102
paulson@13790
   103
lemma projecting_Int: 
paulson@13790
   104
     "[| projecting C h F XA' XA;  projecting C h F XB' XB |]  
paulson@13812
   105
      ==> projecting C h F (XA' \<inter> XB') (XA \<inter> XB)"
paulson@13790
   106
by (unfold projecting_def, blast)
paulson@13790
   107
paulson@13790
   108
lemma projecting_Un: 
paulson@13790
   109
     "[| projecting C h F XA' XA;  projecting C h F XB' XB |]  
paulson@13812
   110
      ==> projecting C h F (XA' \<union> XB') (XA \<union> XB)"
paulson@13790
   111
by (unfold projecting_def, blast)
paulson@13790
   112
paulson@13790
   113
lemma projecting_INT: 
paulson@13812
   114
     "[| !!i. i \<in> I ==> projecting C h F (X' i) (X i) |]  
paulson@13812
   115
      ==> projecting C h F (\<Inter>i \<in> I. X' i) (\<Inter>i \<in> I. X i)"
paulson@13790
   116
by (unfold projecting_def, blast)
paulson@13790
   117
paulson@13790
   118
lemma projecting_UN: 
paulson@13812
   119
     "[| !!i. i \<in> I ==> projecting C h F (X' i) (X i) |]  
paulson@13812
   120
      ==> projecting C h F (\<Union>i \<in> I. X' i) (\<Union>i \<in> I. X i)"
paulson@13790
   121
by (unfold projecting_def, blast)
paulson@13790
   122
paulson@13790
   123
lemma projecting_weaken: 
paulson@13812
   124
     "[| projecting C h F X' X;  U'<=X';  X \<subseteq> U |] ==> projecting C h F U' U"
paulson@13790
   125
by (unfold projecting_def, auto)
paulson@13790
   126
paulson@13790
   127
lemma projecting_weaken_L: 
paulson@13790
   128
     "[| projecting C h F X' X;  U'<=X' |] ==> projecting C h F U' X"
paulson@13790
   129
by (unfold projecting_def, auto)
paulson@13790
   130
paulson@13790
   131
lemma extending_Int: 
paulson@13790
   132
     "[| extending C h F YA' YA;  extending C h F YB' YB |]  
paulson@13812
   133
      ==> extending C h F (YA' \<inter> YB') (YA \<inter> YB)"
paulson@13790
   134
by (unfold extending_def, blast)
paulson@13790
   135
paulson@13790
   136
lemma extending_Un: 
paulson@13790
   137
     "[| extending C h F YA' YA;  extending C h F YB' YB |]  
paulson@13812
   138
      ==> extending C h F (YA' \<union> YB') (YA \<union> YB)"
paulson@13790
   139
by (unfold extending_def, blast)
paulson@13790
   140
paulson@13790
   141
lemma extending_INT: 
paulson@13812
   142
     "[| !!i. i \<in> I ==> extending C h F (Y' i) (Y i) |]  
paulson@13812
   143
      ==> extending C h F (\<Inter>i \<in> I. Y' i) (\<Inter>i \<in> I. Y i)"
paulson@13790
   144
by (unfold extending_def, blast)
paulson@13790
   145
paulson@13790
   146
lemma extending_UN: 
paulson@13812
   147
     "[| !!i. i \<in> I ==> extending C h F (Y' i) (Y i) |]  
paulson@13812
   148
      ==> extending C h F (\<Union>i \<in> I. Y' i) (\<Union>i \<in> I. Y i)"
paulson@13790
   149
by (unfold extending_def, blast)
paulson@13790
   150
paulson@13790
   151
lemma extending_weaken: 
paulson@13812
   152
     "[| extending C h F Y' Y;  Y'<=V';  V \<subseteq> Y |] ==> extending C h F V' V"
paulson@13790
   153
by (unfold extending_def, auto)
paulson@13790
   154
paulson@13790
   155
lemma extending_weaken_L: 
paulson@13790
   156
     "[| extending C h F Y' Y;  Y'<=V' |] ==> extending C h F V' Y"
paulson@13790
   157
by (unfold extending_def, auto)
paulson@13790
   158
paulson@13790
   159
lemma projecting_UNIV: "projecting C h F X' UNIV"
paulson@13790
   160
by (simp add: projecting_def)
paulson@13790
   161
paulson@13790
   162
lemma (in Extend) projecting_constrains: 
paulson@13790
   163
     "projecting C h F (extend_set h A co extend_set h B) (A co B)"
paulson@13790
   164
apply (unfold projecting_def)
paulson@13790
   165
apply (blast intro: project_constrains_I)
paulson@13790
   166
done
paulson@13790
   167
paulson@13790
   168
lemma (in Extend) projecting_stable: 
paulson@13790
   169
     "projecting C h F (stable (extend_set h A)) (stable A)"
paulson@13790
   170
apply (unfold stable_def)
paulson@13790
   171
apply (rule projecting_constrains)
paulson@13790
   172
done
paulson@13790
   173
paulson@13790
   174
lemma (in Extend) projecting_increasing: 
paulson@13790
   175
     "projecting C h F (increasing (func o f)) (increasing func)"
paulson@13790
   176
apply (unfold projecting_def)
paulson@13790
   177
apply (blast intro: project_increasing_I)
paulson@13790
   178
done
paulson@13790
   179
paulson@13790
   180
lemma (in Extend) extending_UNIV: "extending C h F UNIV Y"
paulson@13790
   181
apply (simp (no_asm) add: extending_def)
paulson@13790
   182
done
paulson@13790
   183
paulson@13790
   184
lemma (in Extend) extending_constrains: 
paulson@13790
   185
     "extending (%G. UNIV) h F (extend_set h A co extend_set h B) (A co B)"
paulson@13790
   186
apply (unfold extending_def)
paulson@13790
   187
apply (blast intro: project_constrains_D)
paulson@13790
   188
done
paulson@13790
   189
paulson@13790
   190
lemma (in Extend) extending_stable: 
paulson@13790
   191
     "extending (%G. UNIV) h F (stable (extend_set h A)) (stable A)"
paulson@13790
   192
apply (unfold stable_def)
paulson@13790
   193
apply (rule extending_constrains)
paulson@13790
   194
done
paulson@13790
   195
paulson@13790
   196
lemma (in Extend) extending_increasing: 
paulson@13790
   197
     "extending (%G. UNIV) h F (increasing (func o f)) (increasing func)"
paulson@13790
   198
by (force simp only: extending_def Join_project_increasing)
paulson@13790
   199
paulson@13790
   200
paulson@13798
   201
subsection{*Reachability and project*}
paulson@13790
   202
paulson@13790
   203
(*In practice, C = reachable(...): the inclusion is equality*)
paulson@13790
   204
lemma (in Extend) reachable_imp_reachable_project:
paulson@13819
   205
     "[| reachable (extend h F\<squnion>G) \<subseteq> C;   
paulson@13819
   206
         z \<in> reachable (extend h F\<squnion>G) |]  
paulson@13819
   207
      ==> f z \<in> reachable (F\<squnion>project h C G)"
paulson@13790
   208
apply (erule reachable.induct)
paulson@13790
   209
apply (force intro!: reachable.Init simp add: split_extended_all, auto)
paulson@13790
   210
 apply (rule_tac act = x in reachable.Acts)
paulson@13790
   211
 apply auto
paulson@13790
   212
 apply (erule extend_act_D)
paulson@13790
   213
apply (rule_tac act1 = "Restrict C act"
paulson@13790
   214
       in project_act_I [THEN [3] reachable.Acts], auto) 
paulson@13790
   215
done
paulson@13790
   216
paulson@13790
   217
lemma (in Extend) project_Constrains_D: 
paulson@13819
   218
     "F\<squnion>project h (reachable (extend h F\<squnion>G)) G \<in> A Co B   
paulson@13819
   219
      ==> extend h F\<squnion>G \<in> (extend_set h A) Co (extend_set h B)"
paulson@13790
   220
apply (unfold Constrains_def)
paulson@13790
   221
apply (simp del: Join_constrains
paulson@13790
   222
            add: Join_project_constrains, clarify)
paulson@13790
   223
apply (erule constrains_weaken)
paulson@13790
   224
apply (auto intro: reachable_imp_reachable_project)
paulson@13790
   225
done
paulson@13790
   226
paulson@13790
   227
lemma (in Extend) project_Stable_D: 
paulson@13819
   228
     "F\<squnion>project h (reachable (extend h F\<squnion>G)) G \<in> Stable A   
paulson@13819
   229
      ==> extend h F\<squnion>G \<in> Stable (extend_set h A)"
paulson@13790
   230
apply (unfold Stable_def)
paulson@13790
   231
apply (simp (no_asm_simp) add: project_Constrains_D)
paulson@13790
   232
done
paulson@13790
   233
paulson@13790
   234
lemma (in Extend) project_Always_D: 
paulson@13819
   235
     "F\<squnion>project h (reachable (extend h F\<squnion>G)) G \<in> Always A   
paulson@13819
   236
      ==> extend h F\<squnion>G \<in> Always (extend_set h A)"
paulson@13790
   237
apply (unfold Always_def)
paulson@13790
   238
apply (force intro: reachable.Init simp add: project_Stable_D split_extended_all)
paulson@13790
   239
done
paulson@13790
   240
paulson@13790
   241
lemma (in Extend) project_Increasing_D: 
paulson@13819
   242
     "F\<squnion>project h (reachable (extend h F\<squnion>G)) G \<in> Increasing func   
paulson@13819
   243
      ==> extend h F\<squnion>G \<in> Increasing (func o f)"
paulson@13790
   244
apply (unfold Increasing_def, auto)
paulson@13790
   245
apply (subst extend_set_eq_Collect [symmetric])
paulson@13790
   246
apply (simp (no_asm_simp) add: project_Stable_D)
paulson@13790
   247
done
paulson@13790
   248
paulson@13790
   249
paulson@13798
   250
subsection{*Converse results for weak safety: benefits of the argument C *}
paulson@13790
   251
paulson@13790
   252
(*In practice, C = reachable(...): the inclusion is equality*)
paulson@13790
   253
lemma (in Extend) reachable_project_imp_reachable:
paulson@13819
   254
     "[| C \<subseteq> reachable(extend h F\<squnion>G);    
paulson@13819
   255
         x \<in> reachable (F\<squnion>project h C G) |]  
paulson@13819
   256
      ==> \<exists>y. h(x,y) \<in> reachable (extend h F\<squnion>G)"
paulson@13790
   257
apply (erule reachable.induct)
paulson@13790
   258
apply  (force intro: reachable.Init)
paulson@13790
   259
apply (auto simp add: project_act_def)
paulson@13790
   260
apply (force del: Id_in_Acts intro: reachable.Acts extend_act_D)+
paulson@13790
   261
done
paulson@13790
   262
paulson@13790
   263
lemma (in Extend) project_set_reachable_extend_eq:
paulson@13819
   264
     "project_set h (reachable (extend h F\<squnion>G)) =  
paulson@13819
   265
      reachable (F\<squnion>project h (reachable (extend h F\<squnion>G)) G)"
paulson@13790
   266
by (auto dest: subset_refl [THEN reachable_imp_reachable_project] 
paulson@13790
   267
               subset_refl [THEN reachable_project_imp_reachable])
paulson@13790
   268
paulson@13790
   269
(*UNUSED*)
paulson@13790
   270
lemma (in Extend) reachable_extend_Join_subset:
paulson@13819
   271
     "reachable (extend h F\<squnion>G) \<subseteq> C   
paulson@13819
   272
      ==> reachable (extend h F\<squnion>G) \<subseteq>  
paulson@13819
   273
          extend_set h (reachable (F\<squnion>project h C G))"
paulson@13790
   274
apply (auto dest: reachable_imp_reachable_project)
paulson@13790
   275
done
paulson@13790
   276
paulson@13790
   277
lemma (in Extend) project_Constrains_I: 
paulson@13819
   278
     "extend h F\<squnion>G \<in> (extend_set h A) Co (extend_set h B)   
paulson@13819
   279
      ==> F\<squnion>project h (reachable (extend h F\<squnion>G)) G \<in> A Co B"
paulson@13790
   280
apply (unfold Constrains_def)
paulson@13790
   281
apply (simp del: Join_constrains
paulson@13790
   282
            add: Join_project_constrains extend_set_Int_distrib)
paulson@13790
   283
apply (rule conjI)
paulson@13790
   284
 prefer 2 
paulson@13790
   285
 apply (force elim: constrains_weaken_L
paulson@13790
   286
              dest!: extend_constrains_project_set
paulson@13790
   287
                     subset_refl [THEN reachable_project_imp_reachable])
paulson@13790
   288
apply (blast intro: constrains_weaken_L)
paulson@13790
   289
done
paulson@13790
   290
paulson@13790
   291
lemma (in Extend) project_Stable_I: 
paulson@13819
   292
     "extend h F\<squnion>G \<in> Stable (extend_set h A)   
paulson@13819
   293
      ==> F\<squnion>project h (reachable (extend h F\<squnion>G)) G \<in> Stable A"
paulson@13790
   294
apply (unfold Stable_def)
paulson@13790
   295
apply (simp (no_asm_simp) add: project_Constrains_I)
paulson@13790
   296
done
paulson@13790
   297
paulson@13790
   298
lemma (in Extend) project_Always_I: 
paulson@13819
   299
     "extend h F\<squnion>G \<in> Always (extend_set h A)   
paulson@13819
   300
      ==> F\<squnion>project h (reachable (extend h F\<squnion>G)) G \<in> Always A"
paulson@13790
   301
apply (unfold Always_def)
paulson@13790
   302
apply (auto simp add: project_Stable_I)
paulson@13790
   303
apply (unfold extend_set_def, blast)
paulson@13790
   304
done
paulson@13790
   305
paulson@13790
   306
lemma (in Extend) project_Increasing_I: 
paulson@13819
   307
    "extend h F\<squnion>G \<in> Increasing (func o f)   
paulson@13819
   308
     ==> F\<squnion>project h (reachable (extend h F\<squnion>G)) G \<in> Increasing func"
paulson@13790
   309
apply (unfold Increasing_def, auto)
paulson@13790
   310
apply (simp (no_asm_simp) add: extend_set_eq_Collect project_Stable_I)
paulson@13790
   311
done
paulson@13790
   312
paulson@13790
   313
lemma (in Extend) project_Constrains:
paulson@13819
   314
     "(F\<squnion>project h (reachable (extend h F\<squnion>G)) G \<in> A Co B)  =   
paulson@13819
   315
      (extend h F\<squnion>G \<in> (extend_set h A) Co (extend_set h B))"
paulson@13790
   316
apply (blast intro: project_Constrains_I project_Constrains_D)
paulson@13790
   317
done
paulson@13790
   318
paulson@13790
   319
lemma (in Extend) project_Stable: 
paulson@13819
   320
     "(F\<squnion>project h (reachable (extend h F\<squnion>G)) G \<in> Stable A)  =   
paulson@13819
   321
      (extend h F\<squnion>G \<in> Stable (extend_set h A))"
paulson@13790
   322
apply (unfold Stable_def)
paulson@13790
   323
apply (rule project_Constrains)
paulson@13790
   324
done
paulson@13790
   325
paulson@13790
   326
lemma (in Extend) project_Increasing: 
paulson@13819
   327
   "(F\<squnion>project h (reachable (extend h F\<squnion>G)) G \<in> Increasing func)  =  
paulson@13819
   328
    (extend h F\<squnion>G \<in> Increasing (func o f))"
paulson@13790
   329
apply (simp (no_asm_simp) add: Increasing_def project_Stable extend_set_eq_Collect)
paulson@13790
   330
done
paulson@13790
   331
paulson@13798
   332
subsection{*A lot of redundant theorems: all are proved to facilitate reasoning
paulson@13798
   333
    about guarantees.*}
paulson@13790
   334
paulson@13790
   335
lemma (in Extend) projecting_Constrains: 
paulson@13819
   336
     "projecting (%G. reachable (extend h F\<squnion>G)) h F  
paulson@13790
   337
                 (extend_set h A Co extend_set h B) (A Co B)"
paulson@13790
   338
paulson@13790
   339
apply (unfold projecting_def)
paulson@13790
   340
apply (blast intro: project_Constrains_I)
paulson@13790
   341
done
paulson@13790
   342
paulson@13790
   343
lemma (in Extend) projecting_Stable: 
paulson@13819
   344
     "projecting (%G. reachable (extend h F\<squnion>G)) h F  
paulson@13790
   345
                 (Stable (extend_set h A)) (Stable A)"
paulson@13790
   346
apply (unfold Stable_def)
paulson@13790
   347
apply (rule projecting_Constrains)
paulson@13790
   348
done
paulson@13790
   349
paulson@13790
   350
lemma (in Extend) projecting_Always: 
paulson@13819
   351
     "projecting (%G. reachable (extend h F\<squnion>G)) h F  
paulson@13790
   352
                 (Always (extend_set h A)) (Always A)"
paulson@13790
   353
apply (unfold projecting_def)
paulson@13790
   354
apply (blast intro: project_Always_I)
paulson@13790
   355
done
paulson@13790
   356
paulson@13790
   357
lemma (in Extend) projecting_Increasing: 
paulson@13819
   358
     "projecting (%G. reachable (extend h F\<squnion>G)) h F  
paulson@13790
   359
                 (Increasing (func o f)) (Increasing func)"
paulson@13790
   360
apply (unfold projecting_def)
paulson@13790
   361
apply (blast intro: project_Increasing_I)
paulson@13790
   362
done
paulson@13790
   363
paulson@13790
   364
lemma (in Extend) extending_Constrains: 
paulson@13819
   365
     "extending (%G. reachable (extend h F\<squnion>G)) h F  
paulson@13790
   366
                  (extend_set h A Co extend_set h B) (A Co B)"
paulson@13790
   367
apply (unfold extending_def)
paulson@13790
   368
apply (blast intro: project_Constrains_D)
paulson@13790
   369
done
paulson@13790
   370
paulson@13790
   371
lemma (in Extend) extending_Stable: 
paulson@13819
   372
     "extending (%G. reachable (extend h F\<squnion>G)) h F  
paulson@13790
   373
                  (Stable (extend_set h A)) (Stable A)"
paulson@13790
   374
apply (unfold extending_def)
paulson@13790
   375
apply (blast intro: project_Stable_D)
paulson@13790
   376
done
paulson@13790
   377
paulson@13790
   378
lemma (in Extend) extending_Always: 
paulson@13819
   379
     "extending (%G. reachable (extend h F\<squnion>G)) h F  
paulson@13790
   380
                  (Always (extend_set h A)) (Always A)"
paulson@13790
   381
apply (unfold extending_def)
paulson@13790
   382
apply (blast intro: project_Always_D)
paulson@13790
   383
done
paulson@13790
   384
paulson@13790
   385
lemma (in Extend) extending_Increasing: 
paulson@13819
   386
     "extending (%G. reachable (extend h F\<squnion>G)) h F  
paulson@13790
   387
                  (Increasing (func o f)) (Increasing func)"
paulson@13790
   388
apply (unfold extending_def)
paulson@13790
   389
apply (blast intro: project_Increasing_D)
paulson@13790
   390
done
paulson@13790
   391
paulson@13790
   392
paulson@13798
   393
subsection{*leadsETo in the precondition (??)*}
paulson@13790
   394
paulson@13798
   395
subsubsection{*transient*}
paulson@13790
   396
paulson@13790
   397
lemma (in Extend) transient_extend_set_imp_project_transient: 
paulson@13812
   398
     "[| G \<in> transient (C \<inter> extend_set h A);  G \<in> stable C |]   
paulson@13812
   399
      ==> project h C G \<in> transient (project_set h C \<inter> A)"
paulson@13812
   400
apply (auto simp add: transient_def Domain_project_act)
paulson@13812
   401
apply (subgoal_tac "act `` (C \<inter> extend_set h A) \<subseteq> - extend_set h A")
paulson@13812
   402
 prefer 2
paulson@13790
   403
 apply (simp add: stable_def constrains_def, blast) 
paulson@13790
   404
(*back to main goal*)
paulson@13812
   405
apply (erule_tac V = "?AA \<subseteq> -C \<union> ?BB" in thin_rl)
paulson@13790
   406
apply (drule bspec, assumption) 
paulson@13790
   407
apply (simp add: extend_set_def project_act_def, blast)
paulson@13790
   408
done
paulson@13790
   409
paulson@13790
   410
(*converse might hold too?*)
paulson@13790
   411
lemma (in Extend) project_extend_transient_D: 
paulson@13812
   412
     "project h C (extend h F) \<in> transient (project_set h C \<inter> D)  
paulson@13812
   413
      ==> F \<in> transient (project_set h C \<inter> D)"
paulson@13812
   414
apply (simp add: transient_def Domain_project_act, safe)
paulson@13812
   415
apply blast+
paulson@13790
   416
done
paulson@13790
   417
paulson@13790
   418
paulson@13798
   419
subsubsection{*ensures -- a primitive combining progress with safety*}
paulson@13790
   420
paulson@13790
   421
(*Used to prove project_leadsETo_I*)
paulson@13790
   422
lemma (in Extend) ensures_extend_set_imp_project_ensures:
paulson@13812
   423
     "[| extend h F \<in> stable C;  G \<in> stable C;   
paulson@13819
   424
         extend h F\<squnion>G \<in> A ensures B;  A-B = C \<inter> extend_set h D |]   
paulson@13819
   425
      ==> F\<squnion>project h C G   
paulson@13812
   426
            \<in> (project_set h C \<inter> project_set h A) ensures (project_set h B)"
paulson@13812
   427
apply (simp add: ensures_def project_constrains Join_transient extend_transient,
paulson@13812
   428
       clarify)
paulson@13790
   429
apply (intro conjI) 
paulson@13790
   430
(*first subgoal*)
paulson@13790
   431
apply (blast intro: extend_stable_project_set 
paulson@13790
   432
                  [THEN stableD, THEN constrains_Int, THEN constrains_weaken] 
paulson@13790
   433
             dest!: extend_constrains_project_set equalityD1)
paulson@13790
   434
(*2nd subgoal*)
paulson@13790
   435
apply (erule stableD [THEN constrains_Int, THEN constrains_weaken])
paulson@13790
   436
    apply assumption
paulson@13790
   437
   apply (simp (no_asm_use) add: extend_set_def)
paulson@13790
   438
   apply blast
paulson@13790
   439
 apply (simp add: extend_set_Int_distrib extend_set_Un_distrib)
paulson@13790
   440
 apply (blast intro!: extend_set_project_set [THEN subsetD], blast)
paulson@13790
   441
(*The transient part*)
paulson@13790
   442
apply auto
paulson@13790
   443
 prefer 2
paulson@13790
   444
 apply (force dest!: equalityD1
paulson@13790
   445
              intro: transient_extend_set_imp_project_transient
paulson@13790
   446
                         [THEN transient_strengthen])
paulson@13790
   447
apply (simp (no_asm_use) add: Int_Diff)
paulson@13790
   448
apply (force dest!: equalityD1 
paulson@13790
   449
             intro: transient_extend_set_imp_project_transient 
paulson@13790
   450
               [THEN project_extend_transient_D, THEN transient_strengthen])
paulson@13790
   451
done
paulson@13790
   452
paulson@13812
   453
text{*Transferring a transient property upwards*}
paulson@13812
   454
lemma (in Extend) project_transient_extend_set:
paulson@13812
   455
     "project h C G \<in> transient (project_set h C \<inter> A - B)
paulson@13812
   456
      ==> G \<in> transient (C \<inter> extend_set h A - extend_set h B)"
paulson@13812
   457
apply (simp add: transient_def project_set_def extend_set_def project_act_def)
paulson@13812
   458
apply (elim disjE bexE)
paulson@13812
   459
 apply (rule_tac x=Id in bexI)  
paulson@13812
   460
  apply (blast intro!: rev_bexI )+
paulson@13812
   461
done
paulson@13812
   462
paulson@13812
   463
lemma (in Extend) project_unless2 [rule_format]:
paulson@13812
   464
     "[| G \<in> stable C;  project h C G \<in> (project_set h C \<inter> A) unless B |]  
paulson@13812
   465
      ==> G \<in> (C \<inter> extend_set h A) unless (extend_set h B)"
paulson@13812
   466
by (auto dest: stable_constrains_Int intro: constrains_weaken
paulson@13812
   467
         simp add: unless_def project_constrains Diff_eq Int_assoc 
paulson@13812
   468
                   Int_extend_set_lemma)
paulson@13812
   469
paulson@13812
   470
paulson@13812
   471
lemma (in Extend) extend_unless:
paulson@13812
   472
   "[|extend h F \<in> stable C; F \<in> A unless B|]
paulson@13812
   473
    ==> extend h F \<in> C \<inter> extend_set h A unless extend_set h B"
paulson@13812
   474
apply (simp add: unless_def stable_def)
paulson@13812
   475
apply (drule constrains_Int) 
paulson@13812
   476
apply (erule extend_constrains [THEN iffD2]) 
paulson@13812
   477
apply (erule constrains_weaken, blast) 
paulson@13812
   478
apply blast 
paulson@13812
   479
done
paulson@13812
   480
paulson@13790
   481
(*Used to prove project_leadsETo_D*)
paulson@13798
   482
lemma (in Extend) Join_project_ensures [rule_format]:
paulson@13819
   483
     "[| extend h F\<squnion>G \<in> stable C;   
paulson@13819
   484
         F\<squnion>project h C G \<in> A ensures B |]  
paulson@13819
   485
      ==> extend h F\<squnion>G \<in> (C \<inter> extend_set h A) ensures (extend_set h B)"
paulson@13812
   486
apply (auto simp add: ensures_eq extend_unless project_unless)
paulson@13812
   487
apply (blast intro:  extend_transient [THEN iffD2] transient_strengthen)  
paulson@13812
   488
apply (blast intro: project_transient_extend_set transient_strengthen)  
paulson@13790
   489
done
paulson@13790
   490
paulson@13798
   491
text{*Lemma useful for both STRONG and WEAK progress, but the transient
paulson@13798
   492
    condition's very strong*}
paulson@13790
   493
paulson@13790
   494
(*The strange induction formula allows induction over the leadsTo
paulson@13790
   495
  assumption's non-atomic precondition*)
paulson@13790
   496
lemma (in Extend) PLD_lemma:
paulson@13819
   497
     "[| extend h F\<squnion>G \<in> stable C;   
paulson@13819
   498
         F\<squnion>project h C G \<in> (project_set h C \<inter> A) leadsTo B |]  
paulson@13819
   499
      ==> extend h F\<squnion>G \<in>  
paulson@13812
   500
          C \<inter> extend_set h (project_set h C \<inter> A) leadsTo (extend_set h B)"
paulson@13790
   501
apply (erule leadsTo_induct)
paulson@13790
   502
  apply (blast intro: leadsTo_Basis Join_project_ensures)
paulson@13790
   503
 apply (blast intro: psp_stable2 [THEN leadsTo_weaken_L] leadsTo_Trans)
paulson@13790
   504
apply (simp del: UN_simps add: Int_UN_distrib leadsTo_UN extend_set_Union)
paulson@13790
   505
done
paulson@13790
   506
paulson@13790
   507
lemma (in Extend) project_leadsTo_D_lemma:
paulson@13819
   508
     "[| extend h F\<squnion>G \<in> stable C;   
paulson@13819
   509
         F\<squnion>project h C G \<in> (project_set h C \<inter> A) leadsTo B |]  
paulson@13819
   510
      ==> extend h F\<squnion>G \<in> (C \<inter> extend_set h A) leadsTo (extend_set h B)"
paulson@13790
   511
apply (rule PLD_lemma [THEN leadsTo_weaken])
paulson@13790
   512
apply (auto simp add: split_extended_all)
paulson@13790
   513
done
paulson@13790
   514
paulson@13790
   515
lemma (in Extend) Join_project_LeadsTo:
paulson@13819
   516
     "[| C = (reachable (extend h F\<squnion>G));  
paulson@13819
   517
         F\<squnion>project h C G \<in> A LeadsTo B |]  
paulson@13819
   518
      ==> extend h F\<squnion>G \<in> (extend_set h A) LeadsTo (extend_set h B)"
paulson@13790
   519
by (simp del: Join_stable    add: LeadsTo_def project_leadsTo_D_lemma
paulson@13790
   520
                                  project_set_reachable_extend_eq)
paulson@13790
   521
paulson@13790
   522
paulson@13798
   523
subsection{*Towards the theorem @{text project_Ensures_D}*}
paulson@13790
   524
paulson@13790
   525
lemma (in Extend) project_ensures_D_lemma:
paulson@13812
   526
     "[| G \<in> stable ((C \<inter> extend_set h A) - (extend_set h B));   
paulson@13819
   527
         F\<squnion>project h C G \<in> (project_set h C \<inter> A) ensures B;   
paulson@13819
   528
         extend h F\<squnion>G \<in> stable C |]  
paulson@13819
   529
      ==> extend h F\<squnion>G \<in> (C \<inter> extend_set h A) ensures (extend_set h B)"
paulson@13790
   530
(*unless*)
paulson@13790
   531
apply (auto intro!: project_unless2 [unfolded unless_def] 
paulson@13790
   532
            intro: project_extend_constrains_I 
paulson@13790
   533
            simp add: ensures_def)
paulson@13790
   534
(*transient*)
paulson@13790
   535
(*A G-action cannot occur*)
paulson@13790
   536
 prefer 2
paulson@13812
   537
 apply (blast intro: project_transient_extend_set) 
paulson@13790
   538
(*An F-action*)
paulson@13790
   539
apply (force elim!: extend_transient [THEN iffD2, THEN transient_strengthen]
paulson@13790
   540
             simp add: split_extended_all)
paulson@13790
   541
done
paulson@13790
   542
paulson@13790
   543
lemma (in Extend) project_ensures_D:
paulson@13819
   544
     "[| F\<squnion>project h UNIV G \<in> A ensures B;   
paulson@13812
   545
         G \<in> stable (extend_set h A - extend_set h B) |]  
paulson@13819
   546
      ==> extend h F\<squnion>G \<in> (extend_set h A) ensures (extend_set h B)"
paulson@13790
   547
apply (rule project_ensures_D_lemma [of _ UNIV, THEN revcut_rl], auto)
paulson@13790
   548
done
paulson@13790
   549
paulson@13790
   550
lemma (in Extend) project_Ensures_D: 
paulson@13819
   551
     "[| F\<squnion>project h (reachable (extend h F\<squnion>G)) G \<in> A Ensures B;   
paulson@13819
   552
         G \<in> stable (reachable (extend h F\<squnion>G) \<inter> extend_set h A -  
paulson@13790
   553
                     extend_set h B) |]  
paulson@13819
   554
      ==> extend h F\<squnion>G \<in> (extend_set h A) Ensures (extend_set h B)"
paulson@13790
   555
apply (unfold Ensures_def)
paulson@13790
   556
apply (rule project_ensures_D_lemma [THEN revcut_rl])
paulson@13790
   557
apply (auto simp add: project_set_reachable_extend_eq [symmetric])
paulson@13790
   558
done
paulson@13790
   559
paulson@13790
   560
paulson@13798
   561
subsection{*Guarantees*}
paulson@13790
   562
paulson@13790
   563
lemma (in Extend) project_act_Restrict_subset_project_act:
paulson@13812
   564
     "project_act h (Restrict C act) \<subseteq> project_act h act"
paulson@13790
   565
apply (auto simp add: project_act_def)
paulson@13790
   566
done
wenzelm@32960
   567
                                           
wenzelm@32960
   568
                                                           
paulson@13790
   569
lemma (in Extend) subset_closed_ok_extend_imp_ok_project:
paulson@13790
   570
     "[| extend h F ok G; subset_closed (AllowedActs F) |]  
paulson@13790
   571
      ==> F ok project h C G"
paulson@13790
   572
apply (auto simp add: ok_def)
paulson@13790
   573
apply (rename_tac act) 
paulson@13790
   574
apply (drule subsetD, blast)
paulson@13790
   575
apply (rule_tac x = "Restrict C  (extend_act h act)" in rev_image_eqI)
paulson@13790
   576
apply simp +
paulson@13790
   577
apply (cut_tac project_act_Restrict_subset_project_act)
paulson@13790
   578
apply (auto simp add: subset_closed_def)
paulson@13790
   579
done
paulson@13790
   580
paulson@13790
   581
paulson@13790
   582
(*Weak precondition and postcondition
paulson@13790
   583
  Not clear that it has a converse [or that we want one!]*)
paulson@13790
   584
paulson@13790
   585
(*The raw version; 3rd premise could be weakened by adding the
paulson@13819
   586
  precondition extend h F\<squnion>G \<in> X' *)
paulson@13790
   587
lemma (in Extend) project_guarantees_raw:
paulson@13812
   588
 assumes xguary:  "F \<in> X guarantees Y"
paulson@13790
   589
     and closed:  "subset_closed (AllowedActs F)"
paulson@13819
   590
     and project: "!!G. extend h F\<squnion>G \<in> X' 
paulson@13819
   591
                        ==> F\<squnion>project h (C G) G \<in> X"
paulson@13819
   592
     and extend:  "!!G. [| F\<squnion>project h (C G) G \<in> Y |]  
paulson@13819
   593
                        ==> extend h F\<squnion>G \<in> Y'"
paulson@13812
   594
 shows "extend h F \<in> X' guarantees Y'"
paulson@13790
   595
apply (rule xguary [THEN guaranteesD, THEN extend, THEN guaranteesI])
paulson@13790
   596
apply (blast intro: closed subset_closed_ok_extend_imp_ok_project)
paulson@13790
   597
apply (erule project)
paulson@13790
   598
done
paulson@13790
   599
paulson@13790
   600
lemma (in Extend) project_guarantees:
paulson@13812
   601
     "[| F \<in> X guarantees Y;  subset_closed (AllowedActs F);  
paulson@13790
   602
         projecting C h F X' X;  extending C h F Y' Y |]  
paulson@13812
   603
      ==> extend h F \<in> X' guarantees Y'"
paulson@13790
   604
apply (rule guaranteesI)
paulson@13790
   605
apply (auto simp add: guaranteesD projecting_def extending_def
paulson@13790
   606
                      subset_closed_ok_extend_imp_ok_project)
paulson@13790
   607
done
paulson@13790
   608
paulson@13790
   609
paulson@13790
   610
(*It seems that neither "guarantees" law can be proved from the other.*)
paulson@13790
   611
paulson@13790
   612
paulson@13798
   613
subsection{*guarantees corollaries*}
paulson@13790
   614
paulson@13798
   615
subsubsection{*Some could be deleted: the required versions are easy to prove*}
paulson@13790
   616
paulson@13790
   617
lemma (in Extend) extend_guar_increasing:
paulson@13812
   618
     "[| F \<in> UNIV guarantees increasing func;   
paulson@13790
   619
         subset_closed (AllowedActs F) |]  
paulson@13812
   620
      ==> extend h F \<in> X' guarantees increasing (func o f)"
paulson@13790
   621
apply (erule project_guarantees)
paulson@13790
   622
apply (rule_tac [3] extending_increasing)
paulson@13790
   623
apply (rule_tac [2] projecting_UNIV, auto)
paulson@13790
   624
done
paulson@13790
   625
paulson@13790
   626
lemma (in Extend) extend_guar_Increasing:
paulson@13812
   627
     "[| F \<in> UNIV guarantees Increasing func;   
paulson@13790
   628
         subset_closed (AllowedActs F) |]  
paulson@13812
   629
      ==> extend h F \<in> X' guarantees Increasing (func o f)"
paulson@13790
   630
apply (erule project_guarantees)
paulson@13790
   631
apply (rule_tac [3] extending_Increasing)
paulson@13790
   632
apply (rule_tac [2] projecting_UNIV, auto)
paulson@13790
   633
done
paulson@13790
   634
paulson@13790
   635
lemma (in Extend) extend_guar_Always:
paulson@13812
   636
     "[| F \<in> Always A guarantees Always B;   
paulson@13790
   637
         subset_closed (AllowedActs F) |]  
paulson@13790
   638
      ==> extend h F                    
paulson@13812
   639
            \<in> Always(extend_set h A) guarantees Always(extend_set h B)"
paulson@13790
   640
apply (erule project_guarantees)
paulson@13790
   641
apply (rule_tac [3] extending_Always)
paulson@13790
   642
apply (rule_tac [2] projecting_Always, auto)
paulson@13790
   643
done
paulson@13790
   644
paulson@13790
   645
paulson@13812
   646
subsubsection{*Guarantees with a leadsTo postcondition*}
paulson@13790
   647
paulson@13790
   648
lemma (in Extend) project_leadsTo_D:
paulson@13819
   649
     "F\<squnion>project h UNIV G \<in> A leadsTo B
paulson@13819
   650
      ==> extend h F\<squnion>G \<in> (extend_set h A) leadsTo (extend_set h B)"
paulson@13812
   651
apply (rule_tac C1 = UNIV in project_leadsTo_D_lemma [THEN leadsTo_weaken], auto)
paulson@13790
   652
done
paulson@13790
   653
paulson@13790
   654
lemma (in Extend) project_LeadsTo_D:
paulson@13819
   655
     "F\<squnion>project h (reachable (extend h F\<squnion>G)) G \<in> A LeadsTo B   
paulson@13819
   656
       ==> extend h F\<squnion>G \<in> (extend_set h A) LeadsTo (extend_set h B)"
paulson@13812
   657
apply (rule refl [THEN Join_project_LeadsTo], auto)
paulson@13790
   658
done
paulson@13790
   659
paulson@13790
   660
lemma (in Extend) extending_leadsTo: 
paulson@13812
   661
     "extending (%G. UNIV) h F  
paulson@13812
   662
                (extend_set h A leadsTo extend_set h B) (A leadsTo B)"
paulson@13790
   663
apply (unfold extending_def)
paulson@13790
   664
apply (blast intro: project_leadsTo_D)
paulson@13790
   665
done
paulson@13790
   666
paulson@13790
   667
lemma (in Extend) extending_LeadsTo: 
paulson@13819
   668
     "extending (%G. reachable (extend h F\<squnion>G)) h F  
paulson@13812
   669
                (extend_set h A LeadsTo extend_set h B) (A LeadsTo B)"
paulson@13790
   670
apply (unfold extending_def)
paulson@13790
   671
apply (blast intro: project_LeadsTo_D)
paulson@13790
   672
done
paulson@13790
   673
paulson@7826
   674
end