src/Pure/axclass.ML
author wenzelm
Wed Jul 27 15:14:31 1994 +0200 (1994-07-27)
changeset 487 af83700cb771
parent 474 ac1d1988d528
child 560 6702a715281d
permissions -rw-r--r--
added experimental add_defns (actually should be moved somewhere else);
minor internal changes;
wenzelm@404
     1
(*  Title:      Pure/axclass.ML
wenzelm@404
     2
    ID:         $Id$
wenzelm@404
     3
    Author:     Markus Wenzel, TU Muenchen
wenzelm@404
     4
wenzelm@423
     5
Higher level user interfaces for axiomatic type classes.
wenzelm@449
     6
wenzelm@449
     7
TODO:
wenzelm@449
     8
  remove add_sigclass (?)
wenzelm@449
     9
  remove goal_... (?)
wenzelm@474
    10
  clean signature
wenzelm@404
    11
*)
wenzelm@404
    12
wenzelm@404
    13
signature AX_CLASS =
wenzelm@404
    14
sig
wenzelm@404
    15
  structure Tactical: TACTICAL
wenzelm@423
    16
  local open Tactical Tactical.Thm Tactical.Thm.Sign.Syntax.Mixfix in
wenzelm@423
    17
    val add_thms_as_axms: (string * thm) list -> theory -> theory
wenzelm@423
    18
    val add_classrel_thms: thm list -> theory -> theory
wenzelm@423
    19
    val add_arity_thms: thm list -> theory -> theory
wenzelm@404
    20
    val add_axclass: class * class list -> (string * string) list
wenzelm@404
    21
      -> theory -> theory
wenzelm@404
    22
    val add_axclass_i: class * class list -> (string * term) list
wenzelm@404
    23
      -> theory -> theory
wenzelm@423
    24
    val add_sigclass: class * class list -> (string * string * mixfix) list
wenzelm@423
    25
      -> theory -> theory
wenzelm@423
    26
    val add_sigclass_i: class * class list -> (string * typ * mixfix) list
wenzelm@423
    27
      -> theory -> theory
wenzelm@423
    28
    val prove_classrel: theory -> class * class -> thm list
wenzelm@423
    29
      -> tactic option -> thm
wenzelm@423
    30
    val prove_arity: theory -> string * sort list * class -> thm list
wenzelm@423
    31
      -> tactic option -> thm
wenzelm@449
    32
    val add_inst_subclass: class * class -> string list -> thm list
wenzelm@404
    33
      -> tactic option -> theory -> theory
wenzelm@449
    34
    val add_inst_arity: string * sort list * class list -> string list
wenzelm@423
    35
      -> thm list -> tactic option -> theory -> theory
wenzelm@487
    36
    val add_defns: (string * string) list -> theory -> theory
wenzelm@487
    37
    val add_defns_i: (string * term) list -> theory -> theory
wenzelm@474
    38
    val mk_classrel: class * class -> term
wenzelm@474
    39
    val dest_classrel: term -> class * class
wenzelm@474
    40
    val mk_arity: string * sort list * class -> term
wenzelm@474
    41
    val dest_arity: term -> string * sort list * class
wenzelm@474
    42
    val class_axms: theory -> thm list
wenzelm@474
    43
    val axclass_tac: theory -> thm list -> tactic
wenzelm@474
    44
    val goal_subclass: theory -> class * class -> thm list
wenzelm@474
    45
    val goal_arity: theory -> string * sort list * class -> thm list
wenzelm@404
    46
  end
wenzelm@404
    47
end;
wenzelm@404
    48
wenzelm@404
    49
functor AxClassFun(structure Logic: LOGIC and Goals: GOALS and Tactic: TACTIC
wenzelm@474
    50
  sharing Goals.Tactical = Tactic.Tactical): AX_CLASS =
wenzelm@404
    51
struct
wenzelm@404
    52
wenzelm@404
    53
structure Tactical = Goals.Tactical;
wenzelm@404
    54
structure Thm = Tactical.Thm;
wenzelm@404
    55
structure Sign = Thm.Sign;
wenzelm@404
    56
structure Type = Sign.Type;
wenzelm@487
    57
structure Pretty = Sign.Syntax.Pretty;
wenzelm@404
    58
wenzelm@404
    59
open Logic Thm Tactical Tactic Goals;
wenzelm@404
    60
wenzelm@404
    61
wenzelm@487
    62
(** add constant definitions **)  (* FIXME -> drule.ML (?) *)
wenzelm@487
    63
