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