src/HOL/UNITY/UNITY_tactics.ML
author paulson
Sun Jan 03 11:03:00 2010 +0000 (2010-01-03)
changeset 34234 86a985e9b4df
parent 30610 bcbc34cb9749
child 37936 1e4c5015a72e
permissions -rw-r--r--
removed legacy asm_lr_simp_tac
paulson@13786
     1
(*  Title:      HOL/UNITY/UNITY_tactics.ML
paulson@13786
     2
    ID:         $Id$
paulson@13786
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@13786
     4
    Copyright   2003  University of Cambridge
paulson@13786
     5
wenzelm@24147
     6
Specialized UNITY tactics.
paulson@13786
     7
*)
paulson@13786
     8
paulson@13797
     9
(*Combines two invariance ASSUMPTIONS into one.  USEFUL??*)
wenzelm@24147
    10
val Always_Int_tac = dtac @{thm Always_Int_I} THEN' assume_tac THEN' etac @{thm Always_thin}
paulson@13797
    11
paulson@13797
    12
(*Combines a list of invariance THEOREMS into one.*)
wenzelm@24147
    13
val Always_Int_rule = foldr1 (fn (th1,th2) => [th1,th2] MRS @{thm Always_Int_I})
paulson@13797
    14
paulson@13812
    15
(*Proves "co" properties when the program is specified.  Any use of invariants
paulson@13812
    16
  (from weak constrains) must have been done already.*)
wenzelm@24147
    17
fun constrains_tac(cs,ss) i =
paulson@13786
    18
   SELECT_GOAL
paulson@13786
    19
      (EVERY [REPEAT (Always_Int_tac 1),
paulson@13812
    20
              (*reduce the fancy safety properties to "constrains"*)
wenzelm@24147
    21
              REPEAT (etac @{thm Always_ConstrainsI} 1
wenzelm@24147
    22
                      ORELSE
wenzelm@24147
    23
                      resolve_tac [@{thm StableI}, @{thm stableI},
wenzelm@24147
    24
                                   @{thm constrains_imp_Constrains}] 1),
paulson@13812
    25
              (*for safety, the totalize operator can be ignored*)
wenzelm@24147
    26
              simp_tac (HOL_ss addsimps
wenzelm@24147
    27
                         [@{thm mk_total_program_def}, @{thm totalize_constrains_iff}]) 1,
wenzelm@24147
    28
              rtac @{thm constrainsI} 1,
wenzelm@24147
    29
              full_simp_tac ss 1,
wenzelm@24147
    30
              REPEAT (FIRSTGOAL (etac disjE)),
wenzelm@24147
    31
              ALLGOALS (clarify_tac cs),
paulson@34234
    32
              ALLGOALS (asm_full_simp_tac ss)]) i;
paulson@13786
    33
paulson@13786
    34
(*proves "ensures/leadsTo" properties when the program is specified*)
wenzelm@24147
    35
fun ensures_tac(cs,ss) sact =
paulson@13786
    36
    SELECT_GOAL
paulson@13786
    37
      (EVERY [REPEAT (Always_Int_tac 1),
wenzelm@24147
    38
              etac @{thm Always_LeadsTo_Basis} 1
wenzelm@24147
    39
                  ORELSE   (*subgoal may involve LeadsTo, leadsTo or ensures*)
wenzelm@24147
    40
                  REPEAT (ares_tac [@{thm LeadsTo_Basis}, @{thm leadsTo_Basis},
wenzelm@24147
    41
                                    @{thm EnsuresI}, @{thm ensuresI}] 1),
wenzelm@24147
    42
              (*now there are two subgoals: co & transient*)
wenzelm@24147
    43
              simp_tac (ss addsimps [@{thm mk_total_program_def}]) 2,
wenzelm@27239
    44
              res_inst_tac (Simplifier.the_context ss)
wenzelm@27208
    45
                [(("act", 0), sact)] @{thm totalize_transientI} 2
wenzelm@27239
    46
              ORELSE res_inst_tac (Simplifier.the_context ss)
wenzelm@27208
    47
                [(("act", 0), sact)] @{thm transientI} 2,
paulson@13786
    48
                 (*simplify the command's domain*)
wenzelm@24147
    49
              simp_tac (ss addsimps [@{thm Domain_def}]) 3,
wenzelm@24147
    50
              constrains_tac (cs,ss) 1,
wenzelm@24147
    51
              ALLGOALS (clarify_tac cs),
wenzelm@24147
    52
              ALLGOALS (asm_lr_simp_tac ss)]);
paulson@13796
    53
paulson@13786
    54
paulson@13786
    55
(*Composition equivalences, from Lift_prog*)
paulson@13786
    56
paulson@13786
    57
fun make_o_equivs th =
paulson@13786
    58
    [th,
wenzelm@24147
    59
     th RS @{thm o_equiv_assoc} |> simplify (HOL_ss addsimps [@{thm o_assoc}]),
wenzelm@24147
    60
     th RS @{thm o_equiv_apply} |> simplify (HOL_ss addsimps [@{thm o_def}, @{thm sub_def}])];
paulson@13786
    61
wenzelm@30610
    62
Simplifier.change_simpset (fn ss => ss
wenzelm@30610
    63
  addsimps (make_o_equivs @{thm fst_o_funPair} @ make_o_equivs @{thm snd_o_funPair})
wenzelm@30610
    64
  addsimps (make_o_equivs @{thm fst_o_lift_map} @ make_o_equivs @{thm snd_o_lift_map}));