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