src/HOL/UNITY/SubstAx.ML
author paulson
Thu, 06 Aug 1998 15:47:26 +0200
changeset 5277 e4297d03e5d2
parent 5257 c03e3ba9cbcc
child 5313 1861a564d7e2
permissions -rw-r--r--
A higher-level treatment of LeadsTo, minimizing use of "reachable"
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
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
     9
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    10
(*constrains (Acts prg) B B'
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    11
  ==> constrains (Acts prg) (reachable prg Int B) (reachable prg Int B')*)
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    12
bind_thm ("constrains_reachable",
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    13
	  rewrite_rule [stable_def] stable_reachable RS constrains_Int);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    14
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    15
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    16
(*** Specialized laws for handling invariants ***)
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    17
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    18
Goal "invariant prg INV ==> reachable prg Int INV = reachable prg";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    19
bd invariant_includes_reachable 1;
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    20
by (Blast_tac 1);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    21
qed "reachable_Int_INV";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    22
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    23
Goal "[| invariant prg INV;  LeadsTo prg (INV Int A) A' |]   \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    24
\     ==> LeadsTo prg A A'";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    25
by (asm_full_simp_tac
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    26
    (simpset() addsimps [LeadsTo_def, reachable_Int_INV,
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    27
			 Int_assoc RS sym]) 1);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    28
qed "invariant_LeadsToI";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    29
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    30
Goal "[| invariant prg INV;  LeadsTo prg A A' |]   \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    31
\     ==> LeadsTo prg A (INV Int A')";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    32
by (asm_full_simp_tac
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    33
    (simpset() addsimps [LeadsTo_def, reachable_Int_INV,
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    34
			 Int_assoc RS sym]) 1);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    35
qed "invariant_LeadsToD";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    36
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    37
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    38
(*** Introduction rules: Basis, Trans, Union ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    39
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    40
Goal "leadsTo (Acts prg) A B ==> LeadsTo prg A B";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    41
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
    42
by (blast_tac (claset() addIs [psp_stable2, stable_reachable]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    43
qed "leadsTo_imp_LeadsTo";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    44
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    45
(* ensures (Acts prg) A B ==> LeadsTo prg A B *)
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    46
bind_thm ("LeadsTo_Basis", leadsTo_Basis RS leadsTo_imp_LeadsTo);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    47
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    48
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
    49
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    50
by (blast_tac (claset() addIs [leadsTo_Trans]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    51
qed "LeadsTo_Trans";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    52
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    53
val [prem] = Goalw [LeadsTo_def]
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    54
 "(!!A. A : S ==> LeadsTo prg A B) ==> LeadsTo prg (Union S) B";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    55
by (Simp_tac 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    56
by (stac Int_Union 1);
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    57
by (blast_tac (claset() addIs [leadsTo_UN,
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    58
			        simplify (simpset()) prem]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    59
qed "LeadsTo_Union";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    60
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    61
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    62
(*** Derived rules ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    63
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    64
Goal "id: Acts prg ==> LeadsTo prg A UNIV";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    65
by (asm_simp_tac (simpset() addsimps [LeadsTo_def, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    66
				      Int_lower1 RS subset_imp_leadsTo]) 1);
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*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    71
Goal "LeadsTo prg A (A' Un A') ==> LeadsTo prg A 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
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    75
Goal "LeadsTo prg A (A' Un C Un C) ==> LeadsTo prg A (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 = 
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    80
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
    81
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1);
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*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
    86
Goal "[| LeadsTo prg A C; LeadsTo prg B C |] ==> LeadsTo prg (A Un B) 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
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    91
Goal "[| A <= B;  id: Acts prg |] ==> LeadsTo prg A B";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
    92
by (simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    93
by (blast_tac (claset() addIs [subset_imp_leadsTo]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    94
qed "subset_imp_LeadsTo";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    95
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    96
bind_thm ("empty_LeadsTo", empty_subsetI RS subset_imp_LeadsTo);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    97
Addsimps [empty_LeadsTo];
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
    98
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
    99
Goal "[| LeadsTo prg A A';  A' <= B' |] ==> LeadsTo prg A B'";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   100
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   101
by (blast_tac (claset() addIs [leadsTo_weaken_R]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   102
qed_spec_mp "LeadsTo_weaken_R";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   103
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   104
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   105
Goal "[| LeadsTo prg A A';  B <= A; id: Acts prg |]  \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   106
\     ==> LeadsTo prg B A'";
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_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   109
qed_spec_mp "LeadsTo_weaken_L";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   110
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   111
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   112
(*Distributes over binary unions*)
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   113
Goal "id: Acts prg ==> \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   114
\       LeadsTo prg (A Un B) C  =  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   115
\       (LeadsTo prg A C & LeadsTo prg B C)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   116
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   117
qed "LeadsTo_Un_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   118
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   119
Goal "id: Acts prg ==> \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   120
\       LeadsTo prg (UN i:I. A i) B  =  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   121
\       (ALL i : I. LeadsTo prg (A i) B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   122
by (blast_tac (claset() addIs [LeadsTo_UN, LeadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   123
qed "LeadsTo_UN_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   124
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   125
Goal "id: Acts prg ==> \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   126
\       LeadsTo prg (Union S) B  =  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   127
\       (ALL A : S. LeadsTo prg A B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   128
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   129
qed "LeadsTo_Union_distrib";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   130
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   131
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   132
Goal "[| LeadsTo prg A A'; id: Acts prg;   \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   133
\        B  <= A;   A' <= B' |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   134
\     ==> LeadsTo prg B B'";
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   135
(*PROOF FAILED*)
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   136
by (blast_tac (claset() addIs [LeadsTo_Trans, LeadsTo_weaken_R,
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   137
			       LeadsTo_weaken_L]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   138
qed "LeadsTo_weaken";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   139
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   140
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   141
(** More rules using the premise "invariant prg" **)
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   142
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   143
Goal "[| invariant prg INV;      \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   144
\        constrains (Acts prg) (INV Int (A-A')) (A Un A'); \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   145
\        transient  (Acts prg) (INV Int (A-A')) |]   \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   146
\ ==> LeadsTo prg A A'";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   147
br invariant_LeadsToI 1;
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   148
ba 1;
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   149
by (rtac (ensuresI RS LeadsTo_Basis) 1);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   150
by (ALLGOALS 
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   151
    (full_simp_tac (simpset() addsimps [Int_Diff, Int_Un_distrib RS sym, 
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   152
					Diff_Int_distrib RS sym])));
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   153
be invariantE 1;
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   154
by (blast_tac (claset() addSDs [stable_constrains_Int]
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   155
			addIs [constrains_weaken]) 1);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   156
qed "invariant_LeadsTo_Basis";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   157
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   158
Goal "[| invariant prg INV;      \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   159
\        LeadsTo prg A A'; id: Acts prg;   \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   160
\        INV Int B  <= A;  INV Int A' <= B' |] \
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   161
\     ==> LeadsTo prg B B'";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   162
br invariant_LeadsToI 1;
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   163
ba 1;
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   164
bd invariant_LeadsToD 1;
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   165
ba 1;
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   166
by (blast_tac (claset()addIs [LeadsTo_weaken]) 1);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   167
qed "invariant_LeadsTo_weaken";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   168
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   169
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   170
(*Set difference: maybe combine with leadsTo_weaken_L??
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   171
  This is the most useful form of the "disjunction" rule*)
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   172
Goal "[| LeadsTo prg (A-B) C; LeadsTo prg B C; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   173
\     ==> LeadsTo prg A C";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   174
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   175
qed "LeadsTo_Diff";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   176
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   177
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   178
val prems = 
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   179
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
   180
\     ==> LeadsTo prg (UN i:I. A i) (UN i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   181
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   182
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_R] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   183
                        addIs prems) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   184
qed "LeadsTo_UN_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   185
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   186
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   187
(*Version with no index set*)
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   188
val prems = 
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   189
Goal "(!! i. LeadsTo prg (A i) (A' i)) \
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   190
\     ==> LeadsTo prg (UN i. A i) (UN i. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   191
by (blast_tac (claset() addIs [LeadsTo_UN_UN] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   192
                        addIs prems) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   193
qed "LeadsTo_UN_UN_noindex";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   194
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   195
(*Version with no index set*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   196
Goal "ALL i. LeadsTo prg (A i) (A' i) \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   197
\     ==> LeadsTo prg (UN i. A i) (UN i. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   198
by (blast_tac (claset() addIs [LeadsTo_UN_UN]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   199
qed "all_LeadsTo_UN_UN";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   200
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   201
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   202
(*Binary union version*)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   203
Goal "[| LeadsTo prg A A'; LeadsTo prg B B' |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   204
\           ==> LeadsTo prg (A Un B) (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   205
by (blast_tac (claset() addIs [LeadsTo_Un, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   206
			       LeadsTo_weaken_R]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   207
qed "LeadsTo_Un_Un";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   208
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   209
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   210
(** The cancellation law **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   211
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   212
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
   213
\        id: Acts prg |]    \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   214
\     ==> LeadsTo prg A (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   215
by (blast_tac (claset() addIs [LeadsTo_Un_Un, 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   216
			       subset_imp_LeadsTo, LeadsTo_Trans]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   217
qed "LeadsTo_cancel2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   218
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   219
Goal "[| LeadsTo prg A (A' Un B); LeadsTo prg (B-A') B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   220
\     ==> LeadsTo prg A (A' Un B')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   221
by (rtac LeadsTo_cancel2 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   222
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   223
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   224
qed "LeadsTo_cancel_Diff2";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   225
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   226
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg B B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   227
\     ==> LeadsTo prg A (B' Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   228
by (asm_full_simp_tac (simpset() addsimps [Un_commute]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   229
by (blast_tac (claset() addSIs [LeadsTo_cancel2]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   230
qed "LeadsTo_cancel1";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   231
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   232
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg (B-A') B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   233
\     ==> LeadsTo prg A (B' Un A')";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   234
by (rtac LeadsTo_cancel1 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   235
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   236
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   237
qed "LeadsTo_cancel_Diff1";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   238
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   239
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   240
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   241
(** The impossibility law **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   242
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   243
(*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
   244
Goal "LeadsTo prg A {} ==> reachable prg Int A = {}";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   245
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   246
by (etac leadsTo_empty 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   247
qed "LeadsTo_empty";
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
(** PSP: Progress-Safety-Progress **)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   251
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   252
(*Special case of PSP: Misra's "stable conjunction".  Doesn't need id:Acts. *)
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   253
Goal "[| LeadsTo prg A A'; stable (Acts prg) B |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   254
\     ==> LeadsTo prg (A Int B) (A' Int B)";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   255
by (asm_full_simp_tac (simpset() addsimps [LeadsTo_def, Int_assoc RS sym, 
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   256
					   psp_stable]) 1);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   257
qed "PSP_stable";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   258
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   259
Goal "[| LeadsTo prg A A'; stable (Acts prg) B |] \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   260
\     ==> LeadsTo prg (B Int A) (B Int A')";
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   261
by (asm_simp_tac (simpset() addsimps (PSP_stable::Int_ac)) 1);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   262
qed "PSP_stable2";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   263
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   264
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   265
Goal "[| LeadsTo prg A A'; constrains (Acts prg) B B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   266
\     ==> LeadsTo prg (A Int B) ((A' Int B) Un (B' - B))";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   267
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   268
by (dtac psp 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   269
by (etac constrains_reachable 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   270
by (etac leadsTo_weaken 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   271
by (ALLGOALS Blast_tac);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   272
qed "PSP";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   273
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   274
Goal "[| LeadsTo prg A A'; constrains (Acts prg) B B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   275
\     ==> LeadsTo prg (B Int A) ((B Int A') Un (B' - B))";
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   276
by (asm_simp_tac (simpset() addsimps (PSP::Int_ac)) 1);
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   277
qed "PSP2";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   278
5069
3ea049f7979d isatool fixgoal;
wenzelm
parents: 4776
diff changeset
   279
Goalw [unless_def]
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   280
   "[| LeadsTo prg A A'; unless (Acts prg) B B'; id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   281
\     ==> 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
   282
by (dtac PSP 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   283
by (assume_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   284
by (asm_full_simp_tac (simpset() addsimps [Un_Diff_Diff, Int_Diff_Un]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   285
by (asm_full_simp_tac (simpset() addsimps [Diff_Int_distrib]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   286
by (etac LeadsTo_Diff 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   287
by (blast_tac (claset() addIs [subset_imp_LeadsTo]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   288
by Auto_tac;
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   289
qed "PSP_unless";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   290
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   291
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   292
(*** Induction rules ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   293
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   294
(** Meta or object quantifier ????? **)
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   295
Goal "[| wf r;     \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   296
\        ALL m. LeadsTo prg (A Int f-``{m})                     \
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   297
\                                 ((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
   298
\        id: Acts prg |] \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   299
\     ==> LeadsTo prg A B";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   300
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   301
by (etac leadsTo_wf_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   302
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   303
by (blast_tac (claset() addIs [leadsTo_weaken]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   304
qed "LeadsTo_wf_induct";
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   305
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   306
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   307
Goal "[| wf r;     \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   308
\        ALL m:I. LeadsTo prg (A Int f-``{m})                   \
5257
c03e3ba9cbcc Indentation, comments
paulson
parents: 5253
diff changeset
   309
\                             ((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
   310
\        id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   311
\     ==> LeadsTo prg A ((A - (f-``I)) Un B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   312
by (etac LeadsTo_wf_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   313
by Safe_tac;
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   314
by (case_tac "m:I" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   315
by (blast_tac (claset() addIs [LeadsTo_weaken]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   316
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
   317
qed "Bounded_induct";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   318
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   319
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   320
Goal "[| ALL m. LeadsTo prg (A Int f-``{m})                     \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   321
\                           ((A Int f-``(lessThan m)) Un B);   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   322
\        id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   323
\     ==> LeadsTo prg A B";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   324
by (rtac (wf_less_than RS 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 (Asm_simp_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   327
qed "LessThan_induct";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   328
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   329
Goal "[| ALL m:(greaterThan l). LeadsTo prg (A Int f-``{m})   \
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   330
\                                        ((A Int f-``(lessThan m)) Un B);   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   331
\              id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   332
\           ==> LeadsTo prg A ((A Int (f-``(atMost l))) Un B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   333
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
   334
by (rtac (wf_less_than RS Bounded_induct) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   335
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   336
by (Asm_simp_tac 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   337
qed "LessThan_bounded_induct";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   338
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   339
Goal "[| ALL m:(lessThan l). LeadsTo prg (A Int f-``{m})   \
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   340
\                              ((A Int f-``(greaterThan m)) Un B);   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   341
\        id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   342
\     ==> LeadsTo prg A ((A Int (f-``(atLeast l))) Un B)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   343
by (res_inst_tac [("f","f"),("f1", "%k. l - k")]
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   344
    (wf_less_than RS wf_inv_image RS LeadsTo_wf_induct) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   345
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   346
by (simp_tac (simpset() addsimps [inv_image_def, Image_singleton]) 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   347
by (Clarify_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   348
by (case_tac "m<l" 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   349
by (blast_tac (claset() addIs [not_leE, subset_imp_LeadsTo]) 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   350
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
   351
qed "GreaterThan_bounded_induct";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   352
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   353
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   354
(*** Completion: Binary and General Finite versions ***)
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   355
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   356
Goal "[| LeadsTo prg A A';  stable (Acts prg) A';   \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   357
\        LeadsTo prg B B';  stable (Acts prg) B';  id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   358
\     ==> LeadsTo prg (A Int B) (A' Int B')";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   359
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   360
by (blast_tac (claset() addIs [stable_completion RS leadsTo_weaken] 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   361
                        addSIs [stable_Int, stable_reachable]) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   362
qed "Stable_completion";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   363
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   364
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   365
Goal "[| finite I;  id: Acts prg |]                     \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   366
\     ==> (ALL i:I. LeadsTo prg (A i) (A' i)) -->  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   367
\         (ALL i:I. stable (Acts prg) (A' i)) -->         \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   368
\         LeadsTo prg (INT i:I. A i) (INT i:I. A' i)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   369
by (etac finite_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   370
by (Asm_simp_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   371
by (asm_simp_tac 
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   372
    (simpset() addsimps [Stable_completion, stable_def, 
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   373
			 ball_constrains_INT]) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   374
qed_spec_mp "Finite_stable_completion";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   375
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   376
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   377
Goal "[| LeadsTo prg A (A' Un C);  constrains (Acts prg) A' (A' Un C); \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   378
\        LeadsTo prg B (B' Un C);  constrains (Acts prg) B' (B' Un C); \
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   379
\        id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   380
\     ==> LeadsTo prg (A Int B) ((A' Int B') Un C)";
5111
8f4b72f0c15d Uncurried functions LeadsTo and reach
paulson
parents: 5069
diff changeset
   381
by (full_simp_tac (simpset() addsimps [LeadsTo_def, Int_Un_distrib]) 1);
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   382
by (dtac completion 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   383
by (assume_tac 2);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   384
by (ALLGOALS 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   385
    (asm_simp_tac 
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   386
     (simpset() addsimps [constrains_reachable, Int_Un_distrib RS sym])));
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   387
by (blast_tac (claset() addIs [leadsTo_weaken]) 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   388
qed "Completion";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   389
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   390
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   391
Goal "[| finite I;  id: Acts prg |] \
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   392
\     ==> (ALL i:I. LeadsTo prg (A i) (A' i Un C)) -->  \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   393
\         (ALL i:I. constrains (Acts prg) (A' i) (A' i Un C)) --> \
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   394
\         LeadsTo prg (INT i:I. A i) ((INT i:I. A' i) Un C)";
4776
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   395
by (etac finite_induct 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   396
by (ALLGOALS Asm_simp_tac);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   397
by (Clarify_tac 1);
1f9362e769c1 New UNITY theory
paulson
parents:
diff changeset
   398
by (dtac ball_constrains_INT 1);
5277
e4297d03e5d2 A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents: 5257
diff changeset
   399
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
   400
qed "Finite_completion";
5232
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   401
e5a7cdd07ea5 Tidied; uses records
paulson
parents: 5111
diff changeset
   402
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   403
(** Constrains/Ensures tactics 
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   404
    main_def defines the main program as a set;
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   405
    cmd_defs defines the separate commands
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   406
**)
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   407
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   408
(*proves "constrains" properties when the program is specified*)
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   409
fun constrains_tac (main_def::cmd_defs) = 
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   410
   SELECT_GOAL
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   411
      (EVERY [TRY (rtac stableI 1),
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   412
	      rtac constrainsI 1,
5253
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   413
	      full_simp_tac (simpset() addsimps [main_def]) 1,
82a5ca6290aa New record type of programs
paulson
parents: 5240
diff changeset
   414
	      REPEAT_FIRST (eresolve_tac [disjE]),
5240
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   415
	      rewrite_goals_tac cmd_defs,
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   416
	      ALLGOALS (SELECT_GOAL Auto_tac)]);
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   417
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   418
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   419
(*proves "ensures" properties when the program is specified*)
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   420
fun ensures_tac (main_def::cmd_defs) sact = 
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   421
    SELECT_GOAL
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   422
      (EVERY [REPEAT (invariant_Int_tac 1),
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   423
	      etac invariant_LeadsTo_Basis 1 
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   424
	          ORELSE   (*subgoal may involve LeadsTo, leadsTo or ensures*)
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   425
		  REPEAT (ares_tac [leadsTo_imp_LeadsTo, leadsTo_Basis, 
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   426
				    ensuresI] 1),
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   427
	      res_inst_tac [("act", sact)] transient_mem 2,
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   428
	      simp_tac (simpset() addsimps (Domain_partial_func::cmd_defs)) 3,
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   429
	      simp_tac (simpset() addsimps [main_def]) 2,
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   430
	      constrains_tac (main_def::cmd_defs) 1,
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   431
	      rewrite_goals_tac cmd_defs,
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   432
	      ALLGOALS Clarify_tac,
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   433
	      Auto_tac]);
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   434
bbcd79ef7cf2 Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents: 5232
diff changeset
   435