src/HOL/UNITY/Lift_prog.thy
author haftmann
Fri Oct 10 19:55:32 2014 +0200 (2014-10-10)
changeset 58646 cd63a4b12a33
parent 46911 6d2a2f0e904e
child 58889 5b7a9633cfa8
permissions -rw-r--r--
specialized specification: avoid trivial instances
paulson@7186
     1
(*  Title:      HOL/UNITY/Lift_prog.thy
paulson@7186
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@7186
     3
    Copyright   1999  University of Cambridge
paulson@7186
     4
paulson@13786
     5
lift_prog, etc: replication of components and arrays of processes. 
paulson@7186
     6
*)
paulson@7186
     7
paulson@13798
     8
header{*Replication of Components*}
paulson@13798
     9
haftmann@16417
    10
theory Lift_prog imports Rename begin
paulson@7186
    11
haftmann@35416
    12
definition insert_map :: "[nat, 'b, nat=>'b] => (nat=>'b)" where
paulson@8251
    13
    "insert_map i z f k == if k<i then f k
paulson@8251
    14
                           else if k=i then z
wenzelm@11701
    15
                           else f(k - 1)"
paulson@7186
    16
haftmann@35416
    17
definition delete_map :: "[nat, nat=>'b] => (nat=>'b)" where
paulson@8251
    18
    "delete_map i g k == if k<i then g k else g (Suc k)"
paulson@7186
    19
haftmann@35416
    20
definition lift_map :: "[nat, 'b * ((nat=>'b) * 'c)] => (nat=>'b) * 'c" where
paulson@8251
    21
    "lift_map i == %(s,(f,uu)). (insert_map i s f, uu)"
paulson@8251
    22
haftmann@35416
    23
definition drop_map :: "[nat, (nat=>'b) * 'c] => 'b * ((nat=>'b) * 'c)" where
paulson@8251
    24
    "drop_map i == %(g, uu). (g i, (delete_map i g, uu))"
paulson@7186
    25
haftmann@35416
    26
definition lift_set :: "[nat, ('b * ((nat=>'b) * 'c)) set] => ((nat=>'b) * 'c) set" where
nipkow@10834
    27
    "lift_set i A == lift_map i ` A"
paulson@7186
    28
haftmann@35416
    29
definition lift :: "[nat, ('b * ((nat=>'b) * 'c)) program] => ((nat=>'b) * 'c) program" where
paulson@8251
    30
    "lift i == rename (lift_map i)"
paulson@7186
    31
paulson@7186
    32
  (*simplifies the expression of specifications*)
haftmann@35416
    33
definition sub :: "['a, 'a=>'b] => 'b" where
paulson@13786
    34
    "sub == %i f. f i"
paulson@13786
    35
paulson@13786
    36
paulson@13786
    37
declare insert_map_def [simp] delete_map_def [simp]
paulson@13786
    38
paulson@13786
    39
lemma insert_map_inverse: "delete_map i (insert_map i x f) = f"
paulson@13798
    40
by (rule ext, simp)
paulson@13786
    41
paulson@13786
    42
lemma insert_map_delete_map_eq: "(insert_map i x (delete_map i g)) = g(i:=x)"
paulson@13786
    43
apply (rule ext)
paulson@13786
    44
apply (auto split add: nat_diff_split)
paulson@13786
    45
done
paulson@13786
    46
paulson@13812
    47
subsection{*Injectiveness proof*}
paulson@13786
    48
paulson@13786
    49
lemma insert_map_inject1: "(insert_map i x f) = (insert_map i y g) ==> x=y"
paulson@13798
    50
by (drule_tac x = i in fun_cong, simp)
paulson@13786
    51
paulson@13786
    52
lemma insert_map_inject2: "(insert_map i x f) = (insert_map i y g) ==> f=g"
paulson@13786
    53
apply (drule_tac f = "delete_map i" in arg_cong)
paulson@13798
    54
apply (simp add: insert_map_inverse)
paulson@13786
    55
done
paulson@13786
    56
paulson@13786
    57
lemma insert_map_inject':
paulson@13786
    58
     "(insert_map i x f) = (insert_map i y g) ==> x=y & f=g"
