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