src/HOL/UNITY/Union.thy
author wenzelm
Sat Oct 17 14:43:18 2009 +0200 (2009-10-17)
changeset 32960 69916a850301
parent 30304 d8e4cd2ac2a1
child 35054 a5db9779b026
permissions -rw-r--r--
eliminated hard tabulators, guessing at each author's individual tab-width;
tuned headers;
paulson@5252
     1
(*  Title:      HOL/UNITY/Union.thy
paulson@5252
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@5252
     3
    Copyright   1998  University of Cambridge
paulson@5252
     4
wenzelm@32960
     5
Partly from Misra's Chapter 5: Asynchronous Compositions of Programs.
paulson@5252
     6
*)
paulson@5252
     7
paulson@13798
     8
header{*Unions of Programs*}
paulson@13798
     9
haftmann@16417
    10
theory Union imports SubstAx FP begin
paulson@5252
    11
paulson@5252
    12
constdefs
paulson@10064
    13
paulson@13805
    14
  (*FIXME: conjoin Init F \<inter> Init G \<noteq> {} *) 
paulson@13792
    15
  ok :: "['a program, 'a program] => bool"      (infixl "ok" 65)
paulson@13805
    16
    "F ok G == Acts F \<subseteq> AllowedActs G &
paulson@13805
    17
               Acts G \<subseteq> AllowedActs F"
paulson@10064
    18
paulson@13805
    19
  (*FIXME: conjoin (\<Inter>i \<in> I. Init (F i)) \<noteq> {} *) 
paulson@13792
    20
  OK  :: "['a set, 'a => 'b program] => bool"
paulson@13805
    21
    "OK I F == (\<forall>i \<in> I. \<forall>j \<in> I-{i}. Acts (F i) \<subseteq> AllowedActs (F j))"
paulson@10064
    22
paulson@13792
    23
  JOIN  :: "['a set, 'a => 'b program] => 'b program"
paulson@13805
    24
    "JOIN I F == mk_program (\<Inter>i \<in> I. Init (F i), \<Union>i \<in> I. Acts (F i),
wenzelm@32960
    25
                             \<Inter>i \<in> I. AllowedActs (F i))"
paulson@5252
    26
paulson@13792
    27
  Join :: "['a program, 'a program] => 'a program"      (infixl "Join" 65)
paulson@13805
    28
    "F Join G == mk_program (Init F \<inter> Init G, Acts F \<union> Acts G,
wenzelm@32960
    29
                             AllowedActs F \<inter> AllowedActs G)"
paulson@5252
    30
paulson@13792
    31
  SKIP :: "'a program"
paulson@10064
    32
    "SKIP == mk_program (UNIV, {}, UNIV)"
paulson@10064
    33
paulson@13812
    34
  (*Characterizes safety properties.  Used with specifying Allowed*)
paulson@10064
    35
  safety_prop :: "'a program set => bool"
paulson@13805
    36
    "safety_prop X == SKIP: X & (\<forall>G. Acts G \<subseteq> UNION X Acts --> G \<in> X)"
paulson@5259
    37
paulson@5313
    38
syntax
paulson@13792
    39
  "@JOIN1"     :: "[pttrns, 'b set] => 'b set"         ("(3JN _./ _)" 10)
paulson@13792
    40
  "@JOIN"      :: "[pttrn, 'a set, 'b set] => 'b set"  ("(3JN _:_./ _)" 10)
paulson@5313
    41
paulson@5313
    42
translations
paulson@13805
    43
  "JN x : A. B"   == "JOIN A (%x. B)"
paulson@7359
    44
  "JN x y. B"   == "JN x. JN y. B"
haftmann@30304
    45
  "JN x. B"     == "JOIN CONST UNIV (%x. B)"
paulson@5313
    46
wenzelm@12114
    47
syntax (xsymbols)
paulson@13819
    48
  SKIP     :: "'a program"                              ("\<bottom>")
paulson@13819
    49
  Join     :: "['a program, 'a program] => 'a program"  (infixl "\<squnion>" 65)
