src/HOL/UNITY/PPROD.ML
author paulson
Mon Oct 11 10:53:39 1999 +0200 (1999-10-11)
changeset 7826 c6a8b73b6c2a
parent 7689 affe0c2fdfbf
child 7947 b999c1ab9327
permissions -rw-r--r--
working shapshot with "projecting" and "extending"
paulson@5899
     1
(*  Title:      HOL/UNITY/PPROD.ML
paulson@5899
     2
    ID:         $Id$
paulson@5899
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@7188
     4
    Copyright   1999  University of Cambridge
paulson@7188
     5
paulson@7188
     6
Abstraction over replicated components (PLam)
paulson@7188
     7
General products of programs (Pi operation)
paulson@7188
     8
paulson@7826
     9
Probably some dead wood here!
paulson@5899
    10
*)
paulson@5899
    11
paulson@6020
    12
paulson@7826
    13
val image_eqI' = read_instantiate_sg (sign_of thy)
paulson@7826
    14
                     [("x", "?ff(i := ?u)")] image_eqI;
paulson@7826
    15
paulson@5899
    16
(*** Basic properties ***)
paulson@5899
    17
paulson@6842
    18
Goalw [PLam_def] "Init (PLam I F) = (INT i:I. lift_set i (Init (F i)))";
paulson@5972
    19
by Auto_tac;
paulson@6842
    20
qed "Init_PLam";
paulson@6842
    21
Addsimps [Init_PLam];
paulson@5972
    22
paulson@6842
    23
Goal "Acts (PLam I F) = insert Id (UN i:I. lift_act i `` Acts (F i))";
paulson@5899
    24
by (auto_tac (claset(),
paulson@7537
    25
	      simpset() addsimps [PLam_def]));
paulson@6842
    26
qed "Acts_PLam";
paulson@5899
    27
paulson@6842
    28
Goal "PLam {} F = SKIP";
paulson@6842
    29
by (simp_tac (simpset() addsimps [PLam_def]) 1);
paulson@6842
    30
qed "PLam_empty";
paulson@5899
    31
paulson@6842
    32
Goal "(plam i: I. SKIP) = SKIP";
paulson@6842
    33
by (simp_tac (simpset() addsimps [PLam_def,lift_prog_SKIP,JN_constant]) 1);
paulson@6842
    34
qed "PLam_SKIP";
paulson@6299
    35
paulson@6842
    36
Addsimps [PLam_SKIP, PLam_empty];
paulson@5899
    37
paulson@6842
    38
Goalw [PLam_def]
paulson@6842
    39
    "PLam (insert i I) F = (lift_prog i (F i)) Join (PLam I F)";
paulson@5899
    40
by Auto_tac;
paulson@6842
    41
qed "PLam_insert";
paulson@5899
    42
paulson@7399
    43
Goalw [PLam_def] "i : I ==> lift_prog i (F i) <= (PLam I F)";
paulson@5972
    44
