src/HOL/UNITY/PPROD.ML
author paulson
Wed, 03 Mar 1999 10:50:42 +0100
changeset 6299 1a88db6e7c7e
parent 6295 351b3c2b0d83
child 6451 bc943acc5fda
permissions -rw-r--r--
UNITY fully working at last...
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/PPROD.ML
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
     2
    ID:         $Id$
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
     5
*)
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
     6
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
     7
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
     8
val rinst = read_instantiate_sg (sign_of thy);
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
     9
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    10
(**** PPROD ****)
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    11
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    12
(*** Basic properties ***)
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    13
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
    14
Goalw [lift_set_def] "(f : lift_set i A) = (f i : A)";
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
    15
by Auto_tac;
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
    16
qed "lift_set_iff";
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
    17
AddIffs [lift_set_iff];
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
    18
6295
351b3c2b0d83 removed the infernal States, eqStates, compatible, etc.
paulson
parents: 6020
diff changeset
    19
Goalw [lift_act_def] "lift_act i Id = Id";
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    20
by Auto_tac;
6295
351b3c2b0d83 removed the infernal States, eqStates, compatible, etc.
paulson
parents: 6020
diff changeset
    21
qed "lift_act_Id";
351b3c2b0d83 removed the infernal States, eqStates, compatible, etc.
paulson
parents: 6020
diff changeset
    22
Addsimps [lift_act_Id];
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    23
6299
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
    24
(*NEEDED????????????????????????????????????????????????????????????????*)
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
    25
Goal "Id : lift_act i `` Acts F";
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
    26
by (auto_tac (claset() addSIs [lift_act_Id RS sym], 
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
    27
	      simpset() addsimps [image_iff]));
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
    28
qed "Id_mem_lift_act";
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
    29
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
    30
Goalw [lift_prog_def] "Init (lift_prog i F) = lift_set i (Init F)";
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    31
by Auto_tac;
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    32
qed "Init_lift_prog";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    33
Addsimps [Init_lift_prog];
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    34
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    35
Goalw [lift_prog_def] "Acts (lift_prog i F) = lift_act i `` Acts F";
6295
351b3c2b0d83 removed the infernal States, eqStates, compatible, etc.
paulson
parents: 6020
diff changeset
    36
by (auto_tac (claset() addIs [Id_in_Acts RSN (2,image_eqI)], simpset()));
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    37
qed "Acts_lift_prog";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    38
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
    39
Goalw [PPROD_def] "Init (PPROD I F) = (INT i:I. lift_set i (Init (F i)))";
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    40
by Auto_tac;
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    41
qed "Init_PPROD";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    42
Addsimps [Init_PPROD];
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    43
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    44
Goalw [lift_act_def]
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    45
    "((f,f') : lift_act i act) = (EX s'. f' = f(i := s') & (f i, s') : act)";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    46
by (Blast_tac 1);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    47
qed "lift_act_eq";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    48
AddIffs [lift_act_eq];
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    49
6299
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
    50
Goal "Acts (PPROD I F) = insert Id (UN i:I. lift_act i `` Acts (F i))";
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    51
by (auto_tac (claset(),
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    52
	      simpset() addsimps [PPROD_def, Acts_lift_prog, Acts_JN]));
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    53
qed "Acts_PPROD";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    54
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    55
Goal "PPROD {} F = SKIP";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    56
by (simp_tac (simpset() addsimps [PPROD_def]) 1);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    57
qed "PPROD_empty";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    58
6299
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
    59
Goal "(PPI i: I. SKIP) = SKIP";
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
    60
by (auto_tac (claset() addSIs [program_equalityI],
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
    61
	      simpset() addsimps [Acts_lift_prog, SKIP_def, Acts_PPROD]));
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
    62
