src/Pure/Isar/theory_target.ML
changeset 38311 228566e1ab00
parent 38310 9d4c0c74ae7d
child 38312 9dd57db3c0f2
equal deleted inserted replaced
38310:9d4c0c74ae7d 38311:228566e1ab00
   139 local
   139 local
   140 
   140 
   141 fun syntax_error c = error ("Illegal mixfix syntax for overloaded constant " ^ quote c);
   141 fun syntax_error c = error ("Illegal mixfix syntax for overloaded constant " ^ quote c);
   142 
   142 
   143 fun foundation (ta as Target {target, is_locale, is_class, ...})
   143 fun foundation (ta as Target {target, is_locale, is_class, ...})
   144     (((b, U), mx), rhs') name' params (extra_tfrees, type_params) lthy =
   144     (((b, U), mx), (b_def, rhs')) params (extra_tfrees, type_params) lthy =
   145   let
   145   let
   146     val (mx1, mx2, mx3) = prep_mixfix lthy ta (b, extra_tfrees) mx;
   146     val (mx1, mx2, mx3) = prep_mixfix lthy ta (b, extra_tfrees) mx;
   147     val (const, lthy2) = lthy |>
   147     val (const, lthy2) = lthy |>
   148       (case Class_Target.instantiation_param lthy b of
   148       (case Class_Target.instantiation_param lthy b of
   149         SOME c' =>
   149         SOME c' =>
   162   in
   162   in
   163     lthy2
   163     lthy2
   164     |> pair lhs'
   164     |> pair lhs'
   165     ||>> Local_Theory.theory_result
   165     ||>> Local_Theory.theory_result
   166       (case Overloading.operation lthy b of
   166       (case Overloading.operation lthy b of
   167         SOME (_, checked) => Overloading.define checked name' (head, rhs')
   167         SOME (_, checked) => Overloading.define checked b_def (head, rhs')
   168       | NONE =>
   168       | NONE =>
   169           if is_some (Class_Target.instantiation_param lthy b)
   169           if is_some (Class_Target.instantiation_param lthy b)
   170           then AxClass.define_overloaded name' (head, rhs')
   170           then AxClass.define_overloaded b_def (head, rhs')
   171           else Thm.add_def false false (name', Logic.mk_equals (lhs', rhs')) #>> snd)
   171           else Thm.add_def false false (b_def, Logic.mk_equals (lhs', rhs')) #>> snd)
   172     ||> is_locale ? locale_const_declaration ta Syntax.mode_default ((b, mx2), lhs')
   172     ||> is_locale ? locale_const_declaration ta Syntax.mode_default ((b, mx2), lhs')
   173     ||> is_class ? class_target ta
   173     ||> is_class ? class_target ta
   174           (Class_Target.declare target ((b, mx1), (type_params, lhs')))
   174           (Class_Target.declare target ((b, mx1), (type_params, lhs')))
   175   end;
   175   end;
   176 
   176