(*blast_tac doesn't use HO unification*)
paulson@5972
    45
by (fast_tac (claset() addIs [component_JN]) 1);
paulson@6842
    46
qed "component_PLam";
paulson@5899
    47
paulson@5972
    48
paulson@7523
    49
(** Safety & Progress **)
paulson@6835
    50
paulson@5899
    51
Goal "i : I ==>  \
paulson@6842
    52
\     (PLam I F : (lift_set i A) co (lift_set i B))  =  \
paulson@6536
    53
\     (F i : A co B)";
paulson@7523
    54
by (asm_simp_tac (simpset() addsimps [PLam_def, JN_constrains]) 1);
paulson@7344
    55
by (blast_tac (claset() addIs [lift_prog_constrains RS iffD1, 
paulson@5972
    56
			       constrains_imp_lift_prog_constrains]) 1);
paulson@6842
    57
qed "PLam_constrains";
paulson@5899
    58
paulson@6842
    59
Goal "i : I ==> (PLam I F : stable (lift_set i A)) = (F i : stable A)";
paulson@6842
    60
by (asm_simp_tac (simpset() addsimps [stable_def, PLam_constrains]) 1);
paulson@6842
    61
qed "PLam_stable";
paulson@5972
    62
paulson@7523
    63
Goal "i : I ==> \
paulson@7523
    64
\   PLam I F : transient A = (EX i:I. lift_prog i (F i) : transient A)";
paulson@7523
    65
by (asm_simp_tac (simpset() addsimps [JN_transient, PLam_def]) 1);
paulson@7523
    66
qed "PLam_transient";
paulson@7523
    67
paulson@7523
    68
Addsimps [PLam_constrains, PLam_stable, PLam_transient];
paulson@7523
    69
paulson@7538
    70
Goal "[| i : I;  F i : A ensures B |] ==>  \
paulson@7538
    71
\     PLam I F : (lift_set i A) ensures lift_set i B";
paulson@7538
    72
by (auto_tac (claset(), 
paulson@7538
    73
	      simpset() addsimps [ensures_def, lift_prog_transient_eq_disj]));
paulson@7538
    74
qed "PLam_ensures";
paulson@7538
    75
paulson@7523
    76
Goal "[| i : I;  F i : (A-B) co (A Un B);  F i : transient (A-B) |] ==>  \
paulson@7523
    77
\     PLam I F : (lift_set i A) leadsTo lift_set i B";
paulson@7538
    78
by (rtac (PLam_ensures RS leadsTo_Basis) 1);
paulson@7538
    79
by (rtac ensuresI 2);
paulson@7538
    80
by (ALLGOALS assume_tac);
paulson@7523
    81
qed "PLam_leadsTo_Basis";
paulson@5972
    82
paulson@6842
    83
Goal "[| PLam I F : AA co BB;  i: I |] \
paulson@6835
    84
\     ==> F i : (drop_set i AA) co (drop_set i BB)";
paulson@7188
    85
by (rtac lift_prog_constrains_drop_set 1);
paulson@5972
    86
(*rotate this assumption to be last*)
paulson@6842
    87
by (dres_inst_tac [("psi", "PLam I F : ?C")] asm_rl 1);
paulson@7523
    88
by (asm_full_simp_tac (simpset() addsimps [PLam_def, JN_constrains]) 1);
paulson@7188
    89
qed "PLam_constrains_drop_set";
paulson@5899
    90
paulson@5899
    91
paulson@5972
    92
(** invariant **)
paulson@5972
    93
paulson@6299
    94
Goal "[| F i : invariant A;  i : I |] \
paulson@6842
    95
\     ==> PLam I F : invariant (lift_set i A)";
paulson@5972
    96
by (auto_tac (claset(),
paulson@7523
    97
	      simpset() addsimps [invariant_def]));
paulson@6842
    98
qed "invariant_imp_PLam_invariant";
paulson@5972
    99
paulson@5972
   100
(*The f0 premise ensures that the product is well-defined.*)
paulson@6842
   101
Goal "[| PLam I F : invariant (lift_set i A);  i : I;  \
paulson@6842
   102
\        f0: Init (PLam I F) |] ==> F i : invariant A";
paulson@5899
   103
by (auto_tac (claset(),
paulson@7523
   104
	      simpset() addsimps [invariant_def]));
paulson@5972
   105
by (dres_inst_tac [("c", "f0(i:=x)")] subsetD 1);
paulson@5972
   106
by Auto_tac;
paulson@6842
   107
qed "PLam_invariant_imp_invariant";
paulson@5972
   108
paulson@6842
   109
Goal "[| i : I;  f0: Init (PLam I F) |] \
paulson@6842
   110
\     ==> (PLam I F : invariant (lift_set i A)) = (F i : invariant A)";
paulson@6842
   111
by (blast_tac (claset() addIs [invariant_imp_PLam_invariant, 
paulson@6842
   112
			       PLam_invariant_imp_invariant]) 1);
paulson@6842
   113
qed "PLam_invariant";
paulson@5899
   114
paulson@5972
   115
