src/HOL/UNITY/SubstAx.ML
author paulson
Wed, 23 Sep 1998 10:11:18 +0200
changeset 5536 130f3d891fb2
parent 5479 5a5dfb0f0d7d
child 5544 96078cf5fd2c
permissions -rw-r--r--
tidying and deleting needless parentheses
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
by (blast_tac (claset() addIs [LeadsTo_weaken_R, LeadsTo_weaken_L,
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   104
			       LeadsTo_Trans]) 1);
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   105
qed "LeadsTo_weaken";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   106
5340
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   107
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   108
(** Two theorems for "proof lattices" **)
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   109
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   110
Goal "[| id: Acts prg; LeadsTo prg A B |] ==> LeadsTo prg (A Un B) B";
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   111
by (blast_tac (claset() addIs [LeadsTo_Un, subset_imp_LeadsTo]) 1);
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   112
qed "LeadsTo_Un_post";
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   113
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   114
Goal "[| id: Acts prg;  LeadsTo prg A B;  LeadsTo prg B C |] \
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   115
\     ==> LeadsTo prg (A Un B) C";
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   116
by (blast_tac (claset() addIs [LeadsTo_Un, subset_imp_LeadsTo, 
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   117
			       LeadsTo_weaken_L, LeadsTo_Trans]) 1);
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   118
qed "LeadsTo_Trans_Un";
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   119
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   120
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   121
(** Distributive laws **)
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   122
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   123
Goal "id: Acts prg ==> \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   124
\       LeadsTo prg (A Un B) C  =  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   125
\       (LeadsTo prg A C & LeadsTo prg B C)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   126
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   127
qed "LeadsTo_Un_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   128
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   129
Goal "id: Acts prg ==> \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   130
\       LeadsTo prg (UN i:I. A i) B  =  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   131
\       (ALL i : I. LeadsTo prg (A i) B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   132
by (blast_tac (claset() addIs [LeadsTo_UN, LeadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   133
qed "LeadsTo_UN_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   134
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   135
Goal "id: Acts prg ==> \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   136
\       LeadsTo prg (Union S) B  =  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   137
\       (ALL A : S. LeadsTo prg A B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   138
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   139
qed "LeadsTo_Union_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   140
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   141
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   142
(** More rules using the premise "Invariant prg" **)
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   143
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   144
Goalw [LeadsTo_def, Constrains_def]
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   145
     "[| 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
   146
\     ==> LeadsTo prg A A'";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   147
by (rtac (ensuresI RS leadsTo_Basis) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   148
by (blast_tac (claset() addIs [transient_strengthen]) 2);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   149
by (blast_tac (claset() addIs [constrains_weaken]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   150
qed "LeadsTo_Basis";
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   151
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   152
Goal "[| Invariant prg INV;      \
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   153
\        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
   154
\        transient  (Acts prg) (INV Int (A-A')) |]   \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   155
\ ==> LeadsTo prg A A'";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   156
by (rtac Invariant_LeadsToI 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   157
by (assume_tac 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   158
by (rtac LeadsTo_Basis 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   159
by (blast_tac (claset() addIs [transient_strengthen]) 2);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   160
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
   161
qed "Invariant_LeadsTo_Basis";
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   162
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   163
Goal "[| Invariant prg INV;      \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   164
\        LeadsTo prg A A'; id: Acts prg;   \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   165
\        INV Int B  <= A;  INV Int A' <= B' |] \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   166
\     ==> LeadsTo prg B B'";
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   167
by (rtac Invariant_LeadsToI 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   168
by (assume_tac 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   169
by (dtac Invariant_LeadsToD 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   170
by (assume_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   171
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
   172
qed "Invariant_LeadsTo_weaken";
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   173
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   174
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   175
(*Set difference: maybe combine with leadsTo_weaken_L??
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   176
  This is the most useful form of the "disjunction" rule*)
5340
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   177
Goal "[| LeadsTo prg (A-B) C; LeadsTo prg (A Int B) C; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   178
\     ==> LeadsTo prg A C";
5479
5a5dfb0f0d7d fixed PROOF FAILED
paulson
parents: 5426
diff changeset
   179
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   180
qed "LeadsTo_Diff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   181
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   182
5340
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   183
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   184
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   185
val prems = 
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   186
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
   187
\     ==> LeadsTo prg (UN i:I. A i) (UN i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   188
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   189
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_R] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   190
                        addIs prems) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   191
qed "LeadsTo_UN_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   192
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   193
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   194
(*Version with no index set*)
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   195
val prems = 
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   196
Goal "(!! i. LeadsTo prg (A i) (A' i)) \
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   197
\     ==> LeadsTo prg (UN i. A i) (UN i. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   198
by (blast_tac (claset() addIs [LeadsTo_UN_UN] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   199
                        addIs prems) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   200
qed "LeadsTo_UN_UN_noindex";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   201
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   202
(*Version with no index set*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   203
Goal "ALL i. LeadsTo prg (A i) (A' i) \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   204
\     ==> LeadsTo prg (UN i. A i) (UN i. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   205
by (blast_tac (claset() addIs [LeadsTo_UN_UN]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   206
qed "all_LeadsTo_UN_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   207
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   208
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   209
(*Binary union version*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   210
Goal "[| LeadsTo prg A A'; LeadsTo prg B B' |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   211
\           ==> LeadsTo prg (A Un B) (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   212
by (blast_tac (claset() addIs [LeadsTo_Un, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   213
			       LeadsTo_weaken_R]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   214
qed "LeadsTo_Un_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   215
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   216
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   217
(** The cancellation law **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   218
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   219
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
   220
\        id: Acts prg |]    \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   221
\     ==> LeadsTo prg A (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   222
by (blast_tac (claset() addIs [LeadsTo_Un_Un, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   223
			       subset_imp_LeadsTo, LeadsTo_Trans]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   224
qed "LeadsTo_cancel2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   225
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   226
Goal "[| LeadsTo prg A (A' Un B); LeadsTo prg (B-A') B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   227
\     ==> LeadsTo prg A (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   228
by (rtac LeadsTo_cancel2 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   229
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   230
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   231
qed "LeadsTo_cancel_Diff2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   232
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   233
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg B B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   234
\     ==> LeadsTo prg A (B' Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   235
by (asm_full_simp_tac (simpset() addsimps [Un_commute]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   236
by (blast_tac (claset() addSIs [LeadsTo_cancel2]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   237
qed "LeadsTo_cancel1";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   238
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   239
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg (B-A') B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   240
\     ==> LeadsTo prg A (B' Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   241
by (rtac LeadsTo_cancel1 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_Diff1";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   245
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   246
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   247
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   248
(** The impossibility law **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   249
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   250
(*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
   251
Goal "LeadsTo prg A {} ==> reachable prg Int A = {}";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   252
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   253
by (etac leadsTo_empty 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   254
qed "LeadsTo_empty";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   255
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   256
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   257
(** PSP: Progress-Safety-Progress **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   258
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   259
(*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
   260
Goal
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   261
  "[| 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
   262
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
   263
by (dtac psp_stable 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   264
by (assume_tac 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   265
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
   266
qed "PSP_stable";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   267
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   268
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
   269
\     ==> LeadsTo prg (B Int A) (B Int A')";
5536
130f3d891fb2 tidying and deleting needless parentheses
paulson
parents: 5479
diff changeset
   270
by (asm_simp_tac (simpset() addsimps PSP_stable::Int_ac) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   271
qed "PSP_stable2";
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
Goalw [LeadsTo_def, Constrains_def]
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   274
     "[| LeadsTo prg A A'; Constrains prg B B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   275
\     ==> 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
   276
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
   277
qed "PSP";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   278
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   279
Goal "[| LeadsTo prg A A'; Constrains prg B B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   280
\     ==> LeadsTo prg (B Int A) ((B Int A') Un (B' - B))";
5536
130f3d891fb2 tidying and deleting needless parentheses
paulson
parents: 5479
diff changeset
   281
by (asm_simp_tac (simpset() addsimps PSP::Int_ac) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   282
qed "PSP2";
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
Goalw [Unless_def]
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   285
     "[| LeadsTo prg A A'; Unless prg B B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   286
\     ==> 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
   287
by (dtac PSP 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   288
by (assume_tac 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   289
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
   290
			       subset_imp_LeadsTo]) 2);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   291
by (assume_tac 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   292
qed "PSP_Unless";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   293
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   294
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   295
(*** Induction rules ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   296
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   297
(** Meta or object quantifier ????? **)
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   298
Goal "[| wf r;     \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   299
\        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
   300
\                           ((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
   301
\        id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   302
\     ==> LeadsTo prg A B";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   303
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   304
by (etac leadsTo_wf_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   305
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   306
by (blast_tac (claset() addIs [leadsTo_weaken]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   307
qed "LeadsTo_wf_induct";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   308
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   309
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   310
Goal "[| wf r;     \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   311
\        ALL m:I. LeadsTo prg (A Int f-``{m})                   \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   312
\                             ((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
   313
\        id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   314
\     ==> LeadsTo prg A ((A - (f-``I)) Un B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   315
by (etac LeadsTo_wf_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   316
by Safe_tac;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   317
by (case_tac "m:I" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   318
by (blast_tac (claset() addIs [LeadsTo_weaken]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   319
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
   320
qed "Bounded_induct";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   321
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   322
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   323
Goal "[| ALL m. LeadsTo prg (A Int f-``{m})                     \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   324
\                           ((A Int f-``(lessThan m)) Un B);   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   325
\        id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   326
\     ==> LeadsTo prg A B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   327
by (rtac (wf_less_than RS LeadsTo_wf_induct) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   328
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   329
by (Asm_simp_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   330
qed "LessThan_induct";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   331
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   332
Goal "[| ALL m:(greaterThan l). LeadsTo prg (A Int f-``{m})   \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   333
\                                        ((A Int f-``(lessThan m)) Un B);   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   334
\              id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   335
\           ==> LeadsTo prg A ((A Int (f-``(atMost l))) Un B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   336
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
   337
by (rtac (wf_less_than RS Bounded_induct) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   338
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   339
by (Asm_simp_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   340
qed "LessThan_bounded_induct";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   341
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   342
Goal "[| ALL m:(lessThan l). LeadsTo prg (A Int f-``{m})   \
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   343
\                              ((A Int f-``(greaterThan m)) Un B);   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   344
\        id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   345
\     ==> LeadsTo prg A ((A Int (f-``(atLeast l))) Un B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   346
by (res_inst_tac [("f","f"),("f1", "%k. l - k")]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   347
    (wf_less_than RS wf_inv_image RS LeadsTo_wf_induct) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   348
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   349
by (simp_tac (simpset() addsimps [inv_image_def, Image_singleton]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   350
by (Clarify_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   351
by (case_tac "m<l" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   352
by (blast_tac (claset() addIs [not_leE, subset_imp_LeadsTo]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   353
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
   354
qed "GreaterThan_bounded_induct";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   355
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   356
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   357
(*** Completion: Binary and General Finite versions ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   358
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   359
Goal "[| LeadsTo prg A A';  Stable prg A';   \
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   360
\        LeadsTo prg B B';  Stable prg B';  id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   361
\     ==> 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
   362
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
   363
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
   364
qed "Stable_completion";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   365
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   366
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   367
Goal "[| finite I;  id: Acts prg |]      \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   368
\     ==> (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
   369
\         (ALL i:I. Stable prg (A' i)) -->         \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   370
\         LeadsTo prg (INT i:I. A i) (INT i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   371
by (etac finite_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   372
by (Asm_simp_tac 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   373
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
   374
qed_spec_mp "Finite_stable_completion";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   375
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   376
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   377
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
   378
\        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
   379
\        id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   380
\     ==> 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
   381
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
   382
				       Int_Un_distrib]) 1);
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   383
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
   384
qed "Completion";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   385
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   386
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   387
Goal "[| finite I;  id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   388
\     ==> (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
   389
\         (ALL i:I. Constrains prg (A' i) (A' i Un C)) --> \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   390
\         LeadsTo prg (INT i:I. A i) ((INT i:I. A' i) Un C)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   391
by (etac finite_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   392
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   393
by (Clarify_tac 1);
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   394
by (dtac ball_Constrains_INT 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   395
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
   396
qed "Finite_completion";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   397
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   398
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   399
(*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
   400
fun ensures_tac sact = 
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   401
    SELECT_GOAL
5313
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   402
      (EVERY [REPEAT (Invariant_Int_tac 1),
1861a564d7e2 Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents: 5277
diff changeset
   403
	      etac Invariant_LeadsTo_Basis 1 
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   404
	          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
   405
		  REPEAT (ares_tac [LeadsTo_Basis, ensuresI] 1),
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   406
	      res_inst_tac [("act", sact)] transient_mem 2,
5340
d75c03cf77b5 Misc changes
paulson
parents: 5313
diff changeset
   407
                 (*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
   408
	      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
   409
	      constrains_tac 1,
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   410
	      ALLGOALS Clarify_tac,
5422
578dc167453f Moved constrains_tac from SubstAx to Constrains.
paulson
parents: 5340
diff changeset
   411
	      ALLGOALS Asm_full_simp_tac]);
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   412
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   413