wenzelm@487
    64
(* all_axioms_of *)
wenzelm@487
    65
wenzelm@487
    66
(*results may contain duplicates!*)
wenzelm@487
    67
wenzelm@487
    68
fun ancestry_of thy =
wenzelm@487
    69
  thy :: flat (map ancestry_of (parents_of thy));
wenzelm@487
    70
wenzelm@487
    71
val all_axioms_of = flat o map axioms_of o ancestry_of;
wenzelm@487
    72
wenzelm@487
    73
wenzelm@487
    74
(* clash_types, clash_consts *)
wenzelm@487
    75
wenzelm@487
    76
(*check if types have common instance (ignoring sorts)*)
wenzelm@487
    77
wenzelm@487
    78
fun clash_types ty1 ty2 =
wenzelm@487
    79
  let
wenzelm@487
    80
    val ty1' = Type.varifyT ty1;
wenzelm@487
    81
    val ty2' = incr_tvar (maxidx_of_typ ty1' + 1) (Type.varifyT ty2);
wenzelm@487
    82
  in
wenzelm@487
    83
    Type.raw_unify (ty1', ty2')
wenzelm@487
    84
  end;
wenzelm@487
    85
wenzelm@487
    86
fun clash_consts (c1, ty1) (c2, ty2) =
wenzelm@487
    87
  c1 = c2 andalso clash_types ty1 ty2;
wenzelm@487
    88
wenzelm@487
    89
wenzelm@487
    90
(* clash_defns *)
wenzelm@487
    91
wenzelm@487
    92
