src/HOL/Tools/datatype_codegen.ML
changeset 26732 6ea9de67e576
parent 26513 6f306c8c2c54
child 26975 103dca19ef2e
equal deleted inserted replaced
26731:48df747c8543 26732:6ea9de67e576
   437       let
   437       let
   438         val ty = Type (tyco, map TFree vs');
   438         val ty = Type (tyco, map TFree vs');
   439         fun mk_side const_name = Const (const_name, ty --> ty --> HOLogic.boolT)
   439         fun mk_side const_name = Const (const_name, ty --> ty --> HOLogic.boolT)
   440           $ Free ("x", ty) $ Free ("y", ty);
   440           $ Free ("x", ty) $ Free ("y", ty);
   441         val def = HOLogic.mk_Trueprop (HOLogic.mk_eq
   441         val def = HOLogic.mk_Trueprop (HOLogic.mk_eq
   442           (mk_side @{const_name eq}, mk_side @{const_name "op ="}));
   442           (mk_side @{const_name eq_class.eq}, mk_side @{const_name "op ="}));
   443         val def' = Syntax.check_term lthy def;
   443         val def' = Syntax.check_term lthy def;
   444         val ((_, (_, thm)), lthy') = Specification.definition
   444         val ((_, (_, thm)), lthy') = Specification.definition
   445           (NONE, (("", []), def')) lthy;
   445           (NONE, (("", []), def')) lthy;
   446         val ctxt_thy = ProofContext.init (ProofContext.theory_of lthy);
   446         val ctxt_thy = ProofContext.init (ProofContext.theory_of lthy);
   447         val thm' = singleton (ProofContext.export lthy' ctxt_thy) thm;
   447         val thm' = singleton (ProofContext.export lthy' ctxt_thy) thm;
   453       |> map Simpdata.mk_eq
   453       |> map Simpdata.mk_eq
   454       |> map (MetaSimplifier.rewrite_rule [Thm.transfer thy @{thm equals_eq}]);
   454       |> map (MetaSimplifier.rewrite_rule [Thm.transfer thy @{thm equals_eq}]);
   455     fun add_eq_thms dtco thy =
   455     fun add_eq_thms dtco thy =
   456       let
   456       let
   457         val thy_ref = Theory.check_thy thy;
   457         val thy_ref = Theory.check_thy thy;
   458         val const = AxClass.param_of_inst thy (@{const_name eq}, dtco);
   458         val const = AxClass.param_of_inst thy (@{const_name eq_class.eq}, dtco);
   459         val get_thms = (fn () => get_eq' (Theory.deref thy_ref) dtco |> rev);
   459         val get_thms = (fn () => get_eq' (Theory.deref thy_ref) dtco |> rev);
   460       in
   460       in
   461         Code.add_funcl (const, Susp.delay get_thms) thy
   461         Code.add_funcl (const, Susp.delay get_thms) thy
   462       end;
   462       end;
   463   in
   463   in