src/HOL/UNITY/SubstAx.ML
author paulson
Thu, 03 Sep 1998 16:40:02 +0200
changeset 5426 566f47250bd0
parent 5422 578dc167453f
child 5479 5a5dfb0f0d7d
permissions -rw-r--r--
A new approach, using simp_of_act and simp_of_set to activate definitions when necessary
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
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
     6
LeadsTo relation, restricted to the set of reachable states.
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     7
*)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
     8
5340
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
     9
(*Map its type, ['a program, 'a set, 'a set] => bool, to just 'a*)
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
    10
Blast.overloaded ("SubstAx.LeadsTo", 
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
    11
		  HOLogic.dest_setT o domain_type o range_type);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    12
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    13
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    14
(*** Specialized laws for handling invariants ***)
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    15
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
    16
Goal "[| Invariant prg INV;  LeadsTo prg (INV Int A) A' |]   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    17
\     ==> LeadsTo prg A A'";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    18
by (asm_full_simp_tac
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    19
    (simpset() addsimps [LeadsTo_def, reachable_Int_INV,
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    20
			 Int_assoc RS sym]) 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
    21
qed "Invariant_LeadsToI";
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    22
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
    23
Goal "[| Invariant prg INV;  LeadsTo prg A A' |]   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    24
\     ==> LeadsTo prg A (INV Int A')";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    25
by (asm_full_simp_tac
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    26
    (simpset() addsimps [LeadsTo_def, reachable_Int_INV,
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    27
			 Int_assoc RS sym]) 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
    28
qed "Invariant_LeadsToD";
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    29
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    30
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    31
(*** Introduction rules: Basis, Trans, Union ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    32
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    33
Goal "leadsTo (Acts prg) A B ==> LeadsTo prg A B";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    34
by (simp_tac (simpset() addsimps [LeadsTo_def]) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    35
by (blast_tac (claset() addIs [psp_stable2, stable_reachable]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    36
qed "leadsTo_imp_LeadsTo";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    37
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    38
Goal "[| LeadsTo prg A B;  LeadsTo prg B C |] ==> LeadsTo prg A C";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    39
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    40
by (blast_tac (claset() addIs [leadsTo_Trans]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    41
qed "LeadsTo_Trans";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    42
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    43
val [prem] = Goalw [LeadsTo_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    44
 "(!!A. A : S ==> LeadsTo prg A B) ==> LeadsTo prg (Union S) B";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    45
by (Simp_tac 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    46
by (stac Int_Union 1);
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    47
by (blast_tac (claset() addIs [leadsTo_UN,
5340
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
    48
			       simplify (simpset()) prem]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    49
qed "LeadsTo_Union";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    50
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    51
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    52
(*** Derived rules ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    53
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    54
Goal "id: Acts prg ==> LeadsTo prg A UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    55
by (asm_simp_tac (simpset() addsimps [LeadsTo_def, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    56
				      Int_lower1 RS subset_imp_leadsTo]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    57
qed "LeadsTo_UNIV";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    58
Addsimps [LeadsTo_UNIV];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    59
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    60
(*Useful with cancellation, disjunction*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    61
Goal "LeadsTo prg A (A' Un A') ==> LeadsTo prg A A'";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    62
by (asm_full_simp_tac (simpset() addsimps Un_ac) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    63
qed "LeadsTo_Un_duplicate";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    64
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    65
Goal "LeadsTo prg A (A' Un C Un C) ==> LeadsTo prg A (A' Un C)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    66
by (asm_full_simp_tac (simpset() addsimps Un_ac) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    67
qed "LeadsTo_Un_duplicate2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    68
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    69
val prems = 
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    70
Goal "(!!i. i : I ==> LeadsTo prg (A i) B) ==> LeadsTo prg (UN i:I. A i) B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    71
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    72
by (blast_tac (claset() addIs (LeadsTo_Union::prems)) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    73
qed "LeadsTo_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    74
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    75
(*Binary union introduction rule*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    76
Goal "[| LeadsTo prg A C; LeadsTo prg B C |] ==> LeadsTo prg (A Un B) C";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    77
by (stac Un_eq_Union 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    78
by (blast_tac (claset() addIs [LeadsTo_Union]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    79
qed "LeadsTo_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    80
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    81
Goal "[| A <= B;  id: Acts prg |] ==> LeadsTo prg A B";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    82
by (simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    83
by (blast_tac (claset() addIs [subset_imp_leadsTo]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    84
qed "subset_imp_LeadsTo";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    85
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    86
bind_thm ("empty_LeadsTo", empty_subsetI RS subset_imp_LeadsTo);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    87
Addsimps [empty_LeadsTo];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    88
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    89
Goal "[| LeadsTo prg A A';  A' <= B' |] ==> LeadsTo prg A B'";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    90
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    91
by (blast_tac (claset() addIs [leadsTo_weaken_R]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    92
qed_spec_mp "LeadsTo_weaken_R";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    93
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    94
Goal "[| LeadsTo prg A A';  B <= A; id: Acts prg |]  \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    95
\     ==> LeadsTo prg B A'";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    96
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    97
by (blast_tac (claset() addIs [leadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    98
qed_spec_mp "LeadsTo_weaken_L";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    99
5340
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   100
Goal "[| LeadsTo prg A A'; id: Acts prg;   \
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   101
\        B  <= A;   A' <= B' |] \
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   102
\     ==> LeadsTo prg B B'";
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   103
(*PROOF FAILED unless the Trans rule is last*)
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   104
by (blast_tac (claset() addIs [LeadsTo_weaken_R, LeadsTo_weaken_L,
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   105
			       LeadsTo_Trans]) 1);
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   106
qed "LeadsTo_weaken";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   107
5340
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   108
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   109
(** Two theorems for "proof lattices" **)
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   110
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   111
Goal "[| id: Acts prg; LeadsTo prg A B |] ==> LeadsTo prg (A Un B) B";
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   112
by (blast_tac (claset() addIs [LeadsTo_Un, subset_imp_LeadsTo]) 1);
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   113
qed "LeadsTo_Un_post";
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   114
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   115
Goal "[| id: Acts prg;  LeadsTo prg A B;  LeadsTo prg B C |] \
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   116
\     ==> LeadsTo prg (A Un B) C";
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   117
by (blast_tac (claset() addIs [LeadsTo_Un, subset_imp_LeadsTo, 
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   118
			       LeadsTo_weaken_L, LeadsTo_Trans]) 1);
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   119
qed "LeadsTo_Trans_Un";
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   120
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   121
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   122
(** Distributive laws **)
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   123
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   124
Goal "id: Acts prg ==> \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   125
\       LeadsTo prg (A Un B) C  =  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   126
\       (LeadsTo prg A C & LeadsTo prg B C)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   127
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   128
qed "LeadsTo_Un_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   129
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   130
Goal "id: Acts prg ==> \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   131
\       LeadsTo prg (UN i:I. A i) B  =  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   132
\       (ALL i : I. LeadsTo prg (A i) B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   133
by (blast_tac (claset() addIs [LeadsTo_UN, LeadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   134
qed "LeadsTo_UN_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   135
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   136
Goal "id: Acts prg ==> \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   137
\       LeadsTo prg (Union S) B  =  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   138
\       (ALL A : S. LeadsTo prg A B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   139
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   140
qed "LeadsTo_Union_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   141
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   142
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   143
(** More rules using the premise "Invariant prg" **)
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   144
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   145
Goalw [LeadsTo_def, Constrains_def]
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   146
     "[| Constrains prg (A-A') (A Un A'); transient  (Acts prg) (A-A') |]   \
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   147
\     ==> LeadsTo prg A A'";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   148
by (rtac (ensuresI RS leadsTo_Basis) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   149
by (blast_tac (claset() addIs [transient_strengthen]) 2);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   150
by (blast_tac (claset() addIs [constrains_weaken]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   151
qed "LeadsTo_Basis";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   152
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   153
Goal "[| Invariant prg INV;      \
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   154
\        Constrains prg (INV Int (A-A')) (A Un A'); \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   155
\        transient  (Acts prg) (INV Int (A-A')) |]   \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   156
\ ==> LeadsTo prg A A'";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   157
by (rtac Invariant_LeadsToI 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   158
by (assume_tac 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   159
by (rtac LeadsTo_Basis 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   160
by (blast_tac (claset() addIs [transient_strengthen]) 2);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   161
by (blast_tac (claset() addIs [Invariant_ConstrainsD RS Constrains_weaken]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   162
qed "Invariant_LeadsTo_Basis";
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   163
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   164
Goal "[| Invariant prg INV;      \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   165
\        LeadsTo prg A A'; id: Acts prg;   \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   166
\        INV Int B  <= A;  INV Int A' <= B' |] \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   167
\     ==> LeadsTo prg B B'";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   168
by (rtac Invariant_LeadsToI 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   169
by (assume_tac 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   170
by (dtac Invariant_LeadsToD 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   171
by (assume_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   172
by (blast_tac (claset()addIs [LeadsTo_weaken]) 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   173
qed "Invariant_LeadsTo_weaken";
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   174
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   175
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   176
(*Set difference: maybe combine with leadsTo_weaken_L??
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   177
  This is the most useful form of the "disjunction" rule*)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   178
Goal "[| LeadsTo prg (A-B) C; LeadsTo prg (A Int B) C; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   179
\     ==> LeadsTo prg A C";
5340
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   180
by (stac (Un_Diff_Int RS sym) 1 THEN rtac LeadsTo_Un 1);
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   181
by (REPEAT (assume_tac 1));
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   182
(*One step, but PROOF FAILED...
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   183
  by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken]) 1);
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   184
*)
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   185
qed "LeadsTo_Diff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   186
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   187
5340
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   188
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   189
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   190
val prems = 
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   191
Goal "(!! i. i:I ==> LeadsTo prg (A i) (A' i)) \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   192
\     ==> LeadsTo prg (UN i:I. A i) (UN i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   193
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   194
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_R] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   195
                        addIs prems) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   196
qed "LeadsTo_UN_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   197
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   198
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   199
(*Version with no index set*)
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   200
val prems = 
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   201
Goal "(!! i. LeadsTo prg (A i) (A' i)) \
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   202
\     ==> LeadsTo prg (UN i. A i) (UN i. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   203
by (blast_tac (claset() addIs [LeadsTo_UN_UN] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   204
                        addIs prems) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   205
qed "LeadsTo_UN_UN_noindex";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   206
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   207
(*Version with no index set*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   208
Goal "ALL i. LeadsTo prg (A i) (A' i) \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   209
\     ==> LeadsTo prg (UN i. A i) (UN i. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   210
by (blast_tac (claset() addIs [LeadsTo_UN_UN]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   211
qed "all_LeadsTo_UN_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   212
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   213
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   214
(*Binary union version*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   215
Goal "[| LeadsTo prg A A'; LeadsTo prg B B' |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   216
\           ==> LeadsTo prg (A Un B) (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   217
by (blast_tac (claset() addIs [LeadsTo_Un, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   218
			       LeadsTo_weaken_R]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   219
qed "LeadsTo_Un_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   220
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   221
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   222
(** The cancellation law **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   223
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   224
Goal "[| LeadsTo prg A (A' Un B); LeadsTo prg B B'; \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   225
\        id: Acts prg |]    \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   226
\     ==> LeadsTo prg A (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   227
by (blast_tac (claset() addIs [LeadsTo_Un_Un, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   228
			       subset_imp_LeadsTo, LeadsTo_Trans]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   229
qed "LeadsTo_cancel2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   230
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   231
Goal "[| LeadsTo prg A (A' Un B); LeadsTo prg (B-A') B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   232
\     ==> LeadsTo prg A (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   233
by (rtac LeadsTo_cancel2 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   234
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   235
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   236
qed "LeadsTo_cancel_Diff2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   237
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   238
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg B B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   239
\     ==> LeadsTo prg A (B' Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   240
by (asm_full_simp_tac (simpset() addsimps [Un_commute]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   241
by (blast_tac (claset() addSIs [LeadsTo_cancel2]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   242
qed "LeadsTo_cancel1";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   243
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   244
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg (B-A') B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   245
\     ==> LeadsTo prg A (B' Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   246
by (rtac LeadsTo_cancel1 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   247
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   248
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   249
qed "LeadsTo_cancel_Diff1";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   250
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   251
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   252
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   253
(** The impossibility law **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   254
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   255
(*The set "A" may be non-empty, but it contains no reachable states*)
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   256
Goal "LeadsTo prg A {} ==> reachable prg Int A = {}";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   257
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   258
by (etac leadsTo_empty 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   259
qed "LeadsTo_empty";
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
(** PSP: Progress-Safety-Progress **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   263
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   264
(*Special case of PSP: Misra's "stable conjunction".  Doesn't need id:Acts. *)
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   265
Goal
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   266
  "[| LeadsTo prg A A';  Stable prg B |] ==> LeadsTo prg (A Int B) (A' Int B)";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   267
by (full_simp_tac (simpset() addsimps [LeadsTo_def, Stable_eq_stable]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   268
by (dtac psp_stable 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   269
by (assume_tac 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   270
by (asm_full_simp_tac (simpset() addsimps Int_ac) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   271
qed "PSP_stable";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   272
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   273
Goal "[| LeadsTo prg A A'; Stable prg B |] \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   274
\     ==> LeadsTo prg (B Int A) (B Int A')";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   275
by (asm_simp_tac (simpset() addsimps (PSP_stable::Int_ac)) 1);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   276
qed "PSP_stable2";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   277
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   278
Goalw [LeadsTo_def, Constrains_def]
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   279
     "[| LeadsTo prg A A'; Constrains prg B B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   280
\     ==> LeadsTo prg (A Int B) ((A' Int B) Un (B' - B))";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   281
by (blast_tac (claset() addDs [psp] addIs [leadsTo_weaken]) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   282
qed "PSP";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   283
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   284
Goal "[| LeadsTo prg A A'; Constrains prg B B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   285
\     ==> LeadsTo prg (B Int A) ((B Int A') Un (B' - B))";
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   286
by (asm_simp_tac (simpset() addsimps (PSP::Int_ac)) 1);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   287
qed "PSP2";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   288
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   289
Goalw [Unless_def]
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   290
     "[| LeadsTo prg A A'; Unless prg B B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   291
\     ==> LeadsTo prg (A Int B) ((A' Int B) Un B')";
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   292
by (dtac PSP 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   293
by (assume_tac 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   294
by (blast_tac (claset() addIs [LeadsTo_Diff, LeadsTo_weaken, 
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   295
			       subset_imp_LeadsTo]) 2);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   296
by (assume_tac 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   297
qed "PSP_Unless";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   298
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   299
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   300
(*** Induction rules ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   301
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   302
(** Meta or object quantifier ????? **)
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   303
Goal "[| wf r;     \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   304
\        ALL m. LeadsTo prg (A Int f-``{m})                     \
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   305
\                           ((A Int f-``(r^-1 ^^ {m})) Un B);   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   306
\        id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   307
\     ==> LeadsTo prg A B";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   308
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   309
by (etac leadsTo_wf_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   310
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   311
by (blast_tac (claset() addIs [leadsTo_weaken]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   312
qed "LeadsTo_wf_induct";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   313
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   314
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   315
Goal "[| wf r;     \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   316
\        ALL m:I. LeadsTo prg (A Int f-``{m})                   \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   317
\                             ((A Int f-``(r^-1 ^^ {m})) Un B);   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   318
\        id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   319
\     ==> LeadsTo prg A ((A - (f-``I)) Un B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   320
by (etac LeadsTo_wf_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   321
by Safe_tac;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   322
by (case_tac "m:I" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   323
by (blast_tac (claset() addIs [LeadsTo_weaken]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   324
by (blast_tac (claset() addIs [subset_imp_LeadsTo]) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   325
qed "Bounded_induct";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   326
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   327
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   328
Goal "[| ALL m. LeadsTo prg (A Int f-``{m})                     \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   329
\                           ((A Int f-``(lessThan m)) Un B);   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   330
\        id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   331
\     ==> LeadsTo prg A B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   332
by (rtac (wf_less_than RS LeadsTo_wf_induct) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   333
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   334
by (Asm_simp_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   335
qed "LessThan_induct";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   336
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   337
Goal "[| ALL m:(greaterThan l). LeadsTo prg (A Int f-``{m})   \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   338
\                                        ((A Int f-``(lessThan m)) Un B);   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   339
\              id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   340
\           ==> LeadsTo prg A ((A Int (f-``(atMost l))) Un B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   341
by (simp_tac (HOL_ss addsimps [Diff_eq RS sym, vimage_Compl, Compl_greaterThan RS sym]) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   342
by (rtac (wf_less_than RS Bounded_induct) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   343
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   344
by (Asm_simp_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   345
qed "LessThan_bounded_induct";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   346
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   347
Goal "[| ALL m:(lessThan l). LeadsTo prg (A Int f-``{m})   \
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   348
\                              ((A Int f-``(greaterThan m)) Un B);   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   349
\        id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   350
\     ==> LeadsTo prg A ((A Int (f-``(atLeast l))) Un B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   351
by (res_inst_tac [("f","f"),("f1", "%k. l - k")]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   352
    (wf_less_than RS wf_inv_image RS LeadsTo_wf_induct) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   353
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   354
by (simp_tac (simpset() addsimps [inv_image_def, Image_singleton]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   355
by (Clarify_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   356
by (case_tac "m<l" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   357
by (blast_tac (claset() addIs [not_leE, subset_imp_LeadsTo]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   358
by (blast_tac (claset() addIs [LeadsTo_weaken_R, diff_less_mono2]) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   359
qed "GreaterThan_bounded_induct";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   360
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   361
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   362
(*** Completion: Binary and General Finite versions ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   363
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   364
Goal "[| LeadsTo prg A A';  Stable prg A';   \
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   365
\        LeadsTo prg B B';  Stable prg B';  id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   366
\     ==> LeadsTo prg (A Int B) (A' Int B')";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   367
by (full_simp_tac (simpset() addsimps [LeadsTo_def, Stable_eq_stable]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   368
by (blast_tac (claset() addIs [stable_completion, leadsTo_weaken]) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   369
qed "Stable_completion";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   370
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   371
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   372
Goal "[| finite I;  id: Acts prg |]      \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   373
\     ==> (ALL i:I. LeadsTo prg (A i) (A' i)) -->  \
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   374
\         (ALL i:I. Stable prg (A' i)) -->         \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   375
\         LeadsTo prg (INT i:I. A i) (INT i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   376
by (etac finite_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   377
by (Asm_simp_tac 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   378
by (asm_simp_tac (simpset() addsimps [Stable_completion, ball_Stable_INT]) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   379
qed_spec_mp "Finite_stable_completion";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   380
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   381
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   382
Goal "[| LeadsTo prg A (A' Un C);  Constrains prg A' (A' Un C); \
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   383
\        LeadsTo prg B (B' Un C);  Constrains prg B' (B' Un C); \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   384
\        id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   385
\     ==> LeadsTo prg (A Int B) ((A' Int B') Un C)";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   386
by (full_simp_tac (simpset() addsimps [LeadsTo_def, Constrains_def,
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   387
				       Int_Un_distrib]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   388
by (blast_tac (claset() addIs [completion, leadsTo_weaken]) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   389
qed "Completion";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   390
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   391
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   392
Goal "[| finite I;  id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   393
\     ==> (ALL i:I. LeadsTo prg (A i) (A' i Un C)) -->  \
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   394
\         (ALL i:I. Constrains prg (A' i) (A' i Un C)) --> \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   395
\         LeadsTo prg (INT i:I. A i) ((INT i:I. A' i) Un C)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   396
by (etac finite_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   397
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   398
by (Clarify_tac 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   399
by (dtac ball_Constrains_INT 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   400
by (asm_full_simp_tac (simpset() addsimps [Completion]) 1); 
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   401
qed "Finite_completion";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   402
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   403
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   404
(*proves "ensures/leadsTo" properties when the program is specified*)
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5422
diff changeset
   405
fun ensures_tac sact = 
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   406
    SELECT_GOAL
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   407
      (EVERY [REPEAT (Invariant_Int_tac 1),
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   408
	      etac Invariant_LeadsTo_Basis 1 
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   409
	          ORELSE   (*subgoal may involve LeadsTo, leadsTo or ensures*)
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   410
		  REPEAT (ares_tac [LeadsTo_Basis, ensuresI] 1),
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   411
	      res_inst_tac [("act", sact)] transient_mem 2,
5340
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   412
                 (*simplify the command's domain*)
5426
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5422
diff changeset
   413
	      simp_tac (simpset() addsimps [Domain_def]) 3,
566f47250bd0 A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents: 5422
diff changeset
   414
	      constrains_tac 1,
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   415
	      ALLGOALS Clarify_tac,
5422
578dc167453f Moved constrains_tac from SubstAx to Constrains.
paulson
parents: 5340
diff changeset
   416
	      ALLGOALS Asm_full_simp_tac]);
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   417
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   418