src/HOL/UNITY/UNITY.ML
author paulson
Mon, 11 Oct 1999 10:53:39 +0200
changeset 7826 c6a8b73b6c2a
parent 7630 d0e4a6f1f05c
child 7915 c7fd7eb3b0ef
permissions -rw-r--r--
working shapshot with "projecting" and "extending"
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
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    13
6012
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    14
(*** General lemmas ***)
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    15
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    16
Goal "UNIV Times UNIV = UNIV";
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    17
by Auto_tac;
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    18
qed "UNIV_Times_UNIV"; 
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    19
Addsimps [UNIV_Times_UNIV];
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    20
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    21
Goal "- (UNIV Times A) = UNIV Times (-A)";
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    22
by Auto_tac;
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    23
qed "Compl_Times_UNIV1"; 
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    24
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    25
Goal "- (A Times UNIV) = (-A) Times UNIV";
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    26
by Auto_tac;
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    27
qed "Compl_Times_UNIV2"; 
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    28
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
    29
Addsimps [Compl_Times_UNIV1, Compl_Times_UNIV2]; 
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
6535
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    32
(*** The abstract type of programs ***)
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    33
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    34
val rep_ss = simpset() addsimps 
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    35
                [Init_def, Acts_def, mk_program_def, Program_def, Rep_Program, 
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    36
		 Rep_Program_inverse, Abs_Program_inverse];
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    37
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    38
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    39
Goal "Id : Acts F";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    40
by (cut_inst_tac [("x", "F")] Rep_Program 1);
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    41
by (auto_tac (claset(), rep_ss));
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    42
qed "Id_in_Acts";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    43
AddIffs [Id_in_Acts];
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    44
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    45
Goal "insert Id (Acts F) = Acts F";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    46
by (simp_tac (simpset() addsimps [insert_absorb, Id_in_Acts]) 1);
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    47
qed "insert_Id_Acts";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    48
AddIffs [insert_Id_Acts];
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    49
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    50
(** Inspectors for type "program" **)
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    51
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    52
Goal "Init (mk_program (init,acts)) = init";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    53
by (auto_tac (claset(), rep_ss));
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    54
qed "Init_eq";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    55
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    56
Goal "Acts (mk_program (init,acts)) = insert Id acts";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    57
by (auto_tac (claset(), rep_ss));
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    58
qed "Acts_eq";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    59
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    60
Addsimps [Acts_eq, Init_eq];
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    61
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    62
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    63
(** The notation of equality for type "program" **)
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    64
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    65
Goal "[| Init F = Init G; Acts F = Acts G |] ==> F = G";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    66
by (subgoals_tac ["EX x. Rep_Program F = x",
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    67
		  "EX x. Rep_Program G = x"] 1);
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    68
by (REPEAT (Blast_tac 2));
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    69
by (Clarify_tac 1);
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    70
by (auto_tac (claset(), rep_ss));
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    71
by (REPEAT (dres_inst_tac [("f", "Abs_Program")] arg_cong 1));
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    72
by (asm_full_simp_tac rep_ss 1);
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    73
qed "program_equalityI";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    74
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    75
val [major,minor] =
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    76
Goal "[| F = G; [| Init F = Init G; Acts F = Acts G |] ==> P |] ==> P";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    77
by (rtac minor 1);
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    78
by (auto_tac (claset(), simpset() addsimps [major]));
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    79
qed "program_equalityE";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    80
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    81
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    82
(*** These rules allow "lazy" definition expansion 
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    83
     They avoid expanding the full program, which is a large expression
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    84
***)
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    85
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    86
Goal "F == mk_program (init,acts) ==> Init F = init";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    87
by Auto_tac;
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    88
qed "def_prg_Init";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    89
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    90
(*The program is not expanded, but its Init and Acts are*)
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    91
val [rew] = goal thy
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    92
    "[| F == mk_program (init,acts) |] \
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    93
\    ==> Init F = init & Acts F = insert Id acts";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    94
by (rewtac rew);
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    95
by Auto_tac;
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    96
qed "def_prg_simps";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    97
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    98
(*An action is expanded only if a pair of states is being tested against it*)
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
    99
Goal "[| act == {(s,s'). P s s'} |] ==> ((s,s') : act) = P s s'";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
   100
by Auto_tac;
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
   101
qed "def_act_simp";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
   102
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
   103
fun simp_of_act def = def RS def_act_simp;
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
   104
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
   105
(*A set is expanded only if an element is being tested against it*)
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
   106
Goal "A == B ==> (x : A) = (x : B)";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
   107