paulson@13786
    59
by (blast dest: insert_map_inject1 insert_map_inject2)
paulson@13786
    60
paulson@13786
    61
lemmas insert_map_inject = insert_map_inject' [THEN conjE, elim!]
paulson@13786
    62
paulson@13786
    63
(*The general case: we don't assume i=i'*)
paulson@13786
    64
lemma lift_map_eq_iff [iff]: 
paulson@13786
    65
     "(lift_map i (s,(f,uu)) = lift_map i' (s',(f',uu')))  
paulson@13786
    66
      = (uu = uu' & insert_map i s f = insert_map i' s' f')"
paulson@13798
    67
by (unfold lift_map_def, auto)
paulson@13786
    68
paulson@13786
    69
(*The !!s allows the automatic splitting of the bound variable*)
paulson@13786
    70
lemma drop_map_lift_map_eq [simp]: "!!s. drop_map i (lift_map i s) = s"
paulson@13786
    71
apply (unfold lift_map_def drop_map_def)
paulson@13786
    72
apply (force intro: insert_map_inverse)
paulson@13786
    73
done
paulson@13786
    74
paulson@13786
    75
lemma inj_lift_map: "inj (lift_map i)"
paulson@13786
    76
apply (unfold lift_map_def)
paulson@13786
    77
apply (rule inj_onI, auto)
paulson@13786
    78
done
paulson@13786
    79
paulson@13812
    80
subsection{*Surjectiveness proof*}
paulson@13786
    81
paulson@13786
    82
lemma lift_map_drop_map_eq [simp]: "!!s. lift_map i (drop_map i s) = s"
paulson@13786
    83
apply (unfold lift_map_def drop_map_def)
paulson@13786
    84
apply (force simp add: insert_map_delete_map_eq)
paulson@13786
    85
done
paulson@13786
    86
paulson@13786
    87
lemma drop_map_inject [dest!]: "(drop_map i s) = (drop_map i s') ==> s=s'"
paulson@13798
    88
by (drule_tac f = "lift_map i" in arg_cong, simp)
paulson@13786
    89
paulson@13786
    90
lemma surj_lift_map: "surj (lift_map i)"
paulson@13786
    91
apply (rule surjI)
paulson@13786
    92
apply (rule lift_map_drop_map_eq)
paulson@13786
    93
done
paulson@13786
    94
paulson@13786
    95
lemma bij_lift_map [iff]: "bij (lift_map i)"
paulson@13798
    96
by (simp add: bij_def inj_lift_map surj_lift_map)
paulson@13786
    97
paulson@13786
    98
lemma inv_lift_map_eq [simp]: "inv (lift_map i) = drop_map i"
paulson@13786
    99
by (rule inv_equality, auto)
paulson@13786
   100
paulson@13786
   101
lemma inv_drop_map_eq [simp]: "inv (drop_map i) = lift_map i"
paulson@13786
   102
by (rule inv_equality, auto)
paulson@13786
   103
paulson@13786
   104
lemma bij_drop_map [iff]: "bij (drop_map i)"
paulson@13786
   105
by (simp del: inv_lift_map_eq add: inv_lift_map_eq [symmetric] bij_imp_bij_inv)
paulson@13786
   106
paulson@13786
   107