qed "PPROD_SKIP";
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
    63
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    64
Addsimps [PPROD_SKIP, PPROD_empty];
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    65
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    66
Goalw [PPROD_def]
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    67
    "PPROD (insert i I) F = (lift_prog i (F i)) Join (PPROD I F)";
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    68
by Auto_tac;
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    69
qed "PPROD_insert";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    70
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    71
Goalw [PPROD_def] "i : I ==> component (lift_prog i (F i)) (PPROD I F)";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    72
(*blast_tac doesn't use HO unification*)
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    73
by (fast_tac (claset() addIs [component_JN]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    74
qed "component_PPROD";
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    75
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    76
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    77
(*** Safety: constrains, stable, invariant ***)
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    78
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    79
(** 1st formulation of lifting **)
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
    80
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
    81
Goal "(lift_prog i F : constrains (lift_set i A) (lift_set i B))  =  \
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    82
\     (F : constrains A B)";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    83
by (auto_tac (claset(), 
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    84
	      simpset() addsimps [constrains_def, Acts_lift_prog]));
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    85
by (Blast_tac 2);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    86
by (Force_tac 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    87
qed "lift_prog_constrains_eq";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    88
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
    89
Goal "(lift_prog i F : stable (lift_set i A)) = (F : stable A)";
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    90
by (simp_tac (simpset() addsimps [stable_def, lift_prog_constrains_eq]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    91
qed "lift_prog_stable_eq";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    92
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    93
(*This one looks strange!  Proof probably is by case analysis on i=j.*)
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    94
Goal "F i : constrains A B  \
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
    95
\     ==> lift_prog j (F j) : constrains (lift_set i A) (lift_set i B)";
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    96
by (auto_tac (claset(), 
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    97
	      simpset() addsimps [constrains_def, Acts_lift_prog]));
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    98
by (REPEAT (Blast_tac 1));
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
    99
qed "constrains_imp_lift_prog_constrains";
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   100
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   101
Goal "i : I ==>  \
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
   102
\     (PPROD I F : constrains (lift_set i A) (lift_set i B))  =  \
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   103
\     (F i : constrains A B)";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   104
by (asm_simp_tac (simpset() addsimps [PPROD_def, constrains_JN]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   105
by (blast_tac (claset() addIs [lift_prog_constrains_eq RS iffD1, 
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   106
			       constrains_imp_lift_prog_constrains]) 1);
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   107
qed "PPROD_constrains";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   108
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
   109
Goal "i : I ==> (PPROD I F : stable (lift_set i A)) = (F i : stable A)";
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   110
by (asm_simp_tac (simpset() addsimps [stable_def, PPROD_constrains]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   111
qed "PPROD_stable";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   112
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   113
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   114
(** 2nd formulation of lifting **)
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   115
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   116
Goal "[| lift_prog i F : constrains AA BB |] \
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   117
\     ==> F : constrains (Applyall AA i) (Applyall BB i)";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   118
by (auto_tac (claset(), 
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   119
	      simpset() addsimps [Applyall_def, constrains_def, 
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   120
				  Acts_lift_prog]));
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   121
by (force_tac (claset() addSIs [rinst [("x", "?ff(i := ?u)")] image_eqI],
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   122
	       simpset()) 1);
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   123
qed "lift_prog_constrains_projection";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   124
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   125
Goal "[| PPROD I F : constrains AA BB;  i: I |] \
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   126
\     ==> F i : constrains (Applyall AA i) (Applyall BB i)";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   127
by (rtac lift_prog_constrains_projection 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   128
(*rotate this assumption to be last*)
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   129
by (dres_inst_tac [("psi", "PPROD I F : ?C")] asm_rl 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   130
by (asm_full_simp_tac (simpset() addsimps [PPROD_def, constrains_JN]) 1);
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   131
qed "PPROD_constrains_projection";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   132
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   133
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   134
(** invariant **)
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   135
6299
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
   136
(*????????????????*)
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
   137
Goal "F : invariant A ==> lift_prog i F : invariant (lift_set i A)";
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   138
by (auto_tac (claset(),
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   139
	      simpset() addsimps [invariant_def, lift_prog_stable_eq]));
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   140
qed "invariant_imp_lift_prog_invariant";
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   141
6299
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
   142
(*????????????????*)
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
   143
Goal "[| lift_prog i F : invariant (lift_set i A) |] ==> F : invariant A";
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   144
by (auto_tac (claset(),
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   145
	      simpset() addsimps [invariant_def, lift_prog_stable_eq]));
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   146
qed "lift_prog_invariant_imp_invariant";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   147
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   148
(*NOT clear that the previous lemmas help in proving this one.*)
6299
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
   149
Goal "[| F i : invariant A;  i : I |] \
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
   150
\     ==> PPROD I F : invariant (lift_set i A)";
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   151
by (auto_tac (claset(),
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   152
	      simpset() addsimps [invariant_def, PPROD_stable]));
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   153
qed "invariant_imp_PPROD_invariant";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   154
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   155
(*The f0 premise ensures that the product is well-defined.*)
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
   156
Goal "[| PPROD I F : invariant (lift_set i A);  i : I;  \
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   157
\        f0: Init (PPROD I F) |] ==> F i : invariant A";
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   158
by (auto_tac (claset(),
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   159
	      simpset() addsimps [invariant_def, PPROD_stable]));
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   160
by (dres_inst_tac [("c", "f0(i:=x)")] subsetD 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   161
by Auto_tac;
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   162
qed "PPROD_invariant_imp_invariant";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   163
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   164
Goal "[| i : I;  f0: Init (PPROD I F) |] \
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
   165
\     ==> (PPROD I F : invariant (lift_set i A)) = (F i : invariant A)";
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   166
by (blast_tac (claset() addIs [invariant_imp_PPROD_invariant, 
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   167
			       PPROD_invariant_imp_invariant]) 1);
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   168
qed "PPROD_invariant";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   169
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   170
(*The f0 premise isn't needed if F is a constant program because then
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   171
  we get an initial state by replicating that of F*)
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   172
Goal "i : I \
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
   173
\     ==> ((PPI x:I. F) : invariant (lift_set i A)) = (F : invariant A)";
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   174
by (auto_tac (claset(),
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   175
	      simpset() addsimps [invariant_def, PPROD_stable]));
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   176
qed "PFUN_invariant";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   177
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   178
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   179
(*** Substitution Axiom versions: Constrains, Stable ***)
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   180
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   181
(** Reachability **)
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   182
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   183
Goal "[| f : reachable (PPROD I F);  i : I |] ==> f i : reachable (F i)";
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   184
by (etac reachable.induct 1);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   185
by (auto_tac
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   186
    (claset() addIs reachable.intrs,
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   187
     simpset() addsimps [Acts_PPROD]));
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   188
qed "reachable_PPROD";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   189
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   190
Goal "reachable (PPROD I F) <= {f. ALL i:I. f i : reachable (F i)}";
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   191
by (force_tac (claset() addSDs [reachable_PPROD], simpset()) 1);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   192
qed "reachable_PPROD_subset1";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   193
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   194
Goal "[| i ~: I;  A : reachable (F i) |]     \
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   195
\  ==> ALL f. f : reachable (PPROD I F)      \
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   196
\             --> f(i:=A) : reachable (lift_prog i (F i) Join PPROD I F)";
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   197
by (etac reachable.induct 1);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   198
by (ALLGOALS Clarify_tac);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   199
by (etac reachable.induct 1);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   200
(*Init, Init case*)
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   201
by (force_tac (claset() addIs reachable.intrs,
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   202
	       simpset() addsimps [Acts_lift_prog]) 1);
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   203
(*Init of F, action of PPROD F case*)
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   204
by (rtac reachable.Acts 1);
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   205
by (force_tac (claset(), simpset() addsimps [Acts_Join]) 1);
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   206
by (assume_tac 1);
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   207
by (force_tac (claset() addIs [ext], simpset() addsimps [Acts_PPROD]) 1);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   208
(*induction over the 2nd "reachable" assumption*)
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   209
by (eres_inst_tac [("xa","f")] reachable.induct 1);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   210
(*Init of PPROD F, action of F case*)
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   211
by (res_inst_tac [("act","lift_act i act")] reachable.Acts 1);
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   212
by (force_tac (claset(), simpset() addsimps [Acts_lift_prog, Acts_Join]) 1);
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   213
by (force_tac (claset() addIs [reachable.Init], simpset()) 1);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   214
by (force_tac (claset() addIs [ext], simpset() addsimps [lift_act_def]) 1);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   215
(*last case: an action of PPROD I F*)
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   216
by (rtac reachable.Acts 1);
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   217
by (force_tac (claset(), simpset() addsimps [Acts_Join]) 1);
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   218
by (assume_tac 1);
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   219
by (force_tac (claset() addIs [ext], simpset() addsimps [Acts_PPROD]) 1);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   220
qed_spec_mp "reachable_lift_Join_PPROD";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   221
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   222
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   223
(*The index set must be finite: otherwise infinitely many copies of F can
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   224
  perform actions, and PPROD can never catch up in finite time.*)
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   225
Goal "finite I \
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   226
\     ==> {f. ALL i:I. f i : reachable (F i)} <= reachable (PPROD I F)";
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   227
by (etac finite_induct 1);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   228
by (Simp_tac 1);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   229
by (force_tac (claset() addDs [reachable_lift_Join_PPROD], 
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   230
	       simpset() addsimps [PPROD_insert]) 1);
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   231
qed "reachable_PPROD_subset2";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   232
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   233
Goal "finite I ==> \
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   234
\     reachable (PPROD I F) = {f. ALL i:I. f i : reachable (F i)}";
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   235
by (REPEAT_FIRST (ares_tac [equalityI,
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   236
			    reachable_PPROD_subset1, 
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   237
			    reachable_PPROD_subset2]));
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   238
qed "reachable_PPROD_eq";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   239
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   240
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   241
(** Constrains **)
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   242
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   243
Goal "[| F i : Constrains A B;  i: I;  finite I |]  \
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
   244
\     ==> PPROD I F : Constrains (lift_set i A) (lift_set i B)";
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   245
by (auto_tac
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   246
    (claset(),
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   247
     simpset() addsimps [Constrains_def, Collect_conj_eq RS sym,
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   248
			 reachable_PPROD_eq]));
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   249
by (auto_tac (claset(), 
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   250
              simpset() addsimps [constrains_def, Acts_lift_prog, PPROD_def,
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   251
                                  Acts_JN]));
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   252
by (REPEAT (blast_tac (claset() addIs reachable.intrs) 1));
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   253
qed "Constrains_imp_PPROD_Constrains";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   254
6299
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
   255
Goal "[| ALL i:I. f0 i : R i;   i: I |] \
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
   256
\     ==> Applyall ({f. (ALL i:I. f i : R i)} Int lift_set i A) i = R i Int A";
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
   257
by (force_tac (claset() addSIs [rinst [("x", "?ff(i := ?u)")] image_eqI],
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
   258
	       simpset() addsimps [Applyall_def, lift_set_def]) 1);
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   259
qed "Applyall_Int_depend";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   260
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   261
(*Again, we need the f0 premise because otherwise Constrains holds trivially
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   262
  for PPROD I F.*)
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
   263
Goal "[| PPROD I F : Constrains (lift_set i A) (lift_set i B);  \
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   264
\        i: I;  finite I;  f0: Init (PPROD I F) |]  \
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   265
\     ==> F i : Constrains A B";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   266
by (full_simp_tac (simpset() addsimps [Constrains_def]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   267
by (subgoal_tac "ALL i:I. f0 i : reachable (F i)" 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   268
by (blast_tac (claset() addIs [reachable.Init]) 2);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   269
by (dtac PPROD_constrains_projection 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   270
by (assume_tac 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   271
by (asm_full_simp_tac
6299
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
   272
    (simpset() addsimps [Applyall_Int_depend, reachable_PPROD_eq]) 1);
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   273
qed "PPROD_Constrains_imp_Constrains";
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   274
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   275
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   276
Goal "[| i: I;  finite I;  f0: Init (PPROD I F) |]  \
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
   277
\     ==> (PPROD I F : Constrains (lift_set i A) (lift_set i B)) =  \
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   278
\         (F i : Constrains A B)";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   279
by (blast_tac (claset() addIs [Constrains_imp_PPROD_Constrains, 
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   280
			       PPROD_Constrains_imp_Constrains]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   281
qed "PPROD_Constrains";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   282
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   283
Goal "[| i: I;  finite I;  f0: Init (PPROD I F) |]  \
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
   284
\     ==> (PPROD I F : Stable (lift_set i A)) = (F i : Stable A)";
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   285
by (asm_simp_tac (simpset() delsimps [Init_PPROD]
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   286
			    addsimps [Stable_def, PPROD_Constrains]) 1);
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   287
qed "PPROD_Stable";
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   288
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   289
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   290
(** PFUN (no dependence on i) doesn't require the f0 premise **)
5899
13d4753079fe new theory PPROD
paulson
parents:
diff changeset
   291
6299
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
   292
Goal "i: I \
1a88db6e7c7e UNITY fully working at last...
paulson
parents: 6295
diff changeset
   293
\     ==> Applyall ({f. (ALL i:I. f i : R)} Int lift_set i A) i = R Int A";
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   294
by (force_tac (claset(), simpset() addsimps [Applyall_def]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   295
qed "Applyall_Int";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   296
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
   297
Goal "[| (PPI x:I. F) : Constrains (lift_set i A) (lift_set i B);  \
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   298
\        i: I;  finite I |]  \
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   299
\     ==> F : Constrains A B";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   300
by (full_simp_tac (simpset() addsimps [Constrains_def]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   301
by (dtac PPROD_constrains_projection 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   302
by (assume_tac 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   303
by (asm_full_simp_tac
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   304
    (simpset() addsimps [Applyall_Int, Collect_conj_eq RS sym,
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   305
			 reachable_PPROD_eq]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   306
qed "PFUN_Constrains_imp_Constrains";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   307
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   308
Goal "[| i: I;  finite I |]  \
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
   309
\     ==> ((PPI x:I. F) : Constrains (lift_set i A) (lift_set i B)) =  \
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   310
\         (F : Constrains A B)";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   311
by (blast_tac (claset() addIs [Constrains_imp_PPROD_Constrains, 
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   312
			       PFUN_Constrains_imp_Constrains]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   313
qed "PFUN_Constrains";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   314
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   315
Goal "[| i: I;  finite I |]  \
6020
4b109bf75976 towards handling sharing of variables
paulson
parents: 6012
diff changeset
   316
\     ==> ((PPI x:I. F) : Stable (lift_set i A)) = (F : Stable A)";
5972
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   317
by (asm_simp_tac (simpset() addsimps [Stable_def, PFUN_Constrains]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   318
qed "PFUN_Stable";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   319
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   320
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   321
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   322
(*** guarantees properties ***)
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   323
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   324
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   325
Goal "drop_act i (lift_act i act) = act";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   326
by (force_tac (claset() addSIs [rinst [("x", "?ff(i := ?u)")] exI],
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   327
	       simpset() addsimps [drop_act_def, lift_act_def]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   328
qed "lift_act_inverse";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   329
Addsimps [lift_act_inverse];
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   330
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   331
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   332
Goal "(lift_prog i F) Join G = lift_prog i H \
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   333
\     ==> EX J. H = F Join J";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   334
by (etac program_equalityE 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   335
by (auto_tac (claset(), simpset() addsimps [Acts_lift_prog, Acts_Join]));
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   336
by (res_inst_tac [("x", 
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   337
		   "mk_program(Applyall(Init G) i, drop_act i `` Acts G)")] 
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   338
    exI 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   339
by (rtac program_equalityI 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   340
(*Init*)
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   341
by (simp_tac (simpset() addsimps [Applyall_def]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   342
(*Blast_tac can't do HO unification, needed to invent function states*)
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   343
by (fast_tac (claset() addEs [equalityE]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   344
(*Now for the Actions*)
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   345
by (dres_inst_tac [("f", "op `` (drop_act i)")] arg_cong 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   346
by (asm_full_simp_tac 
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   347
    (simpset() addsimps [insert_absorb, Acts_Join,
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   348
			 image_Un, image_compose RS sym, o_def]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   349
qed "lift_prog_Join_eq_lift_prog_D";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   350
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   351
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   352
Goal "F : X guarantees Y \
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   353
\     ==> lift_prog i F : (lift_prog i `` X) guarantees (lift_prog i `` Y)";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   354
by (rtac guaranteesI 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   355
by Auto_tac;
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   356
by (blast_tac (claset() addDs [lift_prog_Join_eq_lift_prog_D, guaranteesD]) 1);
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   357
qed "lift_prog_guarantees";
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   358
2430ccbde87d guarantees laws
paulson
parents: 5899
diff changeset
   359