paulson@13819
    50
  "@JOIN1" :: "[pttrns, 'b set] => 'b set"              ("(3\<Squnion> _./ _)" 10)
paulson@13819
    51
  "@JOIN"  :: "[pttrn, 'a set, 'b set] => 'b set"       ("(3\<Squnion> _\<in>_./ _)" 10)
paulson@13792
    52
paulson@13792
    53
paulson@13798
    54
subsection{*SKIP*}
paulson@13792
    55
paulson@13792
    56
lemma Init_SKIP [simp]: "Init SKIP = UNIV"
paulson@13792
    57
by (simp add: SKIP_def)
paulson@13792
    58
paulson@13792
    59
lemma Acts_SKIP [simp]: "Acts SKIP = {Id}"
paulson@13792
    60
by (simp add: SKIP_def)
paulson@13792
    61
paulson@13792
    62
lemma AllowedActs_SKIP [simp]: "AllowedActs SKIP = UNIV"
paulson@13792
    63
by (auto simp add: SKIP_def)
paulson@13792
    64
paulson@13792
    65
lemma reachable_SKIP [simp]: "reachable SKIP = UNIV"
paulson@13792
    66
by (force elim: reachable.induct intro: reachable.intros)
paulson@13792
    67
paulson@13798
    68
subsection{*SKIP and safety properties*}
paulson@13792
    69
paulson@13805
    70
lemma SKIP_in_constrains_iff [iff]: "(SKIP \<in> A co B) = (A \<subseteq> B)"
paulson@13792
    71
by (unfold constrains_def, auto)
paulson@13792
    72
paulson@13805
    73
lemma SKIP_in_Constrains_iff [iff]: "(SKIP \<in> A Co B) = (A \<subseteq> B)"
paulson@13792
    74
by (unfold Constrains_def, auto)
paulson@13792
    75
paulson@13805
    76
lemma SKIP_in_stable [iff]: "SKIP \<in> stable A"
paulson@13792
    77
by (unfold stable_def, auto)
paulson@13792
    78
paulson@13792
    79
declare SKIP_in_stable [THEN stable_imp_Stable, iff]
paulson@13792
    80
paulson@13792
    81
paulson@13798
    82
subsection{*Join*}
paulson@13792
    83
paulson@13819
    84
lemma Init_Join [simp]: "Init (F\<squnion>G) = Init F \<inter> Init G"
paulson@13792
    85
by (simp add: Join_def)
paulson@13792
    86
paulson@13819
    87
lemma Acts_Join [simp]: "Acts (F\<squnion>G) = Acts F \<union> Acts G"
paulson@13792
    88
by (auto simp add: Join_def)
paulson@13792
    89
paulson@13792
    90
lemma AllowedActs_Join [simp]:
paulson@13819
    91
     "AllowedActs (F\<squnion>G) = AllowedActs F \<inter> AllowedActs G"
paulson@13792
    92
by (auto simp add: Join_def)
paulson@13792
    93
paulson@13792
    94
paulson@13798
    95
subsection{*JN*}
paulson@13792
    96
paulson@13805
    97
lemma JN_empty [simp]: "(\<Squnion>i\<in>{}. F i) = SKIP"
paulson@13792
    98
by (unfold JOIN_def SKIP_def, auto)
paulson@13792
    99
paulson@13819
   100
lemma JN_insert [simp]: "(\<Squnion>i \<in> insert a I. F i) = (F a)\<squnion>(\<Squnion>i \<in> I. F i)"
paulson@13792
   101
apply (rule program_equalityI)
paulson@13792
   102
apply (auto simp add: JOIN_def Join_def)
paulson@13792
   103
done
paulson@13792
   104
paulson@13805
   105
lemma Init_JN [simp]: "Init (\<Squnion>i \<in> I. F i) = (\<Inter>i \<in> I. Init (F i))"
paulson@13792
   106
by (simp add: JOIN_def)
paulson@13792
   107
paulson@13805
   108
lemma Acts_JN [simp]: "Acts (\<Squnion>i \<in> I. F i) = insert Id (\<Union>i \<in> I. Acts (F i))"
paulson@13792
   109
