src/HOL/UNITY/Lift_prog.ML
author paulson
Tue, 31 Aug 1999 15:56:56 +0200
changeset 7399 cf780c2bcccf
parent 7361 477e1bdf230f
child 7482 7badd511844d
permissions -rw-r--r--
changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
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
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
    69
(** These monotonicity results look natural but are UNUSED **)
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
    70
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7361
diff changeset
    71
Goal "F <= G ==> lift_prog i F <= lift_prog i G";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    72
by (full_simp_tac (simpset() addsimps [component_eq_subset]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    73
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    74
qed "lift_prog_mono";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    75
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7361
diff changeset
    76
Goal "F <= G ==> drop_prog i F <= drop_prog i G";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    77
by (full_simp_tac (simpset() addsimps [component_eq_subset, drop_set_def]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    78
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    79
qed "drop_prog_mono";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    80
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    81
Goal "lift_prog i SKIP = SKIP";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    82
by (auto_tac (claset() addSIs [program_equalityI],
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    83
	      simpset() addsimps [SKIP_def, lift_prog_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    84
qed "lift_prog_SKIP";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    85
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    86
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
    87
by (rtac program_equalityI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    88
by (auto_tac (claset(), simpset() addsimps [Acts_Join]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    89
qed "lift_prog_Join";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    90
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    91
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
    92
by (rtac program_equalityI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    93
by (auto_tac (claset(), simpset() addsimps [Acts_JN]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    94
qed "lift_prog_JN";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    95
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    96
Goal "drop_prog i SKIP = SKIP";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    97
by (auto_tac (claset() addSIs [program_equalityI],
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    98
	      simpset() addsimps [SKIP_def, drop_set_def, drop_prog_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
    99
qed "drop_prog_SKIP";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   100
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   101
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   102
(** Injectivity of lift_set, lift_act, lift_prog **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   103
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   104
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
   105
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   106
qed "lift_set_inverse";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   107
Addsimps [lift_set_inverse];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   108
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   109
Goal "inj (lift_set i)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   110
by (rtac inj_on_inverseI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   111
by (rtac lift_set_inverse 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   112
qed "inj_lift_set";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   113
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   114
(*Because A and B could differ outside i, cannot generalize result to 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   115
   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
   116
*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   117
Goalw [lift_set_def, drop_set_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   118
     "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
   119
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   120
qed "drop_set_lift_set_Int";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   121
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   122
Goalw [lift_set_def, drop_set_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   123
     "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
   124
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   125
qed "drop_set_lift_set_Int2";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   126
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   127
Goalw [drop_set_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   128
     "i : I ==> drop_set i (INT j:I. lift_set j A) = A";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   129
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   130
qed "drop_set_INT";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   131
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   132
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
   133
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   134
by (res_inst_tac [("x", "f(i:=a)")] 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 (res_inst_tac [("x", "f(i:=b)")] exI 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
by (rtac ext 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   139
by (Asm_simp_tac 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   140
qed "lift_act_inverse";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   141
Addsimps [lift_act_inverse];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   142
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   143
Goal "inj (lift_act i)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   144
by (rtac inj_on_inverseI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   145
by (rtac lift_act_inverse 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   146
qed "inj_lift_act";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   147
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   148
Goal "drop_prog i (lift_prog i F) = F";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   149
by (simp_tac (simpset() addsimps [lift_prog_def, drop_prog_def]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   150
by (rtac program_equalityI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   151
by (simp_tac (simpset() addsimps [image_compose RS sym, o_def]) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   152
by (Simp_tac 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   153
qed "lift_prog_inverse";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   154
Addsimps [lift_prog_inverse];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   155
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   156
Goal "inj (lift_prog i)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   157
by (rtac inj_on_inverseI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   158
by (rtac lift_prog_inverse 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   159
qed "inj_lift_prog";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   160
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   161
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   162
(*For compatibility with the original definition and perhaps simpler proofs*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   163
Goalw [lift_act_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   164
    "((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
   165
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   166
by (rtac exI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   167
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   168
qed "lift_act_eq";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   169
AddIffs [lift_act_eq];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   170
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   171
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   172
(*** Safety: co, stable, invariant ***)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   173
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   174
(** Safety and lift_prog **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   175
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   176
Goal "(lift_prog i F : (lift_set i A) co (lift_set i B))  =  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   177
\     (F : A co B)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   178
by (auto_tac (claset(), 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   179
	      simpset() addsimps [constrains_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   180
by (Blast_tac 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   181
by (Force_tac 1);
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   182
qed "lift_prog_constrains";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   183
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   184
Goal "(lift_prog i F : stable (lift_set i A)) = (F : stable A)";
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   185
by (simp_tac (simpset() addsimps [stable_def, lift_prog_constrains]) 1);
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   186
qed "lift_prog_stable";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   187
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   188
Goal "(lift_prog i F : invariant (lift_set i A)) = (F : invariant A)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   189
by (auto_tac (claset(),
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   190
	      simpset() addsimps [invariant_def, lift_prog_stable]));
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   191
qed "lift_prog_invariant";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   192
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   193
(*This one looks strange!  Proof probably is by case analysis on i=j.
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   194
  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
   195
  premise ensures A<=B.*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   196
Goal "F i : A co B  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   197
\     ==> lift_prog j (F j) : (lift_set i A) co (lift_set i B)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   198
by (auto_tac (claset(), 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   199
	      simpset() addsimps [constrains_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   200
by (REPEAT (Blast_tac 1));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   201
qed "constrains_imp_lift_prog_constrains";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   202
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   203
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   204
(** Safety and drop_prog **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   205
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   206
Goalw [constrains_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   207
     "(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
   208
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   209
by (force_tac (claset(), 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   210
	       simpset() addsimps [drop_act_def]) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   211
by (blast_tac (claset() addIs [drop_act_I]) 1);
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   212
qed "drop_prog_constrains";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   213
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   214
Goal "(drop_prog i F : stable A)  =  (F : stable (lift_set i A))";
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   215
by (simp_tac (simpset() addsimps [stable_def, drop_prog_constrains]) 1);
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   216
qed "drop_prog_stable";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   217
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   218
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   219
(*** Diff, needed for localTo ***)
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   220
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7361
diff changeset
   221
(** THESE PROOFS CAN BE GENERALIZED AS IN EXTEND.ML **)
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7361
diff changeset
   222
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   223
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
   224
\     ==> Diff (drop_prog i G) (Acts F) : A co B";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   225
by (auto_tac (claset(), 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   226
	      simpset() addsimps [constrains_def, Diff_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   227
by (dtac bspec 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   228
by (Force_tac 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   229
by (auto_tac (claset(), simpset() addsimps [drop_act_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   230
by (auto_tac (claset(), simpset() addsimps [lift_set_def]));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   231
qed "Diff_drop_prog_co";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   232
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   233
Goalw [stable_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   234
     "Diff G (lift_act i `` Acts F) : stable (lift_set i A)  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   235
\     ==> Diff (drop_prog i G) (Acts F) : stable A";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   236
by (etac Diff_drop_prog_co 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   237
qed "Diff_drop_prog_stable";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   238
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   239
Goalw [constrains_def, Diff_def]
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   240
     "Diff G (Acts F) : A co B  \
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   241
\     ==> Diff (lift_prog i G) (lift_act i `` Acts F) \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   242
\         : (lift_set i A) co (lift_set i B)";
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   243
by Auto_tac;
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   244
by (Blast_tac 1);
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   245
qed "Diff_lift_prog_co";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   246
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   247
Goalw [stable_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   248
     "Diff G (Acts F) : stable A  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   249
\     ==> 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
   250
by (etac Diff_lift_prog_co 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   251
qed "Diff_lift_prog_stable";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   252
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   253
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   254
(*** Weak safety primitives: Co, Stable ***)
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   255
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   256
(** Reachability **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   257
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   258
Goal "s : reachable F ==> f(i:=s) : reachable (lift_prog i F)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   259
by (etac reachable.induct 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   260
by (force_tac (claset() addIs [reachable.Acts, ext], 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   261
	       simpset()) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   262
by (force_tac (claset() addIs [reachable.Init], simpset()) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   263
qed "reachable_lift_progI";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   264
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   265
Goal "f : reachable (lift_prog i F) ==> f i : reachable F";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   266
by (etac reachable.induct 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   267
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   268
by (ALLGOALS (blast_tac (claset() addIs reachable.intrs)));
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   269
qed "reachable_lift_progD";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   270
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   271
Goal "reachable (lift_prog i F) = lift_set i (reachable F)";
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
by (etac reachable_lift_progD 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   274
ren "f" 1;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   275
by (dres_inst_tac [("f","f"),("i","i")] reachable_lift_progI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   276
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   277
qed "reachable_lift_prog";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   278
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   279
Goal "(lift_prog i F : (lift_set i A) Co (lift_set i B))  =  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   280
\     (F : A Co B)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   281
by (simp_tac (simpset() addsimps [Constrains_def, reachable_lift_prog,
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   282
				  lift_set_Int RS sym,
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   283
				  lift_prog_constrains]) 1);
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   284
qed "lift_prog_Constrains";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   285
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   286
Goal "(lift_prog i F : Stable (lift_set i A)) = (F : Stable A)";
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   287
by (simp_tac (simpset() addsimps [Stable_def, lift_prog_Constrains]) 1);
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   288
qed "lift_prog_Stable";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   289
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   290
(** Reachability and drop_prog **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   291
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   292
Goal "f : reachable F ==> f i : reachable (drop_prog i F)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   293
by (etac reachable.induct 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   294
by (force_tac (claset() addIs [reachable.Acts, drop_act_I],
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   295
	       simpset()) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   296
by (force_tac (claset() addIs [reachable.Init, drop_set_I],
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   297
	       simpset()) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   298
qed "reachable_imp_reachable_drop_prog";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   299
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   300
(*Converse fails because it would require
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   301
  [| s i : reachable (drop_prog i F); s i : A |] ==> s : reachable F
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   302
*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   303
Goalw [Constrains_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   304
     "drop_prog i F : A Co B ==> F : (lift_set i A) Co (lift_set i B)";
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   305
by (full_simp_tac (simpset() addsimps [drop_prog_constrains]) 1);
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   306
by (etac constrains_weaken_L 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   307
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   308
by (etac reachable_imp_reachable_drop_prog 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   309
qed "drop_prog_Constrains_D";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   310
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   311
Goalw [Stable_def]
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   312
     "drop_prog i F : Stable A ==> F : Stable (lift_set i A)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   313
by (asm_simp_tac (simpset() addsimps [drop_prog_Constrains_D]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   314
qed "drop_prog_Stable_D";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   315
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   316
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   317
(*** Programs of the form lift_prog i F Join G
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   318
     in other words programs containing a replicated component ***)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   319
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   320
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
   321
by (rtac program_equalityI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   322
by (simp_tac (simpset() addsimps [Acts_Join, image_Un,
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   323
				  image_compose RS sym, o_def]) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   324
by (simp_tac (simpset() addsimps [drop_set_lift_set_Int]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   325
qed "drop_prog_lift_prog_Join";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   326
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   327
Goal "(lift_prog i F) Join G = lift_prog i H \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   328
\     ==> H = F Join (drop_prog i G)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   329
by (dres_inst_tac [("f", "drop_prog i")] arg_cong 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   330
by (full_simp_tac (simpset() addsimps [drop_prog_lift_prog_Join]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   331
by (etac sym 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   332
qed "lift_prog_Join_eq_lift_prog_D";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   333
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   334
Goal "f : reachable (lift_prog i F Join G)  \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   335
\     ==> f i : reachable (F Join drop_prog i G)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   336
by (etac reachable.induct 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   337
by (force_tac (claset() addIs [reachable.Init, drop_set_I], simpset()) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   338
(*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
   339
by (force_tac (claset() addIs [reachable.Acts, drop_act_I], 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   340
	       simpset() addsimps [Acts_Join, image_iff]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   341
qed "reachable_lift_prog_Join_D";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   342
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   343
(*Opposite inclusion fails, even for the initial state: lift_set i includes
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   344
  ALL functions determined only by their value at i.*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   345
Goal "reachable (lift_prog i F Join G) <= \
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   346
\     lift_set i (reachable (F Join drop_prog i G))";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   347
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   348
by (etac reachable_lift_prog_Join_D 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   349
qed "reachable_lift_prog_Join_subset";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   350
7361
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   351
Goalw [Constrains_def]
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   352
     "F Join drop_prog i G : A Co B    \
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   353
\     ==> lift_prog i F Join G : (lift_set i A) Co (lift_set i B)";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   354
by (subgoal_tac 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   355
    "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
   356
\                           lift_set i A \
7361
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   357
\    co lift_set i B" 1);
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   358
by (asm_full_simp_tac 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   359
    (simpset() addsimps [lift_set_Int RS sym,
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   360
			 lift_prog_constrains,
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   361
			 drop_prog_constrains RS sym,
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   362
			 drop_prog_lift_prog_Join]) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   363
by (blast_tac (claset() addIs [constrains_weaken, 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   364
			       reachable_lift_prog_Join_D]) 1);
7361
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   365
qed "lift_prog_Join_Constrains";
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   366
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   367
Goal "F Join drop_prog i G : Stable A    \
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   368
\     ==> lift_prog i F Join G : Stable (lift_set i A)";
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   369
by (asm_full_simp_tac (simpset() addsimps [Stable_def, 
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   370
					   lift_prog_Join_Constrains]) 1);
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   371
qed "lift_prog_Join_Stable";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   372
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   373
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   374
(*** guarantees properties ***)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   375
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   376
(** It seems that neither of these can be proved from the other. **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   377
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   378
(*Strong precondition and postcondition; doesn't seem very useful.
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   379
  Probably can be strengthened to an equivalance.*)
7361
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   380
Goal "F : X guarantees Y \
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   381
\     ==> lift_prog i F : (lift_prog i `` X) guarantees (lift_prog i `` Y)";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   382
by (rtac guaranteesI 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   383
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   384
by (blast_tac (claset() addDs [lift_prog_Join_eq_lift_prog_D, guaranteesD]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   385
qed "lift_prog_guarantees";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   386
7399
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7361
diff changeset
   387
(*Weak precondition and postcondition; this is the good one!
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7361
diff changeset
   388
CAN WEAKEN 2ND PREMISE TO  
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7361
diff changeset
   389
      !!G. extend h F Join G : XX ==> F Join project h G : X; 
cf780c2bcccf changed "component" infix in HOL/UNITY/Comp.thy to be overloaded <
paulson
parents: 7361
diff changeset
   390
*)
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   391
val [xguary,drop_prog,lift_prog] =
7361
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   392
Goal "[| F : X guarantees Y;  \
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   393
\        !!H. H : XX ==> drop_prog i H : X;  \
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   394
\        !!G. F Join drop_prog i G : Y ==> lift_prog i F Join G : YY |] \
7361
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   395
\     ==> lift_prog i F : XX guarantees YY";
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   396
by (rtac (xguary RS guaranteesD RS lift_prog RS guaranteesI) 1);
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   397
by (dtac drop_prog 1);
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   398
by (full_simp_tac (simpset() addsimps [drop_prog_lift_prog_Join]) 1);
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   399
qed "drop_prog_guarantees";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   400
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   401
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   402
(*** sub ***)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   403
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   404
Addsimps [sub_def];
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   405
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   406
Goal "lift_set i {s. P s} = {s. P (sub i s)}";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   407
by (asm_simp_tac (simpset() addsimps [lift_set_def]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   408
qed "lift_set_sub";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   409
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   410
Goal "{s. P (s i)} = lift_set i {s. P s}";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   411
by (asm_simp_tac (simpset() addsimps [lift_set_def]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   412
qed "Collect_eq_lift_set";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   413
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   414
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   415
(** Are these two useful?? **)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   416
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   417
(*The other direction fails: having FF : Stable {s. z <= f (s i)} does not
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   418
  ensure that F has the form lift_prog i F for some F.*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   419
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
   420
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   421
by (stac Collect_eq_lift_set 1); 
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   422
by (asm_simp_tac (simpset() addsimps [lift_prog_Stable]) 1);
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   423
qed "image_lift_prog_Stable";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   424
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   425
Goal "lift_prog i `` Increasing f <= Increasing (f o sub i)";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   426
by (simp_tac (simpset() addsimps [Increasing_def,
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   427
				  inj_lift_prog RS image_INT]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   428
by (blast_tac (claset() addIs [impOfSubs image_lift_prog_Stable]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   429
qed "image_lift_prog_Increasing";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   430
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   431
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   432
(*** guarantees corollaries ***)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   433
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   434
Goalw [increasing_def]
7361
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   435
     "F : UNIV guarantees increasing f \
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   436
\     ==> lift_prog i F : UNIV guarantees increasing (f o sub i)";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   437
by (etac drop_prog_guarantees 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   438
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   439
by (stac Collect_eq_lift_set 1); 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   440
by (asm_full_simp_tac
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   441
    (simpset() addsimps [lift_prog_stable, drop_prog_stable, 
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   442
			 stable_Join]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   443
qed "lift_prog_guar_increasing";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   444
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   445
Goalw [Increasing_def]
7361
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   446
     "F : UNIV guarantees Increasing f \
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   447
\     ==> lift_prog i F : UNIV guarantees Increasing (f o sub i)";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   448
by (etac drop_prog_guarantees 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   449
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   450
by (stac Collect_eq_lift_set 1); 
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   451
by (asm_simp_tac (simpset() addsimps [lift_prog_Join_Stable]) 1);
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   452
qed "lift_prog_guar_Increasing";
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   453
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   454
Goalw [localTo_def, increasing_def]
7361
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   455
     "F : (f localTo F) guarantees increasing f  \
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   456
\     ==> lift_prog i F : (f o sub i) localTo (lift_prog i F)  \
7361
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   457
\                         guarantees increasing (f o sub i)";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   458
by (etac drop_prog_guarantees 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   459
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   460
by (stac Collect_eq_lift_set 2); 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   461
(*the "increasing" guarantee*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   462
by (asm_full_simp_tac
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   463
    (simpset() addsimps [lift_prog_stable, drop_prog_stable, 
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   464
			 stable_Join]) 2);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   465
(*the "localTo" requirement*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   466
by (asm_simp_tac
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   467
    (simpset() addsimps [Diff_drop_prog_stable, 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   468
			 Collect_eq_lift_set RS sym]) 1); 
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   469
qed "lift_prog_localTo_guar_increasing";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   470
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   471
Goalw [localTo_def, Increasing_def]
7361
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   472
     "F : (f localTo F) guarantees Increasing f  \
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   473
\     ==> lift_prog i F : (f o sub i) localTo (lift_prog i F)  \
7361
477e1bdf230f changed "guar" back to "guarantees" (sorry)
paulson
parents: 7343
diff changeset
   474
\                         guarantees Increasing (f o sub i)";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   475
by (etac drop_prog_guarantees 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   476
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   477
by (stac Collect_eq_lift_set 2); 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   478
(*the "Increasing" guarantee*)
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   479
by (asm_simp_tac (simpset() addsimps [lift_prog_Join_Stable]) 2);
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   480
(*the "localTo" requirement*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   481
by (asm_simp_tac
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   482
    (simpset() addsimps [Diff_drop_prog_stable, 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   483
			 Collect_eq_lift_set RS sym]) 1); 
7343
4fa705cedbdb renamed some theorems; also better natural deduction style for old ones
paulson
parents: 7186
diff changeset
   484
qed "lift_prog_localTo_guar_Increasing";
7186
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   485
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   486
(*Converse fails.  Useful?*)
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   487
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
   488
by (simp_tac (simpset() addsimps [localTo_def]) 1);
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   489
by Auto_tac;
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   490
by (stac Collect_eq_lift_set 1); 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   491
by (asm_simp_tac (simpset() addsimps [Diff_lift_prog_stable]) 1); 
860479291bb5 new theory UNITY/Lift_prog
paulson
parents:
diff changeset
   492
qed "localTo_lift_prog_I";