src/HOL/Tools/typedef.ML
changeset 61255 15865e0c5598
parent 61248 066792098895
child 61259 6dc3d5d50e57
equal deleted inserted replaced
61254:4918c6e52a02 61255:15865e0c5598
   130 
   130 
   131     val ((RepC, AbsC), consts_lthy) = lthy
   131     val ((RepC, AbsC), consts_lthy) = lthy
   132       |> Local_Theory.background_theory_result
   132       |> Local_Theory.background_theory_result
   133         (Sign.declare_const lthy ((Rep_name, newT --> oldT), NoSyn) ##>>
   133         (Sign.declare_const lthy ((Rep_name, newT --> oldT), NoSyn) ##>>
   134           Sign.declare_const lthy ((Abs_name, oldT --> newT), NoSyn));
   134           Sign.declare_const lthy ((Abs_name, oldT --> newT), NoSyn));
   135 
   135     val const_dep = Theory.const_dep (Proof_Context.theory_of consts_lthy);
   136     val A_consts = fold_aterms (fn Const c => insert (op =) (Theory.DConst c) | _ => I) A [];
   136 
       
   137     val A_consts = fold_aterms (fn Const c => insert (op =) (const_dep c) | _ => I) A [];
   137     val A_types =
   138     val A_types =
   138       (fold_types o fold_subtypes) (fn Type t => insert (op =) (Theory.DType t) | _ => I) A [];
   139       (fold_types o fold_subtypes) (fn Type t => insert (op =) (Theory.type_dep t) | _ => I) A [];
   139     val typedef_deps = A_consts @ A_types;
   140     val typedef_deps = A_consts @ A_types;
   140 
   141 
   141     val newT_dep = Theory.DType (dest_Type newT);
   142     val newT_dep = Theory.type_dep (dest_Type newT);
   142 
   143 
   143     val ((axiom_name, axiom), axiom_lthy) = consts_lthy
   144     val ((axiom_name, axiom), axiom_lthy) = consts_lthy
   144       |> Local_Theory.background_theory_result
   145       |> Local_Theory.background_theory_result
   145         (Thm.add_axiom consts_lthy (type_definition_name, mk_typedef newT oldT RepC AbsC A) ##>
   146         (Thm.add_axiom consts_lthy (type_definition_name, mk_typedef newT oldT RepC AbsC A) ##>
   146           Theory.add_deps consts_lthy "" newT_dep typedef_deps ##>
   147           Theory.add_deps consts_lthy "" newT_dep typedef_deps ##>
   147           Theory.add_deps consts_lthy "" (Theory.DConst (dest_Const RepC)) [newT_dep] ##>
   148           Theory.add_deps consts_lthy "" (const_dep (dest_Const RepC)) [newT_dep] ##>
   148           Theory.add_deps consts_lthy "" (Theory.DConst (dest_Const AbsC)) [newT_dep]);
   149           Theory.add_deps consts_lthy "" (const_dep (dest_Const AbsC)) [newT_dep]);
   149 
   150 
   150   in ((RepC, AbsC, axiom_name, axiom), axiom_lthy) end;
   151   in ((RepC, AbsC, axiom_name, axiom), axiom_lthy) end;
   151 
   152 
   152 
   153 
   153 (* derived bindings *)
   154 (* derived bindings *)