src/HOL/UNITY/UNITY.ML
author paulson
Thu, 06 Aug 1998 15:47:26 +0200
changeset 5277 e4297d03e5d2
parent 5253 82a5ca6290aa
child 5313 1861a564d7e2
permissions -rw-r--r--
A higher-level treatment of LeadsTo, minimizing use of "reachable"
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
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    17
val prems = Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    18
    "(!!act s s'. [| act: acts;  (s,s') : act;  s: A |] ==> s': A') \
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    19
\    ==> constrains acts A A'";
4776
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]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
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
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
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
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
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]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
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]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
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]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
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
(** Union **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    54
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    55
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    56
    "[| constrains acts A A'; constrains acts B B' |]   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    57
\    ==> constrains acts (A Un B) (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    58
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    59
qed "constrains_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    60
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    61
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    62
    "ALL i:I. constrains acts (A i) (A' i) \
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    63
\    ==> constrains acts (UN i:I. A i) (UN i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    64
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    65
qed "ball_constrains_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    66
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    67
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    68
    "[| ALL i. constrains acts (A i) (A' i) |] \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    69
\    ==> constrains acts (UN i. A i) (UN i. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    70
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    71
qed "all_constrains_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    72
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    73
(** Intersection **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    74
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    75
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    76
    "[| constrains acts A A'; constrains acts B B' |]   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    77
\    ==> constrains acts (A Int B) (A' Int 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_Int";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    80
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    81
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    82
    "ALL i:I. constrains acts (A i) (A' i) \
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    83
\    ==> constrains acts (INT i:I. A i) (INT i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    84
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    85
qed "ball_constrains_INT";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    86
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    87
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    88
    "[| ALL i. constrains acts (A i) (A' i) |] \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    89
\    ==> constrains acts (INT i. A i) (INT i. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    90
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    91
qed "all_constrains_INT";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    92
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    93
Goalw [constrains_def]
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    94
    "[| constrains acts A A'; id: acts |] ==> A<=A'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    95
by (Blast_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    96
qed "constrains_imp_subset";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    97
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    98
Goalw [constrains_def]
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    99
    "[| id: acts; constrains acts A B; constrains acts B C |]   \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   100
\    ==> constrains acts A C";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   101
by (Blast_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   102
qed "constrains_trans";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   103
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   104
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   105
(*** stable ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   106
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   107
Goalw [stable_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
   108
    "constrains acts A A ==> stable acts A";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   109
by (assume_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   110
qed "stableI";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   111
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   112
Goalw [stable_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
   113
    "stable acts A ==> constrains acts A A";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   114
by (assume_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   115
qed "stableD";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   116
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   117
Goalw [stable_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
   118
    "[| stable acts A; stable acts A' |]   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   119
\    ==> stable acts (A Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   120
by (blast_tac (claset() addIs [constrains_Un]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   121
qed "stable_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   122
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   123
Goalw [stable_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
   124
    "[| stable acts A; stable acts A' |]   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   125
\    ==> stable acts (A Int A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   126
by (blast_tac (claset() addIs [constrains_Int]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   127
qed "stable_Int";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   128
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   129
Goalw [stable_def, constrains_def]
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   130
    "[| stable acts C; constrains acts A (C Un A') |]   \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   131
\    ==> constrains acts (C Un A) (C Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   132
by (Blast_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   133
qed "stable_constrains_Un";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   134
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   135
Goalw [stable_def, constrains_def]
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   136
    "[| stable acts C; constrains acts (C Int A) A' |]   \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   137
\    ==> constrains acts (C Int A) (C Int A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   138
by (Blast_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   139
qed "stable_constrains_Int";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   140
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   141
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   142
(*The Elimination Theorem.  The "free" m has become universally quantified!
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   143
  Should the premise be !!m instead of ALL m ?  Would make it harder to use
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   144
  in forward proof.*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   145
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
   146
    "[| ALL m. constrains acts {s. s x = m} (B m) |] \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   147
\    ==> constrains acts {s. P(s x)} (UN m. {s. P(m)} Int B m)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   148
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   149
qed "elimination";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   150
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   151
(*As above, but for the trivial case of a one-variable state, in which the
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   152
  state is identified with its one variable.*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   153
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
   154
    "[| ALL m. constrains acts {m} (B m) |] \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   155
\    ==> constrains acts {s. P s} (UN m. {s. P(m)} Int B m)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   156
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   157
qed "elimination_sing";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   158
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   159
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   160
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
   161
   "[| constrains acts A (A' Un B); constrains acts B B'; id: acts |] \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   162
\   ==> constrains acts A (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   163
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   164
qed "constrains_cancel";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   165
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   166
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   167
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   168
(*** Theoretical Results from Section 6 ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   169
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   170
Goalw [constrains_def, strongest_rhs_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
   171
    "constrains acts A (strongest_rhs acts A )";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   172
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   173
qed "constrains_strongest_rhs";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   174
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   175
Goalw [constrains_def, strongest_rhs_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
   176
    "constrains acts A B ==> strongest_rhs acts A <= B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   177
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   178
qed "strongest_rhs_is_strongest";