src/ZF/UNITY/Guar.ML
author paulson
Wed, 10 Jul 2002 16:54:07 +0200
changeset 13339 0f89104dd377
parent 13194 812b00ed1c03
child 14076 5cfc8b9fb880
permissions -rw-r--r--
Fixed quantified variable name preservation for ball and bex (bounded quants) Requires tweaking of other scripts. Also routine tidying.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     1
(*  Title:      ZF/UNITY/Guar.ML
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     2
    ID:         $Id$
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     3
    Author:     Sidi O Ehmety, Computer Laboratory
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     4
    Copyright   2001  University of Cambridge
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     5
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     6
Guarantees, etc.
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     7
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     8
From Chandy and Sanders, "Reasoning About Program Composition"
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     9
Revised by Sidi Ehmety on January 2001
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    10
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    11
Proofs ported from HOL.
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    12
*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    13
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    14
Goal "OK(cons(i, I), F) <-> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    15
\ (i:I & OK(I, F)) | (i~:I & OK(I, F) & F(i) ok JOIN(I,F))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    16
by (asm_full_simp_tac (simpset() addsimps [OK_iff_ok]) 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    17
(** Auto_tac proves the goal in one-step, but takes more time **)
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    18
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    19
by (ALLGOALS(Clarify_tac));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    20
by (REPEAT(blast_tac (claset() addIs [ok_sym]) 10));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    21
by (REPEAT(Blast_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    22
qed "OK_cons_iff";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    23
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    24
(*** existential properties ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    25
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    26
Goalw [ex_prop_def] "ex_prop(X) ==> X<=program";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    27
by (Asm_simp_tac 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    28
qed "ex_imp_subset_program";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    29
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    30
Goalw [ex_prop_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    31
 "GG:Fin(program) ==> (ex_prop(X) \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    32
\ --> GG Int X~=0 --> OK(GG, (%G. G)) -->(JN G:GG. G):X)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    33
by (etac Fin_induct 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    34
by (ALLGOALS(asm_full_simp_tac 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    35
         (simpset() addsimps [OK_cons_iff])));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    36
(* Auto_tac proves the goal in one step *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    37
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    38
by (ALLGOALS(Asm_full_simp_tac));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    39
by (Fast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    40
qed_spec_mp "ex1";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    41
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    42
Goalw [ex_prop_def]
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    43
"X<=program ==> \
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    44
\(ALL GG. GG:Fin(program) & GG Int X ~= 0 --> OK(GG,(%G. G))-->(JN G:GG. G):X)\
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    45
\  --> ex_prop(X)";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    46
by (Clarify_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    47
by (dres_inst_tac [("x", "{F,G}")] spec 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    48
by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [OK_iff_ok])));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    49
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    50
by (auto_tac (claset() addIs [ok_sym], simpset()));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    51
qed "ex2";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    52
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    53
(*Chandy & Sanders take this as a definition*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    54
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    55
Goal "ex_prop(X) <-> (X<=program & \
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    56
\ (ALL GG. GG:Fin(program) & GG Int X ~= 0& OK(GG,( %G. G))-->(JN G:GG. G):X))";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    57
by Auto_tac;
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    58
by (ALLGOALS(blast_tac (claset() addIs [ex1, ex2 RS mp] 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    59
                                 addDs [ex_imp_subset_program])));
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    60
qed "ex_prop_finite";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    61
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    62
(* Equivalent definition of ex_prop given at the end of section 3*)
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    63
Goalw [ex_prop_def, component_of_def]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    64
"ex_prop(X) <-> \
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    65
\ X<=program & (ALL G:program. (G:X <-> (ALL H:program. (G component_of H) --> H:X)))";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    66
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    67
by (stac Join_commute 4);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    68
by (dtac  ok_sym 4);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    69
by (dres_inst_tac [("x", "G")] bspec 4);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    70
by (dres_inst_tac [("x", "F")] bspec 3);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    71
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    72
by (REPEAT(Force_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    73
qed "ex_prop_equiv";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    74
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    75
(*** universal properties ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    76
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    77
Goalw [uv_prop_def] "uv_prop(X)==> X<=program";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    78
by (Asm_simp_tac 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    79
qed "uv_imp_subset_program";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    80
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    81
Goalw [uv_prop_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    82
     "GG:Fin(program) ==> \
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    83
\ (uv_prop(X)--> GG <= X & OK(GG, (%G. G)) --> (JN G:GG. G):X)";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    84
by (etac Fin_induct 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    85
by (auto_tac (claset(), simpset() addsimps 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    86
           [OK_cons_iff]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    87
qed_spec_mp "uv1";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    88
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    89
Goalw [uv_prop_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    90
"X<=program  ==> (ALL GG. GG:Fin(program) & GG <= X & OK(GG,(%G. G)) \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    91
\ --> (JN G:GG. G):X)  --> uv_prop(X)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    92
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    93
by (Clarify_tac 2);
12152
46f128d8133c Renamed some bound variables due to changes in simplifier.
berghofe
parents: 11479
diff changeset
    94
by (dres_inst_tac [("x", "{F,G}")] spec 2);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    95
by (dres_inst_tac [("x", "0")] spec 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    96
by (auto_tac (claset() addDs [ok_sym], 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    97
    simpset() addsimps [OK_iff_ok]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    98
qed "uv2";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    99
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   100
(*Chandy & Sanders take this as a definition*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   101
Goal 
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   102
"uv_prop(X) <-> X<=program & \
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   103
\ (ALL GG. GG:Fin(program) & GG <= X & OK(GG, %G. G) --> (JN G:GG. G): X)";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   104
by Auto_tac;
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   105
by (REPEAT(blast_tac (claset() addIs [uv1,uv2 RS mp]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   106
                               addDs [uv_imp_subset_program]) 1));
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   107
qed "uv_prop_finite";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   108
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   109
(*** guarantees ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   110
val major::prems = Goal
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   111
     "[| (!!G. [| F ok G; F Join G:X; G:program |] ==> F Join G : Y); F:program |]  \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   112
\   ==> F : X guarantees Y";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   113
by (cut_facts_tac prems 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   114
by (simp_tac (simpset() addsimps [guar_def, component_def]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   115
by (blast_tac (claset() addIs [major]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   116
qed "guaranteesI";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   117
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   118
Goalw [guar_def, component_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   119
     "[| F : X guarantees Y;  F ok G;  F Join G:X; G:program |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   120
\     ==> F Join G : Y";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   121
by (Asm_full_simp_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   122
qed "guaranteesD";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   123
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   124
(*This version of guaranteesD matches more easily in the conclusion
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   125
  The major premise can no longer be  F<=H since we need to reason about G*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   126
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   127
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   128
     "[| F : X guarantees Y;  F Join G = H;  H : X;  F ok G; G:program |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   129
\     ==> H : Y";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   130
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   131
qed "component_guaranteesD";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   132
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   133
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   134
     "[| F: X guarantees X'; Y <= X; X' <= Y' |] ==> F: Y guarantees Y'";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   135
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   136
qed "guarantees_weaken";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   137
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   138
Goalw [guar_def] "X <= Y \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   139
\  ==> X guarantees Y = program";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   140
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   141
qed "subset_imp_guarantees_program";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   142
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   143
(*Equivalent to subset_imp_guarantees_UNIV but more intuitive*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   144
Goalw [guar_def] "[| X <= Y; F:program |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   145
\  ==> F : X guarantees Y";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   146
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   147
qed "subset_imp_guarantees";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   148
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   149
Goalw [component_of_def] 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   150
"F ok G ==> F component_of (F Join G)";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   151
by (Blast_tac 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   152
qed "component_of_Join1";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   153
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   154
Goal "F ok G ==> G component_of (F Join G)";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   155
by (stac Join_commute 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   156
by (blast_tac (claset() addIs [ok_sym, component_of_Join1]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   157
qed "component_of_Join2";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   158
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   159
(*Remark at end of section 4.1 *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   160
Goalw [guar_def, component_of_def] 
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   161
"ex_prop(Y) ==> (Y = (program guarantees Y))";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   162
by (full_simp_tac (simpset() addsimps [ex_prop_equiv]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   163
by (Clarify_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   164
by (rtac equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   165
by Safe_tac;
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   166
by (dres_inst_tac [("x", "x")] bspec 2);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   167
by (dres_inst_tac [("x", "x")] bspec 4);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   168
by (dtac iff_sym 5);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   169
by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [component_of_Join1])));
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   170
by (etac iffE 3);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   171
by (ALLGOALS(full_simp_tac (simpset() addsimps [component_of_def])));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   172
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   173
by (REPEAT(Force_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   174
qed "ex_prop_imp";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   175
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   176
Goalw [guar_def] "(Y = program guarantees Y) ==> ex_prop(Y)";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   177
by (asm_simp_tac (simpset() addsimps [ex_prop_equiv]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   178
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   179
by (ALLGOALS(full_simp_tac (simpset() addsimps [component_of_def])));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   180
by (dtac sym 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   181
by (ALLGOALS(etac equalityE));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   182
by (REPEAT(Force_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   183
qed "guarantees_imp";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   184
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   185
Goal "(ex_prop(Y)) <-> (Y = program guarantees Y)";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   186
by (blast_tac (claset() addIs [ex_prop_imp, guarantees_imp]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   187
qed "ex_prop_equiv2";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   188
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   189
(** Distributive laws.  Re-orient to perform miniscoping **)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   190
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   191
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   192
     "i:I ==>(UN i:I. X(i)) guarantees Y = (INT i:I. X(i) guarantees Y)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   193
by (rtac equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   194
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   195
by (Force_tac 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   196
by (REPEAT(Blast_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   197
qed "guarantees_UN_left";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   198
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   199
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   200
     "(X Un Y) guarantees Z = (X guarantees Z) Int (Y guarantees Z)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   201
by (rtac equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   202
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   203
by (REPEAT(Blast_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   204
qed "guarantees_Un_left";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   205
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   206
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   207
     "i:I ==> X guarantees (INT i:I. Y(i)) = (INT i:I. X guarantees Y(i))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   208
by (rtac equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   209
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   210
by (REPEAT(Blast_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   211
qed "guarantees_INT_right";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   212
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   213
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   214
     "Z guarantees (X Int Y) = (Z guarantees X) Int (Z guarantees Y)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   215
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   216
qed "guarantees_Int_right";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   217
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   218
Goal "[| F : Z guarantees X;  F : Z guarantees Y |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   219
\    ==> F : Z guarantees (X Int Y)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   220
by (asm_simp_tac (simpset() addsimps [guarantees_Int_right]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   221
qed "guarantees_Int_right_I";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   222
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   223
Goal "i:I==> (F : X guarantees (INT i:I. Y(i))) <-> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   224
\     (ALL i:I. F : X guarantees Y(i))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   225
by (asm_simp_tac (simpset() addsimps [guarantees_INT_right, INT_iff]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   226
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   227
qed "guarantees_INT_right_iff";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   228
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   229
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   230
Goalw [guar_def] "(X guarantees Y) = (program guarantees ((program-X) Un Y))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   231
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   232
qed "shunting";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   233
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   234
Goalw [guar_def] "(X guarantees Y) = (program - Y) guarantees (program -X)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   235
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   236
qed "contrapositive";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   237
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   238
(** The following two can be expressed using intersection and subset, which
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   239
    is more faithful to the text but looks cryptic.
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   240
**)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   241
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   242
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   243
    "[| F : V guarantees X;  F : (X Int Y) guarantees Z |]\
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   244
\    ==> F : (V Int Y) guarantees Z";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   245
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   246
qed "combining1";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   247
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   248
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   249
    "[| F : V guarantees (X Un Y);  F : Y guarantees Z |]\
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   250
\    ==> F : V guarantees (X Un Z)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   251
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   252
qed "combining2";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   253
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   254
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   255
(** The following two follow Chandy-Sanders, but the use of object-quantifiers
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   256
    does not suit Isabelle... **)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   257
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   258
(*Premise should be (!!i. i: I ==> F: X guarantees Y i) *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   259
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   260
     "[| ALL i:I. F : X guarantees Y(i); i:I |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   261
\   ==> F : X guarantees (INT i:I. Y(i))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   262
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   263
qed "all_guarantees";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   264
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   265
(*Premises should be [| F: X guarantees Y i; i: I |] *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   266
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   267
     "EX i:I. F : X guarantees Y(i) ==> F : X guarantees (UN i:I. Y(i))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   268
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   269
qed "ex_guarantees";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   270
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   271
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   272
(*** Additional guarantees laws, by lcp ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   273
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   274
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   275
    "[| F: U guarantees V;  G: X guarantees Y; F ok G |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   276
\    ==> F Join G: (U Int X) guarantees (V Int Y)"; 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   277
by (Simp_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   278
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   279
by (asm_full_simp_tac (simpset() addsimps [Join_assoc]) 1);
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 13194
diff changeset
   280
by (subgoal_tac "F Join G Join Ga = G Join (F Join Ga)" 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   281
by (asm_full_simp_tac (simpset() addsimps [ok_commute]) 1); 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   282
by (asm_simp_tac (simpset() addsimps Join_ac) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   283
qed "guarantees_Join_Int";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   284
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   285
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   286
    "[| F: U guarantees V;  G: X guarantees Y; F ok G |]  \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   287
\    ==> F Join G: (U Un X) guarantees (V Un Y)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   288
by (Simp_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   289
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   290
by (asm_full_simp_tac (simpset() addsimps [Join_assoc]) 1);
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 13194
diff changeset
   291
by (subgoal_tac "F Join G Join Ga = G Join (F Join Ga)" 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   292
by (rotate_tac 4 1);
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 13194
diff changeset
   293
by (dres_inst_tac [("x", "F Join Ga")] bspec 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   294
by (Simp_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   295
by (force_tac (claset(), simpset() addsimps [ok_commute]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   296
by (asm_simp_tac (simpset() addsimps Join_ac) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   297
qed "guarantees_Join_Un";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   298
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   299
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   300
     "[| ALL i:I. F(i) : X(i) guarantees Y(i);  OK(I,F); i:I |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   301
\     ==> (JN i:I. F(i)) : (INT i:I. X(i)) guarantees (INT i:I. Y(i))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   302
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   303
by (Blast_tac 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   304
by (dres_inst_tac [("x", "xa")] bspec 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   305
by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [INT_iff])));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   306
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   307
by (rotate_tac ~1 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   308
by (dres_inst_tac [("x", "(JN x:(I-{xa}). F(x)) Join G")] bspec 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   309
by (auto_tac
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   310
    (claset() addIs [OK_imp_ok],
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   311
     simpset() addsimps [Join_assoc RS sym, JN_Join_diff, JN_absorb]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   312
qed "guarantees_JN_INT";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   313
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   314
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   315
    "[| ALL i:I. F(i) : X(i) guarantees Y(i);  OK(I,F) |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   316
\    ==> JOIN(I,F) : (UN i:I. X(i)) guarantees (UN i:I. Y(i))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   317
by Auto_tac;
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 13194
diff changeset
   318
by (dres_inst_tac [("x", "y")] bspec 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   319
by (ALLGOALS(Asm_full_simp_tac));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   320
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   321
by (rotate_tac ~1 1);
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 13194
diff changeset
   322
by (rename_tac "G y" 1);
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 13194
diff changeset
   323
by (dres_inst_tac [("x", "JOIN(I-{y}, F) Join G")] bspec 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   324
by (auto_tac
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   325
    (claset() addIs [OK_imp_ok],
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   326
     simpset() addsimps [Join_assoc RS sym, JN_Join_diff, JN_absorb]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   327
qed "guarantees_JN_UN";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   328
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   329
(*** guarantees laws for breaking down the program, by lcp ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   330
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   331
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   332
     "[| F: X guarantees Y;  F ok G |] ==> F Join G: X guarantees Y";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   333
by (Simp_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   334
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   335
by (asm_full_simp_tac (simpset() addsimps [Join_assoc]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   336
qed "guarantees_Join_I1";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   337
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   338
Goal "[| G: X guarantees Y;  F ok G |] ==> F Join G: X guarantees Y";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   339
by (asm_full_simp_tac (simpset() addsimps [inst "G" "G" Join_commute, 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   340
                                           inst "G" "G" ok_commute]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   341
by (blast_tac (claset() addIs [guarantees_Join_I1]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   342
qed "guarantees_Join_I2";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   343
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   344
Goalw [guar_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   345
     "[| i:I; F(i): X guarantees Y;  OK(I,F) |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   346
\     ==> (JN i:I. F(i)) : X guarantees Y";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   347
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   348
by (dres_inst_tac [("x", "JOIN(I-{i},F) Join G")] bspec 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   349
by (Simp_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   350
by (auto_tac (claset() addIs [OK_imp_ok],
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   351
              simpset() addsimps [JN_Join_diff, Join_assoc RS sym]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   352
qed "guarantees_JN_I";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   353
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   354
(*** well-definedness ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   355
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   356
Goalw [welldef_def] "F Join G: welldef ==> programify(F): welldef";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   357
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   358
qed "Join_welldef_D1";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   359
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   360
Goalw [welldef_def] "F Join G: welldef ==> programify(G): welldef";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   361
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   362
qed "Join_welldef_D2";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   363
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   364
(*** refinement ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   365
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   366
Goalw [refines_def] "F refines F wrt X";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   367
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   368
qed "refines_refl";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   369
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   370
(* More results on guarantees, added by Sidi Ehmety from Chandy & Sander, section 6 *)
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   371
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   372
Goalw [wg_def] "wg(F, X) <= program";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   373
by Auto_tac;
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   374
qed "wg_type";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   375
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   376
Goalw [guar_def] "X guarantees Y <= program";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   377
by Auto_tac;
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   378
qed "guarantees_type";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   379
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   380
Goalw [wg_def] "G:wg(F, X) ==> G:program & F:program";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   381
by Auto_tac;
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   382
by (blast_tac (claset() addDs [guarantees_type RS subsetD]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   383
qed "wgD2";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   384
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   385
Goalw [guar_def, component_of_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   386
"(F:X guarantees Y) <-> \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   387
\  F:program & (ALL H:program. H:X --> (F component_of H --> H:Y))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   388
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   389
by (REPEAT(Force_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   390
qed "guarantees_equiv";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   391
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   392
Goalw [wg_def] "!!X. [| F:(X guarantees Y); X <= program |] ==> X <= wg(F,Y)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   393
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   394
qed "wg_weakest";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   395
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   396
Goalw [wg_def, guar_def] 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   397
"F:program ==> F:wg(F,Y) guarantees Y";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   398
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   399
qed "wg_guarantees";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   400
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   401
Goalw [wg_def] "(H: wg(F,X)) <-> ((F component_of H --> H:X) & F:program & H:program)";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   402
by (simp_tac (simpset() addsimps [guarantees_equiv]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   403
by (rtac iffI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   404
by Safe_tac;
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   405
by (res_inst_tac [("x", "{H}")] bexI 4);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   406
by (res_inst_tac [("x", "{H}")] bexI 3);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   407
by (REPEAT(Blast_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   408
qed "wg_equiv";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   409
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   410
Goal
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   411
"F component_of H ==> H:wg(F,X) <-> (H:X & F:program & H:program)";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   412
by (asm_simp_tac (simpset() addsimps [wg_equiv]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   413
qed "component_of_wg";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   414
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   415
Goal
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   416
"ALL FF:Fin(program). FF Int X ~= 0 --> OK(FF, %F. F) \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   417
\  --> (ALL F:FF. ((JN F:FF. F): wg(F,X)) <-> ((JN F:FF. F):X))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   418
by (Clarify_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   419
by (subgoal_tac "F component_of (JN F:FF. F)" 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   420
by (dres_inst_tac [("X", "X")] component_of_wg 1);
13194
812b00ed1c03 conversion of Finite to Isar format
paulson
parents: 12484
diff changeset
   421
by (force_tac (claset() addSDs [thm"Fin.dom_subset" RS subsetD RS PowD],
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   422
               simpset()) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   423
by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [component_of_def])));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   424
by (res_inst_tac [("x", "JN F:(FF-{F}). F")] exI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   425
by (auto_tac (claset() addIs [JN_Join_diff] addDs [ok_sym], 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   426
              simpset() addsimps [OK_iff_ok]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   427
qed "wg_finite";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   428
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   429
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   430
(* "!!FF. [| FF:Fin(program); FF Int X ~=0; OK(FF, %F. F); G:FF |] 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   431
   ==> JOIN(FF, %F. F):wg(G, X) <-> JOIN(FF, %F. F):X"  *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   432
val wg_finite2 = wg_finite RS bspec RS mp RS mp RS bspec;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   433
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   434
Goal "ex_prop(X) ==> (F:X) <-> (ALL H:program. H : wg(F,X) & F:program)";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   435
by (full_simp_tac (simpset() addsimps [ex_prop_equiv, wg_equiv]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   436
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   437
qed "wg_ex_prop";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   438
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   439
(** From Charpentier and Chandy "Theorems About Composition" **)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   440
(* Proposition 2 *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   441
Goalw [wx_def] "wx(X)<=X";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   442
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   443
qed "wx_subset";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   444
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 13194
diff changeset
   445
Goal "ex_prop(wx(X))";
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 13194
diff changeset
   446
by (full_simp_tac (simpset() addsimps [ex_prop_def, wx_def]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   447
by Safe_tac;
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   448
by (Blast_tac 1);
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 13194
diff changeset
   449
by (ALLGOALS(res_inst_tac [("x", "x")] bexI));
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   450
by (REPEAT(Force_tac 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   451
qed "wx_ex_prop";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   452
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 13194
diff changeset
   453
Goalw [wx_def] "ALL Z. Z<=program --> Z<= X --> ex_prop(Z) --> Z <= wx(X)";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   454
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   455
qed "wx_weakest";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   456
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   457
(* Proposition 6 *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   458
Goalw [ex_prop_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   459
 "ex_prop({F:program. ALL G:program. F ok G --> F Join G:X})";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   460
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   461
by (dres_inst_tac [("x", "G Join Ga")] bspec 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   462
by (Simp_tac 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   463
by (force_tac (claset(), simpset() addsimps [Join_assoc]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   464
by (dres_inst_tac [("x", "F Join Ga")] bspec 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   465
by (Simp_tac 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   466
by (Full_simp_tac 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   467
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   468
by (asm_simp_tac (simpset() addsimps [ok_commute]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   469
by (subgoal_tac "F Join G = G Join F" 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   470
by (asm_simp_tac (simpset() addsimps [Join_assoc]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   471
by (simp_tac (simpset() addsimps [Join_commute]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   472
qed "wx'_ex_prop";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   473
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   474
(* Equivalence with the other definition of wx *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   475
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   476
Goalw [wx_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   477
 "wx(X) = {F:program. ALL G:program. F ok G --> (F Join G):X}";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   478
by (rtac equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   479
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   480
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   481
by (full_simp_tac (simpset() addsimps [ex_prop_def]) 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   482
by Safe_tac;
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   483
by (dres_inst_tac [("x", "x")] bspec 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   484
by (dres_inst_tac [("x", "G")] bspec 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   485
by (forw_inst_tac [("c", "x Join G")] subsetD 3);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   486
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   487
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   488
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   489
by (res_inst_tac [("B", "{F:program. ALL G:program. F ok G --> F Join G:X}")] 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   490
                   UnionI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   491
by Safe_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   492
by (rtac wx'_ex_prop 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   493
by (rotate_tac 2 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   494
by (dres_inst_tac [("x", "SKIP")] bspec 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   495
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   496
qed "wx_equiv";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   497
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   498
(* Propositions 7 to 11 are all about this second definition of wx. And
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   499
   by equivalence between the two definition, they are the same as the ones proved *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   500
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   501
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   502
(* Proposition 12 *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   503
(* Main result of the paper *)
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   504
Goalw [guar_def]  "(X guarantees Y) = wx((program-X) Un Y)";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   505
by (simp_tac (simpset() addsimps [wx_equiv]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   506
by Auto_tac;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   507
qed "guarantees_wx_eq";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   508
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   509
(* 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   510
{* Corollary, but this result has already been proved elsewhere *}
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   511
 "ex_prop(X guarantees Y)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   512
  by (simp_tac (simpset() addsimps [guar_wx_iff, wx_ex_prop]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   513
  qed "guarantees_ex_prop";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   514
*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   515
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   516
(* Rules given in section 7 of Chandy and Sander's
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   517
    Reasoning About Program composition paper *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   518
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   519
Goal "[| Init(F) <= A; F:program |] ==> F:(stable(A)) guarantees (Always(A))";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   520
by (rtac guaranteesI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   521
by (assume_tac 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   522
by (simp_tac (simpset() addsimps [Join_commute]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   523
by (rtac stable_Join_Always1 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   524
by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [invariant_def])));
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   525
by (auto_tac (claset(), simpset() addsimps [programify_def, initially_def]));
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   526
qed "stable_guarantees_Always";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   527
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   528
(* To be moved to WFair.ML *)
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   529
Goal "[| F:A co A Un B; F:transient(A); st_set(B) |] ==> F:A leadsTo B";
12484
7ad150f5fc10 isatool expandshort;
wenzelm
parents: 12195
diff changeset
   530
by (ftac constrainsD2 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   531
by (dres_inst_tac [("B", "A-B")] constrains_weaken_L 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   532
by (dres_inst_tac [("B", "A-B")] transient_strengthen 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   533
by (rtac (ensuresI RS leadsTo_Basis) 3);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   534
by (ALLGOALS(Blast_tac));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   535
qed "leadsTo_Basis'";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   536
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   537
Goal "[| F:transient(A); st_set(B) |] ==> F: (A co A Un B) guarantees (A leadsTo (B-A))";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   538
by (rtac guaranteesI 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   539
by (blast_tac (claset() addDs [transient_type RS subsetD]) 2);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   540
by (rtac leadsTo_Basis' 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   541
by (Blast_tac 3);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   542
by (dtac constrains_weaken_R 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   543
by (assume_tac 2);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   544
by (rtac Join_transient_I1 2);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   545
by (REPEAT(Blast_tac 1));
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   546
qed "constrains_guarantees_leadsTo";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   547
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   548