src/HOL/UNITY/SubstAx.ML
author paulson
Wed, 05 Aug 1998 18:20:25 +0200
changeset 5257 c03e3ba9cbcc
parent 5253 82a5ca6290aa
child 5277 e4297d03e5d2
permissions -rw-r--r--
Indentation, comments
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/SubstAx
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
Weak Fairness versions of transient, ensures, LeadsTo.
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
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    11
(*constrains Acts B B' ==> constrains Acts (reachable(Init,Acts) Int B)
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    12
                                           (reachable(Init,Acts) Int B') *)
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    13
bind_thm ("constrains_reachable",
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    14
	  rewrite_rule [stable_def] stable_reachable RS constrains_Int);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    15
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    16
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    17
(*** Introduction rules: Basis, Trans, Union ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    18
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    19
Goal "leadsTo (Acts prg) A B ==> LeadsTo prg A B";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    20
by (simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    21
by (blast_tac (claset() addIs [PSP_stable2, stable_reachable]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    22
qed "leadsTo_imp_LeadsTo";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    23
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    24
Goal "ensures (Acts prg) (reachable prg Int A) (reachable prg Int A') \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    25
\     ==> LeadsTo prg A A'";
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    26
by (full_simp_tac (simpset() addsimps [ensures_def, LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    27
by (rtac (stable_reachable RS stable_ensures_Int RS leadsTo_Basis) 1);
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    28
by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [Diff_Int_distrib])));
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    29
by (blast_tac (claset() addIs [constrains_weaken]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    30
qed "LeadsTo_Basis";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    31
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    32
Goal "[| LeadsTo prg A B;  LeadsTo prg B C |] \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    33
\      ==> LeadsTo prg A C";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    34
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    35
by (blast_tac (claset() addIs [leadsTo_Trans]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    36
qed "LeadsTo_Trans";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    37
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    38
val [prem] = goalw thy [LeadsTo_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    39
 "(!!A. A : S ==> LeadsTo prg A B) ==> LeadsTo prg (Union S) B";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    40
by (Simp_tac 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    41
by (stac Int_Union 1);
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    42
by (blast_tac (claset() addIs [leadsTo_UN,
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    43
			        simplify (simpset()) prem]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    44
qed "LeadsTo_Union";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    45
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    46
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    47
(*** Derived rules ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    48
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    49
Goal "id: (Acts prg) ==> LeadsTo prg A UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    50
by (asm_simp_tac (simpset() addsimps [LeadsTo_def, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    51
				      Int_lower1 RS subset_imp_leadsTo]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    52
qed "LeadsTo_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    53
Addsimps [LeadsTo_UNIV];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    54
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    55
(*Useful with cancellation, disjunction*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    56
Goal "LeadsTo prg A (A' Un A') ==> LeadsTo prg A A'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    57
by (asm_full_simp_tac (simpset() addsimps Un_ac) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    58
qed "LeadsTo_Un_duplicate";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    59
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    60
Goal "LeadsTo prg A (A' Un C Un C) ==> LeadsTo prg A (A' Un C)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    61
by (asm_full_simp_tac (simpset() addsimps Un_ac) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    62
qed "LeadsTo_Un_duplicate2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    63
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    64
val prems = goal thy
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    65
   "(!!i. i : I ==> LeadsTo prg (A i) B) \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    66
\   ==> LeadsTo prg (UN i:I. A i) B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    67
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    68
by (blast_tac (claset() addIs (LeadsTo_Union::prems)) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    69
qed "LeadsTo_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    70
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    71
(*Binary union introduction rule*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    72
Goal "[| LeadsTo prg A C; LeadsTo prg B C |] ==> LeadsTo prg (A Un B) C";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    73
by (stac Un_eq_Union 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    74
by (blast_tac (claset() addIs [LeadsTo_Union]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    75
qed "LeadsTo_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    76
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    77
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    78
Goal "[| reachable prg Int A <= B;  id: (Acts prg) |] \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    79
\     ==> LeadsTo prg A B";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    80
by (simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    81
by (blast_tac (claset() addIs [subset_imp_leadsTo]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    82
qed "Int_subset_imp_LeadsTo";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    83
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    84
Goal "[| A <= B;  id: (Acts prg) |] ==> LeadsTo prg A B";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    85
by (simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    86
by (blast_tac (claset() addIs [subset_imp_leadsTo]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    87
qed "subset_imp_LeadsTo";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    88
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    89
bind_thm ("empty_LeadsTo", empty_subsetI RS subset_imp_LeadsTo);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    90
Addsimps [empty_LeadsTo];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    91
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    92
Goal "[| reachable prg Int A = {};  id: (Acts prg) |] \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    93
\     ==> LeadsTo prg A B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    94
by (asm_simp_tac (simpset() addsimps [Int_subset_imp_LeadsTo]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    95
qed "Int_empty_LeadsTo";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    96
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    97
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    98
Goal "[| LeadsTo prg A A';   \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    99
\        reachable prg Int A' <= B' |] \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   100
\     ==> LeadsTo prg A B'";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   101
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   102
by (blast_tac (claset() addIs [leadsTo_weaken_R]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   103
qed_spec_mp "LeadsTo_weaken_R";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   104
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   105
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   106
Goal "[| LeadsTo prg A A'; \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   107
\        reachable prg Int B <= A; id: (Acts prg) |]  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   108
\     ==> LeadsTo prg B A'";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   109
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   110
by (blast_tac (claset() addIs [leadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   111
qed_spec_mp "LeadsTo_weaken_L";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   112
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   113
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   114
(*Distributes over binary unions*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   115
Goal "id: (Acts prg) ==> \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   116
\       LeadsTo prg (A Un B) C  =  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   117
\       (LeadsTo prg A C & LeadsTo prg B C)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   118
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   119
qed "LeadsTo_Un_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   120
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   121
Goal "id: (Acts prg) ==> \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   122
\       LeadsTo prg (UN i:I. A i) B  =  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   123
\       (ALL i : I. LeadsTo prg (A i) B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   124
by (blast_tac (claset() addIs [LeadsTo_UN, LeadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   125
qed "LeadsTo_UN_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   126
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   127
Goal "id: (Acts prg) ==> \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   128
\       LeadsTo prg (Union S) B  =  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   129
\       (ALL A : S. LeadsTo prg A B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   130
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   131
qed "LeadsTo_Union_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   132
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   133
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   134
Goal "[| LeadsTo prg A A'; id: (Acts prg);   \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   135
\        reachable prg Int B  <= A;     \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   136
\        reachable prg Int A' <= B' |] \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   137
\     ==> LeadsTo prg B B'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   138
(*PROOF FAILED: why?*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   139
by (blast_tac (claset() addIs [LeadsTo_Trans, LeadsTo_weaken_R,
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   140
			       LeadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   141
qed "LeadsTo_weaken";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   142
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   143
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   144
(*Set difference: maybe combine with leadsTo_weaken_L??
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   145
  This is the most useful form of the "disjunction" rule*)
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   146
Goal "[| LeadsTo prg (A-B) C; LeadsTo prg B C; id: (Acts prg) |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   147
\     ==> LeadsTo prg A C";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   148
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   149
qed "LeadsTo_Diff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   150
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   151
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   152
(** Meta or object quantifier ???????????????????
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   153
    see ball_constrains_UN in UNITY.ML***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   154
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   155
val prems = goal thy
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   156
   "(!! i. i:I ==> LeadsTo prg (A i) (A' i)) \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   157
\   ==> LeadsTo prg (UN i:I. A i) (UN i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   158
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   159
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_R] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   160
                        addIs prems) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   161
qed "LeadsTo_UN_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   162
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   163
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   164
(*Version with no index set*)
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   165
val prems = 
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   166
Goal "(!! i. LeadsTo prg (A i) (A' i)) \
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   167
\     ==> LeadsTo prg (UN i. A i) (UN i. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   168
by (blast_tac (claset() addIs [LeadsTo_UN_UN] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   169
                        addIs prems) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   170
qed "LeadsTo_UN_UN_noindex";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   171
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   172
(*Version with no index set*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   173
Goal "ALL i. LeadsTo prg (A i) (A' i) \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   174
\     ==> LeadsTo prg (UN i. A i) (UN i. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   175
by (blast_tac (claset() addIs [LeadsTo_UN_UN]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   176
qed "all_LeadsTo_UN_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   177
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   178
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   179
(*Binary union version*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   180
Goal "[| LeadsTo prg A A'; LeadsTo prg B B' |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   181
\           ==> LeadsTo prg (A Un B) (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   182
by (blast_tac (claset() addIs [LeadsTo_Un, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   183
			       LeadsTo_weaken_R]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   184
qed "LeadsTo_Un_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   185
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   186
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   187
(** The cancellation law **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   188
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   189
Goal "[| LeadsTo prg A (A' Un B); LeadsTo prg B B'; \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   190
\        id: (Acts prg) |]    \
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   191
\     ==> LeadsTo prg A (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   192
by (blast_tac (claset() addIs [LeadsTo_Un_Un, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   193
			       subset_imp_LeadsTo, LeadsTo_Trans]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   194
qed "LeadsTo_cancel2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   195
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   196
Goal "[| LeadsTo prg A (A' Un B); LeadsTo prg (B-A') B'; id: (Acts prg) |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   197
\     ==> LeadsTo prg A (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   198
by (rtac LeadsTo_cancel2 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   199
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   200
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   201
qed "LeadsTo_cancel_Diff2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   202
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   203
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg B B'; id: (Acts prg) |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   204
\     ==> LeadsTo prg A (B' Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   205
by (asm_full_simp_tac (simpset() addsimps [Un_commute]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   206
by (blast_tac (claset() addSIs [LeadsTo_cancel2]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   207
qed "LeadsTo_cancel1";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   208
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   209
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg (B-A') B'; id: (Acts prg) |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   210
\     ==> LeadsTo prg A (B' Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   211
by (rtac LeadsTo_cancel1 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   212
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   213
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   214
qed "LeadsTo_cancel_Diff1";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   215
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   216
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   217
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   218
(** The impossibility law **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   219
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   220
Goal "LeadsTo prg A {} ==> reachable prg Int A  = {}";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   221
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   222
by (etac leadsTo_empty 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   223
qed "LeadsTo_empty";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   224
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   225
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   226
(** PSP: Progress-Safety-Progress **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   227
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   228
(*Special case of PSP: Misra's "stable conjunction".  Doesn't need id:Acts. *)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   229
Goal "[| LeadsTo prg A A'; stable (Acts prg) B |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   230
\     ==> LeadsTo prg (A Int B) (A' Int B)";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   231
by (asm_full_simp_tac (simpset() addsimps [LeadsTo_def, Int_assoc RS sym, 
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   232
					   PSP_stable]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   233
qed "R_PSP_stable";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   234
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   235
Goal "[| LeadsTo prg A A'; stable (Acts prg) B |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   236
\       ==> LeadsTo prg (B Int A) (B Int A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   237
by (asm_simp_tac (simpset() addsimps (R_PSP_stable::Int_ac)) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   238
qed "R_PSP_stable2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   239
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   240
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   241
Goal "[| LeadsTo prg A A'; constrains (Acts prg) B B'; id: (Acts prg) |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   242
\     ==> LeadsTo prg (A Int B) ((A' Int B) Un (B' - B))";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   243
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   244
by (dtac PSP 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   245
by (etac constrains_reachable 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   246
by (etac leadsTo_weaken 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   247
by (ALLGOALS Blast_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   248
qed "R_PSP";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   249
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   250
Goal "[| LeadsTo prg A A'; constrains (Acts prg) B B'; id: (Acts prg) |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   251
\     ==> LeadsTo prg (B Int A) ((B Int A') Un (B' - B))";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   252
by (asm_simp_tac (simpset() addsimps (R_PSP::Int_ac)) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   253
qed "R_PSP2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   254
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   255
Goalw [unless_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   256
   "[| LeadsTo prg A A'; unless (Acts prg) B B'; id: (Acts prg) |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   257
\     ==> LeadsTo prg (A Int B) ((A' Int B) Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   258
by (dtac R_PSP 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   259
by (assume_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   260
by (asm_full_simp_tac (simpset() addsimps [Un_Diff_Diff, Int_Diff_Un]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   261
by (asm_full_simp_tac (simpset() addsimps [Diff_Int_distrib]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   262
by (etac LeadsTo_Diff 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   263
by (blast_tac (claset() addIs [subset_imp_LeadsTo]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   264
by Auto_tac;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   265
qed "R_PSP_unless";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   266
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   267
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   268
(*** Induction rules ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   269
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   270
(** Meta or object quantifier ????? **)
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   271
Goal "[| wf r;     \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   272
\        ALL m. LeadsTo prg (A Int f-``{m})                     \
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   273
\                                 ((A Int f-``(r^-1 ^^ {m})) Un B);   \
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   274
\        id: (Acts prg) |] \
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   275
\     ==> LeadsTo prg A B";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   276
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   277
by (etac leadsTo_wf_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   278
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   279
by (blast_tac (claset() addIs [leadsTo_weaken]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   280
qed "LeadsTo_wf_induct";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   281
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   282
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   283
Goal "[| wf r;     \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   284
\        ALL m:I. LeadsTo prg (A Int f-``{m})                   \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   285
\                             ((A Int f-``(r^-1 ^^ {m})) Un B);   \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   286
\        id: (Acts prg) |] \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   287
\     ==> LeadsTo prg A ((A - (f-``I)) Un B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   288
by (etac LeadsTo_wf_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   289
by Safe_tac;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   290
by (case_tac "m:I" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   291
by (blast_tac (claset() addIs [LeadsTo_weaken]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   292
by (blast_tac (claset() addIs [subset_imp_LeadsTo]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   293
qed "R_bounded_induct";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   294
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   295
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   296
Goal "[| ALL m. LeadsTo prg (A Int f-``{m})                     \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   297
\                           ((A Int f-``(lessThan m)) Un B);   \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   298
\        id: (Acts prg) |] \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   299
\     ==> LeadsTo prg A B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   300
by (rtac (wf_less_than RS LeadsTo_wf_induct) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   301
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   302
by (Asm_simp_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   303
qed "R_lessThan_induct";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   304
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   305
Goal "[| ALL m:(greaterThan l). LeadsTo prg (A Int f-``{m})   \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   306
\                                        ((A Int f-``(lessThan m)) Un B);   \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   307
\              id: (Acts prg) |] \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   308
\           ==> LeadsTo prg A ((A Int (f-``(atMost l))) Un B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   309
by (simp_tac (HOL_ss addsimps [Diff_eq RS sym, vimage_Compl, Compl_greaterThan RS sym]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   310
by (rtac (wf_less_than RS R_bounded_induct) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   311
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   312
by (Asm_simp_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   313
qed "R_lessThan_bounded_induct";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   314
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   315
Goal "[| ALL m:(lessThan l). LeadsTo prg (A Int f-``{m})   \
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   316
\                              ((A Int f-``(greaterThan m)) Un B);   \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   317
\        id: (Acts prg) |] \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   318
\     ==> LeadsTo prg A ((A Int (f-``(atLeast l))) Un B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   319
by (res_inst_tac [("f","f"),("f1", "%k. l - k")]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   320
    (wf_less_than RS wf_inv_image RS LeadsTo_wf_induct) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   321
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   322
by (simp_tac (simpset() addsimps [inv_image_def, Image_singleton]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   323
by (Clarify_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   324
by (case_tac "m<l" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   325
by (blast_tac (claset() addIs [not_leE, subset_imp_LeadsTo]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   326
by (blast_tac (claset() addIs [LeadsTo_weaken_R, diff_less_mono2]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   327
qed "R_greaterThan_bounded_induct";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   328
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   329
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   330
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   331
(*** Completion: Binary and General Finite versions ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   332
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   333
Goal "[| LeadsTo prg A A';  stable (Acts prg) A';   \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   334
\        LeadsTo prg B B';  stable (Acts prg) B';  id: (Acts prg) |] \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   335
\     ==> LeadsTo prg (A Int B) (A' Int B')";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   336
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   337
by (blast_tac (claset() addIs [stable_completion RS leadsTo_weaken] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   338
                        addSIs [stable_Int, stable_reachable]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   339
qed "R_stable_completion";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   340
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   341
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   342
Goal "[| finite I;  id: (Acts prg) |]                     \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   343
\     ==> (ALL i:I. LeadsTo prg (A i) (A' i)) -->  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   344
\         (ALL i:I. stable (Acts prg) (A' i)) -->         \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   345
\         LeadsTo prg (INT i:I. A i) (INT i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   346
by (etac finite_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   347
by (Asm_simp_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   348
by (asm_simp_tac 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   349
    (simpset() addsimps [R_stable_completion, stable_def, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   350
			 ball_constrains_INT]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   351
qed_spec_mp "R_finite_stable_completion";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   352
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   353
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   354
Goal "[| LeadsTo prg A (A' Un C);  constrains (Acts prg) A' (A' Un C); \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   355
\        LeadsTo prg B (B' Un C);  constrains (Acts prg) B' (B' Un C); \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   356
\        id: (Acts prg) |] \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   357
\     ==> LeadsTo prg (A Int B) ((A' Int B') Un C)";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   358
by (full_simp_tac (simpset() addsimps [LeadsTo_def, Int_Un_distrib]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   359
by (dtac completion 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   360
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   361
by (ALLGOALS 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   362
    (asm_simp_tac 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   363
     (simpset() addsimps [constrains_reachable, Int_Un_distrib RS sym])));
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   364
by (blast_tac (claset() addIs [leadsTo_weaken]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   365
qed "R_completion";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   366
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   367
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   368
Goal "[| finite I;  id: (Acts prg) |] \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   369
\     ==> (ALL i:I. LeadsTo prg (A i) (A' i Un C)) -->  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   370
\         (ALL i:I. constrains (Acts prg) (A' i) (A' i Un C)) --> \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   371
\         LeadsTo prg (INT i:I. A i) ((INT i:I. A' i) Un C)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   372
by (etac finite_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   373
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   374
by (Clarify_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   375
by (dtac ball_constrains_INT 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   376
by (asm_full_simp_tac (simpset() addsimps [R_completion]) 1); 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   377
qed "R_finite_completion";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   378
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   379
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   380
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   381
(*** Specialized laws for handling invariants ***)
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   382
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   383
Goalw [transient_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   384
    "[| reachable prg <= INV;  transient (Acts prg) (INV Int A) |]  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   385
\    ==> transient (Acts prg) (reachable prg Int A)";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   386
by (Clarify_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   387
by (rtac bexI 1); 
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   388
by (assume_tac 2);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   389
by (Blast_tac 1);
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   390
qed "reachable_transient";
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   391
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   392
(*Uses the premise "invariant prg".  Raw theorem-proving on this
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   393
  inclusion is slow: the term contains a copy of the program.*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   394
Goal "[| invariant prg INV;      \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   395
\        constrains (Acts prg) (INV Int (A-A')) (A Un A'); \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   396
\        transient  (Acts prg) (INV Int (A-A')) |]   \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   397
\ ==> ensures (Acts prg) (reachable prg Int A) (reachable prg Int A')";
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   398
bd invariant_includes_reachable 1;
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   399
by (rtac ensuresI 1);
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   400
by (ALLGOALS 
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   401
    (full_simp_tac (simpset() addsimps [Int_Un_distrib RS sym, 
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   402
					Diff_Int_distrib RS sym])));
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   403
by (blast_tac (claset() addSIs [reachable_transient]) 2);
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   404
br (stable_reachable RS stable_constrains_Int) 1;
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   405
by (blast_tac (claset() addIs [constrains_weaken]) 1);
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   406
qed "invariant_ensuresI";
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   407
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   408
bind_thm ("invariant_LeadsTo_Basis", invariant_ensuresI RS LeadsTo_Basis);
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   409
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   410
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   411
Goal "[| invariant prg INV;      \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   412
\        LeadsTo prg A A'; id: (Acts prg);   \
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   413
\        INV Int B  <= A;  INV Int A' <= B' |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   414
\     ==> LeadsTo prg B B'";
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   415
by (blast_tac (claset() addDs [invariant_includes_reachable]
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   416
			addIs [LeadsTo_weaken]) 1);
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   417
qed "invariant_LeadsTo_weaken";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   418
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   419
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   420
(** Constrains/Ensures tactics 
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   421
    main_def defines the main program as a set;
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   422
    cmd_defs defines the separate commands
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   423
**)
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   424
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   425
(*proves "constrains" properties when the program is specified*)
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   426
fun constrains_tac (main_def::cmd_defs) = 
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   427
   SELECT_GOAL
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   428
      (EVERY [TRY (rtac stableI 1),
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   429
	      rtac constrainsI 1,
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   430
	      full_simp_tac (simpset() addsimps [main_def]) 1,
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   431
	      REPEAT_FIRST (eresolve_tac [disjE]),
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   432
	      rewrite_goals_tac cmd_defs,
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   433
	      ALLGOALS (SELECT_GOAL Auto_tac)]);
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   434
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   435
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   436
(*proves "ensures" properties when the program is specified*)
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   437
fun ensures_tac (main_def::cmd_defs) sact = 
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   438
    SELECT_GOAL
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   439
      (EVERY [REPEAT (invariant_Int_tac 1),
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   440
	      etac invariant_LeadsTo_Basis 1 
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   441
	          ORELSE   (*subgoal may involve LeadsTo, leadsTo or ensures*)
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   442
		  REPEAT (ares_tac [leadsTo_imp_LeadsTo, leadsTo_Basis, 
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   443
				    ensuresI] 1),
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   444
	      res_inst_tac [("act", sact)] transient_mem 2,
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   445
	      simp_tac (simpset() addsimps (Domain_partial_func::cmd_defs)) 3,
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   446
	      simp_tac (simpset() addsimps [main_def]) 2,
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   447
	      constrains_tac (main_def::cmd_defs) 1,
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   448
	      rewrite_goals_tac cmd_defs,
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   449
	      ALLGOALS Clarify_tac,
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   450
	      Auto_tac]);
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   451
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   452