src/HOL/Tools/Ctr_Sugar/ctr_sugar_code.ML
changeset 63239 d562c9948dee
parent 63180 ddfd021884b4
child 63352 4eaf35781b23
equal deleted inserted replaced
63238:7c593d4f1f89 63239:d562c9948dee
   110     #> add_def
   110     #> add_def
   111     #-> Class.prove_instantiation_exit_result (map o Morphism.thm) tac o single
   111     #-> Class.prove_instantiation_exit_result (map o Morphism.thm) tac o single
   112     #-> fold Code.del_eqn
   112     #-> fold Code.del_eqn
   113     #> `(mk_free_ctr_equations fcT ctrs inject_thms distinct_thms)
   113     #> `(mk_free_ctr_equations fcT ctrs inject_thms distinct_thms)
   114     #-> (fn (thms, thm) => Global_Theory.note_thmss Thm.theoremK
   114     #-> (fn (thms, thm) => Global_Theory.note_thmss Thm.theoremK
   115       [((qualify reflN, [Code.add_nbe_default_eqn_attribute]), [([thm], [])]),
   115       [((qualify reflN, [Code.add_default_eqn_attribute Code.Nbe]), [([thm], [])]),
   116         ((qualify simpsN, [Code.add_default_eqn_attribute]), [(rev thms, [])])])
   116         ((qualify simpsN, [Code.add_default_eqn_attribute Code.Equation]), [(rev thms, [])])])
   117     #> snd
   117     #> snd
   118   end;
   118   end;
   119 
   119 
   120 fun add_ctr_code fcT_name raw_As raw_ctrs inject_thms distinct_thms case_thms thy =
   120 fun add_ctr_code fcT_name raw_As raw_ctrs inject_thms distinct_thms case_thms thy =
   121   let
   121   let
   125     val unover_ctrs = map (fn ctr as (_, fcT) => (Axclass.unoverload_const thy ctr, fcT)) ctrs;
   125     val unover_ctrs = map (fn ctr as (_, fcT) => (Axclass.unoverload_const thy ctr, fcT)) ctrs;
   126   in
   126   in
   127     if can (Code.constrset_of_consts thy) unover_ctrs then
   127     if can (Code.constrset_of_consts thy) unover_ctrs then
   128       thy
   128       thy
   129       |> Code.add_datatype ctrs
   129       |> Code.add_datatype ctrs
   130       |> fold_rev Code.add_default_eqn case_thms
   130       |> fold_rev (Code.add_eqn (Code.Equation, true)) case_thms
   131       |> Code.add_case (mk_case_certificate (Proof_Context.init_global thy) case_thms)
   131       |> Code.add_case (mk_case_certificate (Proof_Context.init_global thy) case_thms)
   132       |> not (Sorts.has_instance (Sign.classes_of thy) fcT_name [HOLogic.class_equal])
   132       |> not (Sorts.has_instance (Sign.classes_of thy) fcT_name [HOLogic.class_equal])
   133         ? add_equality fcT fcT_name As ctrs inject_thms distinct_thms
   133         ? add_equality fcT fcT_name As ctrs inject_thms distinct_thms
   134     else
   134     else
   135       thy
   135       thy