(*sub's main property!*)
paulson@13786
   108
lemma sub_apply [simp]: "sub i f = f i"
paulson@13798
   109
by (simp add: sub_def)
paulson@13786
   110
paulson@13812
   111
lemma all_total_lift: "all_total F ==> all_total (lift i F)"
paulson@13812
   112
by (simp add: lift_def rename_def Extend.all_total_extend)
paulson@13812
   113
paulson@13836
   114
lemma insert_map_upd_same: "(insert_map i t f)(i := s) = insert_map i s f"
paulson@13836
   115
by (rule ext, auto)
paulson@13836
   116
paulson@13836
   117
lemma insert_map_upd:
paulson@13836
   118
     "(insert_map j t f)(i := s) =  
paulson@13836
   119
      (if i=j then insert_map i s f  
paulson@13836
   120
       else if i<j then insert_map j t (f(i:=s))  
paulson@13836
   121
       else insert_map j t (f(i - Suc 0 := s)))"
paulson@13836
   122
apply (rule ext) 
wenzelm@46577
   123
apply (simp split add: nat_diff_split)
paulson@13836
   124
 txt{*This simplification is VERY slow*}
paulson@13836
   125
done
paulson@13836
   126
paulson@13836
   127
lemma insert_map_eq_diff:
paulson@13836
   128
     "[| insert_map i s f = insert_map j t g;  i\<noteq>j |]  
paulson@13836
   129
      ==> \<exists>g'. insert_map i s' f = insert_map j t g'"
paulson@13836
   130
apply (subst insert_map_upd_same [symmetric])
paulson@13836
   131
apply (erule ssubst)
paulson@13836
   132
apply (simp only: insert_map_upd if_False split: split_if, blast)
paulson@13836
   133
done
paulson@13836
   134
paulson@13836
   135
lemma lift_map_eq_diff: 
paulson@13836
   136
     "[| lift_map i (s,(f,uu)) = lift_map j (t,(g,vv));  i\<noteq>j |]  
paulson@13836
   137
      ==> \<exists>g'. lift_map i (s',(f,uu)) = lift_map j (t,(g',vv))"
paulson@13836
   138
apply (unfold lift_map_def, auto)
paulson@13836
   139
apply (blast dest: insert_map_eq_diff)
paulson@13836
   140
done
paulson@13836
   141
paulson@13812
   142
paulson@13812
   143
subsection{*The Operator @{term lift_set}*}
paulson@13786
   144
paulson@13786
   145
lemma lift_set_empty [simp]: "lift_set i {} = {}"
paulson@13786
   146
by (unfold lift_set_def, auto)
paulson@13786
   147
paulson@13805
   148
lemma lift_set_iff: "(lift_map i x \<in> lift_set i A) = (x \<in> A)"
paulson@13786
   149
apply (unfold lift_set_def)
paulson@13786
   150
apply (rule inj_lift_map [THEN inj_image_mem_iff])
paulson@13786
   151
done
paulson@13786
   152
paulson@13786
   153
(*Do we really need both this one and its predecessor?*)
paulson@13786
   154
lemma lift_set_iff2 [iff]:
paulson@13805
   155
     "((f,uu) \<in> lift_set i A) = ((f i, (delete_map i f, uu)) \<in> A)"
paulson@13798
   156
by (simp add: lift_set_def mem_rename_set_iff drop_map_def)
paulson@13786
   157
paulson@13786
   158
paulson@13805
   159
lemma lift_set_mono: "A \<subseteq> B ==> lift_set i A \<subseteq> lift_set i B"
paulson@13786
   160
apply (unfold lift_set_def)
paulson@13786
   161
apply (erule image_mono)
paulson@13786
   162
done
paulson@13786
   163
paulson@13805
   164
lemma lift_set_Un_distrib: "lift_set i (A \<union> B) = lift_set i A \<union> lift_set i B"
paulson@13812
   165
by (simp add: lift_set_def image_Un)
paulson@13786
   166
paulson@13786
   167
lemma lift_set_Diff_distrib: "lift_set i (A-B) = lift_set i A - lift_set i B"
paulson@13786
   168
apply (unfold lift_set_def)
paulson@13786
   169
apply (rule inj_lift_map [THEN image_set_diff])
paulson@13786
   170
done
paulson@13786
   171
paulson@13786
   172
paulson@13812
   173
subsection{*The Lattice Operations*}
paulson@13786
   174
paulson@13786
   175
lemma bij_lift [iff]: "bij (lift i)"
paulson@13798
   176
by (simp add: lift_def)
paulson@13786
   177
paulson@13786
   178
lemma lift_SKIP [simp]: "lift i SKIP = SKIP"
paulson@13798
   179
by (simp add: lift_def)
paulson@13786
   180
paulson@13786
   181
lemma lift_Join [simp]: "lift i (F Join G) = lift i F Join lift i G"
paulson@13798
   182
by (simp add: lift_def)
paulson@13786
   183
paulson@13805
   184
lemma lift_JN [simp]: "lift j (JOIN I F) = (\<Squnion>i \<in> I. lift j (F i))"
paulson@13798
   185
by (simp add: lift_def)
paulson@13786
   186
paulson@13812
   187
subsection{*Safety: constrains, stable, invariant*}
paulson@13786
   188
paulson@13786
   189
lemma lift_constrains: 
paulson@13805
   190
     "(lift i F \<in> (lift_set i A) co (lift_set i B)) = (F \<in> A co B)"
paulson@13798
   191
by (simp add: lift_def lift_set_def rename_constrains)
paulson@13786
   192
paulson@13786
   193
lemma lift_stable: 
paulson@13805
   194
     "(lift i F \<in> stable (lift_set i A)) = (F \<in> stable A)"
paulson@13798
   195
by (simp add: lift_def lift_set_def rename_stable)
paulson@13786
   196
paulson@13786
   197
lemma lift_invariant: 
paulson@13805
   198
     "(lift i F \<in> invariant (lift_set i A)) = (F \<in> invariant A)"
paulson@13812
   199
by (simp add: lift_def lift_set_def rename_invariant)
paulson@13786
   200
paulson@13786
   201
lemma lift_Constrains: 
paulson@13805
   202
     "(lift i F \<in> (lift_set i A) Co (lift_set i B)) = (F \<in> A Co B)"
paulson@13812
   203
by (simp add: lift_def lift_set_def rename_Constrains)
paulson@13786
   204
paulson@13786
   205
lemma lift_Stable: 
paulson@13805
   206
     "(lift i F \<in> Stable (lift_set i A)) = (F \<in> Stable A)"
paulson@13812
   207
by (simp add: lift_def lift_set_def rename_Stable)
paulson@13786
   208
paulson@13786
   209
lemma lift_Always: 
paulson@13805
   210
     "(lift i F \<in> Always (lift_set i A)) = (F \<in> Always A)"
paulson@13812
   211
by (simp add: lift_def lift_set_def rename_Always)
paulson@13786
   212
paulson@13812
   213
subsection{*Progress: transient, ensures*}
paulson@13786
   214
paulson@13786
   215
lemma lift_transient: 
paulson@13805
   216
     "(lift i F \<in> transient (lift_set i A)) = (F \<in> transient A)"
paulson@13798
   217
by (simp add: lift_def lift_set_def rename_transient)
paulson@13786
   218
paulson@13786
   219
lemma lift_ensures: 
paulson@13805
   220
     "(lift i F \<in> (lift_set i A) ensures (lift_set i B)) =  
paulson@13805
   221
      (F \<in> A ensures B)"
paulson@13798
   222
by (simp add: lift_def lift_set_def rename_ensures)
paulson@13786
   223
paulson@13786
   224
lemma lift_leadsTo: 
paulson@13805
   225
     "(lift i F \<in> (lift_set i A) leadsTo (lift_set i B)) =  
paulson@13805
   226
      (F \<in> A leadsTo B)"
paulson@13798
   227
by (simp add: lift_def lift_set_def rename_leadsTo)
paulson@13786
   228
paulson@13786
   229
lemma lift_LeadsTo: 
paulson@13805
   230
     "(lift i F \<in> (lift_set i A) LeadsTo (lift_set i B)) =   
paulson@13805
   231
      (F \<in> A LeadsTo B)"
paulson@13798
   232
by (simp add: lift_def lift_set_def rename_LeadsTo)
paulson@13786
   233
paulson@13786
   234
paulson@13786
   235
(** guarantees **)
paulson@13786
   236
paulson@13786
   237
lemma lift_lift_guarantees_eq: 
paulson@13805
   238
     "(lift i F \<in> (lift i ` X) guarantees (lift i ` Y)) =  
paulson@13805
   239
      (F \<in> X guarantees Y)"
paulson@13786
   240
apply (unfold lift_def)
paulson@13786
   241
apply (subst bij_lift_map [THEN rename_rename_guarantees_eq, symmetric])
paulson@13798
   242
apply (simp add: o_def)
paulson@13786
   243
done
paulson@13786
   244
paulson@13812
   245
lemma lift_guarantees_eq_lift_inv:
paulson@13812
   246
     "(lift i F \<in> X guarantees Y) =  
paulson@13805
   247
      (F \<in> (rename (drop_map i) ` X) guarantees (rename (drop_map i) ` Y))"
paulson@13786
   248
by (simp add: bij_lift_map [THEN rename_guarantees_eq_rename_inv] lift_def)
paulson@7186
   249
paulson@7186
   250
paulson@13786
   251
(*To preserve snd means that the second component is there just to allow
paulson@13786
   252
  guarantees properties to be stated.  Converse fails, for lift i F can 
paulson@13786
   253
  change function components other than i*)
paulson@13805
   254
lemma lift_preserves_snd_I: "F \<in> preserves snd ==> lift i F \<in> preserves snd"
paulson@13786
   255
apply (drule_tac w1=snd in subset_preserves_o [THEN subsetD])
paulson@13798
   256
apply (simp add: lift_def rename_preserves)
wenzelm@46577
   257
apply (simp add: lift_map_def o_def split_def)
paulson@13786
   258
done
paulson@13786
   259
paulson@13786
   260
lemma delete_map_eqE':
paulson@13805
   261
     "(delete_map i g) = (delete_map i g') ==> \<exists>x. g = g'(i:=x)"
paulson@13786
   262
apply (drule_tac f = "insert_map i (g i) " in arg_cong)
paulson@13798
   263
apply (simp add: insert_map_delete_map_eq)
paulson@13786
   264
apply (erule exI)
paulson@13786
   265
done
paulson@13786
   266
paulson@13786
   267
lemmas delete_map_eqE = delete_map_eqE' [THEN exE, elim!]
paulson@13786
   268
paulson@13786
   269
lemma delete_map_neq_apply:
paulson@13805
   270
     "[| delete_map j g = delete_map j g';  i\<noteq>j |] ==> g i = g' i"
paulson@13786
   271
by force
paulson@13786
   272
paulson@13786
   273
(*A set of the form (A <*> UNIV) ignores the second (dummy) state component*)
paulson@13786
   274
paulson@13786
   275
lemma vimage_o_fst_eq [simp]: "(f o fst) -` A = (f-`A) <*> UNIV"
paulson@13786
   276
by auto
paulson@13786
   277
paulson@13786
   278
lemma vimage_sub_eq_lift_set [simp]:
paulson@13786
   279
     "(sub i -`A) <*> UNIV = lift_set i (A <*> UNIV)"
paulson@13786
   280
by auto
paulson@13786
   281
paulson@13786
   282
lemma mem_lift_act_iff [iff]: 
paulson@13805
   283
     "((s,s') \<in> extend_act (%(x,u::unit). lift_map i x) act) =  
paulson@13805
   284
      ((drop_map i s, drop_map i s') \<in> act)"
paulson@13786
   285
apply (unfold extend_act_def, auto)
paulson@13786
   286
apply (rule bexI, auto)
paulson@13786
   287
done
paulson@13786
   288
paulson@13786
   289
lemma preserves_snd_lift_stable:
paulson@13805
   290
     "[| F \<in> preserves snd;  i\<noteq>j |]  
paulson@13805
   291
      ==> lift j F \<in> stable (lift_set i (A <*> UNIV))"
paulson@13798
   292
apply (auto simp add: lift_def lift_set_def stable_def constrains_def 
paulson@13798
   293
                      rename_def extend_def mem_rename_set_iff)
paulson@13786
   294
apply (auto dest!: preserves_imp_eq simp add: lift_map_def drop_map_def)
paulson@13786
   295
apply (drule_tac x = i in fun_cong, auto)
paulson@13786
   296
done
paulson@13786
   297
paulson@13805
   298
(*If i\<noteq>j then lift j F  does nothing to lift_set i, and the 
paulson@13805
   299
  premise ensures A \<subseteq> B.*)
paulson@13786
   300
lemma constrains_imp_lift_constrains:
paulson@13805
   301
    "[| F i \<in> (A <*> UNIV) co (B <*> UNIV);   
paulson@13805
   302
        F j \<in> preserves snd |]   
paulson@13805
   303
     ==> lift j (F j) \<in> (lift_set i (A <*> UNIV)) co (lift_set i (B <*> UNIV))"
wenzelm@46911
   304
apply (cases "i=j")
paulson@13786
   305
apply (simp add: lift_def lift_set_def rename_constrains)
paulson@13798
   306
apply (erule preserves_snd_lift_stable[THEN stableD, THEN constrains_weaken_R],
paulson@13798
   307
       assumption)
paulson@13786
   308
apply (erule constrains_imp_subset [THEN lift_set_mono])
paulson@13786
   309
done
paulson@13786
   310
paulson@13786
   311
(*USELESS??*)
paulson@13812
   312
lemma lift_map_image_Times:
paulson@13812
   313
     "lift_map i ` (A <*> UNIV) =  
paulson@13805
   314
      (\<Union>s \<in> A. \<Union>f. {insert_map i s f}) <*> UNIV"
paulson@13786
   315
apply (auto intro!: bexI image_eqI simp add: lift_map_def)
paulson@13786
   316
apply (rule split_conv [symmetric])
paulson@13786
   317
done
paulson@13786
   318
paulson@13786
   319
lemma lift_preserves_eq:
paulson@13805
   320
     "(lift i F \<in> preserves v) = (F \<in> preserves (v o lift_map i))"
paulson@13786
   321
by (simp add: lift_def rename_preserves)
paulson@13786
   322
paulson@13786
   323
(*A useful rewrite.  If o, sub have been rewritten out already then can also
paulson@13786
   324
  use it as   rewrite_rule [sub_def, o_def] lift_preserves_sub*)
paulson@13786
   325
lemma lift_preserves_sub:
paulson@13805
   326
     "F \<in> preserves snd  
paulson@13805
   327
      ==> lift i F \<in> preserves (v o sub j o fst) =  
paulson@13805
   328
          (if i=j then F \<in> preserves (v o fst) else True)"
paulson@13786
   329
apply (drule subset_preserves_o [THEN subsetD])
wenzelm@46577
   330
apply (simp add: lift_preserves_eq o_def)
paulson@13798
   331
apply (auto cong del: if_weak_cong 
wenzelm@46577
   332
       simp add: lift_map_def eq_commute split_def o_def)
paulson@13786
   333
done
paulson@13786
   334
paulson@13786
   335
paulson@13812
   336
subsection{*Lemmas to Handle Function Composition (o) More Consistently*}
paulson@13786
   337
paulson@13786
   338
(*Lets us prove one version of a theorem and store others*)
paulson@13786
   339
lemma o_equiv_assoc: "f o g = h ==> f' o f o g = f' o h"
nipkow@39302
   340
by (simp add: fun_eq_iff o_def)
paulson@13786
   341
paulson@13805
   342
lemma o_equiv_apply: "f o g = h ==> \<forall>x. f(g x) = h x"
nipkow@39302
   343
by (simp add: fun_eq_iff o_def)
paulson@13786
   344
paulson@13786
   345
lemma fst_o_lift_map: "sub i o fst o lift_map i = fst"
paulson@13786
   346
apply (rule ext)
paulson@13786
   347
apply (auto simp add: o_def lift_map_def sub_def)
paulson@13786
   348
done
paulson@13786
   349
paulson@13786
   350
lemma snd_o_lift_map: "snd o lift_map i = snd o snd"
paulson@13786
   351
apply (rule ext)
paulson@13786
   352
apply (auto simp add: o_def lift_map_def)
paulson@13786
   353
done
paulson@13786
   354
paulson@13786
   355
paulson@13812
   356
subsection{*More lemmas about extend and project*}
paulson@13786
   357
paulson@13812
   358
text{*They could be moved to theory Extend or Project*}
paulson@13812
   359
paulson@13812
   360
lemma extend_act_extend_act:
paulson@13812
   361
     "extend_act h' (extend_act h act) =  
paulson@13786
   362
      extend_act (%(x,(y,y')). h'(h(x,y),y')) act"
paulson@13786
   363
apply (auto elim!: rev_bexI simp add: extend_act_def, blast) 
paulson@13786
   364
done
paulson@13786
   365
paulson@13812
   366
lemma project_act_project_act:
paulson@13812
   367
     "project_act h (project_act h' act) =  
paulson@13786
   368
      project_act (%(x,(y,y')). h'(h(x,y),y')) act"
paulson@13786
   369
by (auto elim!: rev_bexI simp add: project_act_def)
paulson@13786
   370
paulson@13786
   371
lemma project_act_extend_act:
paulson@13786
   372
     "project_act h (extend_act h' act) =  
paulson@13805
   373
        {(x,x'). \<exists>s s' y y' z. (s,s') \<in> act &  
paulson@13786
   374
                 h(x,y) = h'(s,z) & h(x',y') = h'(s',z)}"
paulson@13786
   375
by (simp add: extend_act_def project_act_def, blast)
paulson@13786
   376
paulson@13786
   377
paulson@13812
   378
subsection{*OK and "lift"*}
paulson@13786
   379
paulson@13786
   380
lemma act_in_UNION_preserves_fst:
paulson@13805
   381
     "act \<subseteq> {(x,x'). fst x = fst x'} ==> act \<in> UNION (preserves fst) Acts"
paulson@13786
   382
apply (rule_tac a = "mk_program (UNIV,{act},UNIV) " in UN_I)
paulson@13786
   383
apply (auto simp add: preserves_def stable_def constrains_def)
paulson@13786
   384
done
paulson@13786
   385
paulson@13786
   386
lemma UNION_OK_lift_I:
paulson@13805
   387
     "[| \<forall>i \<in> I. F i \<in> preserves snd;   
paulson@13805
   388
         \<forall>i \<in> I. UNION (preserves fst) Acts \<subseteq> AllowedActs (F i) |]  
paulson@13786
   389
      ==> OK I (%i. lift i (F i))"
paulson@13790
   390
apply (auto simp add: OK_def lift_def rename_def Extend.Acts_extend)
paulson@13798
   391
apply (simp add: Extend.AllowedActs_extend project_act_extend_act)
paulson@13786
   392
apply (rename_tac "act")
paulson@13786
   393
apply (subgoal_tac
paulson@13786
   394
       "{(x, x'). \<exists>s f u s' f' u'. 
paulson@13805
   395
                    ((s, f, u), s', f', u') \<in> act & 
paulson@13786
   396
                    lift_map j x = lift_map i (s, f, u) & 
paulson@13786
   397
                    lift_map j x' = lift_map i (s', f', u') } 
paulson@13805
   398
                \<subseteq> { (x,x') . fst x = fst x'}")
paulson@13786
   399
apply (blast intro: act_in_UNION_preserves_fst, clarify)
paulson@13786
   400
apply (drule_tac x = j in fun_cong)+
paulson@13786
   401
apply (drule_tac x = i in bspec, assumption)
paulson@13786
   402
apply (frule preserves_imp_eq, auto)
paulson@13786
   403
done
paulson@13786
   404
paulson@13786
   405
lemma OK_lift_I:
paulson@13805
   406
     "[| \<forall>i \<in> I. F i \<in> preserves snd;   
paulson@13805
   407
         \<forall>i \<in> I. preserves fst \<subseteq> Allowed (F i) |]  
paulson@13786
   408
      ==> OK I (%i. lift i (F i))"
paulson@13786
   409
by (simp add: safety_prop_AllowedActs_iff_Allowed UNION_OK_lift_I)
paulson@13786
   410
paulson@13786
   411
lemma Allowed_lift [simp]: "Allowed (lift i F) = lift i ` (Allowed F)"
wenzelm@46577
   412
by (simp add: lift_def)
paulson@13786
   413
paulson@13790
   414
lemma lift_image_preserves:
paulson@13790
   415
     "lift i ` preserves v = preserves (v o drop_map i)"
wenzelm@46577
   416
by (simp add: rename_image_preserves lift_def)
paulson@13786
   417
paulson@7186
   418
end