(*The f0 premise isn't needed if F is a constant program because then
paulson@5972
   116
  we get an initial state by replicating that of F*)
paulson@5972
   117
Goal "i : I \
paulson@6842
   118
\     ==> ((plam x:I. F) : invariant (lift_set i A)) = (F : invariant A)";
paulson@5972
   119
by (auto_tac (claset(),
paulson@7523
   120
	      simpset() addsimps [invariant_def]));
paulson@6842
   121
qed "const_PLam_invariant";
paulson@5972
   122
paulson@5899
   123
paulson@7188
   124
(** Reachability **)
paulson@5972
   125
paulson@6842
   126
Goal "[| f : reachable (PLam I F);  i : I |] ==> f i : reachable (F i)";
paulson@5899
   127
by (etac reachable.induct 1);
paulson@5899
   128
by (auto_tac
paulson@5899
   129
    (claset() addIs reachable.intrs,
paulson@6842
   130
     simpset() addsimps [Acts_PLam]));
paulson@6842
   131
qed "reachable_PLam";
paulson@5899
   132
paulson@6842
   133
(*Result to justify a re-organization of this file*)
paulson@6842
   134
Goal "{f. ALL i:I. f i : R i} = (INT i:I. lift_set i (R i))";
paulson@6867
   135
by Auto_tac;
paulson@6842
   136
result();
paulson@6842
   137
paulson@6842
   138
Goal "reachable (PLam I F) <= (INT i:I. lift_set i (reachable (F i)))";
paulson@6842
   139
by (force_tac (claset() addSDs [reachable_PLam], simpset()) 1);
paulson@6842
   140
qed "reachable_PLam_subset1";
paulson@5899
   141
paulson@6826
   142
(*simplify using reachable_lift_prog??*)
paulson@5972
   143
Goal "[| i ~: I;  A : reachable (F i) |]     \
paulson@6842
   144
\  ==> ALL f. f : reachable (PLam I F)      \
paulson@6842
   145
\             --> f(i:=A) : reachable (lift_prog i (F i) Join PLam I F)";
paulson@5899
   146
by (etac reachable.induct 1);
paulson@5899
   147
by (ALLGOALS Clarify_tac);
paulson@5899
   148
by (etac reachable.induct 1);
paulson@5899
   149
(*Init, Init case*)
paulson@6826
   150
by (force_tac (claset() addIs reachable.intrs, simpset()) 1);
paulson@6842
   151
(*Init of F, action of PLam F case*)
paulson@5972
   152
by (rtac reachable.Acts 1);
paulson@7537
   153
by (Force_tac 1);
paulson@5972
   154
by (assume_tac 1);
paulson@6842
   155
by (force_tac (claset() addIs [ext], simpset() addsimps [Acts_PLam]) 1);
paulson@5899
   156
(*induction over the 2nd "reachable" assumption*)
paulson@5899
   157
by (eres_inst_tac [("xa","f")] reachable.induct 1);
paulson@6842
   158
(*Init of PLam F, action of F case*)
paulson@5899
   159
by (res_inst_tac [("act","lift_act i act")] reachable.Acts 1);
paulson@7537
   160
by (Force_tac 1);
paulson@5899
   161
by (force_tac (claset() addIs [reachable.Init], simpset()) 1);
paulson@5899
   162
by (force_tac (claset() addIs [ext], simpset() addsimps [lift_act_def]) 1);
paulson@6842
   163
(*last case: an action of PLam I F*)
paulson@5972
   164
by (rtac reachable.Acts 1);
paulson@7537
   165
by (Force_tac 1);
paulson@5972
   166
by (assume_tac 1);
paulson@6842
   167
by (force_tac (claset() addIs [ext], simpset() addsimps [Acts_PLam]) 1);
paulson@6842
   168
qed_spec_mp "reachable_lift_Join_PLam";
paulson@5899
   169
paulson@5899
   170
paulson@5899
   171
(*The index set must be finite: otherwise infinitely many copies of F can
paulson@6842
   172
  perform actions, and PLam can never catch up in finite time.*)
