src/HOL/UNITY/UNITY.ML
author paulson
Thu, 03 Dec 1998 10:45:06 +0100
changeset 6012 1894bfc4aee9
parent 5804 8e0a4c4fd67b
child 6295 351b3c2b0d83
permissions -rw-r--r--
Addition of the States component; parts of Comp not working
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/UNITY
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     2
    ID:         $Id$
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     5
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     6
The basic UNITY theory (revised version, based upon the "co" operator)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     7
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     8
From Misra, "A Logic for Concurrent Programming", 1994
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     9
*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    10
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    11
set proof_timing;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    12
HOL_quantifiers := false;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    13
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    14
6012
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    15
(*** General lemmas ***)
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    16
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    17
    Goal "Pow UNIV = UNIV";
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    18
    by (Blast_tac 1);
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    19
    qed "Pow_UNIV";
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    20
    Addsimps [Pow_UNIV];
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    21
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    22
Goal "UNIV Times UNIV = UNIV";
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    23
by Auto_tac;
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    24
qed "UNIV_Times_UNIV"; 
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    25
Addsimps [UNIV_Times_UNIV];
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    26
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    27
Goal "- (UNIV Times A) = UNIV Times (-A)";
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    28
by Auto_tac;
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    29
qed "Compl_Times_UNIV1"; 
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    30
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    31
Goal "- (A Times UNIV) = (-A) Times UNIV";
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    32
by Auto_tac;
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    33
qed "Compl_Times_UNIV2"; 
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    34
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    35
Addsimps [Compl_Times_UNIV1, Compl_Times_UNIV2]; 
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    36
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    37
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    38
(*** constrains ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    39
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    40
overload_1st_set "UNITY.constrains";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    41
overload_1st_set "UNITY.stable";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    42
overload_1st_set "UNITY.unless";
5340
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
    43
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    44
val prems = Goalw [constrains_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    45
    "(!!act s s'. [| act: Acts F;  (s,s') : act;  s: A |] ==> s': A') \
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    46
\    ==> F : constrains A A'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    47
by (blast_tac (claset() addIs prems) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    48
qed "constrainsI";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    49
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    50
Goalw [constrains_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    51
    "[| F : constrains A A'; act: Acts F;  (s,s'): act;  s: A |] ==> s': A'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    52
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    53
qed "constrainsD";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    54
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    55
Goalw [constrains_def] "F : constrains {} B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    56
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    57
qed "constrains_empty";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    58
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    59
Goalw [constrains_def] "F : constrains A UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    60
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    61
qed "constrains_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    62
AddIffs [constrains_empty, constrains_UNIV];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    63
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    64
(*monotonic in 2nd argument*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    65
Goalw [constrains_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    66
    "[| F : constrains A A'; A'<=B' |] ==> F : constrains A B'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    67
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    68
qed "constrains_weaken_R";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    69
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    70
(*anti-monotonic in 1st argument*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    71
Goalw [constrains_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    72
    "[| F : constrains A A'; B<=A |] ==> F : constrains B A'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    73
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    74
qed "constrains_weaken_L";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    75
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    76
Goalw [constrains_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    77
   "[| F : constrains A A'; B<=A; A'<=B' |] ==> F : constrains B B'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    78
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    79
qed "constrains_weaken";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    80
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    81
(** Union **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    82
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    83
Goalw [constrains_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    84
    "[| F : constrains A A'; F : constrains B B' |]   \
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    85
\    ==> F : constrains (A Un B) (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    86
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    87
qed "constrains_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    88
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    89
Goalw [constrains_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    90
    "ALL i:I. F : constrains (A i) (A' i) \
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    91
\    ==> F : constrains (UN i:I. A i) (UN i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    92
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    93
qed "ball_constrains_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    94
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    95
(** Intersection **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    96
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    97
Goalw [constrains_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    98
    "[| F : constrains A A'; F : constrains B B' |]   \
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
    99
\    ==> F : constrains (A Int B) (A' Int B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   100
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   101
qed "constrains_Int";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   102
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   103
Goalw [constrains_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   104
    "ALL i:I. F : constrains (A i) (A' i) \
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   105
\    ==> F : constrains (INT i:I. A i) (INT i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   106
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   107
qed "ball_constrains_INT";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   108
6012
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   109
Goalw [constrains_def] "[| F : constrains A A'; A <= States F |] ==> A <= A'";
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   110
by (Force_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   111
qed "constrains_imp_subset";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   112
6012
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   113
(*The reasoning is by subsets since "constrains" refers to single actions
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   114
  only.  So this rule isn't that useful.*)
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   115
Goal "[| F : constrains A B; F : constrains B C; B <= States F |]   \
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   116
\    ==> F : constrains A C";
6012
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   117
by (etac constrains_weaken_R 1);
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   118
by (etac constrains_imp_subset 1);
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   119
by (assume_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   120
qed "constrains_trans";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   121
6012
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   122
Goal "[| F : constrains A (A' Un B); F : constrains B B'; B <= States F|] \
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   123
\     ==> F : constrains A (A' Un B')";
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   124
by (etac constrains_weaken_R 1);
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   125
by (blast_tac (claset() addDs [impOfSubs constrains_imp_subset]) 1);
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   126
qed "constrains_cancel";
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   127
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   128
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   129
(*** stable ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   130
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   131
Goalw [stable_def] "F : constrains A A ==> F : stable A";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   132
by (assume_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   133
qed "stableI";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   134
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   135
Goalw [stable_def] "F : stable A ==> F : constrains A A";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   136
by (assume_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   137
qed "stableD";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   138
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   139
(** Union **)
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   140
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   141
Goalw [stable_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   142
    "[| F : stable A; F : stable A' |] ==> F : stable (A Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   143
by (blast_tac (claset() addIs [constrains_Un]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   144
qed "stable_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   145
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   146
Goalw [stable_def]
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   147
    "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: 5669
diff changeset
   148
by (blast_tac (claset() addIs [ball_constrains_UN]) 1);
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   149
qed "ball_stable_UN";
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   150
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   151
(** Intersection **)
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   152
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   153
Goalw [stable_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   154
    "[| F : stable A; F : stable A' |] ==> F : stable (A Int A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   155
by (blast_tac (claset() addIs [constrains_Int]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   156
qed "stable_Int";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   157
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   158
Goalw [stable_def]
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   159
    "ALL i:I. F : stable (A i) ==> F : stable (INT i:I. A i)";
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   160
by (blast_tac (claset() addIs [ball_constrains_INT]) 1);
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   161
qed "ball_stable_INT";
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   162
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   163
Goalw [stable_def, constrains_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   164
    "[| F : stable C; F : constrains A (C Un A') |]   \
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   165
\    ==> F : constrains (C Un A) (C Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   166
by (Blast_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   167
qed "stable_constrains_Un";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   168
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   169
Goalw [stable_def, constrains_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   170
    "[| F : stable C; F : constrains (C Int A) A' |]   \
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   171
\    ==> F : constrains (C Int A) (C Int A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   172
by (Blast_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   173
qed "stable_constrains_Int";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   174
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   175
Goal "Init F <= reachable F";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   176
by (blast_tac (claset() addIs reachable.intrs) 1);
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   177
qed "Init_subset_reachable";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   178
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   179
Goal "Acts G <= Acts F ==> G : stable (reachable F)";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   180
by (blast_tac (claset() addIs [stableI, constrainsI] @ reachable.intrs) 1);
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   181
qed "stable_reachable";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   182
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   183
(*[| F : stable C; F : constrains (C Int A) A |] ==> F : stable (C Int A)*)
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   184
bind_thm ("stable_constrains_stable", stable_constrains_Int RS stableI);
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   185
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   186
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   187
(*** invariant ***)
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   188
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   189
Goal "[| Init F<=A;  F: stable A |] ==> F : invariant A";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   190
by (asm_simp_tac (simpset() addsimps [invariant_def]) 1);
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   191
qed "invariantI";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   192
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   193
(*Could also say "invariant A Int invariant B <= invariant (A Int B)"*)
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   194
Goal "[| F : invariant A;  F : invariant B |] ==> F : invariant (A Int B)";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   195
by (auto_tac (claset(), simpset() addsimps [invariant_def, stable_Int]));
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   196
qed "invariant_Int";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   197
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   198
(*The set of all reachable states is an invariant...*)
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   199
Goal "F : invariant (reachable F)";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   200
by (simp_tac (simpset() addsimps [invariant_def]) 1);
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   201
by (blast_tac (claset() addIs (stable_reachable::reachable.intrs)) 1);
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   202
qed "invariant_reachable";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   203
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   204
(*...in fact the strongest invariant!*)
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   205
Goal "F : invariant A ==> reachable F <= A";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   206
by (full_simp_tac 
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   207
    (simpset() addsimps [stable_def, constrains_def, invariant_def]) 1);
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   208
by (rtac subsetI 1);
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   209
by (etac reachable.induct 1);
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   210
by (REPEAT (blast_tac (claset() addIs reachable.intrs) 1));
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   211
qed "invariant_includes_reachable";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   212
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   213
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   214
(*** increasing ***)
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   215
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   216
Goalw [increasing_def, stable_def, constrains_def]
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   217
     "increasing f <= increasing (length o f)";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   218
by Auto_tac;
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   219
by (blast_tac (claset() addIs [prefix_length_le, le_trans]) 1);
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   220
qed "increasing_size";
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   221
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   222
Goalw [increasing_def]
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   223
     "increasing f <= {F. ALL z::nat. F: stable {s. z < f s}}";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   224
by (simp_tac (simpset() addsimps [Suc_le_eq RS sym]) 1);
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   225
by (Blast_tac 1);
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   226
qed "increasing_stable_less";
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   227
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   228
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   229
(** The Elimination Theorem.  The "free" m has become universally quantified!
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   230
    Should the premise be !!m instead of ALL m ?  Would make it harder to use
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   231
    in forward proof. **)
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   232
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   233
Goalw [constrains_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   234
    "[| ALL m. F : constrains {s. s x = m} (B m) |] \
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   235
\    ==> F : constrains {s. s x : M} (UN m:M. B m)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   236
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   237
qed "elimination";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   238
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   239
(*As above, but for the trivial case of a one-variable state, in which the
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   240
  state is identified with its one variable.*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   241
Goalw [constrains_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   242
    "(ALL m. F : constrains {m} (B m)) ==> F : constrains M (UN m:M. B m)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   243
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   244
qed "elimination_sing";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   245
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   246
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   247
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   248
(*** Theoretical Results from Section 6 ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   249
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   250
Goalw [constrains_def, strongest_rhs_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   251
    "F : constrains A (strongest_rhs F A )";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   252
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   253
qed "constrains_strongest_rhs";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   254
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   255
Goalw [constrains_def, strongest_rhs_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   256
    "F : constrains A B ==> strongest_rhs F A <= B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   257
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   258
qed "strongest_rhs_is_strongest";