src/HOL/UNITY/Lift_prog.ML
author paulson
Fri, 06 Aug 1999 17:27:51 +0200
changeset 7186 860479291bb5
child 7343 4fa705cedbdb
permissions -rw-r--r--
new theory UNITY/Lift_prog
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/Lift_prog.ML
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
     2
    ID:         $Id$
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
     5
*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
     6
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
     7
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
     8
(*** Basic properties ***)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
     9
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    10
(** lift_set and drop_set **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    11
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    12
Goalw [lift_set_def] "(f : lift_set i A) = (f i : A)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    13
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    14
qed "lift_set_iff";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    15
AddIffs [lift_set_iff];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    16
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    17
Goalw [lift_set_def] "lift_set i (A Int B) = lift_set i A Int lift_set i B";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    18
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    19
qed "lift_set_Int";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    20
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    21
(*Converse fails*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    22
Goalw [drop_set_def] "f : A ==> f i : drop_set i A";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    23
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    24
qed "drop_set_I";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    25
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    26
(** lift_act and drop_act **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    27
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    28
Goalw [lift_act_def] "lift_act i Id = Id";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    29
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    30
by (etac rev_mp 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    31
by (dtac sym 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    32
by (asm_simp_tac (simpset() addsimps [fun_upd_idem_iff]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    33
qed "lift_act_Id";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    34
Addsimps [lift_act_Id];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    35
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    36
Goalw [drop_act_def] "(s, s') : act ==> (s i, s' i) : drop_act i act";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    37
by (auto_tac (claset() addSIs [image_eqI], simpset()));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    38
qed "drop_act_I";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    39
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    40
Goalw [drop_act_def] "drop_act i Id = Id";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    41
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    42
by (res_inst_tac [("x", "((%u. x), (%u. x))")] image_eqI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    43
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    44
qed "drop_act_Id";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    45
Addsimps [drop_act_Id];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    46
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    47
(** lift_prog and drop_prog **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    48
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    49
Goalw [lift_prog_def] "Init (lift_prog i F) = lift_set i (Init F)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    50
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    51
qed "Init_lift_prog";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    52
Addsimps [Init_lift_prog];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    53
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    54
Goalw [lift_prog_def] "Acts (lift_prog i F) = lift_act i `` Acts F";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    55
by (auto_tac (claset() addIs [Id_in_Acts RSN (2,image_eqI)], simpset()));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    56
qed "Acts_lift_prog";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    57
Addsimps [Acts_lift_prog];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    58
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    59
Goalw [drop_prog_def] "Init (drop_prog i F) = drop_set i (Init F)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    60
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    61
qed "Init_drop_prog";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    62
Addsimps [Init_drop_prog];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    63
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    64
Goalw [drop_prog_def] "Acts (drop_prog i F) = drop_act i `` Acts F";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    65
by (auto_tac (claset() addIs [Id_in_Acts RSN (2,image_eqI)], simpset()));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    66
qed "Acts_drop_prog";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    67
Addsimps [Acts_drop_prog];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    68
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    69
Goal "F component G ==> lift_prog i F component lift_prog i G";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    70
by (full_simp_tac (simpset() addsimps [component_eq_subset]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    71
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    72
qed "lift_prog_mono";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    73
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    74
Goal "F component G ==> drop_prog i F component drop_prog i G";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    75
by (full_simp_tac (simpset() addsimps [component_eq_subset, drop_set_def]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    76
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    77
qed "drop_prog_mono";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    78
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    79
Goal "lift_prog i SKIP = SKIP";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    80
by (auto_tac (claset() addSIs [program_equalityI],
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    81
	      simpset() addsimps [SKIP_def, lift_prog_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    82
qed "lift_prog_SKIP";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    83
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    84
Goal "lift_prog i (F Join G) = (lift_prog i F) Join (lift_prog i G)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    85
by (rtac program_equalityI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    86
by (auto_tac (claset(), simpset() addsimps [Acts_Join]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    87
qed "lift_prog_Join";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    88
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    89
Goal "lift_prog i (JOIN I F) = (JN j:I. lift_prog i (F j))";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    90
by (rtac program_equalityI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    91
by (auto_tac (claset(), simpset() addsimps [Acts_JN]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    92
qed "lift_prog_JN";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    93
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    94
Goal "drop_prog i SKIP = SKIP";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    95
by (auto_tac (claset() addSIs [program_equalityI],
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    96
	      simpset() addsimps [SKIP_def, drop_set_def, drop_prog_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    97
qed "drop_prog_SKIP";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    98
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    99
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   100
(** Injectivity of lift_set, lift_act, lift_prog **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   101
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   102
Goalw [lift_set_def, drop_set_def] "drop_set i (lift_set i F) = F";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   103
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   104
qed "lift_set_inverse";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   105
Addsimps [lift_set_inverse];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   106
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   107
Goal "inj (lift_set i)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   108
by (rtac inj_on_inverseI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   109
by (rtac lift_set_inverse 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   110
qed "inj_lift_set";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   111
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   112
(*Because A and B could differ outside i, cannot generalize result to 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   113
   drop_set i (A Int B) = drop_set i A Int drop_set i B
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   114
*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   115
Goalw [lift_set_def, drop_set_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   116
     "drop_set i ((lift_set i A) Int B) = A Int (drop_set i B)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   117
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   118
qed "drop_set_lift_set_Int";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   119
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   120
Goalw [lift_set_def, drop_set_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   121
     "drop_set i (B Int (lift_set i A)) = (drop_set i B) Int A";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   122
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   123
qed "drop_set_lift_set_Int2";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   124
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   125
Goalw [drop_set_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   126
     "i : I ==> drop_set i (INT j:I. lift_set j A) = A";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   127
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   128
qed "drop_set_INT";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   129
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   130
Goalw [lift_act_def, drop_act_def] "drop_act i (lift_act i act) = act";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   131
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   132
by (res_inst_tac [("x", "f(i:=a)")] exI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   133
by (Asm_simp_tac 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   134
by (res_inst_tac [("x", "f(i:=b)")] exI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   135
by (Asm_simp_tac 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   136
by (rtac ext 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   137
by (Asm_simp_tac 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   138
qed "lift_act_inverse";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   139
Addsimps [lift_act_inverse];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   140
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   141
Goal "inj (lift_act i)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   142
by (rtac inj_on_inverseI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   143
by (rtac lift_act_inverse 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   144
qed "inj_lift_act";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   145
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   146
Goal "drop_prog i (lift_prog i F) = F";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   147
by (simp_tac (simpset() addsimps [lift_prog_def, drop_prog_def]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   148
by (rtac program_equalityI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   149
by (simp_tac (simpset() addsimps [image_compose RS sym, o_def]) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   150
by (Simp_tac 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   151
qed "lift_prog_inverse";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   152
Addsimps [lift_prog_inverse];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   153
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   154
Goal "inj (lift_prog i)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   155
by (rtac inj_on_inverseI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   156
by (rtac lift_prog_inverse 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   157
qed "inj_lift_prog";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   158
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   159
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   160
(*For compatibility with the original definition and perhaps simpler proofs*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   161
Goalw [lift_act_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   162
    "((f,f') : lift_act i act) = (EX s'. f' = f(i := s') & (f i, s') : act)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   163
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   164
by (rtac exI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   165
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   166
qed "lift_act_eq";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   167
AddIffs [lift_act_eq];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   168
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   169
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   170
(*** Safety: co, stable, invariant ***)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   171
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   172
(** Safety and lift_prog **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   173
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   174
Goal "(lift_prog i F : (lift_set i A) co (lift_set i B))  =  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   175
\     (F : A co B)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   176
by (auto_tac (claset(), 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   177
	      simpset() addsimps [constrains_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   178
by (Blast_tac 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   179
by (Force_tac 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   180
qed "lift_prog_constrains_eq";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   181
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   182
Goal "(lift_prog i F : stable (lift_set i A)) = (F : stable A)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   183
by (simp_tac (simpset() addsimps [stable_def, lift_prog_constrains_eq]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   184
qed "lift_prog_stable_eq";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   185
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   186
Goal "(lift_prog i F : invariant (lift_set i A)) = (F : invariant A)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   187
by (auto_tac (claset(),
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   188
	      simpset() addsimps [invariant_def, lift_prog_stable_eq]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   189
qed "lift_prog_invariant_eq";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   190
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   191
(*This one looks strange!  Proof probably is by case analysis on i=j.
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   192
  If i~=j then lift_prog j (F j) does nothing to lift_set i, and the 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   193
  premise ensures A<=B.*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   194
Goal "F i : A co B  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   195
\     ==> lift_prog j (F j) : (lift_set i A) co (lift_set i B)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   196
by (auto_tac (claset(), 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   197
	      simpset() addsimps [constrains_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   198
by (REPEAT (Blast_tac 1));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   199
qed "constrains_imp_lift_prog_constrains";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   200
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   201
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   202
(** Safety and drop_prog **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   203
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   204
Goalw [constrains_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   205
     "(drop_prog i F : A co B)  =  (F : (lift_set i A) co (lift_set i B))";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   206
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   207
by (force_tac (claset(), 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   208
	       simpset() addsimps [drop_act_def]) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   209
by (blast_tac (claset() addIs [drop_act_I]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   210
qed "drop_prog_constrains_eq";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   211
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   212
Goal "(drop_prog i F : stable A)  =  (F : stable (lift_set i A))";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   213
by (simp_tac (simpset() addsimps [stable_def, drop_prog_constrains_eq]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   214
qed "drop_prog_stable_eq";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   215
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   216
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   217
(** Diff, needed for localTo **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   218
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   219
Goal "Diff G (lift_act i `` Acts F) : (lift_set i A) co (lift_set i B)  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   220
\     ==> Diff (drop_prog i G) (Acts F) : A co B";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   221
by (auto_tac (claset(), 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   222
	      simpset() addsimps [constrains_def, Diff_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   223
by (dtac bspec 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   224
by (Force_tac 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   225
by (auto_tac (claset(), simpset() addsimps [drop_act_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   226
by (auto_tac (claset(), simpset() addsimps [lift_set_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   227
qed "Diff_drop_prog_co";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   228
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   229
Goalw [stable_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   230
     "Diff G (lift_act i `` Acts F) : stable (lift_set i A)  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   231
\     ==> Diff (drop_prog i G) (Acts F) : stable A";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   232
by (etac Diff_drop_prog_co 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   233
qed "Diff_drop_prog_stable";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   234
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   235
Goal "Diff G (Acts F) : A co B  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   236
\     ==> Diff (lift_prog i G) (lift_act i `` Acts F) \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   237
\         : (lift_set i A) co (lift_set i B)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   238
by (auto_tac (claset(), 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   239
	      simpset() addsimps [constrains_def, Diff_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   240
by (auto_tac (claset(), simpset() addsimps [drop_act_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   241
qed "Diff_lift_prog_co";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   242
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   243
Goalw [stable_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   244
     "Diff G (Acts F) : stable A  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   245
\     ==> Diff (lift_prog i G) (lift_act i `` Acts F) : stable (lift_set i A)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   246
by (etac Diff_lift_prog_co 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   247
qed "Diff_lift_prog_stable";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   248
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   249
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   250
(*** Weak versions: Co, Stable ***)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   251
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   252
(** Reachability **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   253
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   254
Goal "s : reachable F ==> f(i:=s) : reachable (lift_prog i F)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   255
by (etac reachable.induct 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   256
by (force_tac (claset() addIs [reachable.Acts, ext], 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   257
	       simpset()) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   258
by (force_tac (claset() addIs [reachable.Init], simpset()) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   259
qed "reachable_lift_progI";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   260
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   261
Goal "f : reachable (lift_prog i F) ==> f i : reachable F";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   262
by (etac reachable.induct 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   263
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   264
by (ALLGOALS (blast_tac (claset() addIs reachable.intrs)));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   265
qed "reachable_lift_progD";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   266
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   267
Goal "reachable (lift_prog i F) = lift_set i (reachable F)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   268
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   269
by (etac reachable_lift_progD 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   270
ren "f" 1;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   271
by (dres_inst_tac [("f","f"),("i","i")] reachable_lift_progI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   272
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   273
qed "reachable_lift_prog";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   274
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   275
Goal "(lift_prog i F : (lift_set i A) Co (lift_set i B))  =  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   276
\     (F : A Co B)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   277
by (simp_tac (simpset() addsimps [Constrains_def, reachable_lift_prog,
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   278
				  lift_set_Int RS sym,
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   279
				  lift_prog_constrains_eq]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   280
qed "lift_prog_Constrains_eq";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   281
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   282
Goal "(lift_prog i F : Stable (lift_set i A)) = (F : Stable A)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   283
by (simp_tac (simpset() addsimps [Stable_def, lift_prog_Constrains_eq]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   284
qed "lift_prog_Stable_eq";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   285
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   286
(** Reachability and drop_prog **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   287
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   288
Goal "f : reachable F ==> f i : reachable (drop_prog i F)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   289
by (etac reachable.induct 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   290
by (force_tac (claset() addIs [reachable.Acts, drop_act_I],
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   291
	       simpset()) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   292
by (force_tac (claset() addIs [reachable.Init, drop_set_I],
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   293
	       simpset()) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   294
qed "reachable_imp_reachable_drop_prog";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   295
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   296
(*Converse fails because it would require
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   297
  [| s i : reachable (drop_prog i F); s i : A |] ==> s : reachable F
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   298
*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   299
Goalw [Constrains_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   300
     "drop_prog i F : A Co B ==> F : (lift_set i A) Co (lift_set i B)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   301
by (full_simp_tac (simpset() addsimps [drop_prog_constrains_eq]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   302
by (etac constrains_weaken_L 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   303
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   304
by (etac reachable_imp_reachable_drop_prog 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   305
qed "drop_prog_Constrains_D";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   306
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   307
Goalw [Stable_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   308
     "drop_prog i F : Stable A ==> F : Stable (lift_set i A)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   309
by (asm_simp_tac (simpset() addsimps [drop_prog_Constrains_D]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   310
qed "drop_prog_Stable_D";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   311
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   312
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   313
(*** Programs of the form lift_prog i F Join G
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   314
     in other words programs containing a replicated component ***)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   315
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   316
Goal "drop_prog i ((lift_prog i F) Join G) = F Join (drop_prog i G)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   317
by (rtac program_equalityI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   318
by (simp_tac (simpset() addsimps [Acts_Join, image_Un,
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   319
				  image_compose RS sym, o_def]) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   320
by (simp_tac (simpset() addsimps [drop_set_lift_set_Int]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   321
qed "drop_prog_lift_prog_Join";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   322
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   323
Goal "(lift_prog i F) Join G = lift_prog i H \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   324
\     ==> H = F Join (drop_prog i G)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   325
by (dres_inst_tac [("f", "drop_prog i")] arg_cong 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   326
by (full_simp_tac (simpset() addsimps [drop_prog_lift_prog_Join]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   327
by (etac sym 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   328
qed "lift_prog_Join_eq_lift_prog_D";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   329
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   330
Goal "f : reachable (lift_prog i F Join G)  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   331
\     ==> f i : reachable (F Join drop_prog i G)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   332
by (etac reachable.induct 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   333
by (force_tac (claset() addIs [reachable.Init, drop_set_I], simpset()) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   334
(*By case analysis on whether the action is of lift_prog i F  or  G*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   335
by (force_tac (claset() addIs [reachable.Acts, drop_act_I], 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   336
	       simpset() addsimps [Acts_Join, image_iff]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   337
qed "reachable_lift_prog_Join_D";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   338
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   339
(*Opposite inclusion fails, even for the initial state: lift_set i includes
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   340
  ALL functions determined only by their value at i.*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   341
Goal "reachable (lift_prog i F Join G) <= \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   342
\     lift_set i (reachable (F Join drop_prog i G))";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   343
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   344
by (etac reachable_lift_prog_Join_D 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   345
qed "reachable_lift_prog_Join_subset";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   346
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   347
Goal "F Join drop_prog i G : Stable A    \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   348
\     ==> lift_prog i F Join G : Stable (lift_set i A)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   349
by (full_simp_tac (simpset() addsimps [Stable_def, Constrains_def]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   350
by (subgoal_tac 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   351
    "lift_prog i F Join G : lift_set i (reachable (F Join drop_prog i G)) Int \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   352
\                           lift_set i A \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   353
\    co lift_set i A" 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   354
by (asm_full_simp_tac 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   355
    (simpset() addsimps [lift_set_Int RS sym,
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   356
			 lift_prog_constrains_eq,
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   357
			 drop_prog_constrains_eq RS sym,
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   358
			 drop_prog_lift_prog_Join]) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   359
by (blast_tac (claset() addIs [constrains_weaken, 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   360
			       reachable_lift_prog_Join_D]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   361
qed "lift_prog_Join_Stable_eq";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   362
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   363
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   364
(*** guarantees properties ***)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   365
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   366
(** It seems that neither of these can be proved from the other. **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   367
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   368
(*Strong precondition and postcondition; doesn't seem very useful*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   369
Goal "F : X guar Y \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   370
\     ==> lift_prog i F : (lift_prog i `` X) guar (lift_prog i `` Y)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   371
by (rtac guaranteesI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   372
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   373
by (blast_tac (claset() addDs [lift_prog_Join_eq_lift_prog_D, guaranteesD]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   374
qed "lift_prog_guarantees";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   375
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   376
(*Weak precondition and postcondition; doesn't seem very useful*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   377
Goal "[| F : X guar Y;  drop_prog i `` XX <= X;  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   378
\        ALL G. F Join drop_prog i G : Y --> lift_prog i F Join G : YY |] \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   379
\     ==> lift_prog i F : XX guar YY";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   380
by (rtac guaranteesI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   381
by (dtac guaranteesD 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   382
by (etac subsetD 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   383
by (rtac image_eqI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   384
by (auto_tac (claset(), simpset() addsimps [drop_prog_lift_prog_Join]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   385
qed "drop_prog_guarantees";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   386
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   387
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   388
(*** sub ***)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   389
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   390
Addsimps [sub_def];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   391
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   392
Goal "lift_set i {s. P s} = {s. P (sub i s)}";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   393
by (asm_simp_tac (simpset() addsimps [lift_set_def]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   394
qed "lift_set_sub";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   395
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   396
Goal "{s. P (s i)} = lift_set i {s. P s}";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   397
by (asm_simp_tac (simpset() addsimps [lift_set_def]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   398
qed "Collect_eq_lift_set";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   399
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   400
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   401
(** Are these two useful?? **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   402
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   403
(*The other direction fails: having FF : Stable {s. z <= f (s i)} does not
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   404
  ensure that F has the form lift_prog i F for some F.*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   405
Goal "lift_prog i `` Stable {s. P (f s)} <= Stable {s. P (f (s i))}";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   406
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   407
by (stac Collect_eq_lift_set 1); 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   408
by (asm_simp_tac (simpset() addsimps [lift_prog_Stable_eq]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   409
qed "image_lift_prog_Stable";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   410
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   411
Goal "lift_prog i `` Increasing f <= Increasing (f o sub i)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   412
by (simp_tac (simpset() addsimps [Increasing_def,
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   413
				  inj_lift_prog RS image_INT]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   414
by (blast_tac (claset() addIs [impOfSubs image_lift_prog_Stable]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   415
qed "image_lift_prog_Increasing";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   416
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   417
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   418
(*** guarantees corollaries ***)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   419
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   420
Goalw [increasing_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   421
     "F : UNIV guar increasing f \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   422
\     ==> lift_prog i F : UNIV guar increasing (f o sub i)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   423
by (etac drop_prog_guarantees 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   424
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   425
by (stac Collect_eq_lift_set 1); 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   426
by (asm_full_simp_tac
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   427
    (simpset() addsimps [lift_prog_stable_eq, drop_prog_stable_eq, 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   428
			 stable_Join]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   429
qed "lift_prog_guar_increasing";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   430
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   431
Goalw [Increasing_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   432
     "F : UNIV guar Increasing f \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   433
\     ==> lift_prog i F : UNIV guar Increasing (f o sub i)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   434
by (etac drop_prog_guarantees 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   435
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   436
by (stac Collect_eq_lift_set 1); 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   437
by (asm_simp_tac (simpset() addsimps [lift_prog_Join_Stable_eq]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   438
qed "lift_prog_guar_Increasing";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   439
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   440
Goalw [localTo_def, increasing_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   441
     "F : (f localTo F) guar increasing f  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   442
\     ==> lift_prog i F : (f o sub i) localTo (lift_prog i F)  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   443
\                         guar increasing (f o sub i)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   444
by (etac drop_prog_guarantees 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   445
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   446
by (stac Collect_eq_lift_set 2); 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   447
(*the "increasing" guarantee*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   448
by (asm_full_simp_tac
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   449
    (simpset() addsimps [lift_prog_stable_eq, drop_prog_stable_eq, 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   450
			 stable_Join]) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   451
(*the "localTo" requirement*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   452
by (asm_simp_tac
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   453
    (simpset() addsimps [Diff_drop_prog_stable, 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   454
			 Collect_eq_lift_set RS sym]) 1); 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   455
qed "lift_prog_guar_increasing2";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   456
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   457
Goalw [localTo_def, Increasing_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   458
     "F : (f localTo F) guar Increasing f  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   459
\     ==> lift_prog i F : (f o sub i) localTo (lift_prog i F)  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   460
\                         guar Increasing (f o sub i)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   461
by (etac drop_prog_guarantees 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   462
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   463
by (stac Collect_eq_lift_set 2); 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   464
(*the "Increasing" guarantee*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   465
by (asm_simp_tac (simpset() addsimps [lift_prog_Join_Stable_eq]) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   466
(*the "localTo" requirement*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   467
by (asm_simp_tac
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   468
    (simpset() addsimps [Diff_drop_prog_stable, 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   469
			 Collect_eq_lift_set RS sym]) 1); 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   470
qed "lift_prog_guar_Increasing2";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   471
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   472
(*Converse fails.  Useful?*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   473
Goal "lift_prog i `` (f localTo F) <= (f o sub i) localTo (lift_prog i F)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   474
by (simp_tac (simpset() addsimps [localTo_def]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   475
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   476
by (stac Collect_eq_lift_set 1); 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   477
by (asm_simp_tac (simpset() addsimps [Diff_lift_prog_stable]) 1); 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   478
qed "localTo_lift_prog_I";