paulson@5972
   173
Goal "finite I \
paulson@6842
   174
\     ==> (INT i:I. lift_set i (reachable (F i))) <= reachable (PLam I F)";
paulson@5899
   175
by (etac finite_induct 1);
paulson@5899
   176
by (Simp_tac 1);
paulson@6842
   177
by (force_tac (claset() addDs [reachable_lift_Join_PLam], 
paulson@6842
   178
	       simpset() addsimps [PLam_insert]) 1);
paulson@6842
   179
qed "reachable_PLam_subset2";
paulson@5899
   180
paulson@5972
   181
Goal "finite I ==> \
paulson@6842
   182
\     reachable (PLam I F) = (INT i:I. lift_set i (reachable (F i)))";
paulson@5899
   183
by (REPEAT_FIRST (ares_tac [equalityI,
paulson@6842
   184
			    reachable_PLam_subset1, 
paulson@6842
   185
			    reachable_PLam_subset2]));
paulson@6842
   186
qed "reachable_PLam_eq";
paulson@5899
   187
paulson@5899
   188
paulson@6536
   189
(** Co **)
paulson@5899
   190
paulson@6536
   191
Goal "[| F i : A Co B;  i: I;  finite I |]  \
paulson@6842
   192
\     ==> PLam I F : (lift_set i A) Co (lift_set i B)";
paulson@5899
   193
by (auto_tac
paulson@5899
   194
    (claset(),
paulson@5899
   195
     simpset() addsimps [Constrains_def, Collect_conj_eq RS sym,
paulson@6842
   196
			 reachable_PLam_eq]));
paulson@5899
   197
by (auto_tac (claset(), 
paulson@7537
   198
              simpset() addsimps [constrains_def, PLam_def]));
paulson@5899
   199
by (REPEAT (blast_tac (claset() addIs reachable.intrs) 1));
paulson@6842
   200
qed "Constrains_imp_PLam_Constrains";
paulson@5972
   201
paulson@6842
   202
Goal "[| ALL j:I. f0 j : A j;   i: I |] \
paulson@6842
   203
\     ==> drop_set i (INT j:I. lift_set j (A j)) = A i";
paulson@7523
   204
by (force_tac (claset() addSIs [image_eqI'],
paulson@6842
   205
	       simpset() addsimps [drop_set_def]) 1);
paulson@6842
   206
qed "drop_set_INT_lift_set";
paulson@5972
   207
paulson@6842
   208
(*Again, we need the f0 premise so that PLam I F has an initial state;
paulson@6575
   209
  otherwise its Co-property is vacuous.*)
paulson@6842
   210
Goal "[| PLam I F : (lift_set i A) Co (lift_set i B);  \
paulson@6842
   211
\        i: I;  finite I;  f0: Init (PLam I F) |]  \
paulson@6536
   212
\     ==> F i : A Co B";
paulson@6575
   213
by (full_simp_tac (simpset() addsimps [Constrains_eq_constrains]) 1);
paulson@5972
   214
by (subgoal_tac "ALL i:I. f0 i : reachable (F i)" 1);
paulson@5972
   215
by (blast_tac (claset() addIs [reachable.Init]) 2);
paulson@7188
   216
by (dtac PLam_constrains_drop_set 1);
paulson@5972
   217
by (assume_tac 1);
paulson@5972
   218
by (asm_full_simp_tac
paulson@7523
   219
    (simpset() addsimps [drop_set_Int_lift_set2,
paulson@6842
   220
			 drop_set_INT_lift_set, reachable_PLam_eq]) 1);
paulson@6842
   221
qed "PLam_Constrains_imp_Constrains";
paulson@5899
   222
paulson@5899
   223
paulson@6842
   224
Goal "[| i: I;  finite I;  f0: Init (PLam I F) |]  \
paulson@6842
   225
\     ==> (PLam I F : (lift_set i A) Co (lift_set i B)) =  \
paulson@6536
   226
\         (F i : A Co B)";
paulson@6842
   227
