src/HOL/UNITY/UNITY_tactics.ML
author wenzelm
Mon Nov 10 21:49:48 2014 +0100 (2014-11-10)
changeset 58963 26bf09b95dda
parent 51717 9e7d1c139569
child 59498 50b60f501b05
permissions -rw-r--r--
proper context for assume_tac (atac remains as fall-back without context);
paulson@13786
     1
(*  Title:      HOL/UNITY/UNITY_tactics.ML
paulson@13786
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@13786
     3
    Copyright   2003  University of Cambridge
paulson@13786
     4
wenzelm@24147
     5
Specialized UNITY tactics.
paulson@13786
     6
*)
paulson@13786
     7
paulson@13797
     8
(*Combines two invariance ASSUMPTIONS into one.  USEFUL??*)
wenzelm@58963
     9
fun Always_Int_tac ctxt =
wenzelm@58963
    10
  dtac @{thm Always_Int_I} THEN' assume_tac ctxt 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@42767
    17
fun constrains_tac ctxt i =
wenzelm@42793
    18
  SELECT_GOAL
wenzelm@42793
    19
    (EVERY
wenzelm@58963
    20
     [REPEAT (Always_Int_tac ctxt 1),
wenzelm@42793
    21
      (*reduce the fancy safety properties to "constrains"*)
wenzelm@42793
    22
      REPEAT (etac @{thm Always_ConstrainsI} 1
wenzelm@42793
    23
              ORELSE
wenzelm@42793
    24
              resolve_tac [@{thm StableI}, @{thm stableI},
wenzelm@42793
    25
                           @{thm constrains_imp_Constrains}] 1),
wenzelm@42793
    26
      (*for safety, the totalize operator can be ignored*)
wenzelm@51717
    27
      simp_tac (put_simpset HOL_ss ctxt
wenzelm@51717
    28
        addsimps [@{thm mk_total_program_def}, @{thm totalize_constrains_iff}]) 1,
wenzelm@42793
    29
      rtac @{thm constrainsI} 1,
wenzelm@51717
    30
      full_simp_tac ctxt 1,
wenzelm@42793
    31
      REPEAT (FIRSTGOAL (etac disjE)),
wenzelm@42793
    32
      ALLGOALS (clarify_tac ctxt),
wenzelm@51717
    33
      ALLGOALS (asm_full_simp_tac ctxt)]) i;
paulson@13786
    34
paulson@13786
    35
(*proves "ensures/leadsTo" properties when the program is specified*)
wenzelm@42767
    36
fun ensures_tac ctxt sact =
wenzelm@42793
    37
  SELECT_GOAL
wenzelm@42793
    38
    (EVERY
wenzelm@58963
    39
     [REPEAT (Always_Int_tac ctxt 1),
wenzelm@42793
    40
      etac @{thm Always_LeadsTo_Basis} 1
wenzelm@42793
    41
          ORELSE   (*subgoal may involve LeadsTo, leadsTo or ensures*)
wenzelm@42793
    42
          REPEAT (ares_tac [@{thm LeadsTo_Basis}, @{thm leadsTo_Basis},
wenzelm@42793
    43
                            @{thm EnsuresI}, @{thm ensuresI}] 1),
wenzelm@42793
    44
      (*now there are two subgoals: co & transient*)
wenzelm@51717
    45
      simp_tac (ctxt addsimps [@{thm mk_total_program_def}]) 2,
wenzelm@42793
    46
      res_inst_tac ctxt
wenzelm@42793
    47
        [(("act", 0), sact)] @{thm totalize_transientI} 2
wenzelm@42793
    48
      ORELSE res_inst_tac ctxt
wenzelm@42793
    49
        [(("act", 0), sact)] @{thm transientI} 2,
wenzelm@42793
    50
         (*simplify the command's domain*)
wenzelm@51717
    51
      simp_tac (ctxt addsimps @{thms Domain_unfold}) 3,
wenzelm@42793
    52
      constrains_tac ctxt 1,
wenzelm@42793
    53
      ALLGOALS (clarify_tac ctxt),
wenzelm@51717
    54
      ALLGOALS (asm_lr_simp_tac ctxt)]);
paulson@13796
    55
paulson@13786
    56
paulson@13786
    57
(*Composition equivalences, from Lift_prog*)
paulson@13786
    58
wenzelm@51717
    59
fun make_o_equivs ctxt th =
wenzelm@51717
    60
  [th,
wenzelm@51717
    61
   th RS @{thm o_equiv_assoc} |> simplify (put_simpset HOL_ss ctxt addsimps [@{thm o_assoc}]),
wenzelm@51717
    62
   th RS @{thm o_equiv_apply} |> simplify (put_simpset HOL_ss ctxt addsimps [@{thm o_def}, @{thm sub_def}])];
paulson@13786
    63