author | paulson |
Tue, 21 Sep 1999 11:11:09 +0200 | |
changeset 7547 | a72a551b6d79 |
parent 7403 | c318acb88251 |
child 8769 | 981ebe7f1f10 |
permissions | -rw-r--r-- |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
1 |
(* Title: HOL/UNITY/Lift |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
2 |
ID: $Id$ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
4 |
Copyright 1998 University of Cambridge |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
5 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
6 |
The Lift-Control Example |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
7 |
*) |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
8 |
|
5563 | 9 |
Goal "[| x ~: A; y : A |] ==> x ~= y"; |
10 |
by (Blast_tac 1); |
|
11 |
qed "not_mem_distinct"; |
|
12 |
||
13 |
fun distinct_tac i = |
|
14 |
dtac zle_neq_implies_zless i THEN |
|
15 |
eresolve_tac [not_mem_distinct, not_mem_distinct RS not_sym] i THEN |
|
16 |
assume_tac i; |
|
17 |
||
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
18 |
|
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
19 |
(** Rules to move "metric n s" out of the assumptions, for case splitting **) |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
20 |
val mov_metric1 = read_instantiate_sg (sign_of thy) |
5596 | 21 |
[("P", "?x < metric ?n ?s")] rev_mp; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
22 |
|
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
23 |
val mov_metric2 = read_instantiate_sg (sign_of thy) |
5596 | 24 |
[("P", "?x = metric ?n ?s")] rev_mp; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
25 |
|
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
26 |
val mov_metric3 = read_instantiate_sg (sign_of thy) |
5596 | 27 |
[("P", "~ (?x < metric ?n ?s)")] rev_mp; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
28 |
|
5563 | 29 |
val mov_metric4 = read_instantiate_sg (sign_of thy) |
5596 | 30 |
[("P", "(?x <= metric ?n ?s)")] rev_mp; |
5563 | 31 |
|
6916 | 32 |
val mov_metric5 = read_instantiate_sg (sign_of thy) |
33 |
[("P", "?x ~= metric ?n ?s")] rev_mp; |
|
34 |
||
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
35 |
(*The order in which they are applied seems to be critical...*) |
6916 | 36 |
val mov_metrics = [mov_metric2, mov_metric3, mov_metric1, mov_metric4, |
37 |
mov_metric5]; |
|
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
38 |
|
6139 | 39 |
val metric_simps = [metric_def, vimage_def]; |
5563 | 40 |
|
5340 | 41 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
42 |
Addsimps [Lift_def RS def_prg_Init]; |
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
43 |
program_defs_ref := [Lift_def]; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
44 |
|
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
45 |
Addsimps (map simp_of_act |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
46 |
[request_act_def, open_act_def, close_act_def, |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
47 |
req_up_def, req_down_def, move_up_def, move_down_def, |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
48 |
button_press_def]); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
49 |
|
7403 | 50 |
(*The ALWAYS properties*) |
51 |
Addsimps (map simp_of_set [above_def, below_def, queueing_def, |
|
52 |
goingup_def, goingdown_def, ready_def]); |
|
5357 | 53 |
|
54 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
55 |
Addsimps [bounded_def, open_stop_def, open_move_def, stop_floor_def, |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
56 |
moving_up_def, moving_down_def]; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
57 |
|
5357 | 58 |
AddIffs [Min_le_Max]; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
59 |
|
5320 | 60 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
61 |
Goal "Lift : Always open_stop"; |
7403 | 62 |
by (always_tac 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
63 |
qed "open_stop"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
64 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
65 |
Goal "Lift : Always stop_floor"; |
7403 | 66 |
by (always_tac 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
67 |
qed "stop_floor"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
68 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
69 |
(*This one needs open_stop, which was proved above*) |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
70 |
Goal "Lift : Always open_move"; |
7403 | 71 |
by (cut_facts_tac [open_stop] 1); |
72 |
by (always_tac 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
73 |
qed "open_move"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
74 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
75 |
Goal "Lift : Always moving_up"; |
7403 | 76 |
by (always_tac 1); |
77 |
by (auto_tac (claset() addDs [zle_imp_zless_or_eq], |
|
7000
6920cf9b8623
rewrite add1_zle_eq is no longer in the default simpset
paulson
parents:
6916
diff
changeset
|
78 |
simpset() addsimps [add1_zle_eq])); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
79 |
qed "moving_up"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
80 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
81 |
Goal "Lift : Always moving_down"; |
7403 | 82 |
by (always_tac 1); |
5563 | 83 |
by (blast_tac (claset() addDs [zle_imp_zless_or_eq]) 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
84 |
qed "moving_down"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
85 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
86 |
Goal "Lift : Always bounded"; |
7403 | 87 |
by (cut_facts_tac [moving_up, moving_down] 1); |
88 |
by (always_tac 1); |
|
5563 | 89 |
by (ALLGOALS Clarify_tac); |
90 |
by (REPEAT_FIRST distinct_tac); |
|
6161 | 91 |
by Auto_tac; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
92 |
qed "bounded"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
93 |
|
5320 | 94 |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
95 |
|
5320 | 96 |
(*** Progress ***) |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
97 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
98 |
|
5320 | 99 |
val abbrev_defs = [moving_def, stopped_def, |
5340 | 100 |
opened_def, closed_def, atFloor_def, Req_def]; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
101 |
|
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
102 |
Addsimps (map simp_of_set abbrev_defs); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
103 |
|
5340 | 104 |
|
105 |
(** The HUG'93 paper mistakenly omits the Req n from these! **) |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
106 |
|
5357 | 107 |
(** Lift_1 **) |
108 |
||
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
109 |
Goal "Lift : (stopped Int atFloor n) LeadsTo (opened Int atFloor n)"; |
5340 | 110 |
by (cut_facts_tac [stop_floor] 1); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
111 |
by (ensures_tac "open_act" 1); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
112 |
qed "E_thm01"; (*lem_lift_1_5*) |
5340 | 113 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
114 |
Goal "Lift : (Req n Int stopped - atFloor n) LeadsTo \ |
6139 | 115 |
\ (Req n Int opened - atFloor n)"; |
5340 | 116 |
by (cut_facts_tac [stop_floor] 1); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
117 |
by (ensures_tac "open_act" 1); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
118 |
qed "E_thm02"; (*lem_lift_1_1*) |
5340 | 119 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
120 |
Goal "Lift : (Req n Int opened - atFloor n) LeadsTo \ |
6139 | 121 |
\ (Req n Int closed - (atFloor n - queueing))"; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
122 |
by (ensures_tac "close_act" 1); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
123 |
qed "E_thm03"; (*lem_lift_1_2*) |
5340 | 124 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
125 |
Goal "Lift : (Req n Int closed Int (atFloor n - queueing)) \ |
6536 | 126 |
\ LeadsTo (opened Int atFloor n)"; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
127 |
by (ensures_tac "open_act" 1); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
128 |
qed "E_thm04"; (*lem_lift_1_7*) |
5340 | 129 |
|
130 |
||
5357 | 131 |
(** Lift 2. Statements of thm05a and thm05b were wrong! **) |
5340 | 132 |
|
133 |
Open_locale "floor"; |
|
134 |
||
5357 | 135 |
val Min_le_n = thm "Min_le_n"; |
136 |
val n_le_Max = thm "n_le_Max"; |
|
137 |
||
138 |
AddIffs [Min_le_n, n_le_Max]; |
|
5340 | 139 |
|
6676 | 140 |
val le_MinD = Min_le_n RS order_antisym; |
141 |
val Max_leD = n_le_Max RSN (2,order_antisym); |
|
5357 | 142 |
|
6676 | 143 |
val linorder_leI = linorder_not_less RS iffD1; |
144 |
||
145 |
AddSDs [le_MinD, linorder_leI RS le_MinD, |
|
146 |
Max_leD, linorder_leI RS Max_leD]; |
|
5357 | 147 |
|
148 |
(*lem_lift_2_0 |
|
149 |
NOT an ensures property, but a mere inclusion; |
|
150 |
don't know why script lift_2.uni says ENSURES*) |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
151 |
Goal "Lift : (Req n Int closed - (atFloor n - queueing)) \ |
6536 | 152 |
\ LeadsTo ((closed Int goingup Int Req n) Un \ |
6139 | 153 |
\ (closed Int goingdown Int Req n))"; |
7403 | 154 |
by (auto_tac (claset() addSIs [subset_imp_LeadsTo] addSEs [int_neqE], |
155 |
simpset())); |
|
5340 | 156 |
qed "E_thm05c"; |
157 |
||
5357 | 158 |
(*lift_2*) |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
159 |
Goal "Lift : (Req n Int closed - (atFloor n - queueing)) \ |
6536 | 160 |
\ LeadsTo (moving Int Req n)"; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
161 |
by (rtac ([E_thm05c, LeadsTo_Un] MRS LeadsTo_Trans) 1); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
162 |
by (ensures_tac "req_down" 2); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
163 |
by (ensures_tac "req_up" 1); |
5424
771a68a468cc
modified proofs for new constrains_tac and ensures_tac
paulson
parents:
5410
diff
changeset
|
164 |
by Auto_tac; |
5340 | 165 |
qed "lift_2"; |
166 |
||
167 |
||
5357 | 168 |
(** Towards lift_4 ***) |
5563 | 169 |
|
5357 | 170 |
|
171 |
(*lem_lift_4_1 *) |
|
5563 | 172 |
Goal "#0 < N ==> \ |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
173 |
\ Lift : (moving Int Req n Int {s. metric n s = N} Int \ |
6536 | 174 |
\ {s. floor s ~: req s} Int {s. up s}) \ |
175 |
\ LeadsTo \ |
|
6139 | 176 |
\ (moving Int Req n Int {s. metric n s < N})"; |
5357 | 177 |
by (cut_facts_tac [moving_up] 1); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
178 |
by (ensures_tac "move_up" 1); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
179 |
by Safe_tac; |
5357 | 180 |
(*this step consolidates two formulae to the goal metric n s' <= metric n s*) |
6676 | 181 |
by (etac (linorder_leI RS order_antisym RS sym) 1); |
7403 | 182 |
by (REPEAT_FIRST (eresolve_tac mov_metrics ORELSE' distinct_tac)); |
5563 | 183 |
(** LEVEL 6 **) |
7403 | 184 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps metric_simps @ zcompare_rls))); |
5357 | 185 |
qed "E_thm12a"; |
186 |
||
187 |
||
188 |
(*lem_lift_4_3 *) |
|
5563 | 189 |
Goal "#0 < N ==> \ |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
190 |
\ Lift : (moving Int Req n Int {s. metric n s = N} Int \ |
6536 | 191 |
\ {s. floor s ~: req s} - {s. up s}) \ |
192 |
\ LeadsTo (moving Int Req n Int {s. metric n s < N})"; |
|
5357 | 193 |
by (cut_facts_tac [moving_down] 1); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
194 |
by (ensures_tac "move_down" 1); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
195 |
by Safe_tac; |
5357 | 196 |
(*this step consolidates two formulae to the goal metric n s' <= metric n s*) |
6676 | 197 |
by (etac (linorder_leI RS order_antisym RS sym) 1); |
7403 | 198 |
by (REPEAT_FIRST (eresolve_tac mov_metrics ORELSE' distinct_tac)); |
5563 | 199 |
(** LEVEL 6 **) |
6139 | 200 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps metric_simps @ zcompare_rls))); |
5357 | 201 |
qed "E_thm12b"; |
202 |
||
203 |
(*lift_4*) |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
204 |
Goal "#0<N ==> Lift : (moving Int Req n Int {s. metric n s = N} Int \ |
6536 | 205 |
\ {s. floor s ~: req s}) LeadsTo \ |
5563 | 206 |
\ (moving Int Req n Int {s. metric n s < N})"; |
7403 | 207 |
by (rtac ([subset_imp_LeadsTo, [E_thm12a, E_thm12b] MRS LeadsTo_Un] |
208 |
MRS LeadsTo_Trans) 1); |
|
209 |
by Auto_tac; |
|
5357 | 210 |
qed "lift_4"; |
211 |
||
212 |
||
213 |
(** towards lift_5 **) |
|
214 |
||
215 |
(*lem_lift_5_3*) |
|
5563 | 216 |
Goal "#0<N \ |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
217 |
\ ==> Lift : (closed Int Req n Int {s. metric n s = N} Int goingup) LeadsTo \ |
5563 | 218 |
\ (moving Int Req n Int {s. metric n s < N})"; |
5357 | 219 |
by (cut_facts_tac [bounded] 1); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
220 |
by (ensures_tac "req_up" 1); |
5424
771a68a468cc
modified proofs for new constrains_tac and ensures_tac
paulson
parents:
5410
diff
changeset
|
221 |
by Auto_tac; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
222 |
by (REPEAT_FIRST (eresolve_tac mov_metrics)); |
6139 | 223 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps metric_simps @ zcompare_rls))); |
6128 | 224 |
by (Blast_tac 1); |
5357 | 225 |
qed "E_thm16a"; |
226 |
||
7079
eec20608c791
removed the combine_coeff simproc because linear arith does not handle
paulson
parents:
7000
diff
changeset
|
227 |
(*Must sometimes delete them because they introduce multiplication*) |
eec20608c791
removed the combine_coeff simproc because linear arith does not handle
paulson
parents:
7000
diff
changeset
|
228 |
val metric_ss = simpset() delsimprocs [Int_CC.sum_conv, Int_CC.rel_conv] |
eec20608c791
removed the combine_coeff simproc because linear arith does not handle
paulson
parents:
7000
diff
changeset
|
229 |
addsimps metric_simps; |
eec20608c791
removed the combine_coeff simproc because linear arith does not handle
paulson
parents:
7000
diff
changeset
|
230 |
|
eec20608c791
removed the combine_coeff simproc because linear arith does not handle
paulson
parents:
7000
diff
changeset
|
231 |
|
5357 | 232 |
(*lem_lift_5_1 has ~goingup instead of goingdown*) |
5563 | 233 |
Goal "#0<N ==> \ |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
234 |
\ Lift : (closed Int Req n Int {s. metric n s = N} Int goingdown) LeadsTo \ |
5563 | 235 |
\ (moving Int Req n Int {s. metric n s < N})"; |
5357 | 236 |
by (cut_facts_tac [bounded] 1); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
237 |
by (ensures_tac "req_down" 1); |
5424
771a68a468cc
modified proofs for new constrains_tac and ensures_tac
paulson
parents:
5410
diff
changeset
|
238 |
by Auto_tac; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
239 |
by (REPEAT_FIRST (eresolve_tac mov_metrics)); |
7079
eec20608c791
removed the combine_coeff simproc because linear arith does not handle
paulson
parents:
7000
diff
changeset
|
240 |
by (ALLGOALS (asm_simp_tac (metric_ss addsimps zcompare_rls))); |
6128 | 241 |
by (Blast_tac 1); |
5357 | 242 |
qed "E_thm16b"; |
243 |
||
244 |
||
245 |
(*lem_lift_5_0 proves an intersection involving ~goingup and goingup, |
|
246 |
i.e. the trivial disjunction, leading to an asymmetrical proof.*) |
|
5563 | 247 |
Goal "#0<N ==> Req n Int {s. metric n s = N} <= goingup Un goingdown"; |
7079
eec20608c791
removed the combine_coeff simproc because linear arith does not handle
paulson
parents:
7000
diff
changeset
|
248 |
by (asm_simp_tac metric_ss 1); |
5758
27a2b36efd95
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5706
diff
changeset
|
249 |
by (force_tac (claset() delrules [impCE] addEs [impCE], |
6139 | 250 |
simpset() addsimps conj_comms) 1); |
5357 | 251 |
qed "E_thm16c"; |
252 |
||
253 |
||
254 |
(*lift_5*) |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
255 |
Goal "#0<N ==> Lift : (closed Int Req n Int {s. metric n s = N}) LeadsTo \ |
5563 | 256 |
\ (moving Int Req n Int {s. metric n s < N})"; |
7403 | 257 |
by (rtac ([subset_imp_LeadsTo, [E_thm16a, E_thm16b] MRS LeadsTo_Un] |
258 |
MRS LeadsTo_Trans) 1); |
|
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
259 |
by (dtac E_thm16c 1); |
7403 | 260 |
by Auto_tac; |
5357 | 261 |
qed "lift_5"; |
262 |
||
263 |
||
264 |
(** towards lift_3 **) |
|
265 |
||
266 |
(*lemma used to prove lem_lift_3_1*) |
|
5563 | 267 |
Goal "[| metric n s = #0; Min <= floor s; floor s <= Max |] ==> floor s = n"; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
268 |
by (etac rev_mp 1); |
5563 | 269 |
(*force simplification of "metric..." while in conclusion part*) |
7079
eec20608c791
removed the combine_coeff simproc because linear arith does not handle
paulson
parents:
7000
diff
changeset
|
270 |
by (asm_simp_tac metric_ss 1); |
5357 | 271 |
qed "metric_eq_0D"; |
272 |
||
273 |
AddDs [metric_eq_0D]; |
|
274 |
||
275 |
||
276 |
(*lem_lift_3_1*) |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
277 |
Goal "Lift : (moving Int Req n Int {s. metric n s = #0}) LeadsTo \ |
5357 | 278 |
\ (stopped Int atFloor n)"; |
279 |
by (cut_facts_tac [bounded] 1); |
|
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
280 |
by (ensures_tac "request_act" 1); |
5424
771a68a468cc
modified proofs for new constrains_tac and ensures_tac
paulson
parents:
5410
diff
changeset
|
281 |
by Auto_tac; |
5357 | 282 |
qed "E_thm11"; |
283 |
||
6916 | 284 |
val metric_tac = REPEAT (FIRSTGOAL (eresolve_tac mov_metrics)) |
7079
eec20608c791
removed the combine_coeff simproc because linear arith does not handle
paulson
parents:
7000
diff
changeset
|
285 |
THEN auto_tac (claset(), metric_ss); |
6916 | 286 |
|
5357 | 287 |
(*lem_lift_3_5*) |
6536 | 288 |
Goal |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
289 |
"Lift : (moving Int Req n Int {s. metric n s = N} Int {s. floor s : req s}) \ |
6536 | 290 |
\ LeadsTo (stopped Int Req n Int {s. metric n s = N} Int {s. floor s : req s})"; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
291 |
by (ensures_tac "request_act" 1); |
6916 | 292 |
by metric_tac; |
5357 | 293 |
qed "E_thm13"; |
294 |
||
295 |
(*lem_lift_3_6*) |
|
5563 | 296 |
Goal "#0 < N ==> \ |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
297 |
\ Lift : \ |
5563 | 298 |
\ (stopped Int Req n Int {s. metric n s = N} Int {s. floor s : req s}) \ |
6536 | 299 |
\ LeadsTo (opened Int Req n Int {s. metric n s = N})"; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
300 |
by (ensures_tac "open_act" 1); |
6916 | 301 |
by metric_tac; |
5357 | 302 |
qed "E_thm14"; |
303 |
||
304 |
(*lem_lift_3_7*) |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
305 |
Goal "Lift : (opened Int Req n Int {s. metric n s = N}) \ |
6536 | 306 |
\ LeadsTo (closed Int Req n Int {s. metric n s = N})"; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
307 |
by (ensures_tac "close_act" 1); |
6916 | 308 |
by metric_tac; |
5357 | 309 |
qed "E_thm15"; |
310 |
||
311 |
||
312 |
(** the final steps **) |
|
313 |
||
5563 | 314 |
Goal "#0 < N ==> \ |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
315 |
\ Lift : \ |
5563 | 316 |
\ (moving Int Req n Int {s. metric n s = N} Int {s. floor s : req s}) \ |
6536 | 317 |
\ LeadsTo (moving Int Req n Int {s. metric n s < N})"; |
5479 | 318 |
by (blast_tac (claset() addSIs [E_thm13, E_thm14, E_thm15, lift_5] |
319 |
addIs [LeadsTo_Trans]) 1); |
|
5357 | 320 |
qed "lift_3_Req"; |
321 |
||
322 |
||
5563 | 323 |
(*Now we observe that our integer metric is really a natural number*) |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
324 |
Goal "Lift : Always {s. #0 <= metric n s}"; |
6570 | 325 |
by (rtac (bounded RS Always_weaken) 1); |
6916 | 326 |
by metric_tac; |
6570 | 327 |
qed "Always_nonneg"; |
5563 | 328 |
|
6570 | 329 |
val R_thm11 = [Always_nonneg, E_thm11] MRS Always_LeadsTo_weaken; |
5563 | 330 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
331 |
Goal "Lift : (moving Int Req n) LeadsTo (stopped Int atFloor n)"; |
6570 | 332 |
by (rtac (Always_nonneg RS integ_0_le_induct) 1); |
5563 | 333 |
by (case_tac "#0 < z" 1); |
334 |
(*If z <= #0 then actually z = #0*) |
|
7403 | 335 |
by (force_tac (claset() addIs [R_thm11, order_antisym], |
336 |
simpset() addsimps [linorder_not_less]) 2); |
|
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
337 |
by (rtac ([asm_rl, Un_upper1] MRS LeadsTo_weaken_R) 1); |
7403 | 338 |
by (rtac ([subset_imp_LeadsTo, [lift_4, lift_3_Req] MRS LeadsTo_Un] |
339 |
MRS LeadsTo_Trans) 1); |
|
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
340 |
by Auto_tac; |
5357 | 341 |
qed "lift_3"; |
342 |
||
343 |
||
7403 | 344 |
val LeadsTo_Trans_Un' = rotate_prems 1 LeadsTo_Trans_Un; |
345 |
(* [| Lift: B LeadsTo C; Lift: A LeadsTo B |] ==> Lift: (A Un B) LeadsTo C *) |
|
346 |
||
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
347 |
Goal "Lift : (Req n) LeadsTo (opened Int atFloor n)"; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
348 |
by (rtac LeadsTo_Trans 1); |
7403 | 349 |
by (rtac ([E_thm04, LeadsTo_Un_post] MRS LeadsTo_Un) 2); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
350 |
by (rtac (E_thm01 RS LeadsTo_Trans_Un') 2); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
351 |
by (rtac (lift_3 RS LeadsTo_Trans_Un') 2); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
352 |
by (rtac (lift_2 RS LeadsTo_Trans_Un') 2); |
7403 | 353 |
by (rtac ([E_thm03,E_thm02] MRS LeadsTo_Trans_Un') 2); |
6570 | 354 |
by (rtac (open_move RS Always_LeadsToI) 1); |
7403 | 355 |
by (rtac ([open_stop, subset_imp_LeadsTo] MRS Always_LeadsToI) 1); |
5340 | 356 |
by (Clarify_tac 1); |
5484 | 357 |
(*The case split is not essential but makes Blast_tac much faster. |
7403 | 358 |
Calling rotate_tac prevents simplification from looping*) |
5484 | 359 |
by (case_tac "open x" 1); |
360 |
by (ALLGOALS (rotate_tac ~1)); |
|
7403 | 361 |
by Auto_tac; |
5340 | 362 |
qed "lift_1"; |
363 |
||
6024 | 364 |
Close_locale "floor"; |