by (auto simp add: JOIN_def)
paulson@13792
   110
paulson@13792
   111
lemma AllowedActs_JN [simp]:
paulson@13805
   112
     "AllowedActs (\<Squnion>i \<in> I. F i) = (\<Inter>i \<in> I. AllowedActs (F i))"
paulson@13792
   113
by (auto simp add: JOIN_def)
paulson@13792
   114
paulson@13792
   115
paulson@13792
   116
lemma JN_cong [cong]: 
paulson@13805
   117
    "[| I=J;  !!i. i \<in> J ==> F i = G i |] ==> (\<Squnion>i \<in> I. F i) = (\<Squnion>i \<in> J. G i)"
paulson@13792
   118
by (simp add: JOIN_def)
paulson@13792
   119
paulson@13792
   120
paulson@13798
   121
subsection{*Algebraic laws*}
paulson@13792
   122
paulson@13819
   123
lemma Join_commute: "F\<squnion>G = G\<squnion>F"
paulson@13792
   124
by (simp add: Join_def Un_commute Int_commute)
paulson@13792
   125
paulson@13819
   126
lemma Join_assoc: "(F\<squnion>G)\<squnion>H = F\<squnion>(G\<squnion>H)"
paulson@13792
   127
by (simp add: Un_ac Join_def Int_assoc insert_absorb)
paulson@13792
   128
 
paulson@13819
   129
lemma Join_left_commute: "A\<squnion>(B\<squnion>C) = B\<squnion>(A\<squnion>C)"
paulson@13792
   130
by (simp add: Un_ac Int_ac Join_def insert_absorb)
paulson@13792
   131
paulson@13819
   132
lemma Join_SKIP_left [simp]: "SKIP\<squnion>F = F"
paulson@13792
   133
apply (unfold Join_def SKIP_def)
paulson@13792
   134
apply (rule program_equalityI)
paulson@13792
   135
apply (simp_all (no_asm) add: insert_absorb)
paulson@13792
   136
done
paulson@13792
   137
paulson@13819
   138
lemma Join_SKIP_right [simp]: "F\<squnion>SKIP = F"
paulson@13792
   139
apply (unfold Join_def SKIP_def)
paulson@13792
   140
apply (rule program_equalityI)
paulson@13792
   141
apply (simp_all (no_asm) add: insert_absorb)
paulson@13792
   142
done
paulson@13792
   143
paulson@13819
   144
lemma Join_absorb [simp]: "F\<squnion>F = F"
paulson@13792
   145
apply (unfold Join_def)
paulson@13792
   146
apply (rule program_equalityI, auto)
paulson@13792
   147
done
paulson@13792
   148
paulson@13819
   149
lemma Join_left_absorb: "F\<squnion>(F\<squnion>G) = F\<squnion>G"
paulson@13792
   150
apply (unfold Join_def)
paulson@13792
   151
apply (rule program_equalityI, auto)
paulson@13792
   152
done
paulson@13792
   153
paulson@13792
   154
(*Join is an AC-operator*)
paulson@13792
   155
lemmas Join_ac = Join_assoc Join_left_absorb Join_commute Join_left_commute
paulson@13792
   156
paulson@13792
   157
paulson@14150
   158
subsection{*Laws Governing @{text "\<Squnion>"}*}
paulson@13792
   159
paulson@13792
   160
(*Also follows by JN_insert and insert_absorb, but the proof is longer*)
paulson@13819
   161
lemma JN_absorb: "k \<in> I ==> F k\<squnion>(\<Squnion>i \<in> I. F i) = (\<Squnion>i \<in> I. F i)"
paulson@13792
   162
by (auto intro!: program_equalityI)
paulson@13792
   163
paulson@13819
   164
lemma JN_Un: "(\<Squnion>i \<in> I \<union> J. F i) = ((\<Squnion>i \<in> I. F i)\<squnion>(\<Squnion>i \<in> J. F i))"
paulson@13792
   165
by (auto intro!: program_equalityI)
paulson@13792
   166
paulson@13805
   167
lemma JN_constant: "(\<Squnion>i \<in> I. c) = (if I={} then SKIP else c)"
paulson@13792
   168
