src/HOL/Tools/record.ML
changeset 63239 d562c9948dee
parent 63180 ddfd021884b4
child 63342 49fa6aaa4529
equal deleted inserted replaced
63238:7c593d4f1f89 63239:d562c9948dee
  1776       val ensure_exhaustive_record =
  1776       val ensure_exhaustive_record =
  1777         ensure_sort_record (@{sort full_exhaustive}, mk_full_exhaustive_eq);
  1777         ensure_sort_record (@{sort full_exhaustive}, mk_full_exhaustive_eq);
  1778     in
  1778     in
  1779       thy
  1779       thy
  1780       |> Code.add_datatype [ext]
  1780       |> Code.add_datatype [ext]
  1781       |> fold Code.add_default_eqn simps
  1781       |> fold (Code.add_eqn (Code.Equation, true)) simps
  1782       |> Class.instantiation ([ext_tyco], vs, [HOLogic.class_equal])
  1782       |> Class.instantiation ([ext_tyco], vs, [HOLogic.class_equal])
  1783       |> `(fn lthy => Syntax.check_term lthy eq)
  1783       |> `(fn lthy => Syntax.check_term lthy eq)
  1784       |-> (fn eq => Specification.definition NONE [] [] (Attrib.empty_binding, eq))
  1784       |-> (fn eq => Specification.definition NONE [] [] (Attrib.empty_binding, eq))
  1785       |-> (fn (_, (_, eq_def)) =>
  1785       |-> (fn (_, (_, eq_def)) =>
  1786          Class.prove_instantiation_exit_result Morphism.thm tac eq_def)
  1786          Class.prove_instantiation_exit_result Morphism.thm tac eq_def)
  1787       |-> (fn eq_def => fn thy =>
  1787       |-> (fn eq_def => fn thy =>
  1788             thy
  1788             thy
  1789             |> Code.del_eqn eq_def
  1789             |> Code.del_eqn eq_def
  1790             |> Code.add_default_eqn (mk_eq (Proof_Context.init_global thy) eq_def))
  1790             |> Code.add_eqn (Code.Equation, true) (mk_eq (Proof_Context.init_global thy) eq_def))
  1791       |> (fn thy => Code.add_nbe_default_eqn (mk_eq_refl (Proof_Context.init_global thy)) thy)
  1791       |> (fn thy => Code.add_eqn (Code.Nbe, true) (mk_eq_refl (Proof_Context.init_global thy)) thy)
  1792       |> ensure_random_record ext_tyco vs (fst ext) (binder_types (snd ext))
  1792       |> ensure_random_record ext_tyco vs (fst ext) (binder_types (snd ext))
  1793       |> ensure_exhaustive_record ext_tyco vs (fst ext) (binder_types (snd ext))
  1793       |> ensure_exhaustive_record ext_tyco vs (fst ext) (binder_types (snd ext))
  1794     end
  1794     end
  1795   else thy;
  1795   else thy;
  1796 
  1796 
  2043           |> (Global_Theory.add_defs false o
  2043           |> (Global_Theory.add_defs false o
  2044                 map (Thm.no_attributes o apfst (Binding.concealed o Binding.name))) sel_specs
  2044                 map (Thm.no_attributes o apfst (Binding.concealed o Binding.name))) sel_specs
  2045           ||>> (Global_Theory.add_defs false o
  2045           ||>> (Global_Theory.add_defs false o
  2046                 map (Thm.no_attributes o apfst (Binding.concealed o Binding.name))) upd_specs
  2046                 map (Thm.no_attributes o apfst (Binding.concealed o Binding.name))) upd_specs
  2047           ||>> (Global_Theory.add_defs false o
  2047           ||>> (Global_Theory.add_defs false o
  2048                 map (rpair [Code.add_default_eqn_attribute]
  2048                 map (rpair [Code.add_default_eqn_attribute Code.Equation]
  2049                 o apfst (Binding.concealed o Binding.name)))
  2049                 o apfst (Binding.concealed o Binding.name)))
  2050             [make_spec, fields_spec, extend_spec, truncate_spec]);
  2050             [make_spec, fields_spec, extend_spec, truncate_spec]);
  2051     val defs_ctxt = Proof_Context.init_global defs_thy;
  2051     val defs_ctxt = Proof_Context.init_global defs_thy;
  2052 
  2052 
  2053     (* prepare propositions *)
  2053     (* prepare propositions *)