src/HOL/UNITY/Constrains.ML
author paulson
Tue, 21 Dec 1999 15:03:02 +0100
changeset 8069 19b9f92ca503
parent 7689 affe0c2fdfbf
child 8216 e4b3192dfefa
permissions -rw-r--r--
working with weak LeadsTo in guarantees precondition\!
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/Constrains
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
     2
    ID:         $Id$
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
     5
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
     6
Safety relations: restricted to the set of reachable states.
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
     7
*)
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
     8
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
     9
6535
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    10
(*** traces and reachable ***)
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    11
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    12
Goal "reachable F = {s. EX evs. (s,evs): traces (Init F) (Acts F)}";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    13
by Safe_tac;
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    14
by (etac traces.induct 2);
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    15
by (etac reachable.induct 1);
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    16
by (ALLGOALS (blast_tac (claset() addIs reachable.intrs @ traces.intrs)));
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    17
qed "reachable_equiv_traces";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    18
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    19
Goal "Init F <= reachable F";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    20
by (blast_tac (claset() addIs reachable.intrs) 1);
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    21
qed "Init_subset_reachable";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    22
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    23
Goal "Acts G <= Acts F ==> G : stable (reachable F)";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    24
by (blast_tac (claset() addIs [stableI, constrainsI] @ reachable.intrs) 1);
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    25
qed "stable_reachable";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    26
8069
19b9f92ca503 working with weak LeadsTo in guarantees precondition\!
paulson
parents: 7689
diff changeset
    27
AddSIs [stable_reachable];
19b9f92ca503 working with weak LeadsTo in guarantees precondition\!
paulson
parents: 7689
diff changeset
    28
Addsimps [stable_reachable];
6535
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    29
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    30
(*The set of all reachable states is an invariant...*)
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    31
Goal "F : invariant (reachable F)";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    32
by (simp_tac (simpset() addsimps [invariant_def]) 1);
8069
19b9f92ca503 working with weak LeadsTo in guarantees precondition\!
paulson
parents: 7689
diff changeset
    33
by (blast_tac (claset() addIs reachable.intrs) 1);
6535
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    34
qed "invariant_reachable";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    35
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    36
(*...in fact the strongest invariant!*)
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    37
Goal "F : invariant A ==> reachable F <= A";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    38
by (full_simp_tac 
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    39
    (simpset() addsimps [stable_def, constrains_def, invariant_def]) 1);
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    40
by (rtac subsetI 1);
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    41
by (etac reachable.induct 1);
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    42
by (REPEAT (blast_tac (claset() addIs reachable.intrs) 1));
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    43
qed "invariant_includes_reachable";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    44
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    45
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
    46
(*** Co ***)
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    47
7403
c318acb88251 tidied some proofs
paulson
parents: 6741
diff changeset
    48
(*Needed because its operands are sets*)
c318acb88251 tidied some proofs
paulson
parents: 6741
diff changeset
    49
overload_1st_set "Constrains.Constrains";
5340
d75c03cf77b5 Misc changes
paulson
parents: 5319
diff changeset
    50
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
    51
(*F : B co B' ==> F : (reachable F Int B) co (reachable F Int B')*)
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    52
bind_thm ("constrains_reachable_Int",
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    53
	  subset_refl RS
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    54
	  rewrite_rule [stable_def] stable_reachable RS 
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    55
	  constrains_Int);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    56
6575
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
    57
(*Resembles the previous definition of Constrains*)
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
    58
Goalw [Constrains_def]
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
    59
     "A Co B = {F. F : (reachable F  Int  A) co (reachable F  Int  B)}";
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
    60
by (blast_tac (claset() addDs [constrains_reachable_Int]
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
    61
			addIs [constrains_weaken]) 1);
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
    62
qed "Constrains_eq_constrains";
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
    63
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
    64
Goalw [Constrains_def] "F : A co A' ==> F : A Co A'";
6575
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
    65
