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