src/HOL/Tools/BNF/bnf_lfp_size.ML
changeset 60728 26ffdb966759
parent 59988 c92afea6eb4b
child 60784 4f590c08fd5d
equal deleted inserted replaced
60727:53697011b03a 60728:26ffdb966759
    61 
    61 
    62 val size_gen_o_map_simps = @{thms inj_on_id snd_comp_apfst[unfolded apfst_def]};
    62 val size_gen_o_map_simps = @{thms inj_on_id snd_comp_apfst[unfolded apfst_def]};
    63 
    63 
    64 fun mk_size_gen_o_map_tac ctxt size_def rec_o_map inj_maps size_maps =
    64 fun mk_size_gen_o_map_tac ctxt size_def rec_o_map inj_maps size_maps =
    65   unfold_thms_tac ctxt [size_def] THEN
    65   unfold_thms_tac ctxt [size_def] THEN
    66   HEADGOAL (rtac (rec_o_map RS trans) THEN'
    66   HEADGOAL (rtac ctxt (rec_o_map RS trans) THEN'
    67     asm_simp_tac (ss_only (inj_maps @ size_maps @ size_gen_o_map_simps) ctxt)) THEN
    67     asm_simp_tac (ss_only (inj_maps @ size_maps @ size_gen_o_map_simps) ctxt)) THEN
    68   IF_UNSOLVED (unfold_thms_tac ctxt @{thms id_def o_def} THEN HEADGOAL (rtac refl));
    68   IF_UNSOLVED (unfold_thms_tac ctxt @{thms id_def o_def} THEN HEADGOAL (rtac ctxt refl));
    69 
    69 
    70 fun mk_size_neq ctxt cts exhaust sizes =
    70 fun mk_size_neq ctxt cts exhaust sizes =
    71   HEADGOAL (rtac (Ctr_Sugar_Util.cterm_instantiate_pos (map SOME cts) exhaust)) THEN
    71   HEADGOAL (rtac ctxt (Ctr_Sugar_Util.cterm_instantiate_pos (map SOME cts) exhaust)) THEN
    72   ALLGOALS (hyp_subst_tac ctxt) THEN
    72   ALLGOALS (hyp_subst_tac ctxt) THEN
    73   Ctr_Sugar_Tactics.unfold_thms_tac ctxt (@{thm neq0_conv} :: sizes) THEN
    73   Ctr_Sugar_Tactics.unfold_thms_tac ctxt (@{thm neq0_conv} :: sizes) THEN
    74   ALLGOALS (REPEAT_DETERM o (rtac @{thm zero_less_Suc} ORELSE' rtac @{thm trans_less_add2}));
    74   ALLGOALS (REPEAT_DETERM o (rtac ctxt @{thm zero_less_Suc} ORELSE' rtac ctxt @{thm trans_less_add2}));
    75 
    75 
    76 fun generate_datatype_size (fp_sugars as ({T = Type (_, As), BT = Type (_, Bs), fp = Least_FP,
    76 fun generate_datatype_size (fp_sugars as ({T = Type (_, As), BT = Type (_, Bs), fp = Least_FP,
    77         fp_res = {bnfs = fp_bnfs, ...}, fp_nesting_bnfs, live_nesting_bnfs, ...} : fp_sugar) :: _)
    77         fp_res = {bnfs = fp_bnfs, ...}, fp_nesting_bnfs, live_nesting_bnfs, ...} : fp_sugar) :: _)
    78       lthy0 =
    78       lthy0 =
    79     let
    79     let