107 ML {* |
107 ML {* |
108 (* The following functions are specialized versions of the corresponding |
108 (* The following functions are specialized versions of the corresponding |
109 functions defined in Intensional.ML in that they introduce a |
109 functions defined in Intensional.ML in that they introduce a |
110 "world" parameter of the form (s,t) and apply additional rewrites. |
110 "world" parameter of the form (s,t) and apply additional rewrites. |
111 *) |
111 *) |
112 local |
|
113 val action_rews = thms "action_rews"; |
|
114 val actionD = thm "actionD"; |
|
115 in |
|
116 |
112 |
117 fun action_unlift th = |
113 fun action_unlift th = |
118 (rewrite_rule action_rews (th RS actionD)) |
114 (rewrite_rule @{thms action_rews} (th RS @{thm actionD})) |
119 handle THM _ => int_unlift th; |
115 handle THM _ => int_unlift th; |
120 |
116 |
121 (* Turn |- A = B into meta-level rewrite rule A == B *) |
117 (* Turn |- A = B into meta-level rewrite rule A == B *) |
122 val action_rewrite = int_rewrite |
118 val action_rewrite = int_rewrite |
123 |
119 |
124 fun action_use th = |
120 fun action_use th = |
125 case (concl_of th) of |
121 case (concl_of th) of |
126 Const _ $ (Const ("Intensional.Valid", _) $ _) => |
122 Const _ $ (Const ("Intensional.Valid", _) $ _) => |
127 (flatten (action_unlift th) handle THM _ => th) |
123 (flatten (action_unlift th) handle THM _ => th) |
128 | _ => th; |
124 | _ => th; |
129 |
|
130 end |
|
131 *} |
125 *} |
132 |
126 |
133 setup {* |
127 setup {* |
134 Attrib.add_attributes [ |
128 Attrib.add_attributes [ |
135 ("action_unlift", Attrib.no_args (Thm.rule_attribute (K action_unlift)), ""), |
129 ("action_unlift", Attrib.no_args (Thm.rule_attribute (K action_unlift)), ""), |
267 ML {* |
261 ML {* |
268 (* A dumb simplification-based tactic with just a little first-order logic: |
262 (* A dumb simplification-based tactic with just a little first-order logic: |
269 should plug in only "very safe" rules that can be applied blindly. |
263 should plug in only "very safe" rules that can be applied blindly. |
270 Note that it applies whatever simplifications are currently active. |
264 Note that it applies whatever simplifications are currently active. |
271 *) |
265 *) |
272 local |
|
273 val actionI = thm "actionI"; |
|
274 val intI = thm "intI"; |
|
275 in |
|
276 |
|
277 fun action_simp_tac ss intros elims = |
266 fun action_simp_tac ss intros elims = |
278 asm_full_simp_tac |
267 asm_full_simp_tac |
279 (ss setloop ((resolve_tac ((map action_use intros) |
268 (ss setloop ((resolve_tac ((map action_use intros) |
280 @ [refl,impI,conjI,actionI,intI,allI])) |
269 @ [refl,impI,conjI,@{thm actionI},@{thm intI},allI])) |
281 ORELSE' (eresolve_tac ((map action_use elims) |
270 ORELSE' (eresolve_tac ((map action_use elims) |
282 @ [conjE,disjE,exE])))); |
271 @ [conjE,disjE,exE])))); |
283 |
|
284 (* default version without additional plug-in rules *) |
|
285 val Action_simp_tac = action_simp_tac (simpset()) [] [] |
|
286 |
|
287 end |
|
288 *} |
272 *} |
289 |
273 |
290 (* ---------------- enabled_tac: tactic to prove (Enabled A) -------------------- *) |
274 (* ---------------- enabled_tac: tactic to prove (Enabled A) -------------------- *) |
291 |
275 |
292 ML {* |
276 ML {* |
297 variables in the successor state, and resolve the goal with the result. |
281 variables in the successor state, and resolve the goal with the result. |
298 - Resolve with enabledI and do some rewriting. |
282 - Resolve with enabledI and do some rewriting. |
299 - Solve for the unknowns using standard HOL reasoning. |
283 - Solve for the unknowns using standard HOL reasoning. |
300 The following tactic combines these steps except the final one. |
284 The following tactic combines these steps except the final one. |
301 *) |
285 *) |
302 local |
286 |
303 val base_enabled = thm "base_enabled"; |
287 fun enabled_tac (cs, ss) base_vars = |
304 in |
288 clarsimp_tac (cs addSIs [base_vars RS @{thm base_enabled}], ss); |
305 |
|
306 fun enabled_tac base_vars = |
|
307 clarsimp_tac (claset() addSIs [base_vars RS base_enabled], simpset()); |
|
308 |
|
309 end |
|
310 *} |
289 *} |
311 |
290 |
312 (* Example *) |
291 (* Example *) |
313 |
292 |
314 lemma |
293 lemma |
315 assumes "basevars (x,y,z)" |
294 assumes "basevars (x,y,z)" |
316 shows "|- x --> Enabled ($x & (y$ = #False))" |
295 shows "|- x --> Enabled ($x & (y$ = #False))" |
317 apply (tactic {* enabled_tac (thm "assms") 1 *}) |
296 apply (tactic {* enabled_tac @{clasimpset} @{thm assms} 1 *}) |
318 apply auto |
297 apply auto |
319 done |
298 done |
320 |
299 |
321 end |
300 end |