src/HOL/UNITY/UNITY.ML
author paulson
Fri, 31 Jul 1998 18:46:55 +0200
changeset 5232 e5a7cdd07ea5
parent 5111 8f4b72f0c15d
child 5253 82a5ca6290aa
permissions -rw-r--r--
Tidied; uses records
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
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    15
(*** constrains ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    16
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    17
val prems = goalw thy [constrains_def]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    18
    "(!!act s s'. [| act: Acts;  (s,s') : act;  s: A |] ==> s': A') \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    19
\    ==> constrains Acts A A'";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    20
by (blast_tac (claset() addIs prems) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    21
qed "constrainsI";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    22
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    23
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    24
    "[| constrains Acts A A'; act: Acts;  (s,s'): act;  s: A |] \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    25
\            ==> s': A'";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    26
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    27
qed "constrainsD";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    28
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    29
Goalw [constrains_def] "constrains Acts {} B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    30
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    31
qed "constrains_empty";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    32
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    33
Goalw [constrains_def] "constrains Acts A UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    34
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    35
qed "constrains_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    36
AddIffs [constrains_empty, constrains_UNIV];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    37
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    38
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    39
    "[| constrains Acts A A'; A'<=B' |] ==> constrains Acts A B'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    40
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    41
qed "constrains_weaken_R";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    42
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    43
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    44
    "[| constrains Acts A A'; B<=A |] ==> constrains Acts B A'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    45
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    46
qed "constrains_weaken_L";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    47
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    48
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    49
   "[| constrains Acts A A'; B<=A; A'<=B' |] ==> constrains Acts B B'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    50
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    51
qed "constrains_weaken";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    52
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    53
(*Set difference: UNUSED*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    54
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    55
  "[| constrains Acts (A-B) C; constrains Acts B C |] \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    56
\       ==> constrains Acts A C";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    57
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    58
qed "constrains_Diff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    59
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    60
(** Union **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    61
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    62
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    63
    "[| constrains Acts A A'; constrains Acts B B' |]   \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    64
\           ==> constrains Acts (A Un B) (A' Un B')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    65
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    66
qed "constrains_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    67
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    68
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    69
    "ALL i:I. constrains Acts (A i) (A' i) \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    70
\    ==> constrains Acts (UN i:I. A i) (UN i:I. A' i)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    71
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    72
qed "ball_constrains_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    73
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    74
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    75
    "[| ALL i. constrains Acts (A i) (A' i) |] \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    76
\           ==> constrains Acts (UN i. A i) (UN i. A' i)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    77
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    78
qed "all_constrains_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    79
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    80
(** Intersection **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    81
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    82
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    83
    "[| constrains Acts A A'; constrains Acts B B' |]   \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    84
\           ==> constrains Acts (A Int B) (A' Int B')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    85
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    86
qed "constrains_Int";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    87
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    88
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    89
    "ALL i:I. constrains Acts (A i) (A' i) \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    90
\    ==> constrains Acts (INT i:I. A i) (INT i:I. A' i)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    91
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    92
qed "ball_constrains_INT";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    93
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    94
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    95
    "[| ALL i. constrains Acts (A i) (A' i) |] \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    96
\           ==> constrains Acts (INT i. A i) (INT i. A' i)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    97
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    98
qed "all_constrains_INT";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    99
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   100
Goalw [stable_def, constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   101
    "[| stable Acts C; constrains Acts A (C Un A') |]   \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   102
\           ==> constrains Acts (C Un A) (C Un A')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   103
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   104
qed "stable_constrains_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   105
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   106
Goalw [stable_def, constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   107
    "[| stable Acts C; constrains Acts (C Int A) A' |]   \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   108
\           ==> constrains Acts (C Int A) (C Int A')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   109
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   110
qed "stable_constrains_Int";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   111
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   112
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   113
(*** stable ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   114
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   115
Goalw [stable_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   116
    "constrains Acts A A ==> stable Acts A";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   117
by (assume_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   118
qed "stableI";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   119
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   120
Goalw [stable_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   121
    "stable Acts A ==> constrains Acts A A";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   122
by (assume_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   123
qed "stableD";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   124
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   125
Goalw [stable_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   126
    "[| stable Acts A; stable Acts A' |]   \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   127
\           ==> stable Acts (A Un A')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   128
by (blast_tac (claset() addIs [constrains_Un]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   129
qed "stable_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   130
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   131
Goalw [stable_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   132
    "[| stable Acts A; stable Acts A' |]   \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   133
\           ==> stable Acts (A Int A')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   134
by (blast_tac (claset() addIs [constrains_Int]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   135
qed "stable_Int";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   136
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   137
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   138
    "[| constrains Acts A A'; id: Acts |] ==> A<=A'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   139
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   140
qed "constrains_imp_subset";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   141
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   142
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   143
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   144
    "[| id: Acts; constrains Acts A B; constrains Acts B C |]   \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   145
\           ==> constrains Acts A C";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   146
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   147
qed "constrains_trans";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   148
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   149
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   150
(*The Elimination Theorem.  The "free" m has become universally quantified!
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   151
  Should the premise be !!m instead of ALL m ?  Would make it harder to use
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   152
  in forward proof.*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   153
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   154
    "[| ALL m. constrains Acts {s. s x = m} (B m) |] \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   155
\           ==> constrains Acts {s. P(s x)} (UN m. {s. P(m)} Int B m)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   156
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   157
qed "elimination";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   158
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   159
(*As above, but for the trivial case of a one-variable state, in which the
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   160
  state is identified with its one variable.*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   161
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   162
    "[| ALL m. constrains Acts {m} (B m) |] \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   163
\           ==> constrains Acts {s. P s} (UN m. {s. P(m)} Int B m)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   164
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   165
qed "elimination_sing";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   166
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   167
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   168
Goalw [constrains_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   169
   "[| constrains Acts A (A' Un B); constrains Acts B B'; id: Acts |] \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   170
\           ==> constrains Acts A (A' Un B')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   171
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   172
qed "constrains_cancel";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   173
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   174
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   175
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   176
(*** Theoretical Results from Section 6 ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   177
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   178
Goalw [constrains_def, strongest_rhs_def]
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   179
    "constrains Acts A (strongest_rhs Acts A )";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   180
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   181
qed "constrains_strongest_rhs";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   182
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   183
Goalw [constrains_def, strongest_rhs_def]
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   184
    "constrains Acts A B ==> strongest_rhs Acts A <= B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   185
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   186
qed "strongest_rhs_is_strongest";