Nominal/activities/tphols09/IDW/MW-Ex2.thy
changeset 415 f1be8028a4a9
equal deleted inserted replaced
414:05e5d68c9627 415:f1be8028a4a9
       
     1 theory Ex2
       
     2 imports Main
       
     3 begin
       
     4 
       
     5 section {* Simple methods *}
       
     6 
       
     7 ML Method.setup
       
     8 ML SIMPLE_METHOD'
       
     9 ML SIMPLE_METHOD
       
    10 
       
    11 method_setup my_method1 = {*
       
    12   Scan.succeed (K (SIMPLE_METHOD' (fn i: int => no_tac)))
       
    13 *}  ""
       
    14 
       
    15 method_setup my_method2 = {*
       
    16   Scan.succeed (fn ctxt: Proof.context =>
       
    17     SIMPLE_METHOD' (fn i: int => no_tac))
       
    18 *}  ""
       
    19 
       
    20 method_setup my_method3 = {*
       
    21   Attrib.thms >> (fn thms: thm list => fn ctxt: Proof.context =>
       
    22     SIMPLE_METHOD' (fn i: int => no_tac))
       
    23 *}  ""
       
    24 
       
    25 
       
    26 section {* My simplification method *}
       
    27 
       
    28 ML {*
       
    29 structure My_Simps = NamedThmsFun
       
    30 (
       
    31   val name = "my_simp";
       
    32   val description = "My simp declaration";
       
    33 )
       
    34 *}
       
    35 setup My_Simps.setup
       
    36 
       
    37 method_setup my_simp = {*
       
    38   Scan.succeed (fn ctxt =>
       
    39     SIMPLE_METHOD' (fn i =>
       
    40       CHANGED (asm_full_simp_tac
       
    41         (HOL_basic_ss addsimps (My_Simps.get ctxt)) i)))
       
    42 *} ""
       
    43 
       
    44 lemma True
       
    45 proof
       
    46 
       
    47   fix a b c
       
    48   assume [my_simp]: "a = b"
       
    49   assume [my_simp]: "b = c"
       
    50   have "a = c" by my_simp
       
    51 
       
    52 qed
       
    53 
       
    54 
       
    55 method_setup my_simp_all = {*
       
    56   Scan.succeed (fn ctxt =>
       
    57     SIMPLE_METHOD
       
    58       (CHANGED
       
    59         (ALLGOALS (asm_full_simp_tac
       
    60           (HOL_basic_ss addsimps (My_Simps.get ctxt))))))
       
    61 *} ""
       
    62 
       
    63 
       
    64 lemma True
       
    65 proof
       
    66 
       
    67   fix a b c
       
    68   assume [my_simp]: "a = b"
       
    69   assume [my_simp]: "b = c"
       
    70   have "a = c" and "c = b" by my_simp_all
       
    71 
       
    72 qed
       
    73 
       
    74 
       
    75 end