by Auto_tac;
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
   108
qed "def_set_simp";
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
   109
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
   110
fun simp_of_set def = def RS def_set_simp;
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
   111
880f31a62784 eliminated theory UNITY/Traces
paulson
parents: 6295
diff changeset
   112
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   113
(*** co ***)
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   114
7403
c318acb88251 tidied some proofs
paulson
parents: 7345
diff changeset
   115
(*These operators are not overloaded, but their operands are sets, and 
c318acb88251 tidied some proofs
paulson
parents: 7345
diff changeset
   116
  ultimately there's a risk of reaching equality, which IS overloaded*)
c318acb88251 tidied some proofs
paulson
parents: 7345
diff changeset
   117
overload_1st_set "UNITY.constrains";
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   118
overload_1st_set "UNITY.stable";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   119
overload_1st_set "UNITY.unless";
5340
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   120
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   121
val prems = Goalw [constrains_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   122
    "(!!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
   123
\    ==> F : A co A'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   124
by (blast_tac (claset() addIs prems) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   125
qed "constrainsI";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   126
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   127
Goalw [constrains_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   128
    "[| F : A co A'; act: Acts F;  (s,s'): act;  s: A |] ==> s': A'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   129
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   130
qed "constrainsD";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   131
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   132
Goalw [constrains_def] "F : {} co B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   133
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   134
qed "constrains_empty";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   135
7826
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   136
Goalw [constrains_def] "(F : A co {}) = (A={})";
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   137
by (Blast_tac 1);
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   138
qed "constrains_empty2";
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   139
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   140
Goalw [constrains_def] "(F : UNIV co B) = (B = UNIV)";
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   141
by (Blast_tac 1);
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   142
qed "constrains_UNIV";
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   143
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   144
Goalw [constrains_def] "F : A co UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   145
by (Blast_tac 1);
7826
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   146
qed "constrains_UNIV2";
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   147
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   148
AddIffs [constrains_empty, constrains_empty2, 
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   149
	 constrains_UNIV, constrains_UNIV2];
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   150
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   151
(*monotonic in 2nd argument*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   152
Goalw [constrains_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   153
    "[| F : A co A'; A'<=B' |] ==> F : A co B'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   154
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   155
qed "constrains_weaken_R";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   156
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   157
(*anti-monotonic in 1st argument*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   158
Goalw [constrains_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   159
    "[| F : A co A'; B<=A |] ==> F : B co A'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   160
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   161
qed "constrains_weaken_L";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   162
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   163
Goalw [constrains_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   164
   "[| F : A co A'; B<=A; A'<=B' |] ==> F : B co B'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   165
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   166
qed "constrains_weaken";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   167
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   168
(** Union **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   169
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   170
Goalw [constrains_def]
7345
paulson
parents: 7240
diff changeset
   171
    "[| F : A co A'; F : B co B' |] ==> F : (A Un B) co (A' Un B')";
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_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   174
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   175
Goalw [constrains_def]
7345
paulson
parents: 7240
diff changeset
   176
    "ALL i:I. F : (A i) co (A' i) ==> F : (UN i:I. A i) co (UN i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   177
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   178
qed "ball_constrains_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   179
7826
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   180
Goalw [constrains_def] "(A Un B) co C = (A co C) Int (B co C)";
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   181
by (Blast_tac 1);
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   182
qed "constrains_Un_distrib";
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   183
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   184
Goalw [constrains_def] "(UN i:I. A i) co B = (INT i:I. A i co B)";
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   185
by (Blast_tac 1);
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   186
qed "constrains_UN_distrib";
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   187
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   188
Goalw [constrains_def] "C co (A Int B) = (C co A) Int (C co B)";
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   189
by (Blast_tac 1);
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   190
qed "constrains_Int_distrib";
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   191
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   192
Goalw [constrains_def] "A co (INT i:I. B i) = (INT i:I. A co B i)";
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   193
by (Blast_tac 1);
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   194
qed "constrains_INT_distrib";
c6a8b73b6c2a working shapshot with "projecting" and "extending"
paulson
parents: 7630
diff changeset
   195
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   196
(** Intersection **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   197
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   198
Goalw [constrains_def]
7345
paulson
parents: 7240
diff changeset
   199
    "[| F : A co A'; F : B co B' |] ==> F : (A Int B) co (A' Int B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   200
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   201
qed "constrains_Int";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   202
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   203
Goalw [constrains_def]
7345
paulson
parents: 7240
diff changeset
   204
    "ALL i:I. F : (A i) co (A' i) ==> F : (INT i:I. A i) co (INT i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   205
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   206
qed "ball_constrains_INT";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   207
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   208
Goalw [constrains_def] "F : A co A' ==> A <= A'";
6295
351b3c2b0d83 removed the infernal States, eqStates, compatible, etc.
paulson
parents: 6012
diff changeset
   209
by Auto_tac;
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   210
qed "constrains_imp_subset";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   211
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   212
(*The reasoning is by subsets since "co" refers to single actions
6012
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   213
  only.  So this rule isn't that useful.*)
6295
351b3c2b0d83 removed the infernal States, eqStates, compatible, etc.
paulson
parents: 6012
diff changeset
   214
Goalw [constrains_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   215
    "[| F : A co B; F : B co C |] ==> F : A co C";
6295
351b3c2b0d83 removed the infernal States, eqStates, compatible, etc.
paulson
parents: 6012
diff changeset
   216
by (Blast_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   217
qed "constrains_trans";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   218
6295
351b3c2b0d83 removed the infernal States, eqStates, compatible, etc.
paulson
parents: 6012
diff changeset
   219
Goalw [constrains_def]
7345
paulson
parents: 7240
diff changeset
   220
   "[| F : A co (A' Un B); F : B co B' |] ==> F : A co (A' Un B')";
6295
351b3c2b0d83 removed the infernal States, eqStates, compatible, etc.
paulson
parents: 6012
diff changeset
   221
by (Clarify_tac 1);
351b3c2b0d83 removed the infernal States, eqStates, compatible, etc.
paulson
parents: 6012
diff changeset
   222
by (Blast_tac 1);
6012
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   223
qed "constrains_cancel";
1894bfc4aee9 Addition of the States component; parts of Comp not working
paulson
parents: 5804
diff changeset
   224
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   225
7630
d0e4a6f1f05c working snapshot with new theory "Project"
paulson
parents: 7594
diff changeset
   226
(*** unless ***)
d0e4a6f1f05c working snapshot with new theory "Project"
paulson
parents: 7594
diff changeset
   227
d0e4a6f1f05c working snapshot with new theory "Project"
paulson
parents: 7594
diff changeset
   228
Goalw [unless_def] "F : (A-B) co (A Un B) ==> F : A unless B";
d0e4a6f1f05c working snapshot with new theory "Project"
paulson
parents: 7594
diff changeset
   229
by (assume_tac 1);
d0e4a6f1f05c working snapshot with new theory "Project"
paulson
parents: 7594
diff changeset
   230
qed "unlessI";
d0e4a6f1f05c working snapshot with new theory "Project"
paulson
parents: 7594
diff changeset
   231
d0e4a6f1f05c working snapshot with new theory "Project"
paulson
parents: 7594
diff changeset
   232
Goalw [unless_def] "F : A unless B ==> F : (A-B) co (A Un B)";
d0e4a6f1f05c working snapshot with new theory "Project"
paulson
parents: 7594
diff changeset
   233
by (assume_tac 1);
d0e4a6f1f05c working snapshot with new theory "Project"
paulson
parents: 7594
diff changeset
   234
qed "unlessD";
d0e4a6f1f05c working snapshot with new theory "Project"
paulson
parents: 7594
diff changeset
   235
d0e4a6f1f05c working snapshot with new theory "Project"
paulson
parents: 7594
diff changeset
   236
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   237
(*** stable ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   238
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   239
Goalw [stable_def] "F : A co A ==> F : stable A";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   240
by (assume_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   241
qed "stableI";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   242
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   243
Goalw [stable_def] "F : stable A ==> F : A co A";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   244
by (assume_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   245
qed "stableD";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   246
7594
8a188ef6545e working version with co-guarantees-leadsto results
paulson
parents: 7403
diff changeset
   247
Goalw [stable_def, constrains_def] "stable UNIV = UNIV";
8a188ef6545e working version with co-guarantees-leadsto results
paulson
parents: 7403
diff changeset
   248
by Auto_tac;
8a188ef6545e working version with co-guarantees-leadsto results
paulson
parents: 7403
diff changeset
   249
qed "stable_UNIV";
8a188ef6545e working version with co-guarantees-leadsto results
paulson
parents: 7403
diff changeset
   250
Addsimps [stable_UNIV];
8a188ef6545e working version with co-guarantees-leadsto results
paulson
parents: 7403
diff changeset
   251
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   252
(** Union **)
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   253
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   254
Goalw [stable_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   255
    "[| F : stable A; F : stable A' |] ==> F : stable (A Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   256
by (blast_tac (claset() addIs [constrains_Un]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   257
qed "stable_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   258
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   259
Goalw [stable_def]
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   260
    "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
   261
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
   262
qed "ball_stable_UN";
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   263
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   264
(** Intersection **)
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   265
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   266
Goalw [stable_def]
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   267
    "[| F : stable A; F : stable A' |] ==> F : stable (A Int A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   268
by (blast_tac (claset() addIs [constrains_Int]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   269
qed "stable_Int";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   270
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   271
Goalw [stable_def]
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   272
    "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
   273
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
   274
qed "ball_stable_INT";
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   275
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   276
Goalw [stable_def, constrains_def]
7345
paulson
parents: 7240
diff changeset
   277
    "[| F : stable C; F : A co (C Un A') |] ==> F : (C Un A) co (C Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   278
by (Blast_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   279
qed "stable_constrains_Un";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   280
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   281
Goalw [stable_def, constrains_def]
7345
paulson
parents: 7240
diff changeset
   282
  "[| F : stable C; F :  (C Int A) co  A' |] ==> F : (C Int A) co (C Int A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   283
by (Blast_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5253
diff changeset
   284
qed "stable_constrains_Int";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   285
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   286
(*[| F : stable C; F :  co (C Int A) A |] ==> F : stable (C Int A)*)
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   287
bind_thm ("stable_constrains_stable", stable_constrains_Int RS stableI);
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   288
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   289
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   290
(*** invariant ***)
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   291
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   292
Goal "[| Init F<=A;  F: stable A |] ==> F : invariant A";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   293
by (asm_simp_tac (simpset() addsimps [invariant_def]) 1);
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   294
qed "invariantI";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   295
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   296
(*Could also say "invariant A Int invariant B <= invariant (A Int B)"*)
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   297
Goal "[| F : invariant A;  F : invariant B |] ==> F : invariant (A Int B)";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   298
by (auto_tac (claset(), simpset() addsimps [invariant_def, stable_Int]));
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   299
qed "invariant_Int";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   300
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   301
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   302
(*** increasing ***)
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   303
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   304
Goalw [increasing_def, stable_def, constrains_def]
6712
d1bebb7f1c50 generalized increasing_size to mono_increasing_o
paulson
parents: 6536
diff changeset
   305
     "mono g ==> increasing f <= increasing (g o f)";
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   306
by Auto_tac;
6712
d1bebb7f1c50 generalized increasing_size to mono_increasing_o
paulson
parents: 6536
diff changeset
   307
by (blast_tac (claset() addIs [monoD, order_trans]) 1);
d1bebb7f1c50 generalized increasing_size to mono_increasing_o
paulson
parents: 6536
diff changeset
   308
qed "mono_increasing_o";
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   309
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   310
Goalw [increasing_def]
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   311
     "increasing f <= {F. ALL z::nat. F: stable {s. z < f s}}";
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   312
by (simp_tac (simpset() addsimps [Suc_le_eq RS sym]) 1);
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   313
by (Blast_tac 1);
5804
8e0a4c4fd67b Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents: 5669
diff changeset
   314
qed "increasing_stable_less";
5648
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   315
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   316
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   317
(** The Elimination Theorem.  The "free" m has become universally quantified!
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   318
    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
   319
    in forward proof. **)
fe887910e32e specifications as sets of programs
paulson
parents: 5608
diff changeset
   320
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   321
Goalw [constrains_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   322
    "[| ALL m:M. F : {s. s x = m} co (B m) |] \
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   323
\    ==> F : {s. s x : M} co (UN m:M. B m)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   324
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   325
qed "elimination";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   326
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   327
(*As above, but for the trivial case of a one-variable state, in which the
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   328
  state is identified with its one variable.*)
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   329
Goalw [constrains_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   330
    "(ALL m:M. F : {m} co (B m)) ==> F : M co (UN m:M. B m)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   331
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   332
qed "elimination_sing";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   333
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   334
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   335
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   336
(*** Theoretical Results from Section 6 ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   337
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   338
Goalw [constrains_def, strongest_rhs_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   339
    "F : A co (strongest_rhs F A )";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   340
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   341
qed "constrains_strongest_rhs";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   342
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   343
Goalw [constrains_def, strongest_rhs_def]
6536
281d44905cab made many specification operators infix
paulson
parents: 6535
diff changeset
   344
    "F : A co B ==> strongest_rhs F A <= B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   345
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   346
qed "strongest_rhs_is_strongest";