fun clash_defn c_ty (name, tm) =
wenzelm@487
    93
  let val (c, ty') = dest_Const (head_of (fst (Logic.dest_equals tm))) in
wenzelm@487
    94
    if clash_consts c_ty (c, ty') then Some (name, ty') else None
wenzelm@487
    95
  end handle TERM _ => None;
wenzelm@487
    96
wenzelm@487
    97
fun clash_defns c_ty axms =
wenzelm@487
    98
  distinct (mapfilter (clash_defn c_ty) axms);
wenzelm@487
    99
wenzelm@487
   100
wenzelm@487
   101
(* dest_defn *)
wenzelm@487
   102
wenzelm@487
   103
fun dest_defn tm =
wenzelm@487
   104
  let
wenzelm@487
   105
    fun err msg = raise_term msg [tm];
wenzelm@487
   106
wenzelm@487
   107
    val (lhs, rhs) = Logic.dest_equals tm
wenzelm@487
   108
      handle TERM _ => err "Not a meta-equality (==)";
wenzelm@487
   109
    val (head, args) = strip_comb lhs;
wenzelm@487
   110
    val (c, ty) = dest_Const head
wenzelm@487
   111
      handle TERM _ => err "Head of lhs not a constant";
wenzelm@404
   112
wenzelm@487
   113
    fun occs_const (Const c_ty') = clash_consts (c, ty) c_ty'
wenzelm@487
   114
      | occs_const (Abs (_, _, t)) = occs_const t
wenzelm@487
   115
      | occs_const (t $ u) = occs_const t orelse occs_const u
wenzelm@487
   116
      | occs_const _ = false;
wenzelm@487
   117
  in
wenzelm@487
   118
    if not (forall is_Free args) then
wenzelm@487
   119
      err "Arguments of lhs have to be variables"
wenzelm@487
   120
    else if not (null (duplicates args)) then
wenzelm@487
   121
      err "Duplicate variables on lhs"
wenzelm@487
   122
    else if not (term_frees rhs subset args) then
wenzelm@487
   123
      err "Extra variables on rhs"
wenzelm@487
   124
    else if not (term_tfrees rhs subset typ_tfrees ty) then
wenzelm@487
   125
      err "Extra type variables on rhs"
wenzelm@487
   126
    else if occs_const rhs then
wenzelm@487
   127
      err "Constant to be defined clashes with occurrence(s) on rhs"
wenzelm@487
   128
    else (c, ty)
wenzelm@487
   129
  end;
wenzelm@487
   130
wenzelm@487
   131
wenzelm@487
   132
(* check_defn *)
wenzelm@487
   133
wenzelm@487
   134
fun err_in_axm name msg =
wenzelm@487
   135
  (writeln msg; error ("The error(s) above occurred in axiom " ^ quote name));
wenzelm@487
   136
wenzelm@487
   137
fun check_defn sign (axms, (name, tm)) =
wenzelm@487
   138
  let
wenzelm@487
   139
    fun show_const (c, ty) = quote (Pretty.string_of (Pretty.block
wenzelm@487
   140
      [Pretty.str (c ^ " ::"), Pretty.brk 1, Sign.pretty_typ sign ty]));
wenzelm@487
   141
wenzelm@487
   142
    fun show_defn c (dfn, ty') = show_const (c, ty') ^ " in " ^ dfn;
wenzelm@487
   143
    fun show_defns c = commas o map (show_defn c);
wenzelm@487
   144
wenzelm@487
   145
    val (c, ty) = dest_defn tm
wenzelm@487
   146
      handle TERM (msg, _) => err_in_axm name msg;
wenzelm@487
   147
    val defns = clash_defns (c, ty) axms;
wenzelm@487
   148
  in
wenzelm@487
   149
    if not (null defns) then
wenzelm@487
   150
      err_in_axm name ("Definition of " ^ show_const (c, ty) ^
wenzelm@487
   151
        " clashes with " ^ show_defns c defns)
wenzelm@487
   152
    else (name, tm) :: axms
wenzelm@487
   153
  end;
wenzelm@487
   154
wenzelm@487
   155
wenzelm@487
   156
(* add_defns *)
wenzelm@487
   157
wenzelm@487
   158
fun ext_defns prep_axm raw_axms thy =
wenzelm@487
   159
  let
wenzelm@487
   160
    val axms = map (prep_axm (sign_of thy)) raw_axms;
wenzelm@487
   161
    val all_axms = all_axioms_of thy;
wenzelm@487
   162
  in
wenzelm@487
   163
    foldl (check_defn (sign_of thy)) (all_axms, axms);
wenzelm@487
   164
    add_axioms_i axms thy
wenzelm@487
   165
  end;
wenzelm@487
   166
wenzelm@487
   167
val add_defns_i = ext_defns cert_axm;
wenzelm@487
   168
val add_defns = ext_defns read_axm;
wenzelm@404
   169
wenzelm@404
   170
wenzelm@423
   171
wenzelm@404
   172
(** utilities **)
wenzelm@404
   173
wenzelm@404
   174
(* type vars *)
wenzelm@404
   175
wenzelm@404
   176
fun map_typ_frees f (Type (t, tys)) = Type (t, map (map_typ_frees f) tys)
wenzelm@404
   177
  | map_typ_frees f (TFree a) = f a
wenzelm@404
   178
  | map_typ_frees _ a = a;
wenzelm@404
   179
wenzelm@404
   180
val map_term_tfrees = map_term_types o map_typ_frees;
wenzelm@404
   181
wenzelm@404
   182
fun aT S = TFree ("'a", S);
wenzelm@404
   183
wenzelm@404
   184
wenzelm@404
   185
(* get axioms *)
wenzelm@404
   186
wenzelm@404
   187
fun get_ax thy name =
wenzelm@404
   188
  Some (get_axiom thy name) handle THEORY _ => None;
wenzelm@404
   189
wenzelm@404
   190
val get_axioms = mapfilter o get_ax;
wenzelm@404
   191
wenzelm@404
   192
wenzelm@404
   193
(* is_defn *)
wenzelm@404
   194
wenzelm@404
   195
fun is_defn thm =
wenzelm@404
   196
  (case #prop (rep_thm thm) of
wenzelm@404
   197
    Const ("==", _) $ _ $ _ => true
wenzelm@404
   198
  | _ => false);
wenzelm@404
   199
wenzelm@404
   200
wenzelm@404
   201
wenzelm@423
   202
(** abstract syntax operations **)    (* FIXME -> logic.ML (?) *)
wenzelm@423
   203
wenzelm@423
   204
(* subclass relations as terms *)
wenzelm@423
   205
wenzelm@423
   206
fun mk_classrel (c1, c2) = mk_inclass (aT [c1], c2);
wenzelm@423
   207
wenzelm@423
   208
fun dest_classrel tm =
wenzelm@423
   209
  let
wenzelm@423
   210
    fun err () = raise_term "dest_classrel" [tm];
wenzelm@423
   211
wenzelm@423
   212
    val (ty, c2) = dest_inclass (freeze_vars tm) handle TERM _ => err ();
wenzelm@423
   213
    val c1 = (case ty of TFree (_, [c]) => c | _ => err ());
wenzelm@423
   214
  in
wenzelm@423
   215
    (c1, c2)
wenzelm@423
   216
  end;
wenzelm@423
   217
wenzelm@423
   218
wenzelm@423
   219
(* arities as terms *)
wenzelm@423
   220
wenzelm@423
   221
fun mk_arity (t, ss, c) =
wenzelm@423
   222
  let
wenzelm@449
   223
    val names = tl (variantlist (replicate (length ss + 1) "'", []));
wenzelm@423
   224
    val tfrees = map TFree (names ~~ ss);
wenzelm@423
   225
  in
wenzelm@423
   226
    mk_inclass (Type (t, tfrees), c)
wenzelm@423
   227
  end;
wenzelm@423
   228
wenzelm@423
   229
fun dest_arity tm =
wenzelm@423
   230
  let
wenzelm@423
   231
    fun err () = raise_term "dest_arity" [tm];
wenzelm@423
   232
wenzelm@423
   233
    val (ty, c) = dest_inclass (freeze_vars tm) handle TERM _ => err ();
wenzelm@423
   234
    val (t, tfrees) =
wenzelm@423
   235
      (case ty of
wenzelm@423
   236
        Type (t, tys) => (t, map (fn TFree x => x | _ => err ()) tys)
wenzelm@423
   237
      | _ => err ());
wenzelm@423
   238
    val ss =
wenzelm@423
   239
      if null (gen_duplicates eq_fst tfrees)
wenzelm@423
   240
      then map snd tfrees else err ();
wenzelm@423
   241
  in
wenzelm@423
   242
    (t, ss, c)
wenzelm@423
   243
  end;
wenzelm@423
   244
wenzelm@423
   245
wenzelm@423
   246
wenzelm@423
   247
(** add theorems as axioms **)    (* FIXME -> drule.ML (?) *)
wenzelm@423
   248
wenzelm@423
   249
fun prep_thm_axm thy thm =
wenzelm@423
   250
  let
wenzelm@423
   251
    fun err msg = raise THM ("prep_thm_axm: " ^ msg, 0, [thm]);
wenzelm@423
   252
wenzelm@423
   253
    val {sign, hyps, prop, ...} = rep_thm thm;
wenzelm@423
   254
  in
wenzelm@423
   255
    if not (Sign.subsig (sign, sign_of thy)) then
wenzelm@423
   256
      err "theorem not of same theory"
wenzelm@423
   257
    else if not (null hyps) then
wenzelm@423
   258
      err "theorem may not contain hypotheses"
wenzelm@423
   259
    else prop
wenzelm@423
   260
  end;
wenzelm@423
   261
wenzelm@423
   262
(*general theorems*)
wenzelm@423
   263
fun add_thms_as_axms thms thy =
wenzelm@423
   264
  add_axioms_i (map (apsnd (prep_thm_axm thy)) thms) thy;
wenzelm@423
   265
wenzelm@423
   266
(*theorems expressing class relations*)
wenzelm@423
   267
fun add_classrel_thms thms thy =
wenzelm@423
   268
  let
wenzelm@423
   269
    fun prep_thm thm =
wenzelm@423
   270
      let
wenzelm@423
   271
        val prop = prep_thm_axm thy thm;
wenzelm@423
   272
        val (c1, c2) = dest_classrel prop handle TERM _ =>
wenzelm@423
   273
          raise THM ("add_classrel_thms: theorem is not a class relation", 0, [thm]);
wenzelm@423
   274
      in (c1, c2) end;
wenzelm@423
   275
  in
wenzelm@423
   276
    add_classrel (map prep_thm thms) thy
wenzelm@423
   277
  end;
wenzelm@423
   278
wenzelm@423
   279
(*theorems expressing arities*)
wenzelm@423
   280
fun add_arity_thms thms thy =
wenzelm@423
   281
  let
wenzelm@423
   282
    fun prep_thm thm =
wenzelm@423
   283
      let
wenzelm@423
   284
        val prop = prep_thm_axm thy thm;
wenzelm@423
   285
        val (t, ss, c) = dest_arity prop handle TERM _ =>
wenzelm@423
   286
          raise THM ("add_arity_thms: theorem is not an arity", 0, [thm]);
wenzelm@423
   287
      in (t, ss, [c]) end;
wenzelm@423
   288
  in
wenzelm@423
   289
    add_arities (map prep_thm thms) thy
wenzelm@423
   290
  end;
wenzelm@423
   291
wenzelm@423
   292
wenzelm@423
   293
wenzelm@423
   294
(** add axiomatic type classes **)
wenzelm@404
   295
wenzelm@404
   296
(* errors *)
wenzelm@404
   297
wenzelm@404
   298
fun err_not_logic c =
wenzelm@404
   299
  error ("Axiomatic class " ^ quote c ^ " not subclass of \"logic\"");
wenzelm@404
   300
wenzelm@404
   301
fun err_bad_axsort ax c =
wenzelm@404
   302
  error ("Sort constraint in axiom " ^ quote ax ^ " not supersort of " ^ quote c);
wenzelm@404
   303
wenzelm@404
   304
fun err_bad_tfrees ax =
wenzelm@404
   305
  error ("More than one type variable in axiom " ^ quote ax);
wenzelm@404
   306
wenzelm@404
   307
wenzelm@404
   308
(* ext_axclass *)
wenzelm@404
   309
wenzelm@404
   310
fun ext_axclass prep_axm (class, super_classes) raw_axioms old_thy =
wenzelm@404
   311
  let
wenzelm@404
   312
    val axioms = map (prep_axm (sign_of old_thy)) raw_axioms;
wenzelm@404
   313
    val thy = add_classes [([], class, super_classes)] old_thy;
wenzelm@404
   314
    val sign = sign_of thy;
wenzelm@404
   315
wenzelm@404
   316
wenzelm@404
   317
    (* prepare abstract axioms *)
wenzelm@404
   318
wenzelm@404
   319
    fun abs_axm ax =
wenzelm@404
   320
      if null (term_tfrees ax) then
wenzelm@404
   321
        mk_implies (mk_inclass (aT logicS, class), ax)
wenzelm@404
   322
      else
wenzelm@404
   323
        map_term_tfrees (K (aT [class])) ax;
wenzelm@404
   324
wenzelm@404
   325
    val abs_axioms = map (apsnd abs_axm) axioms;
wenzelm@404
   326
wenzelm@404
   327
wenzelm@404
   328
    (* prepare introduction orule *)
wenzelm@404
   329
wenzelm@404
   330
    val _ =
wenzelm@404
   331
      if Sign.subsort sign ([class], logicS) then ()
wenzelm@404
   332
      else err_not_logic class;
wenzelm@404
   333
wenzelm@404
   334
    fun axm_sort (name, ax) =
wenzelm@404
   335
      (case term_tfrees ax of
wenzelm@404
   336
        [] => []
wenzelm@404
   337
      | [(_, S)] =>
wenzelm@404
   338
          if Sign.subsort sign ([class], S) then S
wenzelm@404
   339
          else err_bad_axsort name class
wenzelm@404
   340
      | _ => err_bad_tfrees name);
wenzelm@404
   341
wenzelm@404
   342
    val axS = Sign.norm_sort sign (logicC :: flat (map axm_sort axioms));
wenzelm@404
   343
wenzelm@404
   344
    val int_axm = close_form o map_term_tfrees (K (aT axS));
wenzelm@404
   345
    fun inclass c = mk_inclass (aT axS, c);
wenzelm@404
   346
wenzelm@404
   347
    val intro_axm = list_implies
wenzelm@404
   348
      (map inclass super_classes @ map (int_axm o snd) axioms, inclass class);
wenzelm@404
   349
  in
wenzelm@404
   350
    add_axioms_i ((class ^ "I", intro_axm) :: abs_axioms) thy
wenzelm@404
   351
  end;
wenzelm@404
   352
wenzelm@404
   353
wenzelm@404
   354
(* external interfaces *)
wenzelm@404
   355
wenzelm@404
   356
val add_axclass = ext_axclass read_axm;
wenzelm@404
   357
val add_axclass_i = ext_axclass cert_axm;
wenzelm@404
   358
wenzelm@404
   359
wenzelm@423
   360
(* add signature classes *)
wenzelm@404
   361
wenzelm@423
   362
fun ext_sigclass add_cnsts (class, super_classes) consts old_thy =
wenzelm@423
   363
  old_thy
wenzelm@423
   364
  |> add_axclass (class, super_classes) []
wenzelm@423
   365
  |> add_defsort [class]
wenzelm@423
   366
  |> add_cnsts consts
wenzelm@423
   367
  |> add_defsort (Type.defaultS (#tsig (Sign.rep_sg (sign_of old_thy))));
wenzelm@404
   368
wenzelm@423
   369
val add_sigclass = ext_sigclass add_consts;
wenzelm@423
   370
val add_sigclass_i = ext_sigclass add_consts_i;
wenzelm@404
   371
wenzelm@404
   372
wenzelm@404
   373
wenzelm@423
   374
(** prove class relations and type arities **)
wenzelm@423
   375
wenzelm@423
   376
(* class_axms *)
wenzelm@404
   377
wenzelm@404
   378
fun class_axms thy =
wenzelm@404
   379
  let
wenzelm@404
   380
    val classes = Sign.classes (sign_of thy);
wenzelm@404
   381
    val intros = map (fn c => c ^ "I") classes;
wenzelm@404
   382
  in
wenzelm@404
   383
    get_axioms thy intros @
wenzelm@404
   384
    map (class_triv thy) classes
wenzelm@404
   385
  end;
wenzelm@404
   386
wenzelm@423
   387
wenzelm@423
   388
(* axclass_tac *)
wenzelm@423
   389
wenzelm@487
   390
(*(1) repeatedly resolve goals of form "OFCLASS(ty, c_class)",
wenzelm@423
   391
      try "cI" axioms first and use class_triv as last resort
wenzelm@423
   392
  (2) rewrite goals using user supplied definitions
wenzelm@423
   393
  (3) repeatedly resolve goals with user supplied non-definitions*)
wenzelm@423
   394
wenzelm@423
   395
fun axclass_tac thy thms =
wenzelm@423
   396
  TRY (REPEAT_FIRST (resolve_tac (class_axms thy))) THEN
wenzelm@423
   397
  TRY (rewrite_goals_tac (filter is_defn thms)) THEN
wenzelm@423
   398
  TRY (REPEAT_FIRST (resolve_tac (filter_out is_defn thms)));
wenzelm@404
   399
wenzelm@404
   400
wenzelm@423
   401
(* provers *)
wenzelm@404
   402
wenzelm@423
   403
fun prove term_of str_of thy sig_prop thms usr_tac =
wenzelm@404
   404
  let
wenzelm@404
   405
    val sign = sign_of thy;
wenzelm@423
   406
    val goal = cterm_of sign (term_of sig_prop);
wenzelm@423
   407
    val tac = axclass_tac thy thms THEN (if_none usr_tac all_tac);
wenzelm@423
   408
  in
wenzelm@423
   409
    prove_goalw_cterm [] goal (K [tac])
wenzelm@423
   410
  end
wenzelm@423
   411
  handle ERROR => error ("The error(s) above occurred while trying to prove "
wenzelm@423
   412
    ^ quote (str_of sig_prop));
wenzelm@404
   413
wenzelm@423
   414
val prove_classrel =
wenzelm@423
   415
  prove mk_classrel (fn (c1, c2) => c1 ^ " < " ^ c2);
wenzelm@404
   416
wenzelm@423
   417
val prove_arity =
wenzelm@423
   418
  prove mk_arity (fn (t, ss, c) => Type.str_of_arity (t, ss, [c]));
wenzelm@404
   419
wenzelm@404
   420
wenzelm@423
   421
(* make goals (for interactive use) *)
wenzelm@423
   422
wenzelm@423
   423
fun mk_goal term_of thy sig_prop =
wenzelm@423
   424
  goalw_cterm [] (cterm_of (sign_of thy) (term_of sig_prop));
wenzelm@423
   425
wenzelm@423
   426
val goal_subclass = mk_goal mk_classrel;
wenzelm@423
   427
val goal_arity = mk_goal mk_arity;
wenzelm@423
   428
wenzelm@423
   429
wenzelm@423
   430
wenzelm@449
   431
(** add proved subclass relations and arities **)
wenzelm@404
   432
wenzelm@449
   433
fun add_inst_subclass (c1, c2) axms thms usr_tac thy =
wenzelm@423
   434
  add_classrel_thms
wenzelm@423
   435
  [prove_classrel thy (c1, c2) (get_axioms thy axms @ thms) usr_tac] thy;
wenzelm@423
   436
wenzelm@449
   437
fun add_inst_arity (t, ss, cs) axms thms usr_tac thy =
wenzelm@423
   438
  let
wenzelm@423
   439
    val usr_thms = get_axioms thy axms @ thms;
wenzelm@423
   440
    fun prove c =
wenzelm@423
   441
      prove_arity thy (t, ss, c) usr_thms usr_tac;
wenzelm@423
   442
  in
wenzelm@423
   443
    add_arity_thms (map prove cs) thy
wenzelm@423
   444
  end;
wenzelm@404
   445
wenzelm@404
   446
wenzelm@404
   447
end;
wenzelm@404
   448