src/ZF/UNITY/Constrains.ML
author paulson
Fri, 16 Nov 2001 13:48:43 +0100
changeset 12220 9dc4e8fec63d
parent 12215 55c084921240
child 12484 7ad150f5fc10
permissions -rw-r--r--
last-minute 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/Constrains.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
Safety relations: restricted to the set of reachable states.
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     7
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     8
Proofs ported from HOL.
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
     9
*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    10
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    11
(*** traces and reachable ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    12
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    13
Goal  "reachable(F) <= state";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    14
by (cut_inst_tac [("F", "F")] Init_type 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    15
by (cut_inst_tac [("F", "F")] Acts_type 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    16
by (cut_inst_tac [("F", "F")] reachable.dom_subset 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    17
by (Blast_tac 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    18
qed "reachable_type";
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    19
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    20
Goalw [st_set_def] "st_set(reachable(F))";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    21
by (resolve_tac [reachable_type] 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    22
qed "st_set_reachable";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    23
AddIffs [st_set_reachable];
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    24
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    25
Goal "reachable(F) Int state = reachable(F)";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    26
by (cut_facts_tac [reachable_type] 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    27
by Auto_tac;
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    28
qed "reachable_Int_state";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    29
AddIffs [reachable_Int_state];
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    30
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    31
Goal "state Int reachable(F) = reachable(F)";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    32
by (cut_facts_tac [reachable_type] 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    33
by Auto_tac;
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    34
qed "state_Int_reachable";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    35
AddIffs [state_Int_reachable];
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    36
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    37
Goal 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    38
"F:program ==> reachable(F)={s:state. EX evs. <s,evs>:traces(Init(F), Acts(F))}";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    39
by (rtac equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    40
by Safe_tac;
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    41
by (blast_tac (claset() addDs [reachable_type RS subsetD]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    42
by (etac traces.induct 2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    43
by (etac reachable.induct 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    44
by (ALLGOALS (blast_tac (claset() addIs reachable.intrs @ traces.intrs)));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    45
qed "reachable_equiv_traces";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    46
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    47
Goal "Init(F) <= reachable(F)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    48
by (blast_tac (claset() addIs reachable.intrs) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    49
qed "Init_into_reachable";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    50
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    51
Goal "[| F:program; G:program; \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    52
\   Acts(G) <= Acts(F)  |] ==> G:stable(reachable(F))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    53
by (blast_tac (claset() 
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    54
   addIs [stableI, constrainsI, st_setI,
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    55
          reachable_type RS subsetD] @ reachable.intrs) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    56
qed "stable_reachable";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    57
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    58
AddSIs [stable_reachable];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    59
Addsimps [stable_reachable];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    60
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    61
(*The set of all reachable states is an invariant...*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    62
Goalw [invariant_def, initially_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    63
   "F:program ==> F:invariant(reachable(F))";
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    64
by (blast_tac (claset() addIs [reachable_type RS subsetD]@reachable.intrs) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    65
qed "invariant_reachable";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    66
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    67
(*...in fact the strongest invariant!*)
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    68
Goal "F:invariant(A) ==> reachable(F) <= A";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    69
by (cut_inst_tac [("F", "F")] Acts_type 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    70
by (cut_inst_tac [("F", "F")] Init_type 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    71
by (cut_inst_tac [("F", "F")] reachable_type 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    72
by (full_simp_tac (simpset() addsimps [stable_def, constrains_def, 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    73
                                       invariant_def, initially_def]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    74
by (rtac subsetI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    75
by (etac reachable.induct 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    76
by (REPEAT (blast_tac (claset()  addIs reachable.intrs) 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    77
qed "invariant_includes_reachable";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    78
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    79
(*** Co ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    80
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    81
Goal "F:B co B'==>F:(reachable(F) Int B) co (reachable(F) Int B')";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    82
by (forward_tac [constrains_type RS subsetD] 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    83
by (forward_tac [[asm_rl, asm_rl, subset_refl] MRS stable_reachable] 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    84
by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [stable_def, constrains_Int])));
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    85
qed "constrains_reachable_Int";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    86
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    87
(*Resembles the previous definition of Constrains*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    88
Goalw [Constrains_def]
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    89
"A Co B = {F:program. F:(reachable(F) Int A) co (reachable(F)  Int  B)}";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    90
by (blast_tac (claset() addDs [constrains_reachable_Int, 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    91
                                      constrains_type RS subsetD]
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    92
                        addIs [constrains_weaken]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
    93
qed "Constrains_eq_constrains";
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    94
val Constrains_def2 =  Constrains_eq_constrains RS  eq_reflection;
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    95
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    96
Goalw [Constrains_def] 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    97
 "F:A co A' ==> F:A Co A'";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    98
by (blast_tac (claset() addIs [constrains_weaken_L] addDs [constrainsD2]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
    99
qed "constrains_imp_Constrains";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   100
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   101
val prems = Goalw [Constrains_def, constrains_def, st_set_def]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   102
"[|(!!act s s'. [| act: Acts(F); <s,s'>:act; s:A |] ==> s':A'); F:program|]==>F:A Co A'";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   103
by (auto_tac (claset(), simpset() addsimps prems));
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   104
by (blast_tac (claset() addDs [reachable_type RS subsetD]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   105
qed "ConstrainsI";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   106
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   107
Goalw [Constrains_def] 
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   108
 "A Co B <= program";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   109
by (Blast_tac 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   110
qed "Constrains_type";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   111
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   112
Goal "F : 0 Co B <-> F:program";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   113
by (auto_tac (claset() addDs [Constrains_type RS subsetD]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   114
                       addIs [constrains_imp_Constrains], simpset()));
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   115
qed "Constrains_empty";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   116
AddIffs [Constrains_empty];
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   117
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   118
Goalw [Constrains_def] "F : A Co state <-> F:program";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   119
by (auto_tac (claset() addDs [Constrains_type RS subsetD]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   120
                       addIs [constrains_imp_Constrains], simpset()));
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   121
qed "Constrains_state";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   122
AddIffs [Constrains_state];
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   123
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   124
Goalw  [Constrains_def2] 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   125
        "[| F : A Co A'; A'<=B' |] ==> F : A Co B'";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   126
by (blast_tac (claset()  addIs [constrains_weaken_R]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   127
qed "Constrains_weaken_R";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   128
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   129
Goalw  [Constrains_def2] 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   130
    "[| F : A Co A'; B<=A |] ==> F : B Co A'";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   131
by (blast_tac (claset() addIs [constrains_weaken_L, st_set_subset]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   132
qed "Constrains_weaken_L";  
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   133
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   134
Goalw [Constrains_def2]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   135
   "[| F : A Co A'; B<=A; A'<=B' |] ==> F : B Co B'";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   136
by (blast_tac (claset() addIs [constrains_weaken, st_set_subset]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   137
qed "Constrains_weaken";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   138
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   139
(** Union **)
12215
55c084921240 Modified to make the files build with the new changes in ZF
ehmety
parents: 12195
diff changeset
   140
Goalw [Constrains_def2] 
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   141
"[| F : A Co A'; F : B Co B' |] ==> F : (A Un B) Co (A' Un B')";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   142
by Auto_tac;
12215
55c084921240 Modified to make the files build with the new changes in ZF
ehmety
parents: 12195
diff changeset
   143
by (asm_full_simp_tac (simpset() addsimps [Int_Un_distrib]) 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   144
by (blast_tac (claset() addIs [constrains_Un]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   145
qed "Constrains_Un";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   146
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   147
val [major, minor] = Goalw [Constrains_def2]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   148
"[|(!!i. i:I==>F:A(i) Co A'(i)); F:program|] ==> F:(UN i:I. A(i)) Co (UN i:I. A'(i))";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   149
by (cut_facts_tac [minor] 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   150
by (auto_tac (claset() addDs [major]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   151
                       addIs [constrains_UN],
12215
55c084921240 Modified to make the files build with the new changes in ZF
ehmety
parents: 12195
diff changeset
   152
              simpset() delsimps UN_simps addsimps [Int_UN_distrib]));
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   153
qed "Constrains_UN";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   154
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   155
(** Intersection **)
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   156
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   157
Goalw [Constrains_def]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   158
"[| F : A Co A'; F : B Co B'|]==> F:(A Int B) Co (A' Int B')";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   159
by (subgoal_tac "reachable(F) Int (A Int B) = \
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   160
              \ (reachable(F) Int A) Int (reachable(F) Int B)" 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   161
by (ALLGOALS(force_tac (claset() addIs [constrains_Int], simpset())));
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   162
qed "Constrains_Int";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   163
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   164
val [major,minor] = Goal 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   165
"[| (!!i. i:I ==>F: A(i) Co A'(i)); F:program  |] \
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   166
\  ==> F:(INT i:I. A(i)) Co (INT i:I. A'(i))";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   167
by (cut_facts_tac [minor] 1);
12220
9dc4e8fec63d last-minute tidying
paulson
parents: 12215
diff changeset
   168
by (asm_simp_tac (simpset() delsimps INT_simps
9dc4e8fec63d last-minute tidying
paulson
parents: 12215
diff changeset
   169
	  	 	    addsimps [Constrains_def]@INT_extend_simps) 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   170
by (rtac constrains_INT 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   171
by (dresolve_tac [major] 1);
12220
9dc4e8fec63d last-minute tidying
paulson
parents: 12215
diff changeset
   172
by (auto_tac (claset(), simpset() addsimps [Constrains_def])); 
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   173
qed "Constrains_INT";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   174
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   175
Goalw [Constrains_def] "F : A Co A' ==> reachable(F) Int A <= A'";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   176
by (blast_tac (claset() addDs [constrains_imp_subset]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   177
qed "Constrains_imp_subset";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   178
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   179
Goalw [Constrains_def2]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   180
 "[| F : A Co B; F : B Co C |] ==> F : A Co C";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   181
by (blast_tac (claset() addIs [constrains_trans, constrains_weaken]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   182
qed "Constrains_trans";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   183
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   184
Goalw [Constrains_def2]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   185
"[| F : A Co (A' Un B); F : B Co B' |] ==> F : A Co (A' Un B')";
12215
55c084921240 Modified to make the files build with the new changes in ZF
ehmety
parents: 12195
diff changeset
   186
by (full_simp_tac (simpset() addsimps [Int_Un_distrib]) 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   187
by (blast_tac (claset() addIs [constrains_cancel]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   188
qed "Constrains_cancel";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   189
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   190
(*** Stable ***)
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   191
(* Useful because there's no Stable_weaken.  [Tanja Vos] *)
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   192
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   193
Goalw [stable_def, Stable_def] 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   194
"F : stable(A) ==> F : Stable(A)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   195
by (etac constrains_imp_Constrains 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   196
qed "stable_imp_Stable";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   197
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   198
Goal "[| F: Stable(A); A = B |] ==> F : Stable(B)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   199
by (Blast_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   200
qed "Stable_eq";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   201
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   202
Goal
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   203
"F : Stable(A) <->  (F:stable(reachable(F) Int A))";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   204
by (auto_tac (claset() addDs [constrainsD2], 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   205
              simpset() addsimps [Stable_def, stable_def, Constrains_def2]));
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   206
qed "Stable_eq_stable";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   207
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   208
Goalw [Stable_def] "F:A Co A ==> F : Stable(A)";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   209
by (assume_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   210
qed "StableI";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   211
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   212
Goalw [Stable_def] "F : Stable(A) ==> F : A Co A";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   213
by (assume_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   214
qed "StableD";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   215
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   216
Goalw [Stable_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   217
    "[| F : Stable(A); F : Stable(A') |] ==> F : Stable(A Un A')";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   218
by (blast_tac (claset() addIs [Constrains_Un]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   219
qed "Stable_Un";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   220
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   221
Goalw [Stable_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   222
    "[| F : Stable(A); F : Stable(A') |] ==> F : Stable (A Int A')";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   223
by (blast_tac (claset() addIs [Constrains_Int]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   224
qed "Stable_Int";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   225
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   226
Goalw [Stable_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   227
    "[| F : Stable(C); F : A Co (C Un A') |]   \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   228
\    ==> F : (C Un A) Co (C Un A')";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   229
by (blast_tac (claset() addIs [Constrains_Un RS Constrains_weaken_R]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   230
qed "Stable_Constrains_Un";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   231
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   232
Goalw [Stable_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   233
    "[| F : Stable(C); F : (C Int A) Co A' |]   \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   234
\    ==> F : (C Int A) Co (C Int A')";
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   235
by (blast_tac (claset() addIs [Constrains_Int RS Constrains_weaken]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   236
qed "Stable_Constrains_Int";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   237
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   238
val [major,minor] = Goalw [Stable_def]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   239
"[| (!!i. i:I ==> F : Stable(A(i))); F:program |]==> F : Stable (UN i:I. A(i))";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   240
by (cut_facts_tac [minor] 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   241
by (blast_tac (claset() addIs [Constrains_UN,major]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   242
qed "Stable_UN";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   243
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   244
val [major,minor] = Goalw [Stable_def]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   245
"[|(!!i. i:I ==> F:Stable(A(i))); F:program |]==> F : Stable (INT i:I. A(i))";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   246
by (cut_facts_tac [minor] 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   247
by (blast_tac (claset() addIs [Constrains_INT, major]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   248
qed "Stable_INT";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   249
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   250
Goal "F:program ==>F : Stable (reachable(F))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   251
by (asm_simp_tac (simpset() 
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   252
    addsimps [Stable_eq_stable, Int_absorb]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   253
qed "Stable_reachable";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   254
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   255
Goalw [Stable_def]
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   256
"Stable(A) <= program";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   257
by (rtac Constrains_type 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   258
qed "Stable_type";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   259
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   260
(*** The Elimination Theorem.  The "free" m has become universally quantified!
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   261
     Should the premise be !!m instead of ALL m ?  Would make it harder to use
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   262
     in forward proof. ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   263
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   264
Goalw [Constrains_def]  
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   265
"[| ALL m:M. F : ({s:A. x(s) = m}) Co (B(m)); F:program |] \
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   266
\    ==> F : ({s:A. x(s):M}) Co (UN m:M. B(m))";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   267
by Auto_tac;
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   268
by (res_inst_tac [("A1","reachable(F)Int A")] (elimination RS constrains_weaken_L) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   269
by (auto_tac (claset() addIs [constrains_weaken_L], simpset()));
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   270
qed "Elimination";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   271
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   272
(* As above, but for the special case of A=state *)
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   273
Goal
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   274
 "[| ALL m:M. F : {s:state. x(s) = m} Co B(m); F:program |] \
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   275
\    ==> F : {s:state. x(s):M} Co (UN m:M. B(m))";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   276
by (blast_tac (claset() addIs [Elimination]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   277
qed "Elimination2";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   278
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   279
(** Unless **)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   280
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   281
Goalw [Unless_def] "A Unless B <=program";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   282
by (rtac Constrains_type 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   283
qed "Unless_type";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   284
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   285
(*** Specialized laws for handling Always ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   286
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   287
(** Natural deduction rules for "Always A" **)
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   288
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   289
Goalw [Always_def, initially_def]
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   290
"[| Init(F)<=A;  F : Stable(A) |] ==> F : Always(A)";
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   291
by (forward_tac [Stable_type RS subsetD] 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   292
by Auto_tac;
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   293
qed "AlwaysI";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   294
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   295
Goal "F : Always(A) ==> Init(F)<=A & F : Stable(A)";
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   296
by (asm_full_simp_tac (simpset() addsimps [Always_def, initially_def]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   297
qed "AlwaysD";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   298
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   299
bind_thm ("AlwaysE", AlwaysD RS conjE);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   300
bind_thm ("Always_imp_Stable", AlwaysD RS conjunct2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   301
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   302
(*The set of all reachable states is Always*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   303
Goal "F : Always(A) ==> reachable(F) <= A";
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   304
by (full_simp_tac (simpset() addsimps 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   305
        [Stable_def, Constrains_def, constrains_def, Always_def, initially_def]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   306
by (rtac subsetI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   307
by (etac reachable.induct 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   308
by (REPEAT (blast_tac (claset() addIs reachable.intrs) 1));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   309
qed "Always_includes_reachable";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   310
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   311
Goalw [Always_def, invariant_def, Stable_def, stable_def]
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   312
     "F : invariant(A) ==> F : Always(A)";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   313
by (blast_tac (claset() addIs [constrains_imp_Constrains]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   314
qed "invariant_imp_Always";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   315
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   316
bind_thm ("Always_reachable", invariant_reachable RS invariant_imp_Always);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   317
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   318
Goal "Always(A) = {F:program. F : invariant(reachable(F) Int A)}";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   319
by (simp_tac (simpset() addsimps [Always_def, invariant_def, Stable_def, 
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   320
                                  Constrains_def2, stable_def, initially_def]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   321
by (rtac equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   322
by (ALLGOALS(Clarify_tac));
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   323
by (REPEAT(blast_tac (claset() addIs reachable.intrs@[reachable_type]) 1));
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   324
qed "Always_eq_invariant_reachable";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   325
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   326
(*the RHS is the traditional definition of the "always" operator*)
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   327
Goal "Always(A) = {F:program. reachable(F) <= A}";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   328
br equalityI 1;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   329
by (ALLGOALS(Clarify_tac));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   330
by (auto_tac (claset() addDs [invariant_includes_reachable],
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   331
              simpset() addsimps [subset_Int_iff, invariant_reachable,
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   332
                                  Always_eq_invariant_reachable]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   333
qed "Always_eq_includes_reachable";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   334
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   335
Goalw [Always_def, initially_def] "Always(A) <= program";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   336
by Auto_tac;
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   337
qed "Always_type";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   338
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   339
Goal "Always(state) = program";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   340
br equalityI 1;
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   341
by (auto_tac (claset() addDs [Always_type RS subsetD, 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   342
                              reachable_type RS subsetD], 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   343
              simpset() addsimps [Always_eq_includes_reachable]));
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   344
qed "Always_state_eq";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   345
Addsimps [Always_state_eq];
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   346
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   347
Goal "F:program ==> F : Always(state)";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   348
by (auto_tac (claset() addDs [reachable_type RS subsetD], simpset() 
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   349
    addsimps [Always_eq_includes_reachable]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   350
qed "state_AlwaysI";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   351
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   352
Goal "st_set(A) ==> Always(A) = (UN I: Pow(A). invariant(I))";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   353
by (simp_tac (simpset() addsimps [Always_eq_includes_reachable]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   354
by (rtac equalityI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   355
by (ALLGOALS(Clarify_tac));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   356
by (REPEAT(blast_tac (claset() 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   357
         addIs [invariantI, impOfSubs Init_into_reachable, 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   358
         impOfSubs invariant_includes_reachable]
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   359
                        addDs [invariant_type RS subsetD]) 1));
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   360
qed "Always_eq_UN_invariant";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   361
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   362
Goal "[| F : Always(A); A <= B |] ==> F : Always(B)";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   363
by (auto_tac (claset(), simpset() addsimps [Always_eq_includes_reachable]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   364
qed "Always_weaken";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   365
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   366
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   367
(*** "Co" rules involving Always ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   368
val Int_absorb2 = rewrite_rule [iff_def] subset_Int_iff RS conjunct1 RS mp;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   369
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   370
Goal "F:Always(I) ==> (F:(I Int A) Co A') <-> (F : A Co A')";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   371
by (asm_simp_tac
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   372
    (simpset() addsimps [Always_includes_reachable RS Int_absorb2,
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   373
                         Constrains_def, Int_assoc RS sym]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   374
qed "Always_Constrains_pre";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   375
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   376
Goal "F:Always(I) ==> (F : A Co (I Int A')) <->(F : A Co A')";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   377
by (asm_simp_tac
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   378
    (simpset() addsimps [Always_includes_reachable RS Int_absorb2,
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   379
                         Constrains_eq_constrains, Int_assoc RS sym]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   380
qed "Always_Constrains_post";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   381
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   382
Goal "[| F : Always(I);  F : (I Int A) Co A' |] ==> F : A Co A'";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   383
by (blast_tac (claset() addIs [Always_Constrains_pre RS iffD1]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   384
qed "Always_ConstrainsI";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   385
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   386
(* [| F : Always(I);  F : A Co A' |] ==> F : A Co (I Int A') *)
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   387
bind_thm ("Always_ConstrainsD", Always_Constrains_post RS iffD2);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   388
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   389
(*The analogous proof of Always_LeadsTo_weaken doesn't terminate*)
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   390
Goal 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   391
"[|F:Always(C); F:A Co A'; C Int B<=A; C Int A'<=B'|]==>F:B Co B'";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   392
by (rtac Always_ConstrainsI 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   393
by (dtac Always_ConstrainsD 2);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   394
by (ALLGOALS(Asm_simp_tac));
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   395
by (blast_tac (claset() addIs [Constrains_weaken]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   396
qed "Always_Constrains_weaken";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   397
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   398
(** Conjoining Always properties **)
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   399
Goal "Always(A Int B) = Always(A) Int Always(B)";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   400
by (auto_tac (claset(), simpset() addsimps [Always_eq_includes_reachable]));
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   401
qed "Always_Int_distrib";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   402
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   403
(* the premise i:I is need since INT is formally not defined for I=0 *)
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   404
Goal "i:I==>Always(INT i:I. A(i)) = (INT i:I. Always(A(i)))";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   405
by (rtac equalityI 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   406
by (auto_tac (claset(), simpset() addsimps
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   407
              [Inter_iff, Always_eq_includes_reachable]));
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   408
qed "Always_INT_distrib";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   409
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   410
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   411
Goal "[| F:Always(A);  F:Always(B) |] ==> F:Always(A Int B)";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   412
by (asm_simp_tac (simpset() addsimps [Always_Int_distrib]) 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   413
qed "Always_Int_I";
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   414
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   415
(*Allows a kind of "implication introduction"*)
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   416
Goal "[| F:Always(A) |] ==> (F : Always(C-A Un B)) <-> (F : Always(B))";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   417
by (auto_tac (claset(), simpset() addsimps [Always_eq_includes_reachable]));
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   418
qed "Always_Diff_Un_eq";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   419
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   420
(*Delete the nearest invariance assumption (which will be the second one
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   421
  used by Always_Int_I) *)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   422
val Always_thin =
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   423
    read_instantiate_sg (sign_of thy)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   424
                [("V", "?F : Always(?A)")] thin_rl;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   425
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   426
(*Combines two invariance ASSUMPTIONS into one.  USEFUL??*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   427
val Always_Int_tac = dtac Always_Int_I THEN' assume_tac THEN' etac Always_thin;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   428
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   429
(*Combines a list of invariance THEOREMS into one.*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   430
val Always_Int_rule = foldr1 (fn (th1,th2) => [th1,th2] MRS Always_Int_I);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   431
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   432
(*** Increasing ***)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   433
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   434
Goalw [Increasing_def] "Increasing(A,r,f) <= program";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   435
by (auto_tac (claset() addDs [Stable_type RS subsetD]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   436
                       addSDs [bspec], simpset() addsimps [INT_iff]));
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   437
qed "Increasing_type";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   438
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   439
Goalw [Increasing_def]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   440
"[| F:Increasing(A, r, f); a:A |] ==> F: Stable({s:state. <a,f`s>:r})";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   441
by (Blast_tac 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   442
qed "IncreasingD";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   443
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   444
Goalw [Increasing_def]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   445
"F:Increasing(A, r, f) ==> F:program & (EX a. a:A)";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   446
by (auto_tac (claset(), simpset() addsimps [INT_iff]));
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   447
by (blast_tac (claset() addDs [Stable_type RS subsetD]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   448
qed "IncreasingD2";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   449
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   450
Goalw [increasing_def, Increasing_def]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   451
     "F : increasing(A, r, f) ==> F : Increasing(A, r, f)";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   452
by (asm_full_simp_tac (simpset() addsimps [INT_iff]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   453
by (blast_tac (claset() addIs [stable_imp_Stable]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   454
qed "increasing_imp_Increasing";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   455
12220
9dc4e8fec63d last-minute tidying
paulson
parents: 12215
diff changeset
   456
Goal "F:Increasing(A, r, lam x:state. c) <-> F:program & (EX a. a:A)";
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   457
by (auto_tac (claset() addDs [IncreasingD2]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   458
                       addIs [increasing_imp_Increasing], simpset()));
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   459
qed "Increasing_constant";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   460
AddIffs [Increasing_constant];
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   461
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   462
Goalw [Increasing_def, Stable_def, stable_def, Constrains_def, 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   463
        constrains_def, part_order_def, st_set_def]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   464
"[| g:mono_map(A,r,A,r); part_order(A, r); f:state->A |] \
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   465
\  ==> Increasing(A, r,f) <= Increasing(A, r,g O f)";
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   466
by (case_tac "A=0" 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   467
by (Asm_full_simp_tac 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   468
by (etac not_emptyE 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   469
by (Clarify_tac 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   470
by (cut_inst_tac [("F", "xa")] Acts_type 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   471
by (asm_full_simp_tac (simpset() addsimps [Inter_iff, mono_map_def]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   472
by Auto_tac;
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   473
by (dres_inst_tac [("psi", "ALL x:A. ALL xa:A. ?u(x,xa)")] asm_rl 1); 
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   474
by (dres_inst_tac [("x", "f`xf")] bspec 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   475
by Auto_tac;
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   476
by (dres_inst_tac [("psi", "ALL x:A. ALL xa:A. ?u(x,xa)")] asm_rl 1); 
12152
46f128d8133c Renamed some bound variables due to changes in simplifier.
berghofe
parents: 11479
diff changeset
   477
by (dres_inst_tac [("x", "act")] bspec 1);
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   478
by Auto_tac;
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   479
by (dres_inst_tac [("psi", "Acts(?u) <= ?v")] asm_rl 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   480
by (dres_inst_tac [("psi", "?u <= state")] asm_rl 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   481
by (dres_inst_tac [("c", "xe")] subsetD 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   482
by (rtac imageI 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   483
by Auto_tac;
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   484
by (asm_full_simp_tac (simpset() addsimps [refl_def, apply_type]) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   485
by (dres_inst_tac [("x1", "f`xf"), ("x", "f`xe")] (bspec RS bspec) 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   486
by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [apply_type])));
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   487
by (res_inst_tac [("b", "g ` (f ` xf)")] trans_onD 1);
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   488
by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [apply_type])));
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   489
qed "mono_Increasing_comp";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   490
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   491
Goalw [Increasing_def]
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   492
     "[| F:Increasing(nat, {<m,n>:nat*nat. m le n}, f); f:state->nat; k:nat |] \
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   493
\  ==> F: Stable({s:state. k < f`s})";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   494
by (Clarify_tac 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   495
by (asm_full_simp_tac (simpset() addsimps [INT_iff]) 1);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   496
by Safe_tac;
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   497
by (dres_inst_tac [("x", "succ(k)")] bspec 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   498
by (auto_tac (claset(), simpset() addsimps [apply_type, Collect_conj_eq]));
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   499
by (subgoal_tac "{x: state . f`x : nat} = state" 1);
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   500
by Auto_tac;
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   501
qed "strict_IncreasingD";
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   502
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   503
(*To allow expansion of the program's definition when appropriate*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   504
val program_defs_ref = ref ([] : thm list);
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   505
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   506
(*proves "co" properties when the program is specified*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   507
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   508
fun constrains_tac i = 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   509
   SELECT_GOAL
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   510
      (EVERY [REPEAT (Always_Int_tac 1),
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   511
              REPEAT (etac Always_ConstrainsI 1
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   512
                      ORELSE
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   513
                      resolve_tac [StableI, stableI,
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   514
                                   constrains_imp_Constrains] 1),
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   515
              rtac constrainsI 1,
12195
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   516
              (* Three subgoals *)
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   517
              rewrite_goal_tac [st_set_def] 3,
ed2893765a08 *** empty log message ***
ehmety
parents: 12152
diff changeset
   518
              REPEAT (Force_tac 2),
11479
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   519
              full_simp_tac (simpset() addsimps !program_defs_ref) 1,
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   520
              ALLGOALS Clarify_tac,
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   521
              REPEAT (FIRSTGOAL (etac disjE)),
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   522
              ALLGOALS Clarify_tac,
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   523
              REPEAT (FIRSTGOAL (etac disjE)),
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   524
              ALLGOALS Clarify_tac,
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   525
              ALLGOALS Asm_full_simp_tac,
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   526
              ALLGOALS Clarify_tac]) i;
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   527
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   528
(*For proving invariants*)
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   529
fun always_tac i = 
697dcaaf478f new ZF/UNITY theory
paulson
parents:
diff changeset
   530
    rtac AlwaysI i THEN Force_tac i THEN constrains_tac i;