100 lemmas action_rews = act_rews intensional_rews |
100 lemmas action_rews = act_rews intensional_rews |
101 |
101 |
102 |
102 |
103 (* ================ Functions to "unlift" action theorems into HOL rules ================ *) |
103 (* ================ Functions to "unlift" action theorems into HOL rules ================ *) |
104 |
104 |
105 ML {* |
105 ML \<open> |
106 (* The following functions are specialized versions of the corresponding |
106 (* The following functions are specialized versions of the corresponding |
107 functions defined in Intensional.ML in that they introduce a |
107 functions defined in Intensional.ML in that they introduce a |
108 "world" parameter of the form (s,t) and apply additional rewrites. |
108 "world" parameter of the form (s,t) and apply additional rewrites. |
109 *) |
109 *) |
110 |
110 |
118 fun action_use ctxt th = |
118 fun action_use ctxt th = |
119 case Thm.concl_of th of |
119 case Thm.concl_of th of |
120 Const _ $ (Const (@{const_name Valid}, _) $ _) => |
120 Const _ $ (Const (@{const_name Valid}, _) $ _) => |
121 (flatten (action_unlift ctxt th) handle THM _ => th) |
121 (flatten (action_unlift ctxt th) handle THM _ => th) |
122 | _ => th; |
122 | _ => th; |
123 *} |
123 \<close> |
124 |
124 |
125 attribute_setup action_unlift = |
125 attribute_setup action_unlift = |
126 {* Scan.succeed (Thm.rule_attribute (action_unlift o Context.proof_of)) *} |
126 \<open>Scan.succeed (Thm.rule_attribute (action_unlift o Context.proof_of))\<close> |
127 attribute_setup action_rewrite = |
127 attribute_setup action_rewrite = |
128 {* Scan.succeed (Thm.rule_attribute (action_rewrite o Context.proof_of)) *} |
128 \<open>Scan.succeed (Thm.rule_attribute (action_rewrite o Context.proof_of))\<close> |
129 attribute_setup action_use = |
129 attribute_setup action_use = |
130 {* Scan.succeed (Thm.rule_attribute (action_use o Context.proof_of)) *} |
130 \<open>Scan.succeed (Thm.rule_attribute (action_use o Context.proof_of))\<close> |
131 |
131 |
132 |
132 |
133 (* =========================== square / angle brackets =========================== *) |
133 (* =========================== square / angle brackets =========================== *) |
134 |
134 |
135 lemma idle_squareI: "(s,t) \<Turnstile> unchanged v \<Longrightarrow> (s,t) \<Turnstile> [A]_v" |
135 lemma idle_squareI: "(s,t) \<Turnstile> unchanged v \<Longrightarrow> (s,t) \<Turnstile> [A]_v" |
254 apply assumption |
254 apply assumption |
255 done |
255 done |
256 |
256 |
257 (* ======================= action_simp_tac ============================== *) |
257 (* ======================= action_simp_tac ============================== *) |
258 |
258 |
259 ML {* |
259 ML \<open> |
260 (* A dumb simplification-based tactic with just a little first-order logic: |
260 (* A dumb simplification-based tactic with just a little first-order logic: |
261 should plug in only "very safe" rules that can be applied blindly. |
261 should plug in only "very safe" rules that can be applied blindly. |
262 Note that it applies whatever simplifications are currently active. |
262 Note that it applies whatever simplifications are currently active. |
263 *) |
263 *) |
264 fun action_simp_tac ctxt intros elims = |
264 fun action_simp_tac ctxt intros elims = |
265 asm_full_simp_tac |
265 asm_full_simp_tac |
266 (ctxt setloop (fn _ => (resolve_tac ctxt ((map (action_use ctxt) intros) |
266 (ctxt setloop (fn _ => (resolve_tac ctxt ((map (action_use ctxt) intros) |
267 @ [refl,impI,conjI,@{thm actionI},@{thm intI},allI])) |
267 @ [refl,impI,conjI,@{thm actionI},@{thm intI},allI])) |
268 ORELSE' (eresolve_tac ctxt ((map (action_use ctxt) elims) |
268 ORELSE' (eresolve_tac ctxt ((map (action_use ctxt) elims) |
269 @ [conjE,disjE,exE])))); |
269 @ [conjE,disjE,exE])))); |
270 *} |
270 \<close> |
271 |
271 |
272 (* ---------------- enabled_tac: tactic to prove (Enabled A) -------------------- *) |
272 (* ---------------- enabled_tac: tactic to prove (Enabled A) -------------------- *) |
273 |
273 |
274 ML {* |
274 ML \<open> |
275 (* "Enabled A" can be proven as follows: |
275 (* "Enabled A" can be proven as follows: |
276 - Assume that we know which state variables are "base variables" |
276 - Assume that we know which state variables are "base variables" |
277 this should be expressed by a theorem of the form "basevars (x,y,z,...)". |
277 this should be expressed by a theorem of the form "basevars (x,y,z,...)". |
278 - Resolve this theorem with baseE to introduce a constant for the value of the |
278 - Resolve this theorem with baseE to introduce a constant for the value of the |
279 variables in the successor state, and resolve the goal with the result. |
279 variables in the successor state, and resolve the goal with the result. |
282 The following tactic combines these steps except the final one. |
282 The following tactic combines these steps except the final one. |
283 *) |
283 *) |
284 |
284 |
285 fun enabled_tac ctxt base_vars = |
285 fun enabled_tac ctxt base_vars = |
286 clarsimp_tac (ctxt addSIs [base_vars RS @{thm base_enabled}]); |
286 clarsimp_tac (ctxt addSIs [base_vars RS @{thm base_enabled}]); |
287 *} |
287 \<close> |
288 |
288 |
289 method_setup enabled = {* |
289 method_setup enabled = \<open> |
290 Attrib.thm >> (fn th => fn ctxt => SIMPLE_METHOD' (enabled_tac ctxt th)) |
290 Attrib.thm >> (fn th => fn ctxt => SIMPLE_METHOD' (enabled_tac ctxt th)) |
291 *} |
291 \<close> |
292 |
292 |
293 (* Example *) |
293 (* Example *) |
294 |
294 |
295 lemma |
295 lemma |
296 assumes "basevars (x,y,z)" |
296 assumes "basevars (x,y,z)" |