by (blast_tac (claset() addIs [Constrains_imp_PLam_Constrains, 
paulson@6842
   228
			       PLam_Constrains_imp_Constrains]) 1);
paulson@6842
   229
qed "PLam_Constrains";
paulson@5972
   230
paulson@6842
   231
Goal "[| i: I;  finite I;  f0: Init (PLam I F) |]  \
paulson@6842
   232
\     ==> (PLam I F : Stable (lift_set i A)) = (F i : Stable A)";
paulson@6842
   233
by (asm_simp_tac (simpset() delsimps [Init_PLam]
paulson@6842
   234
			    addsimps [Stable_def, PLam_Constrains]) 1);
paulson@6842
   235
qed "PLam_Stable";
paulson@5899
   236
paulson@5899
   237
paulson@6842
   238
(** const_PLam (no dependence on i) doesn't require the f0 premise **)
paulson@5899
   239
paulson@6842
   240
Goal "[| (plam x:I. F) : (lift_set i A) Co (lift_set i B);  \
paulson@5972
   241
\        i: I;  finite I |]  \
paulson@6536
   242
\     ==> F : A Co B";
paulson@6575
   243
by (full_simp_tac (simpset() addsimps [Constrains_eq_constrains]) 1);
paulson@7188
   244
by (dtac PLam_constrains_drop_set 1);
paulson@5972
   245
by (assume_tac 1);
paulson@5972
   246
by (asm_full_simp_tac
paulson@6842
   247
    (simpset() addsimps [drop_set_INT,
paulson@7523
   248
			 drop_set_Int_lift_set2, Collect_conj_eq RS sym,
paulson@6842
   249
			 reachable_PLam_eq]) 1);
paulson@6842
   250
qed "const_PLam_Constrains_imp_Constrains";
paulson@5972
   251
paulson@5972
   252
Goal "[| i: I;  finite I |]  \
paulson@6842
   253
\     ==> ((plam x:I. F) : (lift_set i A) Co (lift_set i B)) =  \
paulson@6536
   254
\         (F : A Co B)";
paulson@6842
   255
by (blast_tac (claset() addIs [Constrains_imp_PLam_Constrains, 
paulson@6842
   256
			       const_PLam_Constrains_imp_Constrains]) 1);
paulson@6842
   257
qed "const_PLam_Constrains";
paulson@5972
   258
paulson@5972
   259
Goal "[| i: I;  finite I |]  \
paulson@6842
   260
\     ==> ((plam x:I. F) : Stable (lift_set i A)) = (F : Stable A)";
paulson@6842
   261
by (asm_simp_tac (simpset() addsimps [Stable_def, const_PLam_Constrains]) 1);
paulson@6842
   262
qed "const_PLam_Stable";
paulson@5972
   263
paulson@7188
   264
Goalw [Increasing_def]
paulson@7188
   265
     "[| i: I;  finite I |]  \
paulson@7188
   266
\     ==> ((plam x:I. F) : Increasing (f o sub i)) = (F : Increasing f)";
paulson@7188
   267
by (subgoal_tac "ALL z. {s. z <= (f o sub i) s} = lift_set i {s. z <= f s}" 1);
paulson@7188
   268
by (asm_simp_tac (simpset() addsimps [lift_set_sub]) 2);
paulson@7188
   269
by (asm_full_simp_tac
paulson@7188
   270
    (simpset() addsimps [finite_lessThan, const_PLam_Stable]) 1);
paulson@7188
   271
qed "const_PLam_Increasing";
paulson@5972
   272
paulson@5972
   273
paulson@5972
   274
(*** guarantees properties ***)
paulson@5972
   275
paulson@6842
   276
Goalw [PLam_def]
paulson@7689
   277
    "[| lift_prog i (F i): X guarantees Y;  i : I |]  \
paulson@7361
   278
\    ==> (PLam I F) : X guarantees Y";
paulson@7344
   279
by (asm_simp_tac (simpset() addsimps [guarantees_JN_I]) 1);
paulson@7344
   280
qed "guarantees_PLam_I";