author | paulson |
Mon, 24 May 1999 15:56:24 +0200 | |
changeset 6718 | e869ff059252 |
parent 6676 | 62d1e642da30 |
child 6740 | 5b5bf511fdd5 |
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 |
|
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
9 |
(*split_all_tac causes a big blow-up*) |
5706 | 10 |
claset_ref() := claset() delSWrapper record_split_name; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
11 |
|
5563 | 12 |
Goal "[| x ~: A; y : A |] ==> x ~= y"; |
13 |
by (Blast_tac 1); |
|
14 |
qed "not_mem_distinct"; |
|
15 |
||
16 |
fun distinct_tac i = |
|
17 |
dtac zle_neq_implies_zless i THEN |
|
18 |
eresolve_tac [not_mem_distinct, not_mem_distinct RS not_sym] i THEN |
|
19 |
assume_tac i; |
|
20 |
||
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
21 |
|
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
22 |
(** 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
|
23 |
val mov_metric1 = 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_metric2 = 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 |
|
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
29 |
val mov_metric3 = read_instantiate_sg (sign_of thy) |
5596 | 30 |
[("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
|
31 |
|
5563 | 32 |
val mov_metric4 = read_instantiate_sg (sign_of thy) |
5596 | 33 |
[("P", "(?x <= metric ?n ?s)")] rev_mp; |
5563 | 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...*) |
5563 | 36 |
val mov_metrics = [mov_metric2, mov_metric3, mov_metric1, mov_metric4]; |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
37 |
|
6139 | 38 |
val metric_simps = [metric_def, vimage_def]; |
5563 | 39 |
|
5340 | 40 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
41 |
Addsimps [Lift_def RS def_prg_Init]; |
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
42 |
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
|
43 |
|
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
44 |
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
|
45 |
[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
|
46 |
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
|
47 |
button_press_def]); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
48 |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
49 |
val always_defs = [above_def, below_def, queueing_def, |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
50 |
goingup_def, goingdown_def, ready_def]; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
51 |
|
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
52 |
Addsimps (map simp_of_set always_defs); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
53 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
54 |
|
5583 | 55 |
val LeadsTo_Trans_Un' = rotate_prems 1 LeadsTo_Trans_Un; |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
56 |
(* [| Lift: B LeadsTo C; Lift: A LeadsTo B |] ==> Lift: (A Un B) LeadsTo C *) |
5357 | 57 |
|
58 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
59 |
(*Simplification for records*) |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
60 |
Addsimps (thms"state.update_defs"); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
61 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
62 |
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
|
63 |
moving_up_def, moving_down_def]; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
64 |
|
5357 | 65 |
AddIffs [Min_le_Max]; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
66 |
|
5320 | 67 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
68 |
Goal "Lift : Always open_stop"; |
6570 | 69 |
by (rtac AlwaysI 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
70 |
by (Force_tac 1); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
71 |
by (constrains_tac 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
72 |
qed "open_stop"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
73 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
74 |
Goal "Lift : Always stop_floor"; |
6570 | 75 |
by (rtac AlwaysI 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
76 |
by (Force_tac 1); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
77 |
by (constrains_tac 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
78 |
qed "stop_floor"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
79 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
80 |
(*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
|
81 |
Goal "Lift : Always open_move"; |
6570 | 82 |
by (rtac AlwaysI 1); |
83 |
by (rtac (open_stop RS Always_ConstrainsI RS StableI) 2); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
84 |
by (Force_tac 1); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
85 |
by (constrains_tac 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
86 |
qed "open_move"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
87 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
88 |
Goal "Lift : Always moving_up"; |
6570 | 89 |
by (rtac AlwaysI 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
90 |
by (Force_tac 1); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
91 |
by (constrains_tac 1); |
5563 | 92 |
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
|
93 |
qed "moving_up"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
94 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
95 |
Goal "Lift : Always moving_down"; |
6570 | 96 |
by (rtac AlwaysI 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
97 |
by (Force_tac 1); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
98 |
by (constrains_tac 1); |
5563 | 99 |
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
|
100 |
qed "moving_down"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
101 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
102 |
Goal "Lift : Always bounded"; |
6570 | 103 |
by (rtac AlwaysI 1); |
104 |
by (rtac (Always_Int_rule [moving_up, moving_down] RS Always_StableI) 2); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
105 |
by (Force_tac 1); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
106 |
by (constrains_tac 1); |
5563 | 107 |
by (ALLGOALS Clarify_tac); |
108 |
by (REPEAT_FIRST distinct_tac); |
|
6161 | 109 |
by Auto_tac; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
110 |
qed "bounded"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
111 |
|
5320 | 112 |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
113 |
|
5320 | 114 |
(*** Progress ***) |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
115 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
116 |
|
5320 | 117 |
val abbrev_defs = [moving_def, stopped_def, |
5340 | 118 |
opened_def, closed_def, atFloor_def, Req_def]; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
119 |
|
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
120 |
Addsimps (map simp_of_set abbrev_defs); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
diff
changeset
|
121 |
|
5340 | 122 |
|
123 |
(** 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
|
124 |
|
5357 | 125 |
(** Lift_1 **) |
126 |
||
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
127 |
Goal "Lift : (stopped Int atFloor n) LeadsTo (opened Int atFloor n)"; |
5340 | 128 |
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
|
129 |
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
|
130 |
qed "E_thm01"; (*lem_lift_1_5*) |
5340 | 131 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
132 |
Goal "Lift : (Req n Int stopped - atFloor n) LeadsTo \ |
6139 | 133 |
\ (Req n Int opened - atFloor n)"; |
5340 | 134 |
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
|
135 |
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
|
136 |
qed "E_thm02"; (*lem_lift_1_1*) |
5340 | 137 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
138 |
Goal "Lift : (Req n Int opened - atFloor n) LeadsTo \ |
6139 | 139 |
\ (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
|
140 |
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
|
141 |
qed "E_thm03"; (*lem_lift_1_2*) |
5340 | 142 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
143 |
Goal "Lift : (Req n Int closed Int (atFloor n - queueing)) \ |
6536 | 144 |
\ 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
|
145 |
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
|
146 |
qed "E_thm04"; (*lem_lift_1_7*) |
5340 | 147 |
|
148 |
||
5357 | 149 |
(** Lift 2. Statements of thm05a and thm05b were wrong! **) |
5340 | 150 |
|
151 |
Open_locale "floor"; |
|
152 |
||
5357 | 153 |
val Min_le_n = thm "Min_le_n"; |
154 |
val n_le_Max = thm "n_le_Max"; |
|
155 |
||
156 |
AddIffs [Min_le_n, n_le_Max]; |
|
5340 | 157 |
|
6676 | 158 |
val le_MinD = Min_le_n RS order_antisym; |
159 |
val Max_leD = n_le_Max RSN (2,order_antisym); |
|
5357 | 160 |
|
6676 | 161 |
val linorder_leI = linorder_not_less RS iffD1; |
162 |
||
163 |
AddSDs [le_MinD, linorder_leI RS le_MinD, |
|
164 |
Max_leD, linorder_leI RS Max_leD]; |
|
5357 | 165 |
|
166 |
(*lem_lift_2_0 |
|
167 |
NOT an ensures property, but a mere inclusion; |
|
168 |
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
|
169 |
Goal "Lift : (Req n Int closed - (atFloor n - queueing)) \ |
6536 | 170 |
\ LeadsTo ((closed Int goingup Int Req n) Un \ |
6139 | 171 |
\ (closed Int goingdown 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
|
172 |
by (rtac subset_imp_LeadsTo 1); |
5563 | 173 |
by (auto_tac (claset() addSEs [int_neqE], simpset())); |
5340 | 174 |
qed "E_thm05c"; |
175 |
||
5357 | 176 |
(*lift_2*) |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
177 |
Goal "Lift : (Req n Int closed - (atFloor n - queueing)) \ |
6536 | 178 |
\ 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
|
179 |
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
|
180 |
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
|
181 |
by (ensures_tac "req_up" 1); |
5424
771a68a468cc
modified proofs for new constrains_tac and ensures_tac
paulson
parents:
5410
diff
changeset
|
182 |
by Auto_tac; |
5340 | 183 |
qed "lift_2"; |
184 |
||
185 |
||
5357 | 186 |
(** Towards lift_4 ***) |
5563 | 187 |
|
5357 | 188 |
|
189 |
(*lem_lift_4_1 *) |
|
5563 | 190 |
Goal "#0 < N ==> \ |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
191 |
\ Lift : (moving Int Req n Int {s. metric n s = N} Int \ |
6536 | 192 |
\ {s. floor s ~: req s} Int {s. up s}) \ |
193 |
\ LeadsTo \ |
|
6139 | 194 |
\ (moving Int Req n Int {s. metric n s < N})"; |
5357 | 195 |
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
|
196 |
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
|
197 |
by Safe_tac; |
5357 | 198 |
(*this step consolidates two formulae to the goal metric n s' <= metric n s*) |
6676 | 199 |
by (etac (linorder_leI RS order_antisym RS sym) 1); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
200 |
by (REPEAT_FIRST (eresolve_tac mov_metrics)); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
201 |
by (REPEAT_FIRST distinct_tac); |
5563 | 202 |
(** LEVEL 6 **) |
5583 | 203 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps |
204 |
[zle_def] @ metric_simps @ zcompare_rls))); |
|
5357 | 205 |
qed "E_thm12a"; |
206 |
||
207 |
||
208 |
||
209 |
(*lem_lift_4_3 *) |
|
5563 | 210 |
Goal "#0 < N ==> \ |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
211 |
\ Lift : (moving Int Req n Int {s. metric n s = N} Int \ |
6536 | 212 |
\ {s. floor s ~: req s} - {s. up s}) \ |
213 |
\ LeadsTo (moving Int Req n Int {s. metric n s < N})"; |
|
5357 | 214 |
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
|
215 |
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
|
216 |
by Safe_tac; |
5357 | 217 |
(*this step consolidates two formulae to the goal metric n s' <= metric n s*) |
6676 | 218 |
by (etac (linorder_leI RS order_antisym RS sym) 1); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
219 |
by (REPEAT_FIRST (eresolve_tac mov_metrics)); |
5563 | 220 |
by (REPEAT_FIRST distinct_tac); |
221 |
(** LEVEL 6 **) |
|
6139 | 222 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps metric_simps @ zcompare_rls))); |
5357 | 223 |
qed "E_thm12b"; |
224 |
||
225 |
(*lift_4*) |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
226 |
Goal "#0<N ==> Lift : (moving Int Req n Int {s. metric n s = N} Int \ |
6536 | 227 |
\ {s. floor s ~: req s}) LeadsTo \ |
5563 | 228 |
\ (moving 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
|
229 |
by (rtac ([subset_imp_LeadsTo, LeadsTo_Un] MRS LeadsTo_Trans) 1); |
5583 | 230 |
by (etac E_thm12b 3); |
231 |
by (etac E_thm12a 2); |
|
5357 | 232 |
by (Blast_tac 1); |
233 |
qed "lift_4"; |
|
234 |
||
235 |
||
236 |
(** towards lift_5 **) |
|
237 |
||
238 |
(*lem_lift_5_3*) |
|
5563 | 239 |
Goal "#0<N \ |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
240 |
\ ==> Lift : (closed Int Req n Int {s. metric n s = N} Int goingup) LeadsTo \ |
5563 | 241 |
\ (moving Int Req n Int {s. metric n s < N})"; |
5357 | 242 |
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
|
243 |
by (ensures_tac "req_up" 1); |
5424
771a68a468cc
modified proofs for new constrains_tac and ensures_tac
paulson
parents:
5410
diff
changeset
|
244 |
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
|
245 |
by (REPEAT_FIRST (eresolve_tac mov_metrics)); |
6139 | 246 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps metric_simps @ zcompare_rls))); |
6128 | 247 |
by (Blast_tac 1); |
5357 | 248 |
qed "E_thm16a"; |
249 |
||
250 |
(*lem_lift_5_1 has ~goingup instead of goingdown*) |
|
5563 | 251 |
Goal "#0<N ==> \ |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
252 |
\ Lift : (closed Int Req n Int {s. metric n s = N} Int goingdown) LeadsTo \ |
5563 | 253 |
\ (moving Int Req n Int {s. metric n s < N})"; |
5357 | 254 |
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
|
255 |
by (ensures_tac "req_down" 1); |
5424
771a68a468cc
modified proofs for new constrains_tac and ensures_tac
paulson
parents:
5410
diff
changeset
|
256 |
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
|
257 |
by (REPEAT_FIRST (eresolve_tac mov_metrics)); |
6139 | 258 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps metric_simps @ zcompare_rls))); |
6128 | 259 |
by (Blast_tac 1); |
5357 | 260 |
qed "E_thm16b"; |
261 |
||
262 |
||
263 |
||
264 |
(*lem_lift_5_0 proves an intersection involving ~goingup and goingup, |
|
265 |
i.e. the trivial disjunction, leading to an asymmetrical proof.*) |
|
5563 | 266 |
Goal "#0<N ==> Req n Int {s. metric n s = N} <= goingup Un goingdown"; |
267 |
by (asm_simp_tac (simpset() addsimps metric_simps) 1); |
|
5758
27a2b36efd95
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5706
diff
changeset
|
268 |
by (force_tac (claset() delrules [impCE] addEs [impCE], |
6139 | 269 |
simpset() addsimps conj_comms) 1); |
5357 | 270 |
qed "E_thm16c"; |
271 |
||
272 |
||
273 |
(*lift_5*) |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
274 |
Goal "#0<N ==> Lift : (closed Int Req n Int {s. metric n s = N}) LeadsTo \ |
5563 | 275 |
\ (moving 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
|
276 |
by (rtac ([subset_imp_LeadsTo, LeadsTo_Un] MRS LeadsTo_Trans) 1); |
5583 | 277 |
by (etac E_thm16b 3); |
278 |
by (etac E_thm16a 2); |
|
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
279 |
by (dtac E_thm16c 1); |
5357 | 280 |
by (Blast_tac 1); |
281 |
qed "lift_5"; |
|
282 |
||
283 |
||
284 |
(** towards lift_3 **) |
|
285 |
||
286 |
(*lemma used to prove lem_lift_3_1*) |
|
5563 | 287 |
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
|
288 |
by (etac rev_mp 1); |
5563 | 289 |
(*force simplification of "metric..." while in conclusion part*) |
290 |
by (asm_simp_tac (simpset() addsimps metric_simps) 1); |
|
5357 | 291 |
qed "metric_eq_0D"; |
292 |
||
293 |
AddDs [metric_eq_0D]; |
|
294 |
||
295 |
||
296 |
(*lem_lift_3_1*) |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
297 |
Goal "Lift : (moving Int Req n Int {s. metric n s = #0}) LeadsTo \ |
5357 | 298 |
\ (stopped Int atFloor n)"; |
299 |
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
|
300 |
by (ensures_tac "request_act" 1); |
5424
771a68a468cc
modified proofs for new constrains_tac and ensures_tac
paulson
parents:
5410
diff
changeset
|
301 |
by Auto_tac; |
5357 | 302 |
qed "E_thm11"; |
303 |
||
304 |
(*lem_lift_3_5*) |
|
6536 | 305 |
Goal |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
306 |
"Lift : (moving Int Req n Int {s. metric n s = N} Int {s. floor s : req s}) \ |
6536 | 307 |
\ 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
|
308 |
by (ensures_tac "request_act" 1); |
5424
771a68a468cc
modified proofs for new constrains_tac and ensures_tac
paulson
parents:
5410
diff
changeset
|
309 |
by (auto_tac (claset(), simpset() addsimps metric_simps)); |
5357 | 310 |
qed "E_thm13"; |
311 |
||
312 |
(*lem_lift_3_6*) |
|
5563 | 313 |
Goal "#0 < N ==> \ |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
314 |
\ Lift : \ |
5563 | 315 |
\ (stopped Int Req n Int {s. metric n s = N} Int {s. floor s : req s}) \ |
6536 | 316 |
\ 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
|
317 |
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
|
318 |
by (REPEAT_FIRST (eresolve_tac mov_metrics)); |
5424
771a68a468cc
modified proofs for new constrains_tac and ensures_tac
paulson
parents:
5410
diff
changeset
|
319 |
by (auto_tac (claset(), simpset() addsimps metric_simps)); |
5357 | 320 |
qed "E_thm14"; |
321 |
||
322 |
(*lem_lift_3_7*) |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
323 |
Goal "Lift : (opened Int Req n Int {s. metric n s = N}) \ |
6536 | 324 |
\ 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
|
325 |
by (ensures_tac "close_act" 1); |
5424
771a68a468cc
modified proofs for new constrains_tac and ensures_tac
paulson
parents:
5410
diff
changeset
|
326 |
by (auto_tac (claset(), simpset() addsimps metric_simps)); |
5357 | 327 |
qed "E_thm15"; |
328 |
||
329 |
||
330 |
(** the final steps **) |
|
331 |
||
5563 | 332 |
Goal "#0 < N ==> \ |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
333 |
\ Lift : \ |
5563 | 334 |
\ (moving Int Req n Int {s. metric n s = N} Int {s. floor s : req s}) \ |
6536 | 335 |
\ LeadsTo (moving Int Req n Int {s. metric n s < N})"; |
5479 | 336 |
by (blast_tac (claset() addSIs [E_thm13, E_thm14, E_thm15, lift_5] |
337 |
addIs [LeadsTo_Trans]) 1); |
|
5357 | 338 |
qed "lift_3_Req"; |
339 |
||
340 |
||
5563 | 341 |
|
342 |
(*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
|
343 |
Goal "Lift : Always {s. #0 <= metric n s}"; |
6570 | 344 |
by (rtac (bounded RS Always_weaken) 1); |
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
345 |
by (auto_tac (claset(), simpset() addsimps metric_simps)); |
6570 | 346 |
qed "Always_nonneg"; |
5563 | 347 |
|
6570 | 348 |
val R_thm11 = [Always_nonneg, E_thm11] MRS Always_LeadsTo_weaken; |
5563 | 349 |
|
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
350 |
Goal "Lift : (moving Int Req n) LeadsTo (stopped Int atFloor n)"; |
6570 | 351 |
by (rtac (Always_nonneg RS integ_0_le_induct) 1); |
5563 | 352 |
by (case_tac "#0 < z" 1); |
353 |
(*If z <= #0 then actually z = #0*) |
|
354 |
by (fold_tac [zle_def]); |
|
6676 | 355 |
by (force_tac (claset() addIs [R_thm11, order_antisym], simpset()) 2); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
356 |
by (rtac ([asm_rl, Un_upper1] MRS LeadsTo_weaken_R) 1); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
357 |
by (rtac ([subset_imp_LeadsTo, LeadsTo_Un] MRS LeadsTo_Trans) 1); |
5583 | 358 |
by (rtac lift_3_Req 3); |
359 |
by (rtac lift_4 2); |
|
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
360 |
by Auto_tac; |
5357 | 361 |
qed "lift_3"; |
362 |
||
363 |
||
6718
e869ff059252
renamed Lprg to Lift; simplified proof of Always_nonneg
paulson
parents:
6676
diff
changeset
|
364 |
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
|
365 |
by (rtac LeadsTo_Trans 1); |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
366 |
by (rtac (E_thm04 RS LeadsTo_Un) 2); |
5583 | 367 |
by (rtac LeadsTo_Un_post 2); |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
368 |
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
|
369 |
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
|
370 |
by (rtac (lift_2 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
|
371 |
by (rtac (E_thm03 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
|
372 |
by (rtac E_thm02 2); |
6570 | 373 |
by (rtac (open_move RS Always_LeadsToI) 1); |
374 |
by (rtac (open_stop RS Always_LeadsToI) 1); |
|
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
375 |
by (rtac subset_imp_LeadsTo 1); |
5340 | 376 |
by (Clarify_tac 1); |
5484 | 377 |
(*The case split is not essential but makes Blast_tac much faster. |
378 |
Must also be careful to prevent simplification from looping*) |
|
379 |
by (case_tac "open x" 1); |
|
380 |
by (ALLGOALS (rotate_tac ~1)); |
|
381 |
by (ALLGOALS Asm_full_simp_tac); |
|
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5424
diff
changeset
|
382 |
by (Blast_tac 1); |
5340 | 383 |
qed "lift_1"; |
384 |
||
6024 | 385 |
Close_locale "floor"; |