src/HOL/Tools/ctr_sugar.ML
changeset 54635 30666a281ae3
parent 54634 366297517091
child 54691 506312c293f5
--- a/src/HOL/Tools/ctr_sugar.ML	Thu Dec 05 14:11:45 2013 +0100
+++ b/src/HOL/Tools/ctr_sugar.ML	Thu Dec 05 14:35:58 2013 +0100
@@ -930,11 +930,13 @@
             Local_Theory.declaration {syntax = false, pervasive = true}
               (fn phi => Case_Translation.register
                  (Morphism.term phi casex) (map (Morphism.term phi) ctrs))
-         |> Local_Theory.notes (anonymous_notes @ notes) |> snd
-         |> register_ctr_sugar fcT_name ctr_sugar
          |> (not no_code andalso null (Thm.hyps_of (hd case_thms)))
            ? Local_Theory.background_theory
-             (add_ctr_code fcT_name As (map dest_Const ctrs) inject_thms distinct_thms case_thms))
+               (fold (fold Code.del_eqn) [disc_defs, sel_defs]
+                #> add_ctr_code fcT_name As (map dest_Const ctrs) inject_thms distinct_thms
+                  case_thms)
+         |> Local_Theory.notes (anonymous_notes @ notes) |> snd
+         |> register_ctr_sugar fcT_name ctr_sugar)
       end;
   in
     (goalss, after_qed, lthy')