by (blast_tac (claset() addIs [constrains_weaken_L]) 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    66
qed "constrains_imp_Constrains";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    67
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
    68
Goalw [stable_def, Stable_def] "F : stable A ==> F : Stable A";
5631
707f30bc7fe7 new theorems
paulson
parents: 5620
diff changeset
    69
by (etac constrains_imp_Constrains 1);
707f30bc7fe7 new theorems
paulson
parents: 5620
diff changeset
    70
qed "stable_imp_Stable";
707f30bc7fe7 new theorems
paulson
parents: 5620
diff changeset
    71
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    72
val prems = Goal
5620
3ac11c4af76a tidying and renaming
paulson
parents: 5584
diff changeset
    73
    "(!!act s s'. [| act: Acts F;  (s,s') : act;  s: A |] ==> s': A') \
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
    74
\    ==> F : A Co A'";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    75
by (rtac constrains_imp_Constrains 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    76
by (blast_tac (claset() addIs (constrainsI::prems)) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    77
qed "ConstrainsI";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    78
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
    79
Goalw [Constrains_def, constrains_def] "F : {} Co B";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    80
by (Blast_tac 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    81
qed "Constrains_empty";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    82
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
    83
Goal "F : A Co UNIV";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    84
by (blast_tac (claset() addIs [ConstrainsI]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    85
qed "Constrains_UNIV";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    86
AddIffs [Constrains_empty, Constrains_UNIV];
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    87
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    88
Goalw [Constrains_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
    89
    "[| F : A Co A'; A'<=B' |] ==> F : A Co B'";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    90
by (blast_tac (claset() addIs [constrains_weaken_R]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    91
qed "Constrains_weaken_R";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    92
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    93
Goalw [Constrains_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
    94
    "[| F : A Co A'; B<=A |] ==> F : B Co A'";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    95
by (blast_tac (claset() addIs [constrains_weaken_L]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    96
qed "Constrains_weaken_L";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    97
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
    98
Goalw [Constrains_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
    99
   "[| F : A Co A'; B<=A; A'<=B' |] ==> F : B Co B'";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   100
by (blast_tac (claset() addIs [constrains_weaken]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   101
qed "Constrains_weaken";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   102
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   103
(** Union **)
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   104
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   105
Goalw [Constrains_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   106
    "[| F : A Co A'; F : B Co B' |]   \
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   107
\    ==> F : (A Un B) Co (A' Un B')";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   108
by (blast_tac (claset() addIs [constrains_Un RS constrains_weaken]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   109
qed "Constrains_Un";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   110
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   111
Goal "ALL i:I. F : (A i) Co (A' i) \
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   112
\     ==> F : (UN i:I. A i) Co (UN i:I. A' i)";
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   113
by (asm_full_simp_tac (simpset() addsimps [Constrains_def]) 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   114
by (dtac ball_constrains_UN 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   115
by (blast_tac (claset() addIs [constrains_weaken]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   116
qed "ball_Constrains_UN";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   117
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   118
(** Intersection **)
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   119
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   120
Goalw [Constrains_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   121
    "[| F : A Co A'; F : B Co B' |]   \
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   122
\    ==> F : (A Int B) Co (A' Int B')";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   123
by (blast_tac (claset() addIs [constrains_Int RS constrains_weaken]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   124
qed "Constrains_Int";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   125
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   126
Goal "ALL i:I. F : (A i) Co (A' i)   \
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   127
\     ==> F : (INT i:I. A i) Co (INT i:I. A' i)";
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   128
by (asm_full_simp_tac (simpset() addsimps [Constrains_def]) 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   129
by (dtac ball_constrains_INT 1);
5340
d75c03cf77b5 Misc changes
paulson
parents: 5319
diff changeset
   130
by (dtac constrains_reachable_Int 1);
d75c03cf77b5 Misc changes
paulson
parents: 5319
diff changeset
   131
by (blast_tac (claset() addIs [constrains_weaken]) 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   132
qed "ball_Constrains_INT";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   133
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   134
Goal "F : A Co A' ==> reachable F Int A <= A'";
6575
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   135
by (asm_full_simp_tac (simpset() addsimps [constrains_imp_subset, 
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   136
					   Constrains_def]) 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   137
qed "Constrains_imp_subset";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   138
6575
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   139
Goal "[| F : A Co B; F : B Co C |] ==> F : A Co C";
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   140
by (full_simp_tac (simpset() addsimps [Constrains_eq_constrains]) 1);
6295
351b3c2b0d83 removed the infernal States, eqStates, compatible, etc.
paulson
parents: 6012
diff changeset
   141
by (blast_tac (claset() addIs [constrains_trans, constrains_weaken]) 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   142
qed "Constrains_trans";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   143
6575
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   144
Goal "[| F : A Co (A' Un B); F : B Co B' |] ==> F : A Co (A' Un B')";
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   145
by (full_simp_tac (simpset() addsimps [Constrains_eq_constrains, 
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   146
				       constrains_def]) 1);
6295
351b3c2b0d83 removed the infernal States, eqStates, compatible, etc.
paulson
parents: 6012
diff changeset
   147
by (Blast_tac 1);
6012
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   148
qed "Constrains_cancel";
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   149
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   150
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   151
(*** Stable ***)
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   152
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   153
Goal "(F : Stable A) = (F : stable (reachable F Int A))";
6575
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   154
by (simp_tac (simpset() addsimps [Stable_def, Constrains_eq_constrains, 
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   155
				  stable_def]) 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   156
qed "Stable_eq_stable";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   157
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   158
Goalw [Stable_def] "F : A Co A ==> F : Stable A";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   159
by (assume_tac 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   160
qed "StableI";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   161
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   162
Goalw [Stable_def] "F : Stable A ==> F : A Co A";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   163
by (assume_tac 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   164
qed "StableD";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   165
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   166
Goalw [Stable_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   167
    "[| F : Stable A; F : Stable A' |] ==> F : Stable (A Un A')";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   168
by (blast_tac (claset() addIs [Constrains_Un]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   169
qed "Stable_Un";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   170
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   171
Goalw [Stable_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   172
    "[| F : Stable A; F : Stable A' |] ==> F : Stable (A Int A')";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   173
by (blast_tac (claset() addIs [Constrains_Int]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   174
qed "Stable_Int";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   175
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   176
Goalw [Stable_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   177
    "[| F : Stable C; F : A Co (C Un A') |]   \
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   178
\    ==> F : (C Un A) Co (C Un A')";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   179
by (blast_tac (claset() addIs [Constrains_Un RS Constrains_weaken]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   180
qed "Stable_Constrains_Un";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   181
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   182
Goalw [Stable_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   183
    "[| F : Stable C; F : (C Int A) Co A' |]   \
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   184
\    ==> F : (C Int A) Co (C Int A')";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   185
by (blast_tac (claset() addIs [Constrains_Int RS Constrains_weaken]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   186
qed "Stable_Constrains_Int";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   187
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   188
Goalw [Stable_def]
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5784
diff changeset
   189
    "(ALL i:I. F : Stable (A i)) ==> F : Stable (UN i:I. A i)";
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5784
diff changeset
   190
by (etac ball_Constrains_UN 1);
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5784
diff changeset
   191
qed "ball_Stable_UN";
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5784
diff changeset
   192
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5784
diff changeset
   193
Goalw [Stable_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   194
    "(ALL i:I. F : Stable (A i)) ==> F : Stable (INT i:I. A i)";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   195
by (etac ball_Constrains_INT 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   196
qed "ball_Stable_INT";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   197
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   198
Goal "F : Stable (reachable F)";
8069
19b9f92ca503 working with weak LeadsTo in guarantees precondition\!
paulson
parents: 7689
diff changeset
   199
by (simp_tac (simpset() addsimps [Stable_eq_stable]) 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   200
qed "Stable_reachable";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   201
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   202
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   203
5784
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   204
(*** Increasing ***)
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   205
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   206
Goalw [Increasing_def, Stable_def, Constrains_def, stable_def, constrains_def]
6704
5febcf428342 generalized Increasing_size to mono_Increasing_o
paulson
parents: 6672
diff changeset
   207
     "mono g ==> Increasing f <= Increasing (g o f)";
5784
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   208
by Auto_tac;
6704
5febcf428342 generalized Increasing_size to mono_Increasing_o
paulson
parents: 6672
diff changeset
   209
by (blast_tac (claset() addIs [monoD, order_trans]) 1);
5febcf428342 generalized Increasing_size to mono_Increasing_o
paulson
parents: 6672
diff changeset
   210
qed "mono_Increasing_o";
5784
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   211
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   212
Goalw [Increasing_def]
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   213
     "Increasing f <= {F. ALL z::nat. F: Stable {s. z < f s}}";
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   214
by (simp_tac (simpset() addsimps [Suc_le_eq RS sym]) 1);
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   215
by (Blast_tac 1);
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5784
diff changeset
   216
qed "Increasing_Stable_less";
5784
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   217
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   218
Goalw [increasing_def, Increasing_def]
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   219
     "F : increasing f ==> F : Increasing f";
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   220
by (blast_tac (claset() addIs [stable_imp_Stable]) 1);
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   221
qed "increasing_imp_Increasing";
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   222
54276fba8420 the Increasing operator
paulson
parents: 5669
diff changeset
   223
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   224
(*** The Elimination Theorem.  The "free" m has become universally quantified!
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   225
     Should the premise be !!m instead of ALL m ?  Would make it harder to use
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   226
     in forward proof. ***)
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   227
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   228
Goalw [Constrains_def, constrains_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   229
    "[| ALL m. F : {s. s x = m} Co (B m) |] \
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   230
\    ==> F : {s. s x : M} Co (UN m:M. B m)";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   231
by (Blast_tac 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   232
qed "Elimination";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   233
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   234
(*As above, but for the trivial case of a one-variable state, in which the
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   235
  state is identified with its one variable.*)
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   236
Goalw [Constrains_def, constrains_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   237
    "(ALL m. F : {m} Co (B m)) ==> F : M Co (UN m:M. B m)";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   238
by (Blast_tac 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   239
qed "Elimination_sing";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   240
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   241
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   242
(*** Specialized laws for handling Always ***)
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   243
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   244
(** Natural deduction rules for "Always A" **)
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   245
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   246
Goal "[| Init F<=A;  F : Stable A |] ==> F : Always A";
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   247
by (asm_simp_tac (simpset() addsimps [Always_def]) 1);
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   248
qed "AlwaysI";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   249
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   250
Goal "F : Always A ==> Init F<=A & F : Stable A";
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   251
by (asm_full_simp_tac (simpset() addsimps [Always_def]) 1);
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   252
qed "AlwaysD";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   253
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   254
bind_thm ("AlwaysE", AlwaysD RS conjE);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   255
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   256
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   257
(*The set of all reachable states is Always*)
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   258
Goal "F : Always A ==> reachable F <= A";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   259
by (full_simp_tac 
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   260
    (simpset() addsimps [Stable_def, Constrains_def, constrains_def, 
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   261
			 Always_def]) 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   262
by (rtac subsetI 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   263
by (etac reachable.induct 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   264
by (REPEAT (blast_tac (claset() addIs reachable.intrs) 1));
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   265
qed "Always_includes_reachable";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   266
6575
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   267
Goalw [Always_def, invariant_def, Stable_def, stable_def]
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   268
     "F : invariant A ==> F : Always A";
6575
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   269
by (blast_tac (claset() addIs [constrains_imp_Constrains]) 1);
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   270
qed "invariant_imp_Always";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   271
6672
8542c6dda828 new theorem Always_reachable
paulson
parents: 6575
diff changeset
   272
bind_thm ("Always_reachable", invariant_reachable RS invariant_imp_Always);
8542c6dda828 new theorem Always_reachable
paulson
parents: 6575
diff changeset
   273
6575
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   274
Goal "Always A = {F. F : invariant (reachable F Int A)}";
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   275
by (simp_tac (simpset() addsimps [Always_def, invariant_def, Stable_def, 
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   276
				  Constrains_eq_constrains, stable_def]) 1);
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   277
by (blast_tac (claset() addIs reachable.intrs) 1);
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   278
qed "Always_eq_invariant_reachable";
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   279
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   280
(*the RHS is the traditional definition of the "always" operator*)
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   281
Goal "Always A = {F. reachable F <= A}";
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5784
diff changeset
   282
by (auto_tac (claset() addDs [invariant_includes_reachable],
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5784
diff changeset
   283
	      simpset() addsimps [Int_absorb2, invariant_reachable,
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   284
				  Always_eq_invariant_reachable]));
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   285
qed "Always_eq_includes_reachable";
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   286
7689
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7541
diff changeset
   287
Goal "Always UNIV = UNIV";
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7541
diff changeset
   288
by (auto_tac (claset(),
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7541
diff changeset
   289
	      simpset() addsimps [Always_eq_includes_reachable]));
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7541
diff changeset
   290
qed "Always_UNIV_eq";
affe0c2fdfbf working snapshot (even Alloc)
paulson
parents: 7541
diff changeset
   291
Addsimps [Always_UNIV_eq];
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   292
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   293
Goal "Always A = (UN I: Pow A. invariant I)";
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   294
by (simp_tac (simpset() addsimps [Always_eq_includes_reachable]) 1);
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5784
diff changeset
   295
by (blast_tac (claset() addIs [invariantI, impOfSubs Init_subset_reachable, 
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5784
diff changeset
   296
			       impOfSubs invariant_includes_reachable]) 1);
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   297
qed "Always_eq_UN_invariant";
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   298
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   299
Goal "[| F : Always A; A <= B |] ==> F : Always B";
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   300
by (auto_tac (claset(), simpset() addsimps [Always_eq_includes_reachable]));
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   301
qed "Always_weaken";
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5784
diff changeset
   302
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5784
diff changeset
   303
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   304
(*** "Co" rules involving Always ***)
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   305
6739
66e4118eead9 replaced rules Always_ConstrainsI/D by equivalences Always_Constrains_pre,
paulson
parents: 6704
diff changeset
   306
Goal "F : Always INV ==> (F : (INV Int A) Co A') = (F : A Co A')";
66e4118eead9 replaced rules Always_ConstrainsI/D by equivalences Always_Constrains_pre,
paulson
parents: 6704
diff changeset
   307
by (asm_simp_tac
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   308
    (simpset() addsimps [Always_includes_reachable RS Int_absorb2,
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5784
diff changeset
   309
			 Constrains_def, Int_assoc RS sym]) 1);
6739
66e4118eead9 replaced rules Always_ConstrainsI/D by equivalences Always_Constrains_pre,
paulson
parents: 6704
diff changeset
   310
qed "Always_Constrains_pre";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   311
6739
66e4118eead9 replaced rules Always_ConstrainsI/D by equivalences Always_Constrains_pre,
paulson
parents: 6704
diff changeset
   312
Goal "F : Always INV ==> (F : A Co (INV Int A')) = (F : A Co A')";
66e4118eead9 replaced rules Always_ConstrainsI/D by equivalences Always_Constrains_pre,
paulson
parents: 6704
diff changeset
   313
by (asm_simp_tac
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   314
    (simpset() addsimps [Always_includes_reachable RS Int_absorb2,
6575
70d758762c50 new definitions of Co and LeadsTo
paulson
parents: 6570
diff changeset
   315
			 Constrains_eq_constrains, Int_assoc RS sym]) 1);
6739
66e4118eead9 replaced rules Always_ConstrainsI/D by equivalences Always_Constrains_pre,
paulson
parents: 6704
diff changeset
   316
qed "Always_Constrains_post";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   317
6739
66e4118eead9 replaced rules Always_ConstrainsI/D by equivalences Always_Constrains_pre,
paulson
parents: 6704
diff changeset
   318
(* [| F : Always INV;  F : (INV Int A) Co A' |] ==> F : A Co A' *)
66e4118eead9 replaced rules Always_ConstrainsI/D by equivalences Always_Constrains_pre,
paulson
parents: 6704
diff changeset
   319
bind_thm ("Always_ConstrainsI", Always_Constrains_pre RS iffD1);
66e4118eead9 replaced rules Always_ConstrainsI/D by equivalences Always_Constrains_pre,
paulson
parents: 6704
diff changeset
   320
66e4118eead9 replaced rules Always_ConstrainsI/D by equivalences Always_Constrains_pre,
paulson
parents: 6704
diff changeset
   321
(* [| F : Always INV;  F : A Co A' |] ==> F : A Co (INV Int A') *)
66e4118eead9 replaced rules Always_ConstrainsI/D by equivalences Always_Constrains_pre,
paulson
parents: 6704
diff changeset
   322
bind_thm ("Always_ConstrainsD", Always_Constrains_post RS iffD2);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   323
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   324
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   325
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   326
(** Conjoining Always properties **)
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   327
7541
1a7a38d8f5bd new theorem Always_INT_distrib; therefore renamed Always_Int
paulson
parents: 7403
diff changeset
   328
Goal "Always (A Int B) = Always A Int Always B";
1a7a38d8f5bd new theorem Always_INT_distrib; therefore renamed Always_Int
paulson
parents: 7403
diff changeset
   329
by (auto_tac (claset(), simpset() addsimps [Always_eq_includes_reachable]));
1a7a38d8f5bd new theorem Always_INT_distrib; therefore renamed Always_Int
paulson
parents: 7403
diff changeset
   330
qed "Always_Int_distrib";
1a7a38d8f5bd new theorem Always_INT_distrib; therefore renamed Always_Int
paulson
parents: 7403
diff changeset
   331
1a7a38d8f5bd new theorem Always_INT_distrib; therefore renamed Always_Int
paulson
parents: 7403
diff changeset
   332
Goal "Always (INTER I A) = (INT i:I. Always (A i))";
1a7a38d8f5bd new theorem Always_INT_distrib; therefore renamed Always_Int
paulson
parents: 7403
diff changeset
   333
by (auto_tac (claset(), simpset() addsimps [Always_eq_includes_reachable]));
1a7a38d8f5bd new theorem Always_INT_distrib; therefore renamed Always_Int
paulson
parents: 7403
diff changeset
   334
qed "Always_INT_distrib";
1a7a38d8f5bd new theorem Always_INT_distrib; therefore renamed Always_Int
paulson
parents: 7403
diff changeset
   335
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   336
Goal "[| F : Always A;  F : Always B |] ==> F : Always (A Int B)";
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   337
by (auto_tac (claset(), simpset() addsimps [Always_eq_includes_reachable]));
7541
1a7a38d8f5bd new theorem Always_INT_distrib; therefore renamed Always_Int
paulson
parents: 7403
diff changeset
   338
qed "Always_Int_I";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   339
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   340
(*Delete the nearest invariance assumption (which will be the second one
7541
1a7a38d8f5bd new theorem Always_INT_distrib; therefore renamed Always_Int
paulson
parents: 7403
diff changeset
   341
  used by Always_Int_I) *)
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   342
val Always_thin =
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   343
    read_instantiate_sg (sign_of thy)
6570
a7d7985050a9 Invariant -> Always and other tidying
paulson
parents: 6536
diff changeset
   344
                [("V", "?F : Always ?A")] thin_rl;
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   345
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   346
(*Combines two invariance ASSUMPTIONS into one.  USEFUL??*)
7541
1a7a38d8f5bd new theorem Always_INT_distrib; therefore renamed Always_Int
paulson
parents: 7403
diff changeset
   347
val Always_Int_tac = dtac Always_Int_I THEN' assume_tac THEN' etac Always_thin;
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   348
5319
7356d0c88b1b Moved Un_subset_iff and Int_subset_iff from UNITY to equalities.ML
paulson
parents: 5313
diff changeset
   349
(*Combines a list of invariance THEOREMS into one.*)
7541
1a7a38d8f5bd new theorem Always_INT_distrib; therefore renamed Always_Int
paulson
parents: 7403
diff changeset
   350
val Always_Int_rule = foldr1 (fn (th1,th2) => [th1,th2] MRS Always_Int_I);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   351
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
diff changeset
   352
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   353
(*To allow expansion of the program's definition when appropriate*)
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   354
val program_defs_ref = ref ([] : thm list);
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   355
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   356
(*proves "co" properties when the program is specified*)
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   357
fun constrains_tac i = 
5422
578dc167453f Moved constrains_tac from SubstAx to Constrains.
paulson
parents: 5340
diff changeset
   358
   SELECT_GOAL
7403
c318acb88251 tidied some proofs
paulson
parents: 6741
diff changeset
   359
      (EVERY [REPEAT (Always_Int_tac 1),
c318acb88251 tidied some proofs
paulson
parents: 6741
diff changeset
   360
	      REPEAT (etac Always_ConstrainsI 1
c318acb88251 tidied some proofs
paulson
parents: 6741
diff changeset
   361
		      ORELSE
c318acb88251 tidied some proofs
paulson
parents: 6741
diff changeset
   362
		      resolve_tac [StableI, stableI,
5422
578dc167453f Moved constrains_tac from SubstAx to Constrains.
paulson
parents: 5340
diff changeset
   363
				   constrains_imp_Constrains] 1),
578dc167453f Moved constrains_tac from SubstAx to Constrains.
paulson
parents: 5340
diff changeset
   364
	      rtac constrainsI 1,
7403
c318acb88251 tidied some proofs
paulson
parents: 6741
diff changeset
   365
	      full_simp_tac (simpset() addsimps !program_defs_ref) 1,
5620
3ac11c4af76a tidying and renaming
paulson
parents: 5584
diff changeset
   366
	      REPEAT (FIRSTGOAL (etac disjE)),
5422
578dc167453f Moved constrains_tac from SubstAx to Constrains.
paulson
parents: 5340
diff changeset
   367
	      ALLGOALS Clarify_tac,
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5631
diff changeset
   368
	      ALLGOALS Asm_full_simp_tac]) i;
7403
c318acb88251 tidied some proofs
paulson
parents: 6741
diff changeset
   369
c318acb88251 tidied some proofs
paulson
parents: 6741
diff changeset
   370
c318acb88251 tidied some proofs
paulson
parents: 6741
diff changeset
   371
(*For proving invariants*)
c318acb88251 tidied some proofs
paulson
parents: 6741
diff changeset
   372
fun always_tac i = 
c318acb88251 tidied some proofs
paulson
parents: 6741
diff changeset
   373
    rtac AlwaysI i THEN Force_tac i THEN constrains_tac i;