src/HOL/UNITY/WFair.ML
author paulson
Fri, 03 Apr 1998 12:34:33 +0200
changeset 4776 1f9362e769c1
child 5069 3ea049f7979d
permissions -rw-r--r--
New UNITY theory
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/WFair
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
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    11
open WFair;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    12
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    13
goal thy "Union(B) Int A = Union((%C. C Int A)``B)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    14
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    15
qed "Int_Union_Union";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    16
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    17
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    18
(*** transient ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    19
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    20
goalw thy [stable_def, constrains_def, transient_def]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    21
    "!!A. [| stable Acts A; transient Acts A |] ==> A = {}";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    22
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    23
qed "stable_transient_empty";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    24
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    25
goalw thy [transient_def]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    26
    "!!A. [| transient Acts A; B<=A |] ==> transient Acts B";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    27
by (Clarify_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    28
by (rtac bexI 1 THEN assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    29
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    30
qed "transient_strengthen";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    31
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    32
goalw thy [transient_def]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    33
    "!!A. [| act:Acts;  A <= Domain act;  act^^A <= Compl A |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    34
\         ==> transient Acts A";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    35
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    36
qed "transient_mem";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    37
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    38
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    39
(*** ensures ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    40
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    41
goalw thy [ensures_def]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    42
    "!!Acts. [| constrains Acts (A-B) (A Un B); transient Acts (A-B) |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    43
\            ==> ensures Acts A B";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    44
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    45
qed "ensuresI";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    46
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    47
goalw thy [ensures_def]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    48
    "!!Acts. ensures Acts A B  \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    49
\            ==> constrains Acts (A-B) (A Un B) & transient Acts (A-B)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    50
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    51
qed "ensuresD";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    52
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    53
(*The L-version (precondition strengthening) doesn't hold for ENSURES*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    54
goalw thy [ensures_def]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    55
    "!!Acts. [| ensures Acts A A'; A'<=B' |] ==> ensures Acts A B'";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    56
by (blast_tac (claset() addIs [constrains_weaken, transient_strengthen]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    57
qed "ensures_weaken_R";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    58
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    59
goalw thy [ensures_def, constrains_def, transient_def]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    60
    "!!Acts. Acts ~= {} ==> ensures Acts A UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    61
by (Asm_simp_tac 1);  (*omitting this causes PROOF FAILED, even with Safe_tac*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    62
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    63
qed "ensures_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    64
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    65
goalw thy [ensures_def]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    66
    "!!Acts. [| stable Acts C; \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    67
\               constrains Acts (C Int (A - A')) (A Un A'); \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    68
\               transient  Acts (C Int (A-A')) |]   \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    69
\           ==> ensures Acts (C Int A) (C Int A')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    70
by (asm_simp_tac (simpset() addsimps [Int_Un_distrib RS sym,
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    71
				      Diff_Int_distrib RS sym,
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    72
				      stable_constrains_Int]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    73
qed "stable_ensures_Int";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    74
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    75
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    76
(*** leadsTo ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    77
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    78
(*Synonyms for the theorems produced by the inductive defn package*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    79
bind_thm ("leadsTo_Basis", leadsto.Basis);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    80
bind_thm ("leadsTo_Trans", leadsto.Trans);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    81
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    82
goal thy "!!Acts. act: Acts ==> leadsTo Acts A UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    83
by (blast_tac (claset() addIs [ensures_UNIV RS leadsTo_Basis]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    84
qed "leadsTo_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    85
Addsimps [leadsTo_UNIV];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    86
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    87
(*Useful with cancellation, disjunction*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    88
goal thy "!!Acts. leadsTo Acts A (A' Un A') ==> leadsTo Acts A A'";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    89
by (asm_full_simp_tac (simpset() addsimps Un_ac) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    90
qed "leadsTo_Un_duplicate";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    91
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    92
goal thy "!!Acts. leadsTo Acts A (A' Un C Un C) ==> leadsTo Acts A (A' Un C)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    93
by (asm_full_simp_tac (simpset() addsimps Un_ac) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    94
qed "leadsTo_Un_duplicate2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    95
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    96
(*The Union introduction rule as we should have liked to state it*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    97
val prems = goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    98
    "(!!A. A : S ==> leadsTo Acts A B) ==> leadsTo Acts (Union S) B";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    99
by (blast_tac (claset() addIs (leadsto.Union::prems)) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   100
qed "leadsTo_Union";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   101
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   102
val prems = goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   103
    "(!!i. i : I ==> leadsTo Acts (A i) B) ==> leadsTo Acts (UN i:I. A i) B";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   104
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   105
by (blast_tac (claset() addIs (leadsto.Union::prems)) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   106
qed "leadsTo_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   107
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   108
(*Binary union introduction rule*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   109
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   110
  "!!C. [| leadsTo Acts A C; leadsTo Acts B C |] ==> leadsTo Acts (A Un B) C";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   111
by (stac Un_eq_Union 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   112
by (blast_tac (claset() addIs [leadsTo_Union]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   113
qed "leadsTo_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   114
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   115
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   116
(*The INDUCTION rule as we should have liked to state it*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   117
val major::prems = goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   118
  "[| leadsTo Acts za zb;  \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   119
\     !!A B. ensures Acts A B ==> P A B; \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   120
\     !!A B C. [| leadsTo Acts A B; P A B; leadsTo Acts B C; P B C |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   121
\              ==> P A C; \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   122
\     !!B S. ALL A:S. leadsTo Acts A B & P A B ==> P (Union S) B \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   123
\  |] ==> P za zb";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   124
br (major RS leadsto.induct) 1;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   125
by (REPEAT (blast_tac (claset() addIs prems) 1));
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   126
qed "leadsTo_induct";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   127
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   128
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   129
goal thy "!!A B. [| A<=B;  id: Acts |] ==> leadsTo Acts A B";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   130
by (rtac leadsTo_Basis 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   131
by (rewrite_goals_tac [ensures_def, constrains_def, transient_def]);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   132
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   133
qed "subset_imp_leadsTo";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   134
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   135
bind_thm ("empty_leadsTo", empty_subsetI RS subset_imp_leadsTo);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   136
Addsimps [empty_leadsTo];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   137
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   138
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   139
(*There's a direct proof by leadsTo_Trans and subset_imp_leadsTo, but it
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   140
  needs the extra premise id:Acts*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   141
goal thy "!!Acts. leadsTo Acts A A' ==> A'<=B' --> leadsTo Acts A B'";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   142
by (etac leadsTo_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   143
by (Clarify_tac 3);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   144
by (blast_tac (claset() addIs [leadsTo_Union]) 3);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   145
by (blast_tac (claset() addIs [leadsTo_Trans]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   146
by (blast_tac (claset() addIs [leadsTo_Basis, ensures_weaken_R]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   147
qed_spec_mp "leadsTo_weaken_R";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   148
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   149
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   150
goal thy "!!Acts. [| leadsTo Acts A A'; B<=A; id: Acts |] ==>  \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   151
\                 leadsTo Acts B A'";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   152
by (blast_tac (claset() addIs [leadsTo_Basis, leadsTo_Trans, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   153
			       subset_imp_leadsTo]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   154
qed_spec_mp "leadsTo_weaken_L";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   155
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   156
(*Distributes over binary unions*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   157
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   158
  "!!C. id: Acts ==> \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   159
\       leadsTo Acts (A Un B) C  =  (leadsTo Acts A C & leadsTo Acts B C)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   160
by (blast_tac (claset() addIs [leadsTo_Un, leadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   161
qed "leadsTo_Un_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   162
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   163
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   164
  "!!C. id: Acts ==> \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   165
\       leadsTo Acts (UN i:I. A i) B  =  (ALL i : I. leadsTo Acts (A i) B)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   166
by (blast_tac (claset() addIs [leadsTo_UN, leadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   167
qed "leadsTo_UN_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   168
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   169
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   170
  "!!C. id: Acts ==> \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   171
\       leadsTo Acts (Union S) B  =  (ALL A : S. leadsTo Acts A B)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   172
by (blast_tac (claset() addIs [leadsTo_Union, leadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   173
qed "leadsTo_Union_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   174
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   175
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   176
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   177
   "!!Acts. [| leadsTo Acts A A'; id: Acts; B<=A; A'<=B' |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   178
\           ==> leadsTo Acts B B'";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   179
(*PROOF FAILED: why?*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   180
by (blast_tac (claset() addIs [leadsTo_Trans, leadsTo_weaken_R,
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   181
			       leadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   182
qed "leadsTo_weaken";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   183
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   184
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   185
(*Set difference: maybe combine with leadsTo_weaken_L??*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   186
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   187
  "!!C. [| leadsTo Acts (A-B) C; leadsTo Acts B C; id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   188
\       ==> leadsTo Acts A C";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   189
by (blast_tac (claset() addIs [leadsTo_Un, leadsTo_weaken]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   190
qed "leadsTo_Diff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   191
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   192
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   193
(** Meta or object quantifier ???
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   194
    see ball_constrains_UN in UNITY.ML***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   195
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   196
val prems = goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   197
   "(!! i. i:I ==> leadsTo Acts (A i) (A' i)) \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   198
\   ==> leadsTo Acts (UN i:I. A i) (UN i:I. A' i)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   199
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   200
by (blast_tac (claset() addIs [leadsTo_Union, leadsTo_weaken_R] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   201
                        addIs prems) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   202
qed "leadsTo_UN_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   203
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   204
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   205
(*Version with no index set*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   206
val prems = goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   207
   "(!! i. leadsTo Acts (A i) (A' i)) \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   208
\   ==> leadsTo Acts (UN i. A i) (UN i. A' i)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   209
by (blast_tac (claset() addIs [leadsTo_UN_UN] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   210
                        addIs prems) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   211
qed "leadsTo_UN_UN_noindex";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   212
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   213
(*Version with no index set*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   214
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   215
   "!!Acts. ALL i. leadsTo Acts (A i) (A' i) \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   216
\           ==> leadsTo Acts (UN i. A i) (UN i. A' i)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   217
by (blast_tac (claset() addIs [leadsTo_UN_UN]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   218
qed "all_leadsTo_UN_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   219
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   220
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   221
(*Binary union version*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   222
goal thy "!!Acts. [| leadsTo Acts A A'; leadsTo Acts B B' |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   223
\                 ==> leadsTo Acts (A Un B) (A' Un B')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   224
by (blast_tac (claset() addIs [leadsTo_Un, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   225
			       leadsTo_weaken_R]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   226
qed "leadsTo_Un_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   227
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   228
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   229
(** The cancellation law **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   230
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   231
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   232
   "!!Acts. [| leadsTo Acts A (A' Un B); leadsTo Acts B B'; id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   233
\           ==> leadsTo Acts A (A' Un B')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   234
by (blast_tac (claset() addIs [leadsTo_Un_Un, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   235
			       subset_imp_leadsTo, leadsTo_Trans]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   236
qed "leadsTo_cancel2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   237
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   238
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   239
   "!!Acts. [| leadsTo Acts A (A' Un B); leadsTo Acts (B-A') B'; id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   240
\           ==> leadsTo Acts A (A' Un B')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   241
by (rtac leadsTo_cancel2 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   242
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   243
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   244
qed "leadsTo_cancel_Diff2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   245
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   246
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   247
   "!!Acts. [| leadsTo Acts A (B Un A'); leadsTo Acts B B'; id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   248
\           ==> leadsTo Acts A (B' Un A')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   249
by (asm_full_simp_tac (simpset() addsimps [Un_commute]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   250
by (blast_tac (claset() addSIs [leadsTo_cancel2]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   251
qed "leadsTo_cancel1";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   252
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   253
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   254
   "!!Acts. [| leadsTo Acts A (B Un A'); leadsTo Acts (B-A') B'; id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   255
\           ==> leadsTo Acts A (B' Un A')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   256
by (rtac leadsTo_cancel1 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   257
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   258
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   259
qed "leadsTo_cancel_Diff1";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   260
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   261
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   262
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   263
(** The impossibility law **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   264
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   265
goal thy "!!Acts. leadsTo Acts A B ==> B={} --> A={}";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   266
by (etac leadsTo_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   267
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   268
by (rewrite_goals_tac [ensures_def, constrains_def, transient_def]);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   269
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   270
val lemma = result() RS mp;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   271
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   272
goal thy "!!Acts. leadsTo Acts A {} ==> A={}";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   273
by (blast_tac (claset() addSIs [lemma]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   274
qed "leadsTo_empty";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   275
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   276
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   277
(** PSP: Progress-Safety-Progress **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   278
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   279
(*Special case of PSP: Misra's "stable conjunction".  Doesn't need id:Acts. *)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   280
goalw thy [stable_def]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   281
   "!!Acts. [| leadsTo Acts A A'; stable Acts B |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   282
\           ==> leadsTo Acts (A Int B) (A' Int B)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   283
by (etac leadsTo_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   284
by (simp_tac (simpset() addsimps [Int_Union_Union]) 3);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   285
by (blast_tac (claset() addIs [leadsTo_Union]) 3);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   286
by (blast_tac (claset() addIs [leadsTo_Trans]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   287
by (rtac leadsTo_Basis 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   288
by (asm_full_simp_tac
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   289
    (simpset() addsimps [ensures_def, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   290
			 Diff_Int_distrib2 RS sym, Int_Un_distrib2 RS sym]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   291
by (blast_tac (claset() addIs [transient_strengthen, constrains_Int]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   292
qed "PSP_stable";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   293
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   294
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   295
   "!!Acts. [| leadsTo Acts A A'; stable Acts B |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   296
\           ==> leadsTo Acts (B Int A) (B Int A')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   297
by (asm_simp_tac (simpset() addsimps (PSP_stable::Int_ac)) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   298
qed "PSP_stable2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   299
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   300
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   301
goalw thy [ensures_def]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   302
   "!!Acts. [| ensures Acts A A'; constrains Acts B B' |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   303
\           ==> ensures Acts (A Int B) ((A' Int B) Un (B' - B))";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   304
by Safe_tac;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   305
by (blast_tac (claset() addIs [constrainsI] addDs [constrainsD]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   306
by (etac transient_strengthen 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   307
by (Blast_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   308
qed "PSP_ensures";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   309
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   310
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   311
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   312
   "!!Acts. [| leadsTo Acts A A'; constrains Acts B B'; id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   313
\           ==> leadsTo Acts (A Int B) ((A' Int B) Un (B' - B))";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   314
by (etac leadsTo_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   315
by (simp_tac (simpset() addsimps [Int_Union_Union]) 3);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   316
by (blast_tac (claset() addIs [leadsTo_Union]) 3);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   317
(*Transitivity case has a delicate argument involving "cancellation"*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   318
by (rtac leadsTo_Un_duplicate2 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   319
by (etac leadsTo_cancel_Diff1 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   320
by (assume_tac 3);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   321
by (asm_full_simp_tac (simpset() addsimps [Int_Diff, Diff_triv]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   322
(*Basis case*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   323
by (blast_tac (claset() addIs [leadsTo_Basis, PSP_ensures]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   324
qed "PSP";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   325
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   326
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   327
   "!!Acts. [| leadsTo Acts A A'; constrains Acts B B'; id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   328
\           ==> leadsTo Acts (B Int A) ((B Int A') Un (B' - B))";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   329
by (asm_simp_tac (simpset() addsimps (PSP::Int_ac)) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   330
qed "PSP2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   331
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   332
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   333
goalw thy [unless_def]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   334
   "!!Acts. [| leadsTo Acts A A'; unless Acts B B'; id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   335
\           ==> leadsTo Acts (A Int B) ((A' Int B) Un B')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   336
by (dtac PSP 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   337
by (assume_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   338
by (asm_full_simp_tac (simpset() addsimps [Un_Diff_Diff, Int_Diff_Un]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   339
by (asm_full_simp_tac (simpset() addsimps [Diff_Int_distrib]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   340
by (etac leadsTo_Diff 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   341
by (blast_tac (claset() addIs [subset_imp_leadsTo]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   342
by Auto_tac;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   343
qed "PSP_unless";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   344
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   345
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   346
(*** Proving the induction rules ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   347
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   348
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   349
   "!!Acts. [| wf r;     \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   350
\              ALL m. leadsTo Acts (A Int f-``{m})                     \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   351
\                                  ((A Int f-``(r^-1 ^^ {m})) Un B);   \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   352
\              id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   353
\           ==> leadsTo Acts (A Int f-``{m}) B";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   354
by (eres_inst_tac [("a","m")] wf_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   355
by (subgoal_tac "leadsTo Acts (A Int (f -`` (r^-1 ^^ {x}))) B" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   356
by (stac vimage_eq_UN 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   357
by (asm_simp_tac (HOL_ss addsimps (UN_simps RL [sym])) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   358
by (blast_tac (claset() addIs [leadsTo_UN]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   359
by (blast_tac (claset() addIs [leadsTo_cancel1, leadsTo_Un_duplicate]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   360
val lemma = result();
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   361
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   362
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   363
(** Meta or object quantifier ????? **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   364
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   365
   "!!Acts. [| wf r;     \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   366
\              ALL m. leadsTo Acts (A Int f-``{m})                     \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   367
\                                  ((A Int f-``(r^-1 ^^ {m})) Un B);   \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   368
\              id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   369
\           ==> leadsTo Acts A B";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   370
by (res_inst_tac [("t", "A")] subst 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   371
by (rtac leadsTo_UN 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   372
by (etac lemma 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   373
by (REPEAT (assume_tac 2));
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   374
by (Fast_tac 1);    (*Blast_tac: Function unknown's argument not a parameter*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   375
qed "leadsTo_wf_induct";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   376
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   377
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   378
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   379
   "!!Acts. [| wf r;     \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   380
\              ALL m:I. leadsTo Acts (A Int f-``{m})                   \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   381
\                                  ((A Int f-``(r^-1 ^^ {m})) Un B);   \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   382
\              id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   383
\           ==> leadsTo Acts A ((A - (f-``I)) Un B)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   384
by (etac leadsTo_wf_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   385
by Safe_tac;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   386
by (case_tac "m:I" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   387
by (blast_tac (claset() addIs [leadsTo_weaken]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   388
by (blast_tac (claset() addIs [subset_imp_leadsTo]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   389
qed "bounded_induct";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   390
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   391
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   392
(*Alternative proof is via the lemma leadsTo Acts (A Int f-``(lessThan m)) B*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   393
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   394
   "!!Acts. [| ALL m. leadsTo Acts (A Int f-``{m})                     \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   395
\                                  ((A Int f-``(lessThan m)) Un B);   \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   396
\              id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   397
\           ==> leadsTo Acts A B";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   398
by (rtac (wf_less_than RS leadsTo_wf_induct) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   399
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   400
by (Asm_simp_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   401
qed "lessThan_induct";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   402
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   403
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   404
   "!!Acts. [| ALL m:(greaterThan l). leadsTo Acts (A Int f-``{m})   \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   405
\                                        ((A Int f-``(lessThan m)) Un B);   \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   406
\              id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   407
\           ==> leadsTo Acts A ((A Int (f-``(atMost l))) Un B)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   408
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
   409
by (rtac (wf_less_than RS bounded_induct) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   410
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   411
by (Asm_simp_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   412
qed "lessThan_bounded_induct";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   413
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   414
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   415
   "!!Acts. [| ALL m:(lessThan l). leadsTo Acts (A Int f-``{m})   \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   416
\                                    ((A Int f-``(greaterThan m)) Un B);   \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   417
\              id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   418
\           ==> leadsTo Acts A ((A Int (f-``(atLeast l))) Un B)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   419
by (res_inst_tac [("f","f"),("f1", "%k. l - k")]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   420
    (wf_less_than RS wf_inv_image RS leadsTo_wf_induct) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   421
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   422
by (simp_tac (simpset() addsimps [inv_image_def, Image_singleton]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   423
by (Clarify_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   424
by (case_tac "m<l" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   425
by (blast_tac (claset() addIs [not_leE, subset_imp_leadsTo]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   426
by (blast_tac (claset() addIs [leadsTo_weaken_R, diff_less_mono2]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   427
qed "greaterThan_bounded_induct";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   428
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   429
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   430
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   431
(*** wlt ****)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   432
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   433
(*Misra's property W3*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   434
goalw thy [wlt_def] "leadsTo Acts (wlt Acts B) B";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   435
by (blast_tac (claset() addSIs [leadsTo_Union]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   436
qed "wlt_leadsTo";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   437
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   438
goalw thy [wlt_def] "!!Acts. leadsTo Acts A B ==> A <= wlt Acts B";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   439
by (blast_tac (claset() addSIs [leadsTo_Union]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   440
qed "leadsTo_subset";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   441
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   442
(*Misra's property W2*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   443
goal thy "!!Acts. id: Acts ==> leadsTo Acts A B = (A <= wlt Acts B)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   444
by (blast_tac (claset() addSIs [leadsTo_subset, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   445
				wlt_leadsTo RS leadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   446
qed "leadsTo_eq_subset_wlt";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   447
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   448
(*Misra's property W4*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   449
goal thy "!!Acts. id: Acts ==> B <= wlt Acts B";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   450
by (asm_simp_tac (simpset() addsimps [leadsTo_eq_subset_wlt RS sym,
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   451
				      subset_imp_leadsTo]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   452
qed "wlt_increasing";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   453
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   454
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   455
(*Used in the Trans case below*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   456
goalw thy [constrains_def]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   457
   "!!Acts. [| B <= A2;  \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   458
\              constrains Acts (A1 - B) (A1 Un B); \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   459
\              constrains Acts (A2 - C) (A2 Un C) |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   460
\           ==> constrains Acts (A1 Un A2 - C) (A1 Un A2 Un C)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   461
by (Clarify_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   462
by (blast_tac (claset() addSDs [bspec]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   463
val lemma1 = result();
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   464
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   465
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   466
(*Lemma (1,2,3) of Misra's draft book, Chapter 4, "Progress"*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   467
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   468
   "!!Acts. [| leadsTo Acts A A';  id: Acts |] ==> \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   469
\      EX B. A<=B & leadsTo Acts B A' & constrains Acts (B-A') (B Un A')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   470
by (etac leadsTo_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   471
(*Basis*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   472
by (blast_tac (claset() addIs [leadsTo_Basis]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   473
                        addDs [ensuresD]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   474
(*Trans*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   475
by (Clarify_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   476
by (res_inst_tac [("x", "Ba Un Bb")] exI 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   477
by (blast_tac (claset() addIs [lemma1, leadsTo_Un_Un, leadsTo_cancel1,
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   478
			       leadsTo_Un_duplicate]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   479
(*Union*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   480
by (clarify_tac (claset() addSDs [ball_conj_distrib RS iffD1,
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   481
				  bchoice, ball_constrains_UN]) 1);;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   482
by (res_inst_tac [("x", "UN A:S. f A")] exI 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   483
by (blast_tac (claset() addIs [leadsTo_UN, constrains_weaken]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   484
qed "leadsTo_123";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   485
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   486
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   487
(*Misra's property W5*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   488
goal thy "!!Acts. id: Acts ==> constrains Acts (wlt Acts B - B) (wlt Acts B)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   489
by (forward_tac [wlt_leadsTo RS leadsTo_123] 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   490
by (Clarify_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   491
by (subgoal_tac "Ba = wlt Acts B" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   492
by (blast_tac (claset() addDs [leadsTo_eq_subset_wlt]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   493
by (Clarify_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   494
by (asm_full_simp_tac (simpset() addsimps [wlt_increasing, Un_absorb2]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   495
qed "wlt_constrains_wlt";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   496
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   497
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   498
(*** Completion: Binary and General Finite versions ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   499
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   500
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   501
   "!!Acts. [| leadsTo Acts A A';  stable Acts A';   \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   502
\              leadsTo Acts B B';  stable Acts B';  id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   503
\           ==> leadsTo Acts (A Int B) (A' Int B')";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   504
by (subgoal_tac "stable Acts (wlt Acts B')" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   505
by (asm_full_simp_tac (simpset() addsimps [stable_def]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   506
by (EVERY [etac (constrains_Un RS constrains_weaken) 2,
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   507
	   etac wlt_constrains_wlt 2,
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   508
	   fast_tac (claset() addEs [wlt_increasing RSN (2,rev_subsetD)]) 3,
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   509
	   Blast_tac 2]);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   510
by (subgoal_tac "leadsTo Acts (A Int wlt Acts B') (A' Int wlt Acts B')" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   511
by (blast_tac (claset() addIs [PSP_stable]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   512
by (subgoal_tac "leadsTo Acts (A' Int wlt Acts B') (A' Int B')" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   513
by (blast_tac (claset() addIs [wlt_leadsTo, PSP_stable2]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   514
by (subgoal_tac "leadsTo Acts (A Int B) (A Int wlt Acts B')" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   515
by (blast_tac (claset() addIs [leadsTo_subset RS subsetD, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   516
			       subset_imp_leadsTo]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   517
(*Blast_tac gives PROOF FAILED*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   518
by (best_tac (claset() addIs [leadsTo_Trans]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   519
qed "stable_completion";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   520
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   521
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   522
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   523
   "!!Acts. [| finite I;  id: Acts |]                     \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   524
\           ==> (ALL i:I. leadsTo Acts (A i) (A' i)) -->  \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   525
\               (ALL i:I. stable Acts (A' i)) -->         \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   526
\               leadsTo Acts (INT i:I. A i) (INT i:I. A' i)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   527
by (etac finite_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   528
by (Asm_simp_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   529
by (asm_simp_tac 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   530
    (simpset() addsimps [stable_completion, stable_def, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   531
			 ball_constrains_INT]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   532
qed_spec_mp "finite_stable_completion";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   533
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   534
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   535
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   536
   "!!Acts. [| W = wlt Acts (B' Un C);     \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   537
\              leadsTo Acts A (A' Un C);  constrains Acts A' (A' Un C);   \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   538
\              leadsTo Acts B (B' Un C);  constrains Acts B' (B' Un C);   \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   539
\              id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   540
\           ==> leadsTo Acts (A Int B) ((A' Int B') Un C)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   541
by (subgoal_tac "constrains Acts (W-C) (W Un B' Un C)" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   542
by (blast_tac (claset() addIs [[asm_rl, wlt_constrains_wlt] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   543
			       MRS constrains_Un RS constrains_weaken]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   544
by (subgoal_tac "constrains Acts (W-C) W" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   545
by (asm_full_simp_tac 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   546
    (simpset() addsimps [wlt_increasing, Un_assoc, Un_absorb2]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   547
by (subgoal_tac "leadsTo Acts (A Int W - C) (A' Int W Un C)" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   548
by (simp_tac (simpset() addsimps [Int_Diff]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   549
by (blast_tac (claset() addIs [wlt_leadsTo, PSP RS leadsTo_weaken_R]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   550
by (subgoal_tac "leadsTo Acts (A' Int W Un C) (A' Int B' Un C)" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   551
by (blast_tac (claset() addIs [wlt_leadsTo, leadsTo_Un_Un, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   552
                               PSP2 RS leadsTo_weaken_R, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   553
			       subset_refl RS subset_imp_leadsTo, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   554
			       leadsTo_Un_duplicate2]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   555
by (dtac leadsTo_Diff 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   556
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   557
by (blast_tac (claset() addIs [subset_imp_leadsTo]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   558
by (subgoal_tac "A Int B <= A Int W" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   559
by (blast_tac (claset() addIs [leadsTo_subset, Int_mono] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   560
	                delrules [subsetI]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   561
by (blast_tac (claset() addIs [leadsTo_Trans, subset_imp_leadsTo]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   562
bind_thm("completion", refl RS result());
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   563
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   564
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   565
goal thy
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   566
   "!!Acts. [| finite I;  id: Acts |] \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   567
\           ==> (ALL i:I. leadsTo Acts (A i) (A' i Un C)) -->  \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   568
\               (ALL i:I. constrains Acts (A' i) (A' i Un C)) --> \
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   569
\               leadsTo Acts (INT i:I. A i) ((INT i:I. A' i) Un C)";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   570
by (etac finite_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   571
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   572
by (Clarify_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   573
by (dtac ball_constrains_INT 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   574
by (asm_full_simp_tac (simpset() addsimps [completion]) 1); 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   575
qed "finite_completion";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   576