by (rule program_equalityI, auto)
paulson@13792
   169
paulson@13792
   170
lemma JN_Join_distrib:
paulson@13819
   171
     "(\<Squnion>i \<in> I. F i\<squnion>G i) = (\<Squnion>i \<in> I. F i) \<squnion> (\<Squnion>i \<in> I. G i)"
paulson@13792
   172
by (auto intro!: program_equalityI)
paulson@13792
   173
paulson@13792
   174
lemma JN_Join_miniscope:
paulson@13819
   175
     "i \<in> I ==> (\<Squnion>i \<in> I. F i\<squnion>G) = ((\<Squnion>i \<in> I. F i)\<squnion>G)"
paulson@13792
   176
by (auto simp add: JN_Join_distrib JN_constant)
paulson@13792
   177
paulson@13792
   178
(*Used to prove guarantees_JN_I*)
paulson@13819
   179
lemma JN_Join_diff: "i \<in> I ==> F i\<squnion>JOIN (I - {i}) F = JOIN I F"
paulson@13792
   180
apply (unfold JOIN_def Join_def)
paulson@13792
   181
apply (rule program_equalityI, auto)
paulson@13792
   182
done
paulson@13792
   183
paulson@13792
   184
paulson@13798
   185
subsection{*Safety: co, stable, FP*}
paulson@13792
   186
paulson@13805
   187
(*Fails if I={} because it collapses to SKIP \<in> A co B, i.e. to A \<subseteq> B.  So an
paulson@13805
   188
  alternative precondition is A \<subseteq> B, but most proofs using this rule require
paulson@13792
   189
  I to be nonempty for other reasons anyway.*)
paulson@13792
   190
lemma JN_constrains: 
paulson@13805
   191
    "i \<in> I ==> (\<Squnion>i \<in> I. F i) \<in> A co B = (\<forall>i \<in> I. F i \<in> A co B)"
paulson@13792
   192
by (simp add: constrains_def JOIN_def, blast)
paulson@13792
   193
paulson@13792
   194
lemma Join_constrains [simp]:
paulson@13819
   195
     "(F\<squnion>G \<in> A co B) = (F \<in> A co B & G \<in> A co B)"
paulson@13792
   196
by (auto simp add: constrains_def Join_def)
paulson@13792
   197
paulson@13792
   198
lemma Join_unless [simp]:
paulson@13819
   199
     "(F\<squnion>G \<in> A unless B) = (F \<in> A unless B & G \<in> A unless B)"
paulson@13792
   200
by (simp add: Join_constrains unless_def)
paulson@13792
   201
paulson@13792
   202
(*Analogous weak versions FAIL; see Misra [1994] 5.4.1, Substitution Axiom.
paulson@13819
   203
  reachable (F\<squnion>G) could be much bigger than reachable F, reachable G
paulson@13792
   204
*)
paulson@13792
   205
paulson@13792
   206
paulson@13792
   207
lemma Join_constrains_weaken:
paulson@13805
   208
     "[| F \<in> A co A';  G \<in> B co B' |]  
paulson@13819
   209
      ==> F\<squnion>G \<in> (A \<inter> B) co (A' \<union> B')"
paulson@13792
   210
by (simp, blast intro: constrains_weaken)
paulson@13792
   211
paulson@13805
   212
(*If I={}, it degenerates to SKIP \<in> UNIV co {}, which is false.*)
paulson@13792
   213
lemma JN_constrains_weaken:
paulson@13805
   214
     "[| \<forall>i \<in> I. F i \<in> A i co A' i;  i \<in> I |]  
