src/HOL/UNITY/UNITY.ML
author paulson
Thu, 13 Aug 1998 18:06:40 +0200
changeset 5313 1861a564d7e2
parent 5277 e4297d03e5d2
child 5340 d75c03cf77b5
permissions -rw-r--r--
Constrains, Stable, Invariant...more of the substitution axiom, but Union does not work well with them
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]
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
    24
    "[| constrains acts A A'; act: acts;  (s,s'): act;  s: A |] ==> s': A'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    25
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    26
qed "constrainsD";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    27
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    28
Goalw [constrains_def] "constrains acts {} B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    29
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    30
qed "constrains_empty";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    31
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    32
Goalw [constrains_def] "constrains acts A UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    33
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    34
qed "constrains_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    35
AddIffs [constrains_empty, constrains_UNIV];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    36
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    37
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    38
    "[| constrains acts A A'; A'<=B' |] ==> constrains acts A B'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    39
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    40
qed "constrains_weaken_R";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    41
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    42
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    43
    "[| constrains acts A A'; B<=A |] ==> constrains acts B A'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    44
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    45
qed "constrains_weaken_L";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    46
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    47
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    48
   "[| constrains acts A A'; B<=A; A'<=B' |] ==> constrains acts B B'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    49
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    50
qed "constrains_weaken";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    51
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    52
(** Union **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    53
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    54
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    55
    "[| 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
    56
\    ==> constrains acts (A Un B) (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    57
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    58
qed "constrains_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    59
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    60
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    61
    "ALL i:I. constrains acts (A i) (A' i) \
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    62
\    ==> constrains acts (UN i:I. A i) (UN i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    63
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    64
qed "ball_constrains_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    65
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    66
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    67
    "[| 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
    68
\    ==> constrains acts (UN i. A i) (UN i. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    69
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    70
qed "all_constrains_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    71
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    72
(** Intersection **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    73
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    74
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    75
    "[| 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
    76
\    ==> constrains acts (A Int B) (A' Int B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    77
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    78
qed "constrains_Int";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    79
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    80
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    81
    "ALL i:I. constrains acts (A i) (A' i) \
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    82
\    ==> constrains acts (INT i:I. A i) (INT i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    83
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    84
qed "ball_constrains_INT";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    85
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
    86
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
    87
    "[| 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
    88
\    ==> constrains acts (INT i. A i) (INT i. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    89
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    90
qed "all_constrains_INT";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    91
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
    92
Goalw [constrains_def] "[| constrains acts A A'; id: acts |] ==> A<=A'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    93
by (Blast_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    94
qed "constrains_imp_subset";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    95
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    96
Goalw [constrains_def]
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
    97
    "[| 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
    98
\    ==> constrains acts A C";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    99
by (Blast_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   100
qed "constrains_trans";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   101
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   102
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   103
(*** stable ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   104
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   105
Goalw [stable_def] "constrains acts A A ==> stable acts A";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   106
by (assume_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   107
qed "stableI";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   108
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   109
Goalw [stable_def] "stable acts A ==> constrains acts A A";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   110
by (assume_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   111
qed "stableD";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   112
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   113
Goalw [stable_def]
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   114
    "[| stable acts A; stable acts A' |] ==> stable acts (A Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   115
by (blast_tac (claset() addIs [constrains_Un]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   116
qed "stable_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   117
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   118
Goalw [stable_def]
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   119
    "[| stable acts A; stable acts A' |] ==> stable acts (A Int A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   120
by (blast_tac (claset() addIs [constrains_Int]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   121
qed "stable_Int";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   122
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   123
Goalw [stable_def, constrains_def]
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   124
    "[| 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
   125
\    ==> constrains acts (C Un A) (C Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   126
by (Blast_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   127
qed "stable_constrains_Un";
4776
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 (C Int A) A' |]   \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   131
\    ==> constrains acts (C Int A) (C Int 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_Int";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   134
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   135
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   136
(*The Elimination Theorem.  The "free" m has become universally quantified!
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   137
  Should the premise be !!m instead of ALL m ?  Would make it harder to use
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   138
  in forward proof.*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   139
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
   140
    "[| ALL m. constrains acts {s. s x = m} (B m) |] \
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   141
\    ==> constrains acts {s. s x : M} (UN m:M. B m)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   142
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   143
qed "elimination";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   144
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   145
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   146
(*As above, but for the trivial case of a one-variable state, in which the
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   147
  state is identified with its one variable.*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   148
Goalw [constrains_def]
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   149
    "(ALL m. constrains acts {m} (B m)) ==> constrains acts M (UN m:M. B m)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   150
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   151
qed "elimination_sing";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   152
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   153
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   154
Goalw [constrains_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
   155
   "[| 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
   156
\   ==> constrains acts A (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   157
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   158
qed "constrains_cancel";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   159
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   160
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   161
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   162
(*** Theoretical Results from Section 6 ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   163
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   164
Goalw [constrains_def, strongest_rhs_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
   165
    "constrains acts A (strongest_rhs acts A )";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   166
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   167
qed "constrains_strongest_rhs";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   168
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   169
Goalw [constrains_def, strongest_rhs_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5232
diff changeset
   170
    "constrains acts A B ==> strongest_rhs acts A <= B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   171
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   172
qed "strongest_rhs_is_strongest";