581 |
581 |
582 (* ---------------- (Semi-)automatic invariant tactics ---------------------- *) |
582 (* ---------------- (Semi-)automatic invariant tactics ---------------------- *) |
583 |
583 |
584 ML {* |
584 ML {* |
585 (* inv_tac reduces goals of the form ... ==> sigma |= []P *) |
585 (* inv_tac reduces goals of the form ... ==> sigma |= []P *) |
586 fun inv_tac css = SELECT_GOAL |
586 fun inv_tac ctxt = |
587 (EVERY [auto_tac css, |
587 SELECT_GOAL |
588 TRY (merge_box_tac 1), |
588 (EVERY |
589 rtac (temp_use @{thm INV1}) 1, (* fail if the goal is not a box *) |
589 [auto_tac ctxt, |
590 TRYALL (etac @{thm Stable})]); |
590 TRY (merge_box_tac 1), |
|
591 rtac (temp_use @{thm INV1}) 1, (* fail if the goal is not a box *) |
|
592 TRYALL (etac @{thm Stable})]); |
591 |
593 |
592 (* auto_inv_tac applies inv_tac and then tries to attack the subgoals |
594 (* auto_inv_tac applies inv_tac and then tries to attack the subgoals |
593 in simple cases it may be able to handle goals like |- MyProg --> []Inv. |
595 in simple cases it may be able to handle goals like |- MyProg --> []Inv. |
594 In these simple cases the simplifier seems to be more useful than the |
596 In these simple cases the simplifier seems to be more useful than the |
595 auto-tactic, which applies too much propositional logic and simplifies |
597 auto-tactic, which applies too much propositional logic and simplifies |
596 too late. |
598 too late. |
597 *) |
599 *) |
598 fun auto_inv_tac ss = SELECT_GOAL |
600 fun auto_inv_tac ss = |
599 ((inv_tac (@{claset}, ss) 1) THEN |
601 SELECT_GOAL |
600 (TRYALL (action_simp_tac |
602 (inv_tac (map_simpset_local (K ss) @{context}) 1 THEN |
601 (ss addsimps [@{thm Init_stp}, @{thm Init_act}]) [] [@{thm squareE}]))); |
603 (TRYALL (action_simp_tac |
|
604 (ss addsimps [@{thm Init_stp}, @{thm Init_act}]) [] [@{thm squareE}]))); |
602 *} |
605 *} |
603 |
606 |
604 method_setup invariant = {* |
607 method_setup invariant = {* |
605 Method.sections Clasimp.clasimp_modifiers |
608 Method.sections Clasimp.clasimp_modifiers >> (K (SIMPLE_METHOD' o inv_tac)) |
606 >> (K (SIMPLE_METHOD' o inv_tac o clasimpset_of)) |
|
607 *} "" |
609 *} "" |
608 |
610 |
609 method_setup auto_invariant = {* |
611 method_setup auto_invariant = {* |
610 Method.sections Clasimp.clasimp_modifiers |
612 Method.sections Clasimp.clasimp_modifiers |
611 >> (K (SIMPLE_METHOD' o auto_inv_tac o simpset_of)) |
613 >> (K (SIMPLE_METHOD' o auto_inv_tac o simpset_of)) |