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