Nominal/Test.thy
changeset 1335 c3dfd4193b42
parent 1331 0f329449e304
child 1336 6ab8c46b3b4b
equal deleted inserted replaced
1334:80441e27dfd6 1335:c3dfd4193b42
     1 theory Test
     1 theory Test
     2 imports "Parser"
     2 imports "Parser" "../Attic/Prove"
     3 begin
     3 begin
     4 
     4 
     5 text {* weirdo example from Peter Sewell's bestiary *}
     5 text {* weirdo example from Peter Sewell's bestiary *}
     6 
     6 
     7 nominal_datatype weird =
     7 nominal_datatype weird =
    11 | WP "weird" "weird"
    11 | WP "weird" "weird"
    12 
    12 
    13 thm permute_weird_raw.simps[no_vars]
    13 thm permute_weird_raw.simps[no_vars]
    14 thm alpha_weird_raw.intros[no_vars]
    14 thm alpha_weird_raw.intros[no_vars]
    15 thm fv_weird_raw.simps[no_vars]
    15 thm fv_weird_raw.simps[no_vars]
       
    16 
       
    17 thm eqvts
       
    18 
       
    19 local_setup {* (fn ctxt => snd (Local_Theory.note ((@{binding weird_inj}, []), (build_alpha_inj @{thms alpha_weird_raw.intros} @{thms weird_raw.distinct weird_raw.inject} @{thms alpha_weird_raw.cases} ctxt)) ctxt)) *}
       
    20 thm weird_inj
       
    21 
       
    22 local_setup {*
       
    23 (fn ctxt => snd (Local_Theory.note ((@{binding alpha_eqvt}, []),
       
    24 build_alpha_eqvts [@{term alpha_weird_raw}] [@{term "permute :: perm \<Rightarrow> weird_raw \<Rightarrow> weird_raw"}] @{thms permute_weird_raw.simps weird_inj} @{thm alpha_weird_raw.induct} ctxt) ctxt)) *}
       
    25 
       
    26 ML {*
       
    27 fun is_ex (Const ("Ex", _) $ Abs _) = true
       
    28   | is_ex _ = false;
       
    29 *}
       
    30 
       
    31 ML {*
       
    32 fun eetac rule = Subgoal.FOCUS_PARAMS 
       
    33   (fn (focus) =>
       
    34      let
       
    35        val concl = #concl focus
       
    36        val prems = Logic.strip_imp_prems (term_of concl)
       
    37        val exs = filter (fn x => is_ex (HOLogic.dest_Trueprop x)) prems
       
    38        val cexs = map (SOME o (cterm_of (ProofContext.theory_of (#context focus)))) exs
       
    39        val thins = map (fn cex => Drule.instantiate' [] [cex] Drule.thin_rl) cexs
       
    40      in
       
    41      (etac rule THEN' RANGE[
       
    42         atac,
       
    43         eresolve_tac thins
       
    44      ]) 1
       
    45      end
       
    46   )
       
    47 *}
       
    48 
       
    49 
       
    50 prove {* (snd o snd) (build_alpha_refl_gl [@{term alpha_weird_raw}] ("x","y","z")) *}
       
    51 ML_prf {*
       
    52 fun transp_tac ctxt induct alpha_inj term_inj distinct cases eqvt =
       
    53   ind_tac induct THEN_ALL_NEW
       
    54   (TRY o rtac allI THEN' imp_elim_tac cases ctxt) THEN_ALL_NEW
       
    55   asm_full_simp_tac ((mk_minimal_ss ctxt) addsimps alpha_inj) THEN_ALL_NEW
       
    56   split_conjs THEN_ALL_NEW REPEAT o (eetac @{thm exi_sum} ctxt)
       
    57   THEN_ALL_NEW split_conjs
       
    58 *}
       
    59 
       
    60 apply (tactic {* transp_tac @{context} @{thm alpha_weird_raw.induct} @{thms weird_inj}  @{thms weird_raw.inject} @{thms weird_raw.distinct} @{thms alpha_weird_raw.cases} @{thms alpha_eqvt} 1 *})
       
    61 apply (simp_all)
       
    62 apply (erule alpha_gen_compose_trans)
       
    63 apply assumption
       
    64 apply (simp add: alpha_eqvt)
       
    65 defer defer
       
    66 apply (erule alpha_gen_compose_trans)
       
    67 apply assumption
       
    68 apply (simp add: alpha_eqvt)
       
    69 apply (subgoal_tac "pia + pb + (pib + pa) = (pia + pib) + (pb + pa)")
       
    70 apply simp
       
    71 apply (erule alpha_gen_compose_trans)
       
    72 apply assumption
       
    73 apply (simp add: alpha_eqvt)
       
    74 sorry
       
    75 
    16 
    76 
    17 (*
    77 (*
    18 abbreviation "WBind \<equiv> WBind_raw"
    78 abbreviation "WBind \<equiv> WBind_raw"
    19 abbreviation "WP \<equiv> WP_raw"
    79 abbreviation "WP \<equiv> WP_raw"
    20 abbreviation "WV \<equiv> WV_raw"
    80 abbreviation "WV \<equiv> WV_raw"