src/HOL/UNITY/UNITY_tactics.ML
author haftmann
Fri Oct 10 19:55:32 2014 +0200 (2014-10-10)
changeset 58646 cd63a4b12a33
parent 51717 9e7d1c139569
child 58963 26bf09b95dda
permissions -rw-r--r--
specialized specification: avoid trivial instances
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@24147
     9
val Always_Int_tac = dtac @{thm Always_Int_I} THEN' assume_tac THEN' etac @{thm Always_thin}
paulson@13797
    10
paulson@13797
    11
(*Combines a list of invariance THEOREMS into one.*)
wenzelm@24147
    12
val Always_Int_rule = foldr1 (fn (th1,th2) => [th1,th2] MRS @{thm Always_Int_I})
paulson@13797
    13
paulson@13812
    14
(*Proves "co" properties when the program is specified.  Any use of invariants
paulson@13812
    15
  (from weak constrains) must have been done already.*)
wenzelm@42767
    16
fun constrains_tac ctxt i =
wenzelm@42793
    17
  SELECT_GOAL
wenzelm@42793
    18
    (EVERY
wenzelm@42793
    19
     [REPEAT (Always_Int_tac 1),
wenzelm@42793
    20
      (*reduce the fancy safety properties to "constrains"*)
wenzelm@42793
    21
      REPEAT (etac @{thm Always_ConstrainsI} 1
wenzelm@42793
    22
              ORELSE
wenzelm@42793
    23
              resolve_tac [@{thm StableI}, @{thm stableI},
wenzelm@42793
    24
                           @{thm constrains_imp_Constrains}] 1),
wenzelm@42793
    25
      (*for safety, the totalize operator can be ignored*)
wenzelm@51717
    26
      simp_tac (put_simpset HOL_ss ctxt
wenzelm@51717
    27
        addsimps [@{thm mk_total_program_def}, @{thm totalize_constrains_iff}]) 1,
wenzelm@42793
    28
      rtac @{thm constrainsI} 1,
wenzelm@51717
    29
      full_simp_tac ctxt 1,
wenzelm@42793
    30
      REPEAT (FIRSTGOAL (etac disjE)),
wenzelm@42793
    31
      ALLGOALS (clarify_tac ctxt),
wenzelm@51717
    32
      ALLGOALS (asm_full_simp_tac ctxt)]) i;
paulson@13786
    33
paulson@13786
    34
(*proves "ensures/leadsTo" properties when the program is specified*)
wenzelm@42767
    35
fun ensures_tac ctxt sact =
wenzelm@42793
    36
  SELECT_GOAL
wenzelm@42793
    37
    (EVERY
wenzelm@42793
    38
     [REPEAT (Always_Int_tac 1),
wenzelm@42793
    39
      etac @{thm Always_LeadsTo_Basis} 1
wenzelm@42793
    40
          ORELSE   (*subgoal may involve LeadsTo, leadsTo or ensures*)
wenzelm@42793
    41
          REPEAT (ares_tac [@{thm LeadsTo_Basis}, @{thm leadsTo_Basis},
wenzelm@42793
    42
                            @{thm EnsuresI}, @{thm ensuresI}] 1),
wenzelm@42793
    43
      (*now there are two subgoals: co & transient*)
wenzelm@51717
    44
      simp_tac (ctxt addsimps [@{thm mk_total_program_def}]) 2,
wenzelm@42793
    45
      res_inst_tac ctxt
wenzelm@42793
    46
        [(("act", 0), sact)] @{thm totalize_transientI} 2
wenzelm@42793
    47
      ORELSE res_inst_tac ctxt
wenzelm@42793
    48
        [(("act", 0), sact)] @{thm transientI} 2,
wenzelm@42793
    49
         (*simplify the command's domain*)
wenzelm@51717
    50
      simp_tac (ctxt addsimps @{thms Domain_unfold}) 3,
wenzelm@42793
    51
      constrains_tac ctxt 1,
wenzelm@42793
    52
      ALLGOALS (clarify_tac ctxt),
wenzelm@51717
    53
      ALLGOALS (asm_lr_simp_tac ctxt)]);
paulson@13796
    54
paulson@13786
    55
paulson@13786
    56
(*Composition equivalences, from Lift_prog*)
paulson@13786
    57
wenzelm@51717
    58
fun make_o_equivs ctxt th =
wenzelm@51717
    59
  [th,
wenzelm@51717
    60
   th RS @{thm o_equiv_assoc} |> simplify (put_simpset HOL_ss ctxt addsimps [@{thm o_assoc}]),
wenzelm@51717
    61
   th RS @{thm o_equiv_apply} |> simplify (put_simpset HOL_ss ctxt addsimps [@{thm o_def}, @{thm sub_def}])];
paulson@13786
    62