src/HOL/Tools/typedef.ML
changeset 35021 c839a4c670c6
parent 33522 737589bb9bb8
child 35129 ed24ba6f69aa
equal deleted inserted replaced
35020:862a20ffa8e2 35021:c839a4c670c6
   120     fun contract_def NONE th = th
   120     fun contract_def NONE th = th
   121       | contract_def (SOME def_eq) th =
   121       | contract_def (SOME def_eq) th =
   122           let
   122           let
   123             val cert = Thm.cterm_of (Thm.theory_of_thm def_eq);
   123             val cert = Thm.cterm_of (Thm.theory_of_thm def_eq);
   124             val goal_eq = MetaSimplifier.rewrite true [def_eq] (cert goal');
   124             val goal_eq = MetaSimplifier.rewrite true [def_eq] (cert goal');
   125           in Drule.standard (Drule.equal_elim_rule2 OF [goal_eq, th]) end;
   125           in Drule.export_without_context (Drule.equal_elim_rule2 OF [goal_eq, th]) end;
   126 
   126 
   127     fun typedef_result inhabited =
   127     fun typedef_result inhabited =
   128       ObjectLogic.typedecl (t, vs, mx)
   128       ObjectLogic.typedecl (t, vs, mx)
   129       #> snd
   129       #> snd
   130       #> Sign.add_consts_i
   130       #> Sign.add_consts_i
   137         ##>> pair set_def)
   137         ##>> pair set_def)
   138       ##> Theory.add_deps "" (dest_Const RepC) typedef_deps
   138       ##> Theory.add_deps "" (dest_Const RepC) typedef_deps
   139       ##> Theory.add_deps "" (dest_Const AbsC) typedef_deps
   139       ##> Theory.add_deps "" (dest_Const AbsC) typedef_deps
   140       #-> (fn ([type_definition], set_def) => fn thy1 =>
   140       #-> (fn ([type_definition], set_def) => fn thy1 =>
   141         let
   141         let
   142           fun make th = Drule.standard (th OF [type_definition]);
   142           fun make th = Drule.export_without_context (th OF [type_definition]);
   143           val ([Rep, Rep_inverse, Abs_inverse, Rep_inject, Abs_inject,
   143           val ([Rep, Rep_inverse, Abs_inverse, Rep_inject, Abs_inject,
   144               Rep_cases, Abs_cases, Rep_induct, Abs_induct], thy2) =
   144               Rep_cases, Abs_cases, Rep_induct, Abs_induct], thy2) =
   145             thy1
   145             thy1
   146             |> Sign.add_path (Binding.name_of name)
   146             |> Sign.add_path (Binding.name_of name)
   147             |> PureThy.add_thms
   147             |> PureThy.add_thms