src/HOL/UNITY/UNITY_tactics.ML
author haftmann
Fri, 10 Dec 2010 16:10:50 +0100
changeset 41107 8795cd75965e
parent 37936 1e4c5015a72e
child 42767 e6d920bea7a6
permissions -rw-r--r--
moved most fundamental lemmas upwards
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13786
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
     1
(*  Title:      HOL/UNITY/UNITY_tactics.ML
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
     3
    Copyright   2003  University of Cambridge
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
     4
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
     5
Specialized UNITY tactics.
13786
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
     6
*)
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
     7
13797
baefae13ad37 conversion of UNITY theories to new-style
paulson
parents: 13796
diff changeset
     8
(*Combines two invariance ASSUMPTIONS into one.  USEFUL??*)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
     9
val Always_Int_tac = dtac @{thm Always_Int_I} THEN' assume_tac THEN' etac @{thm Always_thin}
13797
baefae13ad37 conversion of UNITY theories to new-style
paulson
parents: 13796
diff changeset
    10
baefae13ad37 conversion of UNITY theories to new-style
paulson
parents: 13796
diff changeset
    11
(*Combines a list of invariance THEOREMS into one.*)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    12
val Always_Int_rule = foldr1 (fn (th1,th2) => [th1,th2] MRS @{thm Always_Int_I})
13797
baefae13ad37 conversion of UNITY theories to new-style
paulson
parents: 13796
diff changeset
    13
13812
91713a1915ee converting HOL/UNITY to use unconditional fairness
paulson
parents: 13798
diff changeset
    14
(*Proves "co" properties when the program is specified.  Any use of invariants
91713a1915ee converting HOL/UNITY to use unconditional fairness
paulson
parents: 13798
diff changeset
    15
  (from weak constrains) must have been done already.*)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    16
fun constrains_tac(cs,ss) i =
13786
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
    17
   SELECT_GOAL
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
    18
      (EVERY [REPEAT (Always_Int_tac 1),
13812
91713a1915ee converting HOL/UNITY to use unconditional fairness
paulson
parents: 13798
diff changeset
    19
              (*reduce the fancy safety properties to "constrains"*)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    20
              REPEAT (etac @{thm Always_ConstrainsI} 1
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    21
                      ORELSE
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    22
                      resolve_tac [@{thm StableI}, @{thm stableI},
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    23
                                   @{thm constrains_imp_Constrains}] 1),
13812
91713a1915ee converting HOL/UNITY to use unconditional fairness
paulson
parents: 13798
diff changeset
    24
              (*for safety, the totalize operator can be ignored*)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    25
              simp_tac (HOL_ss addsimps
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    26
                         [@{thm mk_total_program_def}, @{thm totalize_constrains_iff}]) 1,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    27
              rtac @{thm constrainsI} 1,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    28
              full_simp_tac ss 1,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    29
              REPEAT (FIRSTGOAL (etac disjE)),
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    30
              ALLGOALS (clarify_tac cs),
34234
86a985e9b4df removed legacy asm_lr_simp_tac
paulson
parents: 30610
diff changeset
    31
              ALLGOALS (asm_full_simp_tac ss)]) i;
13786
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
    32
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
    33
(*proves "ensures/leadsTo" properties when the program is specified*)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    34
fun ensures_tac(cs,ss) sact =
13786
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
    35
    SELECT_GOAL
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
    36
      (EVERY [REPEAT (Always_Int_tac 1),
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    37
              etac @{thm Always_LeadsTo_Basis} 1
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    38
                  ORELSE   (*subgoal may involve LeadsTo, leadsTo or ensures*)
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    39
                  REPEAT (ares_tac [@{thm LeadsTo_Basis}, @{thm leadsTo_Basis},
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    40
                                    @{thm EnsuresI}, @{thm ensuresI}] 1),
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    41
              (*now there are two subgoals: co & transient*)
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    42
              simp_tac (ss addsimps [@{thm mk_total_program_def}]) 2,
27239
f2f42f9fa09d pervasive RuleInsts;
wenzelm
parents: 27208
diff changeset
    43
              res_inst_tac (Simplifier.the_context ss)
27208
5fe899199f85 proper context for tactics derived from res_inst_tac;
wenzelm
parents: 24147
diff changeset
    44
                [(("act", 0), sact)] @{thm totalize_transientI} 2
27239
f2f42f9fa09d pervasive RuleInsts;
wenzelm
parents: 27208
diff changeset
    45
              ORELSE res_inst_tac (Simplifier.the_context ss)
27208
5fe899199f85 proper context for tactics derived from res_inst_tac;
wenzelm
parents: 24147
diff changeset
    46
                [(("act", 0), sact)] @{thm transientI} 2,
13786
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
    47
                 (*simplify the command's domain*)
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    48
              simp_tac (ss addsimps [@{thm Domain_def}]) 3,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    49
              constrains_tac (cs,ss) 1,
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    50
              ALLGOALS (clarify_tac cs),
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    51
              ALLGOALS (asm_lr_simp_tac ss)]);
13796
19f50fa807ae converting more UNITY theories to new-style
paulson
parents: 13792
diff changeset
    52
13786
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
    53
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
    54
(*Composition equivalences, from Lift_prog*)
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
    55
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
    56
fun make_o_equivs th =
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
    57
    [th,
24147
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    58
     th RS @{thm o_equiv_assoc} |> simplify (HOL_ss addsimps [@{thm o_assoc}]),
edc90be09ac1 misc cleanup of ML bindings (for multihreading);
wenzelm
parents: 21669
diff changeset
    59
     th RS @{thm o_equiv_apply} |> simplify (HOL_ss addsimps [@{thm o_def}, @{thm sub_def}])];
13786
ab8f39f48a6f More conversion of UNITY to Isar new-style theories
paulson
parents:
diff changeset
    60
30610
bcbc34cb9749 eliminated old Addsimps;
wenzelm
parents: 27239
diff changeset
    61
Simplifier.change_simpset (fn ss => ss
bcbc34cb9749 eliminated old Addsimps;
wenzelm
parents: 27239
diff changeset
    62
  addsimps (make_o_equivs @{thm fst_o_funPair} @ make_o_equivs @{thm snd_o_funPair})
bcbc34cb9749 eliminated old Addsimps;
wenzelm
parents: 27239
diff changeset
    63
  addsimps (make_o_equivs @{thm fst_o_lift_map} @ make_o_equivs @{thm snd_o_lift_map}));