paulson@13805
   215
      ==> (\<Squnion>i \<in> I. F i) \<in> (\<Inter>i \<in> I. A i) co (\<Union>i \<in> I. A' i)"
paulson@13792
   216
apply (simp (no_asm_simp) add: JN_constrains)
paulson@13792
   217
apply (blast intro: constrains_weaken)
paulson@13792
   218
done
paulson@13792
   219
paulson@13805
   220
lemma JN_stable: "(\<Squnion>i \<in> I. F i) \<in> stable A = (\<forall>i \<in> I. F i \<in> stable A)"
paulson@13792
   221
by (simp add: stable_def constrains_def JOIN_def)
paulson@13792
   222
paulson@13792
   223
lemma invariant_JN_I:
paulson@13805
   224
     "[| !!i. i \<in> I ==> F i \<in> invariant A;  i \<in> I |]   
paulson@13805
   225
       ==> (\<Squnion>i \<in> I. F i) \<in> invariant A"
paulson@13792
   226
by (simp add: invariant_def JN_stable, blast)
paulson@13792
   227
paulson@13792
   228
lemma Join_stable [simp]:
paulson@13819
   229
     "(F\<squnion>G \<in> stable A) =  
paulson@13805
   230
      (F \<in> stable A & G \<in> stable A)"
paulson@13792
   231
by (simp add: stable_def)
paulson@13792
   232
paulson@13792
   233
lemma Join_increasing [simp]:
paulson@13819
   234
     "(F\<squnion>G \<in> increasing f) =  
paulson@13805
   235
      (F \<in> increasing f & G \<in> increasing f)"
paulson@13792
   236
by (simp add: increasing_def Join_stable, blast)
paulson@13792
   237
paulson@13792
   238
lemma invariant_JoinI:
paulson@13805
   239
     "[| F \<in> invariant A; G \<in> invariant A |]   
paulson@13819
   240
      ==> F\<squnion>G \<in> invariant A"
paulson@13792
   241
by (simp add: invariant_def, blast)
paulson@13792
   242
paulson@13805
   243
lemma FP_JN: "FP (\<Squnion>i \<in> I. F i) = (\<Inter>i \<in> I. FP (F i))"
paulson@13792
   244
by (simp add: FP_def JN_stable INTER_def)
paulson@13792
   245
paulson@13792
   246
paulson@13798
   247
subsection{*Progress: transient, ensures*}
paulson@13792
   248
paulson@13792
   249
lemma JN_transient:
paulson@13805
   250
     "i \<in> I ==>  
paulson@13805
   251
    (\<Squnion>i \<in> I. F i) \<in> transient A = (\<exists>i \<in> I. F i \<in> transient A)"
paulson@13792
   252
by (auto simp add: transient_def JOIN_def)
paulson@13792
   253
paulson@13792
   254
lemma Join_transient [simp]:
paulson@13819
   255
     "F\<squnion>G \<in> transient A =  
paulson@13805
   256
      (F \<in> transient A | G \<in> transient A)"
paulson@13792
   257
by (auto simp add: bex_Un transient_def Join_def)
paulson@13792
   258
paulson@13819
   259
lemma Join_transient_I1: "F \<in> transient A ==> F\<squnion>G \<in> transient A"
paulson@13792
   260
by (simp add: Join_transient)
paulson@13792
   261
paulson@13819
   262
lemma Join_transient_I2: "G \<in> transient A ==> F\<squnion>G \<in> transient A"
paulson@13792
   263
by (simp add: Join_transient)
paulson@13792
   264
paulson@13805
   265
(*If I={} it degenerates to (SKIP \<in> A ensures B) = False, i.e. to ~(A \<subseteq> B) *)
paulson@13792
   266
lemma JN_ensures:
paulson@13805
   267
     "i \<in> I ==>  
paulson@13805
   268
      (\<Squnion>i \<in> I. F i) \<in> A ensures B =  
paulson@13805
   269
      ((\<forall>i \<in> I. F i \<in> (A-B) co (A \<union> B)) & (\<exists>i \<in> I. F i \<in> A ensures B))"
paulson@13792
   270
by (auto simp add: ensures_def JN_constrains JN_transient)
paulson@13792
   271
paulson@13792
   272
lemma Join_ensures: 
paulson@13819
   273
     "F\<squnion>G \<in> A ensures B =      
paulson@13805
   274
      (F \<in> (A-B) co (A \<union> B) & G \<in> (A-B) co (A \<union> B) &  
paulson@13805
   275
       (F \<in> transient (A-B) | G \<in> transient (A-B)))"
paulson@13792
   276
by (auto simp add: ensures_def Join_transient)
paulson@13792
   277
paulson@13792
   278
lemma stable_Join_constrains: 
paulson@13805
   279
    "[| F \<in> stable A;  G \<in> A co A' |]  
paulson@13819
   280
     ==> F\<squnion>G \<in> A co A'"
paulson@13792
   281
apply (unfold stable_def constrains_def Join_def)
paulson@13792
   282
apply (simp add: ball_Un, blast)
paulson@13792
   283
done
paulson@13792
   284
paulson@13805
   285
(*Premise for G cannot use Always because  F \<in> Stable A  is weaker than
paulson@13805
   286
  G \<in> stable A *)
paulson@13792
   287
lemma stable_Join_Always1:
paulson@13819
   288
     "[| F \<in> stable A;  G \<in> invariant A |] ==> F\<squnion>G \<in> Always A"
paulson@13792
   289
apply (simp (no_asm_use) add: Always_def invariant_def Stable_eq_stable)
paulson@13792
   290
apply (force intro: stable_Int)
paulson@13792
   291
done
paulson@13792
   292
paulson@13792
   293
(*As above, but exchanging the roles of F and G*)
paulson@13792
   294
lemma stable_Join_Always2:
paulson@13819
   295
     "[| F \<in> invariant A;  G \<in> stable A |] ==> F\<squnion>G \<in> Always A"
paulson@13792
   296
apply (subst Join_commute)
paulson@13792
   297
apply (blast intro: stable_Join_Always1)
paulson@13792
   298
done
paulson@13792
   299
paulson@13792
   300
lemma stable_Join_ensures1:
paulson@13819
   301
     "[| F \<in> stable A;  G \<in> A ensures B |] ==> F\<squnion>G \<in> A ensures B"
paulson@13792
   302
apply (simp (no_asm_simp) add: Join_ensures)
paulson@13792
   303
apply (simp add: stable_def ensures_def)
paulson@13792
   304
apply (erule constrains_weaken, auto)
paulson@13792
   305
done
paulson@13792
   306
paulson@13792
   307
(*As above, but exchanging the roles of F and G*)
paulson@13792
   308
lemma stable_Join_ensures2:
paulson@13819
   309
     "[| F \<in> A ensures B;  G \<in> stable A |] ==> F\<squnion>G \<in> A ensures B"
paulson@13792
   310
apply (subst Join_commute)
paulson@13792
   311
apply (blast intro: stable_Join_ensures1)
paulson@13792
   312
done
paulson@13792
   313
paulson@13792
   314
paulson@13798
   315
subsection{*the ok and OK relations*}
paulson@13792
   316
paulson@13792
   317
lemma ok_SKIP1 [iff]: "SKIP ok F"
paulson@13812
   318
by (simp add: ok_def)
paulson@13792
   319
paulson@13792
   320
lemma ok_SKIP2 [iff]: "F ok SKIP"
paulson@13812
   321
by (simp add: ok_def)
paulson@13792
   322
paulson@13792
   323
lemma ok_Join_commute:
paulson@13819
   324
     "(F ok G & (F\<squnion>G) ok H) = (G ok H & F ok (G\<squnion>H))"
paulson@13792
   325
by (auto simp add: ok_def)
paulson@13792
   326
paulson@13792
   327
lemma ok_commute: "(F ok G) = (G ok F)"
paulson@13792
   328
by (auto simp add: ok_def)
paulson@13792
   329
paulson@13792
   330
lemmas ok_sym = ok_commute [THEN iffD1, standard]
paulson@13792
   331
paulson@13792
   332
lemma ok_iff_OK:
paulson@13819
   333
     "OK {(0::int,F),(1,G),(2,H)} snd = (F ok G & (F\<squnion>G) ok H)"
wenzelm@16977
   334
apply (simp add: Ball_def conj_disj_distribR ok_def Join_def OK_def insert_absorb
wenzelm@16977
   335
              all_conj_distrib)
wenzelm@16977
   336
apply blast
wenzelm@16977
   337
done
paulson@13792
   338
paulson@13819
   339
lemma ok_Join_iff1 [iff]: "F ok (G\<squnion>H) = (F ok G & F ok H)"
paulson@13792
   340
by (auto simp add: ok_def)
paulson@13792
   341
paulson@13819
   342
lemma ok_Join_iff2 [iff]: "(G\<squnion>H) ok F = (G ok F & H ok F)"
paulson@13792
   343
by (auto simp add: ok_def)
paulson@13792
   344
paulson@13792
   345
(*useful?  Not with the previous two around*)
paulson@13819
   346
lemma ok_Join_commute_I: "[| F ok G; (F\<squnion>G) ok H |] ==> F ok (G\<squnion>H)"
paulson@13792
   347
by (auto simp add: ok_def)
paulson@13792
   348
paulson@13805
   349
lemma ok_JN_iff1 [iff]: "F ok (JOIN I G) = (\<forall>i \<in> I. F ok G i)"
paulson@13792
   350
by (auto simp add: ok_def)
paulson@13792
   351
paulson@13805
   352
lemma ok_JN_iff2 [iff]: "(JOIN I G) ok F =  (\<forall>i \<in> I. G i ok F)"
paulson@13792
   353
by (auto simp add: ok_def)
paulson@13792
   354
paulson@13805
   355
lemma OK_iff_ok: "OK I F = (\<forall>i \<in> I. \<forall>j \<in> I-{i}. (F i) ok (F j))"
paulson@13792
   356
by (auto simp add: ok_def OK_def)
paulson@13792
   357
paulson@13805
   358
lemma OK_imp_ok: "[| OK I F; i \<in> I; j \<in> I; i \<noteq> j|] ==> (F i) ok (F j)"
paulson@13792
   359
by (auto simp add: OK_iff_ok)
paulson@13792
   360
paulson@13792
   361
paulson@13798
   362
subsection{*Allowed*}
paulson@13792
   363
paulson@13792
   364
lemma Allowed_SKIP [simp]: "Allowed SKIP = UNIV"
paulson@13792
   365
by (auto simp add: Allowed_def)
paulson@13792
   366
paulson@13819
   367
lemma Allowed_Join [simp]: "Allowed (F\<squnion>G) = Allowed F \<inter> Allowed G"
paulson@13792
   368
by (auto simp add: Allowed_def)
paulson@13792
   369
paulson@13805
   370
lemma Allowed_JN [simp]: "Allowed (JOIN I F) = (\<Inter>i \<in> I. Allowed (F i))"
paulson@13792
   371
by (auto simp add: Allowed_def)
paulson@13792
   372
paulson@13805
   373
lemma ok_iff_Allowed: "F ok G = (F \<in> Allowed G & G \<in> Allowed F)"
paulson@13792
   374
by (simp add: ok_def Allowed_def)
paulson@13792
   375
paulson@13805
   376
lemma OK_iff_Allowed: "OK I F = (\<forall>i \<in> I. \<forall>j \<in> I-{i}. F i \<in> Allowed(F j))"
paulson@13792
   377
by (auto simp add: OK_iff_ok ok_iff_Allowed)
paulson@13792
   378
paulson@13812
   379
subsection{*@{term safety_prop}, for reasoning about
paulson@13798
   380
 given instances of "ok"*}
paulson@13792
   381
paulson@13792
   382
lemma safety_prop_Acts_iff:
paulson@13805
   383
     "safety_prop X ==> (Acts G \<subseteq> insert Id (UNION X Acts)) = (G \<in> X)"
paulson@13792
   384
by (auto simp add: safety_prop_def)
paulson@13792
   385
paulson@13792
   386
lemma safety_prop_AllowedActs_iff_Allowed:
paulson@13805
   387
     "safety_prop X ==> (UNION X Acts \<subseteq> AllowedActs F) = (X \<subseteq> Allowed F)"
paulson@13792
   388
by (auto simp add: Allowed_def safety_prop_Acts_iff [symmetric])
paulson@13792
   389
paulson@13792
   390
lemma Allowed_eq:
paulson@13792
   391
     "safety_prop X ==> Allowed (mk_program (init, acts, UNION X Acts)) = X"
paulson@13792
   392
by (simp add: Allowed_def safety_prop_Acts_iff)
paulson@13792
   393
paulson@13792
   394
(*For safety_prop to hold, the property must be satisfiable!*)
paulson@13805
   395
lemma safety_prop_constrains [iff]: "safety_prop (A co B) = (A \<subseteq> B)"
paulson@13792
   396
by (simp add: safety_prop_def constrains_def, blast)
paulson@13792
   397
paulson@13792
   398
lemma safety_prop_stable [iff]: "safety_prop (stable A)"
paulson@13792
   399
by (simp add: stable_def)
paulson@13792
   400
paulson@13792
   401
lemma safety_prop_Int [simp]:
paulson@13805
   402
     "[| safety_prop X; safety_prop Y |] ==> safety_prop (X \<inter> Y)"
paulson@13792
   403
by (simp add: safety_prop_def, blast)
paulson@13792
   404
paulson@13792
   405
lemma safety_prop_INTER1 [simp]:
paulson@13805
   406
     "(!!i. safety_prop (X i)) ==> safety_prop (\<Inter>i. X i)"
paulson@13792
   407
by (auto simp add: safety_prop_def, blast)
wenzelm@32960
   408
paulson@13792
   409
lemma safety_prop_INTER [simp]:
paulson@13805
   410
     "(!!i. i \<in> I ==> safety_prop (X i)) ==> safety_prop (\<Inter>i \<in> I. X i)"
paulson@13792
   411
by (auto simp add: safety_prop_def, blast)
paulson@13792
   412
paulson@13812
   413
lemma def_prg_Allowed:
paulson@13812
   414
     "[| F == mk_program (init, acts, UNION X Acts) ; safety_prop X |]  
paulson@13812
   415
      ==> Allowed F = X"
paulson@13812
   416
by (simp add: Allowed_eq)
paulson@13812
   417
paulson@13812
   418
lemma Allowed_totalize [simp]: "Allowed (totalize F) = Allowed F"
paulson@13812
   419
by (simp add: Allowed_def) 
paulson@13812
   420
paulson@13812
   421
lemma def_total_prg_Allowed:
paulson@13812
   422
     "[| F == mk_total_program (init, acts, UNION X Acts) ; safety_prop X |]  
paulson@13812
   423
      ==> Allowed F = X"
paulson@13812
   424
by (simp add: mk_total_program_def def_prg_Allowed) 
paulson@13812
   425
paulson@13792
   426
lemma def_UNION_ok_iff:
paulson@13792
   427
     "[| F == mk_program(init,acts,UNION X Acts); safety_prop X |]  
paulson@13805
   428
      ==> F ok G = (G \<in> X & acts \<subseteq> AllowedActs G)"
paulson@13792
   429
by (auto simp add: ok_def safety_prop_Acts_iff)
paulson@9685
   430
paulson@13812
   431
text{*The union of two total programs is total.*}
paulson@13819
   432
lemma totalize_Join: "totalize F\<squnion>totalize G = totalize (F\<squnion>G)"
paulson@13812
   433
by (simp add: program_equalityI totalize_def Join_def image_Un)
paulson@13812
   434
paulson@13819
   435
lemma all_total_Join: "[|all_total F; all_total G|] ==> all_total (F\<squnion>G)"
paulson@13812
   436
by (simp add: all_total_def, blast)
paulson@13812
   437
paulson@13812
   438
lemma totalize_JN: "(\<Squnion>i \<in> I. totalize (F i)) = totalize(\<Squnion>i \<in> I. F i)"
paulson@13812
   439
by (simp add: program_equalityI totalize_def JOIN_def image_UN)
paulson@13812
   440
paulson@13812
   441
lemma all_total_JN: "(!!i. i\<in>I ==> all_total (F i)) ==> all_total(\<Squnion>i\<in>I. F i)"
paulson@13812
   442
by (simp add: all_total_iff_totalize totalize_JN [symmetric])
paulson@13812
   443
paulson@5252
   444
end