src/HOL/BNF/Tools/bnf_fp_rec_sugar.ML
changeset 53811 2967fa35d89e
parent 53797 576f9637dc7a
child 53822 6304b12c7627
equal deleted inserted replaced
53810:69e8ba502eda 53811:2967fa35d89e
    20 open BNF_Util
    20 open BNF_Util
    21 open BNF_FP_Util
    21 open BNF_FP_Util
    22 open BNF_FP_Rec_Sugar_Util
    22 open BNF_FP_Rec_Sugar_Util
    23 open BNF_FP_Rec_Sugar_Tactics
    23 open BNF_FP_Rec_Sugar_Tactics
    24 
    24 
       
    25 val codeN = "code"
    25 val ctrN = "ctr"
    26 val ctrN = "ctr"
    26 val discN = "disc"
    27 val discN = "disc"
    27 val selN = "sel"
    28 val selN = "sel"
    28 
    29 
       
    30 val nitpick_attrs = @{attributes [nitpick_simp]};
       
    31 val code_nitpick_simp_attrs = Code.add_default_eqn_attrib :: nitpick_attrs;
    29 val simp_attrs = @{attributes [simp]};
    32 val simp_attrs = @{attributes [simp]};
    30 
    33 
    31 exception Primrec_Error of string * term list;
    34 exception Primrec_Error of string * term list;
    32 
    35 
    33 fun primrec_error str = raise Primrec_Error (str, []);
    36 fun primrec_error str = raise Primrec_Error (str, []);
   346             mk_primrec_tac lthy num_extra_args nested_map_idents nested_map_comps def_thms rec_thm
   349             mk_primrec_tac lthy num_extra_args nested_map_idents nested_map_comps def_thms rec_thm
   347             |> K |> Goal.prove lthy [] [] user_eqn)
   350             |> K |> Goal.prove lthy [] [] user_eqn)
   348 
   351 
   349         val notes =
   352         val notes =
   350           [(inductN, if nontriv then [induct_thm] else [], []),
   353           [(inductN, if nontriv then [induct_thm] else [], []),
   351            (simpsN, simp_thms, simp_attrs)]
   354            (simpsN, simp_thms, code_nitpick_simp_attrs @ simp_attrs)]
   352           |> filter_out (null o #2)
   355           |> filter_out (null o #2)
   353           |> map (fn (thmN, thms, attrs) =>
   356           |> map (fn (thmN, thms, attrs) =>
   354             ((Binding.qualify true fun_name (Binding.name thmN), attrs), [(thms, [])]));
   357             ((Binding.qualify true fun_name (Binding.name thmN), attrs), [(thms, [])]));
   355       in
   358       in
   356         lthy |> Local_Theory.notes notes
   359         lthy |> Local_Theory.notes notes
   849           [(flat safe_ctr_thmss, simp_attrs)]
   852           [(flat safe_ctr_thmss, simp_attrs)]
   850           |> map (fn (thms, attrs) => ((Binding.empty, attrs), [(thms, [])]));
   853           |> map (fn (thms, attrs) => ((Binding.empty, attrs), [(thms, [])]));
   851 
   854 
   852         val notes =
   855         val notes =
   853           [(coinductN, map (if nontriv then single else K []) coinduct_thms, []),
   856           [(coinductN, map (if nontriv then single else K []) coinduct_thms, []),
       
   857            (codeN, ctr_thmss(*FIXME*), code_nitpick_simp_attrs),
   854            (ctrN, ctr_thmss, []),
   858            (ctrN, ctr_thmss, []),
   855            (discN, disc_thmss, simp_attrs),
   859            (discN, disc_thmss, simp_attrs),
   856            (selN, sel_thmss, simp_attrs),
   860            (selN, sel_thmss, simp_attrs),
   857            (simpsN, simp_thmss, []),
   861            (simpsN, simp_thmss, []),
   858            (strong_coinductN, map (if nontriv then single else K []) strong_coinduct_thms, [])]
   862            (strong_coinductN, map (if nontriv then single else K []) strong_coinduct_thms, [])]