src/ZF/UNITY/Union.ML
author paulson
Wed, 08 Aug 2001 14:33:10 +0200
changeset 11479 697dcaaf478f
child 12195 ed2893765a08
permissions -rw-r--r--
new ZF/UNITY theory
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     1
(*  Title:      ZF/UNITY/Union.ML
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     2
    ID:         $Id$
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     3
    Author:     Sidi O Ehmety, Computer Laboratory
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     4
    Copyright   2001  University of Cambridge
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     5
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     6
Unions of programs
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     7
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     8
From Misra's Chapter 5: Asynchronous Compositions of Programs
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     9
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    10
Proofs ported from HOL.
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    11
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    12
*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    13
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    14
(** SKIP **)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    15
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    16
Goal "reachable(SKIP) = state";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    17
by (force_tac (claset() addEs [reachable.induct]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    18
                        addIs reachable.intrs, simpset()) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    19
qed "reachable_SKIP";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    20
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    21
Addsimps [reachable_SKIP];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    22
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    23
(* Elimination programify from ok and Join *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    24
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    25
Goal "programify(F) ok G <-> F ok G";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    26
by (simp_tac (simpset() addsimps [ok_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    27
qed "ok_programify_left";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    28
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    29
Goal "F ok programify(G) <-> F ok G";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    30
by (simp_tac (simpset() addsimps [ok_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    31
qed "ok_programify_right";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    32
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    33
Goal "programify(F) Join G = F Join G";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    34
by (simp_tac (simpset() addsimps [Join_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    35
qed "Join_programify_left";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    36
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    37
Goal "F Join programify(G) = F Join G";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    38
by (simp_tac (simpset() addsimps [Join_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    39
qed "Join_programify_right";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    40
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    41
Addsimps [ok_programify_left, ok_programify_right, 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    42
          Join_programify_left, Join_programify_right];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    43
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    44
(** SKIP and safety properties **)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    45
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    46
Goalw [constrains_def] 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    47
"[| A:condition; B:condition |] ==> (SKIP: A co B) <-> (A<=B)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    48
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    49
qed "SKIP_in_constrains_iff";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    50
Addsimps [SKIP_in_constrains_iff];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    51
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    52
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    53
Goalw [Constrains_def] 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    54
"[| A:condition; B:condition |] ==> (SKIP : A Co B)<-> (A<=B)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    55
by (Asm_simp_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    56
by (auto_tac (claset(), 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    57
    simpset() addsimps [condition_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    58
qed "SKIP_in_Constrains_iff";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    59
Addsimps [SKIP_in_Constrains_iff];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    60
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    61
Goal "A:condition ==>SKIP : stable(A)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    62
by (auto_tac (claset(), 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    63
    simpset() addsimps [stable_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    64
qed "SKIP_in_stable";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    65
Addsimps [SKIP_in_stable, SKIP_in_stable RS stable_imp_Stable];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    66
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    67
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    68
(** Join and JOIN types **)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    69
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    70
Goalw [Join_def]  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    71
  "F Join G : program";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    72
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    73
qed "Join_in_program";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    74
AddIffs [Join_in_program];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    75
AddTCs [Join_in_program];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    76
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    77
Goalw [JOIN_def]  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    78
"JOIN(I,F):program";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    79
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    80
qed "JOIN_in_program";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    81
AddIffs [JOIN_in_program];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    82
AddTCs [JOIN_in_program];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    83
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    84
(* Init, Acts, and AllowedActs of Join and JOIN *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    85
Goal "Init(F Join G) = Init(F) Int Init(G)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    86
by (simp_tac (simpset() 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    87
         addsimps [Int_assoc, Join_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    88
qed "Init_Join";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    89
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    90
Goal "Acts(F Join G) = Acts(F) Un Acts(G)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    91
by (simp_tac (simpset() 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    92
     addsimps [Int_Un_distrib,cons_absorb,Join_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    93
qed "Acts_Join";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    94
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    95
Goal "AllowedActs(F Join G) = \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    96
\ AllowedActs(F) Int AllowedActs(G)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    97
by (simp_tac (simpset() 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    98
     addsimps [Int_assoc,cons_absorb,Join_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    99
qed "AllowedActs_Join";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   100
Addsimps [Init_Join, Acts_Join, AllowedActs_Join];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   101
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   102
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   103
(** Join's algebraic laws **)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   104
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   105
Goal "F Join G = G Join F";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   106
by (simp_tac (simpset() addsimps 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   107
     [Join_def, Un_commute, Int_commute]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   108
qed "Join_commute";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   109
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   110
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   111
Goal "A Join (B Join C) = B Join (A Join C)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   112
by (asm_simp_tac (simpset() addsimps 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   113
     Un_ac@Int_ac@[Join_def,Int_Un_distrib, cons_absorb]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   114
qed "Join_left_commute";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   115
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   116
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   117
Goal "(F Join G) Join H = F Join (G Join H)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   118
by (asm_simp_tac (simpset() addsimps 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   119
          Un_ac@[Join_def, cons_absorb, Int_assoc, Int_Un_distrib]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   120
qed "Join_assoc";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   121
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   122
Goalw [Join_def, SKIP_def] 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   123
    "SKIP Join F = programify(F)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   124
by (simp_tac (simpset() addsimps [Int_absorb, cons_absorb,cons_eq]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   125
qed "Join_SKIP_left";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   126
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   127
Goal  "F Join SKIP =  programify(F)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   128
by (stac Join_commute 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   129
by (asm_simp_tac (simpset() addsimps [Join_SKIP_left]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   130
qed "Join_SKIP_right";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   131
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   132
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   133
Addsimps [Join_SKIP_left, Join_SKIP_right];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   134
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   135
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   136
Goal "F Join F = programify(F)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   137
by (rtac program_equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   138
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   139
qed "Join_absorb";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   140
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   141
Addsimps [Join_absorb];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   142
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   143
Goal "F Join (F Join G) = F Join G";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   144
by (asm_simp_tac (simpset() addsimps [Join_assoc RS sym]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   145
qed "Join_left_absorb";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   146
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   147
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   148
(*Join is an AC-operator*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   149
val Join_ac = [Join_assoc, Join_left_absorb, Join_commute, Join_left_commute];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   150
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   151
(** Eliminating programify in JN and OK expressions **)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   152
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   153
Goal "OK(I, %x. programify(F(x))) <-> OK(I, F)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   154
by (simp_tac (simpset() addsimps [OK_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   155
qed "OK_programify";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   156
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   157
Goal "JOIN(I, %x. programify(F(x))) = JOIN(I, F)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   158
by (simp_tac (simpset() addsimps [JOIN_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   159
qed "JN_programify";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   160
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   161
Addsimps [OK_programify, JN_programify];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   162
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   163
(* JN *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   164
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   165
Goalw [JOIN_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   166
"JOIN(0, F) = SKIP";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   167
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   168
qed "JN_empty";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   169
Addsimps [JN_empty];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   170
AddSEs [not_emptyE];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   171
Addsimps [Inter_0];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   172
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   173
Goal
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   174
   "Init(JN i:I. F(i)) = (if I=0 then state else (INT i:I. Init(F(i))))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   175
by (Asm_full_simp_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   176
by (Clarify_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   177
by (auto_tac (claset(), simpset() 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   178
         addsimps [JOIN_def,INT_Int_distrib2]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   179
qed "Init_JN";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   180
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   181
Goal
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   182
"Acts(JOIN(I,F)) = cons(Id, UN i:I.  Acts(F(i)))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   183
by (auto_tac (claset(), 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   184
    simpset() addsimps [JOIN_def, UN_Int_distrib]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   185
qed "Acts_JN";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   186
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   187
Goal
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   188
"AllowedActs(JN i:I. F(i)) = (if I=0 then action else (INT i:I. AllowedActs(F(i))))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   189
by (auto_tac (claset(), simpset() 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   190
               addsimps [JOIN_def, INT_cons RS sym, INT_Int_distrib2]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   191
qed "AllowedActs_JN";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   192
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   193
Addsimps [Init_JN, Acts_JN, AllowedActs_JN];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   194
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   195
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   196
Goal "(JN i:cons(a,I). F(i)) = F(a) Join (JN i:I. F(i))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   197
by (rtac program_equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   198
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   199
qed "JN_cons";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   200
Addsimps[JN_cons];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   201
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   202
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   203
val prems = Goalw [JOIN_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   204
    "[| I=J;  !!i. i:J ==> F(i) = G(i) |] ==> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   205
\    (JN i:I. F(i)) = (JN i:J. G(i))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   206
by (asm_simp_tac (simpset() addsimps prems) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   207
qed "JN_cong";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   208
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   209
Addcongs [JN_cong];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   210
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   211
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   212
(*** JN laws ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   213
Goal "k:I ==>F(k) Join (JN i:I. F(i)) = (JN i:I. F(i))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   214
by (stac (JN_cons RS sym) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   215
by (auto_tac (claset(), 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   216
           simpset() addsimps [cons_absorb]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   217
qed "JN_absorb";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   218
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   219
Goalw [Inter_def] "[| i:I; j:J |] ==> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   220
\  (INT i:I Un J. A(i)) = ((INT i:I. A(i)) Int  (INT j:J. A(j)))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   221
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   222
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   223
qed "INT_Un";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   224
  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   225
Goal "(JN i: I Un J. F(i)) = ((JN i: I. F(i)) Join (JN i:J. F(i)))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   226
by (rtac program_equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   227
by (ALLGOALS(Asm_full_simp_tac));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   228
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   229
by (ALLGOALS(asm_full_simp_tac (simpset() 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   230
        addsimps [Int_absorb, INT_Int_distrib2, 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   231
                 Int_INT_distrib, UN_cons, INT_cons])));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   232
by (ALLGOALS(Clarify_tac));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   233
by (REPEAT(Blast_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   234
qed "JN_Un";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   235
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   236
Goal "(JN i:I. c) = (if I=0 then SKIP else programify(c))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   237
by (rtac program_equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   238
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   239
qed "JN_constant";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   240
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   241
Goal 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   242
"(JN i:I. F(i) Join G(i)) = (JN i:I. F(i))  Join  (JN i:I. G(i))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   243
by (rtac program_equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   244
by (ALLGOALS(simp_tac (simpset() addsimps [Int_absorb])));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   245
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   246
by (ALLGOALS(asm_full_simp_tac (simpset() addsimps 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   247
              [INT_Int_distrib, Int_absorb])));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   248
by (Force_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   249
qed "JN_Join_distrib";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   250
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   251
Goal 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   252
"(JN i:I. F(i) Join G) = ((JN i:I. F(i) Join G))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   253
by (asm_simp_tac (simpset() 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   254
    addsimps [JN_Join_distrib, JN_constant]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   255
qed "JN_Join_miniscope";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   256
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   257
(*Used to prove guarantees_JN_I*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   258
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   259
Goal "i:I==>F(i) Join JOIN(I - {i}, F) = JOIN(I, F)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   260
by (rtac program_equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   261
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   262
qed "JN_Join_diff";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   263
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   264
(*** Safety: co, stable, FP ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   265
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   266
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   267
(*Fails if I=0 because it collapses to SKIP : A co B, i.e. to A<=B.  So an
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   268
  alternative precondition is A<=B, but most proofs using this rule require
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   269
  I to be nonempty for other reasons anyway.*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   270
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   271
Goalw [constrains_def, JOIN_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   272
 "i:I==>(JN i:I. F(i)):A co B <-> (ALL i:I. programify(F(i)):A co B)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   273
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   274
by (blast_tac (claset() addDs [ActsD]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   275
qed "JN_constrains";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   276
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   277
Goal "(F Join G : A co B) <-> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   278
\  (programify(F):A co B & programify(G):A co B)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   279
by (auto_tac
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   280
    (claset(), simpset() addsimps [constrains_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   281
qed "Join_constrains";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   282
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   283
Goal "(F Join G : A unless B) <-> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   284
\   (programify(F) : A unless B & programify(G):A unless B)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   285
by (asm_simp_tac (simpset() addsimps [Join_constrains, unless_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   286
qed "Join_unless";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   287
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   288
Addsimps [Join_constrains, Join_unless];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   289
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   290
(*Analogous weak versions FAIL; see Misra [1994] 5.4.1, Substitution Axiom.
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   291
  reachable (F Join G) could be much bigger than reachable F, reachable G
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   292
*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   293
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   294
Goal "[| F : A co A';  G:B co B' |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   295
\     ==> F Join G : (A Int B) co (A' Un B')";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   296
by (subgoal_tac "A:condition&A':condition & B: condition&  \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   297
                \ B': condition & F:program & G:program" 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   298
by (blast_tac (claset()  addDs [constrainsD2]) 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   299
by (Asm_simp_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   300
by (blast_tac (claset() addIs [constrains_weaken]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   301
qed "Join_constrains_weaken";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   302
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   303
(*If I=0, it degenerates to SKIP : UNIV co 0, which is false.*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   304
Goal "[| ALL i:I. F(i) : A(i) co A'(i);  i: I |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   305
\     ==> (JN i:I. F(i)) : (INT i:I. A(i)) co (UN i:I. A'(i))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   306
by (asm_simp_tac (simpset() addsimps [JN_constrains]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   307
by (Clarify_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   308
by (subgoal_tac "(ALL i:I. F(i):program & A(i):condition)&\
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   309
                \ (Union(RepFun(I, A')):condition)&\
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   310
                \ (Inter(RepFun(I, A)):condition)" 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   311
by (blast_tac (claset() addDs [constrainsD2]) 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   312
by (Asm_simp_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   313
by (blast_tac (claset() addIs [constrains_weaken]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   314
qed "JN_constrains_weaken";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   315
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   316
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   317
Goal "A:condition ==> (JN i:I. F(i)) : stable(A) <-> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   318
\ (ALL i:I. programify(F(i)):stable(A))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   319
by (asm_simp_tac 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   320
    (simpset() addsimps [stable_def, constrains_def, JOIN_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   321
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   322
by (blast_tac (claset() addDs [ActsD]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   323
qed "JN_stable";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   324
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   325
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   326
Goal "[| ALL i:I. F(i) : invariant(A);  i : I |]  \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   327
\      ==> (JN i:I. F(i)) : invariant(A)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   328
by (subgoal_tac "A:condition" 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   329
by (blast_tac (claset() addDs [invariantD2]) 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   330
by (asm_full_simp_tac (simpset() addsimps [invariant_def, JN_stable]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   331
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   332
bind_thm ("invariant_JN_I", ballI RS result());
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   333
Goal " (F Join G : stable(A)) <->  \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   334
\     (programify(F) : stable(A) & programify(G): stable(A))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   335
by (asm_simp_tac (simpset() addsimps [stable_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   336
qed "Join_stable";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   337
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   338
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   339
(* TO BE DONE: stable_increasing *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   340
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   341
Addsimps [Join_stable];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   342
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   343
Goal "[| F : invariant(A); G : invariant(A) |]  \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   344
\     ==> F Join G : invariant(A)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   345
by (subgoal_tac "F:program&G:program" 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   346
by (blast_tac (claset() addDs [invariantD2]) 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   347
by (full_simp_tac (simpset() addsimps [invariant_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   348
by (auto_tac (claset() addIs [Join_in_program], simpset()));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   349
qed "invariant_JoinI";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   350
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   351
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   352
(* Fails if I=0 because INT i:0. A(i) = 0 *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   353
Goal "i:I ==> FP(JN i:I. F(i)) = (INT i:I. FP (programify(F(i))))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   354
by (asm_simp_tac (simpset() addsimps [FP_def, Inter_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   355
by (rtac equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   356
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   357
by (ALLGOALS(subgoal_tac "{x}:condition"));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   358
by (rotate_tac ~1 3);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   359
by (rotate_tac ~1 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   360
by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [JN_stable])));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   361
by (rewrite_goals_tac [condition_def]);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   362
by (REPEAT(Blast_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   363
qed "FP_JN";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   364
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   365
(*** Progress: transient, ensures ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   366
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   367
Goal "i:I==>(JN i:I. F(i)) : transient(A) <-> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   368
\  (EX i:I. programify(F(i)) : transient(A))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   369
by (auto_tac (claset(),
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   370
              simpset() addsimps [transient_def, JOIN_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   371
by (auto_tac (claset(), simpset() addsimps 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   372
            [condition_def,UN_Int_distrib, INT_Int_distrib]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   373
qed "JN_transient";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   374
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   375
Goal "F Join G : transient(A) <-> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   376
\     (programify(F) : transient(A) | programify(G):transient(A))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   377
by (auto_tac (claset(),
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   378
              simpset() addsimps [transient_def,
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   379
                                  Join_def, Int_Un_distrib]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   380
qed "Join_transient";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   381
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   382
Addsimps [Join_transient];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   383
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   384
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   385
Goal "F : transient(A) ==> F Join G : transient(A)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   386
by (asm_full_simp_tac (simpset() 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   387
           addsimps [Join_transient, transientD]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   388
qed "Join_transient_I1";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   389
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   390
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   391
Goal "G : transient(A) ==> F Join G : transient(A)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   392
by (asm_full_simp_tac (simpset() 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   393
           addsimps [Join_transient, transientD]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   394
qed "Join_transient_I2";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   395
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   396
(*If I=0 it degenerates to (SKIP : A ensures B) = False, i.e. to ~(A<=B) *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   397
Goal "i : I ==> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   398
\     (JN i:I. F(i)) : A ensures B <-> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   399
\     ((ALL i:I. programify(F(i)) : (A-B) co (A Un B)) &  \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   400
\     (EX i:I. programify(F(i)) : A ensures B))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   401
by (auto_tac (claset(),
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   402
              simpset() addsimps [ensures_def, JN_constrains, JN_transient]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   403
qed "JN_ensures";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   404
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   405
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   406
Goalw [ensures_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   407
     "F Join G : A ensures B  <->     \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   408
\     (programify(F) : (A-B) co (A Un B) & programify(G) : (A-B) co (A Un B) & \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   409
\      (programify(F): transient (A-B) | programify(G) : transient (A-B)))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   410
by (auto_tac (claset(), simpset() addsimps [Join_transient]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   411
qed "Join_ensures";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   412
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   413
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   414
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   415
Goalw [stable_def, constrains_def, Join_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   416
    "[| F : stable(A);  G : A co A' |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   417
\    ==> F Join G : A co A'";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   418
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   419
by (rewrite_goals_tac [condition_def]);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   420
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   421
by (blast_tac (claset() addDs [ActsD]) 3);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   422
by (dres_inst_tac [("x", "Id")] bspec 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   423
by (dres_inst_tac [("x", "Id")] bspec 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   424
by (dres_inst_tac [("x", "x")] bspec 4);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   425
by (dres_inst_tac [("x", "Id")] bspec 5);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   426
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   427
qed "stable_Join_constrains";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   428
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   429
(*Premise for G cannot use Always because  F: Stable A  is
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   430
   weaker than G : stable A *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   431
Goal "[| F : stable(A);  G : invariant(A) |] ==> F Join G : Always(A)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   432
by (subgoal_tac "A:condition & F:program" 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   433
by (blast_tac (claset() addDs [stableD2]) 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   434
by (asm_full_simp_tac (simpset() addsimps [Always_def, invariant_def, 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   435
                                       Stable_eq_stable]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   436
by (force_tac(claset() addIs [stable_Int], simpset()) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   437
qed "stable_Join_Always1";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   438
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   439
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   440
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   441
(*As above, but exchanging the roles of F and G*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   442
Goal "[| F : invariant(A);  G : stable(A) |] ==> F Join G : Always(A)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   443
by (stac Join_commute 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   444
by (blast_tac (claset() addIs [stable_Join_Always1]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   445
qed "stable_Join_Always2";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   446
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   447
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   448
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   449
Goal "[| F : stable(A);  G : A ensures B |] ==> F Join G : A ensures B";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   450
by (subgoal_tac "F:program&G:program&A:condition&B:condition" 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   451
by (blast_tac (claset() addDs [stableD2, ensuresD2]) 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   452
by (asm_simp_tac (simpset() addsimps [Join_ensures]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   453
by (asm_full_simp_tac (simpset() addsimps [stable_def, ensures_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   454
by (etac constrains_weaken 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   455
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   456
qed "stable_Join_ensures1";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   457
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   458
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   459
(*As above, but exchanging the roles of F and G*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   460
Goal "[| F : A ensures B;  G : stable(A) |] ==> F Join G : A ensures B";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   461
by (stac Join_commute 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   462
by (blast_tac (claset() addIs [stable_Join_ensures1]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   463
qed "stable_Join_ensures2";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   464
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   465
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   466
(*** the ok and OK relations ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   467
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   468
Goal "SKIP ok F";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   469
by (auto_tac (claset() addDs [ActsD],
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   470
   simpset() addsimps [ok_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   471
qed "ok_SKIP1";  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   472
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   473
Goal "F ok SKIP";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   474
by (auto_tac (claset() addDs [ActsD],
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   475
      simpset() addsimps [ok_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   476
qed "ok_SKIP2";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   477
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   478
AddIffs [ok_SKIP1, ok_SKIP2];  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   480
Goal "(F ok G & (F Join G) ok H) <-> (G ok H & F ok (G Join H))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   481
by (auto_tac (claset(), simpset() addsimps [ok_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   482
qed "ok_Join_commute";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   483
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   484
Goal "(F ok G) <->(G ok F)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   485
by (auto_tac (claset(), simpset() addsimps [ok_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   486
qed "ok_commute";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   487
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   488
bind_thm ("ok_sym", ok_commute RS iffD1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   489
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   490
Goal "OK({<0,F>,<1,G>,<2,H>}, snd) <-> (F ok G & (F Join G) ok H)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   491
by (asm_full_simp_tac
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   492
    (simpset() addsimps [ok_def, Join_def,  OK_def,
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   493
                        Int_assoc, cons_absorb, Int_Un_distrib, Ball_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   494
by (rtac iffI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   495
by Safe_tac; 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   496
by (REPEAT(Force_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   497
qed "ok_iff_OK";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   498
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   499
Goal "F ok (G Join H) <-> (F ok G & F ok H)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   500
by (auto_tac (claset(), simpset() addsimps [ok_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   501
qed "ok_Join_iff1";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   502
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   503
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   504
Goal "(G Join H) ok F <-> (G ok F & H ok F)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   505
by (auto_tac (claset(), simpset() addsimps [ok_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   506
qed "ok_Join_iff2";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   507
AddIffs [ok_Join_iff1, ok_Join_iff2];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   508
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   509
(*useful?  Not with the previous two around*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   510
Goal "[| F ok G; (F Join G) ok H |] ==> F ok (G Join H)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   511
by (auto_tac (claset(), simpset() addsimps [ok_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   512
qed "ok_Join_commute_I";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   513
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   514
Goal "F ok JOIN(I,G) <-> (ALL i:I. F ok G(i))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   515
by (auto_tac (claset(), simpset() addsimps [ok_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   516
by (blast_tac (claset() addDs [ActsD]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   517
by (REPEAT(Force_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   518
qed "ok_JN_iff1";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   519
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   520
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   521
Goal "JOIN(I,G) ok F   <->  (ALL i:I. G(i) ok F)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   522
by (auto_tac (claset(), simpset() addsimps [ok_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   523
by (blast_tac (claset() addDs [ActsD]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   524
qed "ok_JN_iff2";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   525
AddIffs [ok_JN_iff1, ok_JN_iff2];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   526
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   527
Goal "OK(I,F) <-> (ALL i: I. ALL j: I-{i}. F(i) ok (F(j)))"; 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   528
by (auto_tac (claset(), simpset() addsimps [ok_def, OK_def]));  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   529
qed "OK_iff_ok";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   530
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   531
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   532
Goal "[| OK(I,F); i: I; j: I; i~=j|] ==> F(i) ok F(j)"; 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   533
by (auto_tac (claset(), simpset() addsimps [OK_iff_ok]));  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   534
qed "OK_imp_ok";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   535
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   536
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   537
(*** Allowed ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   538
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   539
Goal "Allowed(SKIP) = program";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   540
by (auto_tac (claset() addDs [ActsD], 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   541
               simpset() addsimps [Allowed_def]));  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   542
qed "Allowed_SKIP";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   543
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   544
Goal "Allowed(F Join G) = \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   545
\  Allowed(programify(F)) Int Allowed(programify(G))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   546
by (auto_tac (claset(), simpset() addsimps [Allowed_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   547
qed "Allowed_Join";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   548
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   549
Goal "i:I ==> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   550
\  Allowed(JOIN(I,F)) = (INT i:I. Allowed(programify(F(i))))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   551
by (auto_tac (claset(), simpset() addsimps [Allowed_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   552
br equalityI 1;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   553
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   554
qed "Allowed_JN";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   555
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   556
Addsimps [Allowed_SKIP, Allowed_Join, Allowed_JN];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   557
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   558
Goal 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   559
"F ok G <-> (programify(F):Allowed(programify(G)) & \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   560
\  programify(G):Allowed(programify(F)))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   561
by (asm_simp_tac (simpset() addsimps [ok_def, Allowed_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   562
qed "ok_iff_Allowed";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   563
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   564
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   565
Goal "OK(I,F) <-> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   566
\ (ALL i: I. ALL j: I-{i}. programify(F(i)) : Allowed(programify(F(j))))"; 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   567
by (auto_tac (claset(), simpset() addsimps [OK_iff_ok, ok_iff_Allowed]));  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   568
qed "OK_iff_Allowed";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   569
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   570
(*** safety_prop, for reasoning about given instances of "ok" ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   571
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   572
Goal "safety_prop(X) ==> (Acts(G) <= cons(Id, (UN F:X. Acts(F)))) <-> (programify(G):X)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   573
by (full_simp_tac( simpset() addsimps [safety_prop_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   574
by (Clarify_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   575
by (case_tac "G:program" 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   576
by (ALLGOALS(Asm_full_simp_tac));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   577
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   578
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   579
by (Force_tac 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   580
by (force_tac (claset(), simpset() 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   581
          addsimps [programify_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   582
qed "safety_prop_Acts_iff";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   583
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   584
Goal "X:property ==> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   585
\ (safety_prop(X) --> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   586
\ ((UN G:X. Acts(G)) <= AllowedActs(F)) <-> (X <= Allowed(programify(F))))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   587
by (auto_tac (claset(), 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   588
      simpset() addsimps [Allowed_def, 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   589
              safety_prop_Acts_iff RS iff_sym, property_def]));  
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   590
qed "safety_prop_AllowedActs_iff_Allowed";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   591
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   592
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   593
Goal "X:property ==> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   594
\  safety_prop(X) --> Allowed(mk_program(init, acts, UN F:X. Acts(F))) = X";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   595
by (asm_full_simp_tac (simpset() addsimps [Allowed_def, 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   596
        UN_Int_distrib,safety_prop_Acts_iff, property_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   597
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   598
qed "Allowed_eq";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   599
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   600
Goal "[| F == mk_program (init, acts, UN F:X. Acts(F)); X:property; safety_prop(X) |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   601
\     ==> Allowed(F) = X";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   602
by (asm_simp_tac (simpset() addsimps [Allowed_eq]) 1); 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   603
qed "def_prg_Allowed";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   604
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   605
(*For safety_prop to hold, the property must be satisfiable!*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   606
Goal "B:condition ==> safety_prop(A co B) <-> (A <= B)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   607
by (simp_tac (simpset() addsimps [safety_prop_def, constrains_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   608
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   609
by (Blast_tac 2); 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   610
by (force_tac (claset(), simpset() addsimps [condition_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   611
qed "safety_prop_constrains";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   612
Addsimps [safety_prop_constrains];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   613
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   614
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   615
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   616
Goal "A:condition ==>safety_prop(stable(A))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   617
by (asm_simp_tac (simpset() addsimps [stable_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   618
qed "safety_prop_stable";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   619
Addsimps [safety_prop_stable];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   620
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   621
Goal "[| X:property; Y:property |] ==> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   622
\  safety_prop(X) --> safety_prop(Y) --> safety_prop(X Int Y)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   623
by (asm_full_simp_tac (simpset() 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   624
         addsimps [safety_prop_def, property_def]) 1); 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   625
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   626
by (dres_inst_tac [("B", "Union(RepFun(X Int Y, Acts))"),
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   627
                   ("C", "Union(RepFun(Y, Acts))")] subset_trans 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   628
by (dres_inst_tac [("B", "Union(RepFun(X Int Y, Acts))"),
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   629
                   ("C", "Union(RepFun(X, Acts))")] subset_trans 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   630
by (REPEAT(Blast_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   631
qed "safety_prop_Int";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   632
Addsimps [safety_prop_Int];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   633
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   634
(* If I=0 the conclusion becomes safety_prop(0) which is false *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   635
Goal "[| ALL i:I. X(i):property; i:I |] ==> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   636
\  (ALL i:I. safety_prop(X(i))) --> safety_prop(INT i:I. X(i))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   637
by (asm_full_simp_tac (simpset() addsimps [safety_prop_def, property_def]) 1); 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   638
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   639
by (dres_inst_tac [("B", "Union(RepFun(Inter(RepFun(I, X)), Acts))"),
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   640
                   ("C", "Union(RepFun(X(xb), Acts))")] subset_trans 3);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   641
by (REPEAT(Blast_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   642
bind_thm ("safety_prop_Inter", ballI RS result());
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   643
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   644
Goal "[| F == mk_program(init,acts, UN G:X. Acts(G)); safety_prop(X); X:property |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   645
\     ==> F ok G <-> (programify(G):X & acts Int action <= AllowedActs(G))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   646
by (auto_tac (claset(),
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   647
       simpset() addsimps [ok_def, safety_prop_Acts_iff, UN_Int_distrib, property_def]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   648
qed "def_UNION_ok_iff";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   649