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