src/Pure/more_thm.ML
author haftmann
Fri Jun 19 21:08:07 2009 +0200 (2009-06-19)
changeset 31726 ffd2dc631d88
parent 31177 c39994cb152a
child 31904 a86896359ca4
permissions -rw-r--r--
merged
wenzelm@22362
     1
(*  Title:      Pure/more_thm.ML
wenzelm@22362
     2
    Author:     Makarius
wenzelm@22362
     3
wenzelm@22907
     4
Further operations on type ctyp/cterm/thm, outside the inference kernel.
wenzelm@22362
     5
*)
wenzelm@22362
     6
wenzelm@23169
     7
infix aconvc;
wenzelm@23169
     8
wenzelm@22362
     9
signature THM =
wenzelm@22362
    10
sig
wenzelm@22362
    11
  include THM
wenzelm@24948
    12
  val aconvc: cterm * cterm -> bool
wenzelm@23491
    13
  val add_cterm_frees: cterm -> cterm list -> cterm list
wenzelm@22907
    14
  val mk_binop: cterm -> cterm -> cterm -> cterm
wenzelm@22907
    15
  val dest_binop: cterm -> cterm * cterm
wenzelm@22907
    16
  val dest_implies: cterm -> cterm * cterm
wenzelm@22907
    17
  val dest_equals: cterm -> cterm * cterm
wenzelm@22907
    18
  val dest_equals_lhs: cterm -> cterm
wenzelm@22907
    19
  val dest_equals_rhs: cterm -> cterm
wenzelm@22907
    20
  val lhs_of: thm -> cterm
wenzelm@22907
    21
  val rhs_of: thm -> cterm
wenzelm@22362
    22
  val thm_ord: thm * thm -> order
wenzelm@23599
    23
  val is_reflexive: thm -> bool
wenzelm@22362
    24
  val eq_thm: thm * thm -> bool
wenzelm@22362
    25
  val eq_thms: thm list * thm list -> bool
wenzelm@22362
    26
  val eq_thm_thy: thm * thm -> bool
wenzelm@22362
    27
  val eq_thm_prop: thm * thm -> bool
wenzelm@22362
    28
  val equiv_thm: thm * thm -> bool
wenzelm@28621
    29
  val check_shyps: sort list -> thm -> thm
wenzelm@24048
    30
  val is_dummy: thm -> bool
wenzelm@22695
    31
  val plain_prop_of: thm -> term
wenzelm@22695
    32
  val fold_terms: (term -> 'a -> 'a) -> thm -> 'a -> 'a
wenzelm@24048
    33
  val add_thm: thm -> thm list -> thm list
wenzelm@24048
    34
  val del_thm: thm -> thm list -> thm list
wenzelm@24048
    35
  val merge_thms: thm list * thm list -> thm list
wenzelm@30560
    36
  val intro_rules: thm Item_Net.T
wenzelm@30560
    37
  val elim_rules: thm Item_Net.T
wenzelm@27866
    38
  val elim_implies: thm -> thm -> thm
wenzelm@27866
    39
  val forall_elim_var: int -> thm -> thm
wenzelm@27866
    40
  val forall_elim_vars: int -> thm -> thm
wenzelm@27866
    41
  val unvarify: thm -> thm
wenzelm@27866
    42
  val close_derivation: thm -> thm
haftmann@29579
    43
  val add_axiom: binding * term -> theory -> thm * theory
haftmann@29579
    44
  val add_def: bool -> bool -> binding * term -> theory -> thm * theory
wenzelm@30210
    45
  type binding = binding * attribute list
wenzelm@30210
    46
  val empty_binding: binding
wenzelm@27866
    47
  val rule_attribute: (Context.generic -> thm -> thm) -> attribute
wenzelm@27866
    48
  val declaration_attribute: (thm -> Context.generic -> Context.generic) -> attribute
wenzelm@27866
    49
  val theory_attributes: attribute list -> theory * thm -> theory * thm
wenzelm@27866
    50
  val proof_attributes: attribute list -> Proof.context * thm -> Proof.context * thm
wenzelm@27866
    51
  val no_attributes: 'a -> 'a * 'b list
wenzelm@27866
    52
  val simple_fact: 'a -> ('a * 'b list) list
wenzelm@28017
    53
  val tag_rule: Properties.property -> thm -> thm
wenzelm@27866
    54
  val untag_rule: string -> thm -> thm
wenzelm@28017
    55
  val tag: Properties.property -> attribute
wenzelm@27866
    56
  val untag: string -> attribute
wenzelm@27866
    57
  val position_of: thm -> Position.T
wenzelm@27866
    58
  val default_position: Position.T -> thm -> thm
wenzelm@27866
    59
  val default_position_of: thm -> thm -> thm
wenzelm@30342
    60
  val def_name: string -> string
wenzelm@30342
    61
  val def_name_optional: string -> string -> string
wenzelm@30433
    62
  val def_binding_optional: Binding.binding -> Binding.binding -> Binding.binding
wenzelm@27866
    63
  val has_name_hint: thm -> bool
wenzelm@27866
    64
  val get_name_hint: thm -> string
wenzelm@27866
    65
  val put_name_hint: string -> thm -> thm
wenzelm@27866
    66
  val get_group: thm -> string option
wenzelm@27866
    67
  val put_group: string -> thm -> thm
wenzelm@27866
    68
  val group: string -> attribute
wenzelm@22362
    69
  val axiomK: string
wenzelm@22362
    70
  val assumptionK: string
wenzelm@22362
    71
  val definitionK: string
wenzelm@22362
    72
  val theoremK: string
haftmann@31177
    73
  val generatedK : string
wenzelm@22362
    74
  val lemmaK: string
wenzelm@22362
    75
  val corollaryK: string
wenzelm@22362
    76
  val internalK: string
wenzelm@27866
    77
  val has_kind: thm -> bool
wenzelm@27866
    78
  val get_kind: thm -> string
wenzelm@27866
    79
  val kind_rule: string -> thm -> thm
wenzelm@27866
    80
  val kind: string -> attribute
wenzelm@27866
    81
  val kind_internal: attribute
wenzelm@28017
    82
  val has_internal: Properties.property list -> bool
wenzelm@27866
    83
  val is_internal: thm -> bool
wenzelm@22362
    84
end;
wenzelm@22362
    85
wenzelm@22362
    86
structure Thm: THM =
wenzelm@22362
    87
struct
wenzelm@22362
    88
wenzelm@22695
    89
(** basic operations **)
wenzelm@22362
    90
wenzelm@23491
    91
(* collecting cterms *)
wenzelm@23491
    92
wenzelm@23491
    93
val op aconvc = op aconv o pairself Thm.term_of;
wenzelm@23491
    94
wenzelm@23491
    95
fun add_cterm_frees ct =
wenzelm@23491
    96
  let
wenzelm@23491
    97
    val cert = Thm.cterm_of (Thm.theory_of_cterm ct);
wenzelm@23491
    98
    val t = Thm.term_of ct;
wenzelm@23491
    99
  in Term.fold_aterms (fn v as Free _ => insert (op aconvc) (cert v) | _ => I) t end;
wenzelm@23491
   100
wenzelm@23491
   101
wenzelm@22907
   102
(* cterm constructors and destructors *)
wenzelm@22907
   103
wenzelm@22907
   104
fun mk_binop c a b = Thm.capply (Thm.capply c a) b;
wenzelm@22907
   105
fun dest_binop ct = (Thm.dest_arg1 ct, Thm.dest_arg ct);
wenzelm@22907
   106
wenzelm@22907
   107
fun dest_implies ct =
wenzelm@22907
   108
  (case Thm.term_of ct of
wenzelm@22907
   109
    Const ("==>", _) $ _ $ _ => dest_binop ct
wenzelm@22907
   110
  | _ => raise TERM ("dest_implies", [Thm.term_of ct]));
wenzelm@22907
   111
wenzelm@22907
   112
fun dest_equals ct =
wenzelm@22907
   113
  (case Thm.term_of ct of
wenzelm@22907
   114
    Const ("==", _) $ _ $ _ => dest_binop ct
wenzelm@22907
   115
  | _ => raise TERM ("dest_equals", [Thm.term_of ct]));
wenzelm@22907
   116
wenzelm@22907
   117
fun dest_equals_lhs ct =
wenzelm@22907
   118
  (case Thm.term_of ct of
wenzelm@22907
   119
    Const ("==", _) $ _ $ _ => Thm.dest_arg1 ct
wenzelm@22907
   120
  | _ => raise TERM ("dest_equals_lhs", [Thm.term_of ct]));
wenzelm@22907
   121
wenzelm@22907
   122
fun dest_equals_rhs ct =
wenzelm@22907
   123
  (case Thm.term_of ct of
wenzelm@22907
   124
    Const ("==", _) $ _ $ _ => Thm.dest_arg ct
wenzelm@22907
   125
  | _ => raise TERM ("dest_equals_rhs", [Thm.term_of ct]));
wenzelm@22907
   126
wenzelm@22907
   127
val lhs_of = dest_equals_lhs o Thm.cprop_of;
wenzelm@22907
   128
val rhs_of = dest_equals_rhs o Thm.cprop_of;
wenzelm@22907
   129
wenzelm@22907
   130
wenzelm@22907
   131
(* thm order: ignores theory context! *)
wenzelm@22682
   132
wenzelm@22362
   133
fun thm_ord (th1, th2) =
wenzelm@22362
   134
  let
wenzelm@22362
   135
    val {shyps = shyps1, hyps = hyps1, tpairs = tpairs1, prop = prop1, ...} = Thm.rep_thm th1;
wenzelm@22362
   136
    val {shyps = shyps2, hyps = hyps2, tpairs = tpairs2, prop = prop2, ...} = Thm.rep_thm th2;
wenzelm@22362
   137
  in
wenzelm@29269
   138
    (case TermOrd.fast_term_ord (prop1, prop2) of
wenzelm@22362
   139
      EQUAL =>
wenzelm@29269
   140
        (case list_ord (prod_ord TermOrd.fast_term_ord TermOrd.fast_term_ord) (tpairs1, tpairs2) of
wenzelm@22362
   141
          EQUAL =>
wenzelm@29269
   142
            (case list_ord TermOrd.fast_term_ord (hyps1, hyps2) of
wenzelm@29269
   143
              EQUAL => list_ord TermOrd.sort_ord (shyps1, shyps2)
wenzelm@22362
   144
            | ord => ord)
wenzelm@22362
   145
        | ord => ord)
wenzelm@22362
   146
    | ord => ord)
wenzelm@22362
   147
  end;
wenzelm@22362
   148
wenzelm@22682
   149
wenzelm@22682
   150
(* equality *)
wenzelm@22682
   151
wenzelm@23599
   152
fun is_reflexive th = op aconv (Logic.dest_equals (Thm.prop_of th))
wenzelm@23599
   153
  handle TERM _ => false;
wenzelm@23599
   154
wenzelm@22362
   155
fun eq_thm ths =
wenzelm@22362
   156
  Context.joinable (pairself Thm.theory_of_thm ths) andalso
wenzelm@26653
   157
  is_equal (thm_ord ths);
wenzelm@22362
   158
wenzelm@22362
   159
val eq_thms = eq_list eq_thm;
wenzelm@22362
   160
wenzelm@26665
   161
val eq_thm_thy = Theory.eq_thy o pairself Thm.theory_of_thm;
wenzelm@22362
   162
val eq_thm_prop = op aconv o pairself Thm.full_prop_of;
wenzelm@22362
   163
wenzelm@22682
   164
wenzelm@22682
   165
(* pattern equivalence *)
wenzelm@22682
   166
wenzelm@22362
   167
fun equiv_thm ths =
wenzelm@22362
   168
  Pattern.equiv (Theory.merge (pairself Thm.theory_of_thm ths)) (pairself Thm.full_prop_of ths);
wenzelm@22362
   169
wenzelm@22362
   170
wenzelm@28621
   171
(* sort hypotheses *)
wenzelm@28621
   172
wenzelm@28621
   173
fun check_shyps sorts raw_th =
wenzelm@28621
   174
  let
wenzelm@28621
   175
    val th = Thm.strip_shyps raw_th;
wenzelm@28621
   176
    val prt_sort = Syntax.pretty_sort_global (Thm.theory_of_thm th);
wenzelm@28621
   177
    val pending = Sorts.subtract sorts (Thm.extra_shyps th);
wenzelm@28621
   178
  in
wenzelm@28621
   179
    if null pending then th
wenzelm@28621
   180
    else error (Pretty.string_of (Pretty.block (Pretty.str "Pending sort hypotheses:" ::
wenzelm@28621
   181
      Pretty.brk 1 :: Pretty.commas (map prt_sort pending))))
wenzelm@28621
   182
  end;
wenzelm@28621
   183
wenzelm@28621
   184
wenzelm@22695
   185
(* misc operations *)
wenzelm@22695
   186
wenzelm@24048
   187
fun is_dummy thm =
wenzelm@24048
   188
  (case try Logic.dest_term (Thm.concl_of thm) of
wenzelm@24048
   189
    NONE => false
wenzelm@24048
   190
  | SOME t => Term.is_dummy_pattern t);
wenzelm@24048
   191
wenzelm@22695
   192
fun plain_prop_of raw_thm =
wenzelm@22695
   193
  let
wenzelm@22695
   194
    val thm = Thm.strip_shyps raw_thm;
wenzelm@22695
   195
    fun err msg = raise THM ("plain_prop_of: " ^ msg, 0, [thm]);
wenzelm@22695
   196
    val {hyps, prop, tpairs, ...} = Thm.rep_thm thm;
wenzelm@22695
   197
  in
wenzelm@22695
   198
    if not (null hyps) then
wenzelm@22695
   199
      err "theorem may not contain hypotheses"
wenzelm@22695
   200
    else if not (null (Thm.extra_shyps thm)) then
wenzelm@22695
   201
      err "theorem may not contain sort hypotheses"
wenzelm@22695
   202
    else if not (null tpairs) then
wenzelm@22695
   203
      err "theorem may not contain flex-flex pairs"
wenzelm@22695
   204
    else prop
wenzelm@22695
   205
  end;
wenzelm@22695
   206
wenzelm@22695
   207
fun fold_terms f th =
wenzelm@22695
   208
  let val {tpairs, prop, hyps, ...} = Thm.rep_thm th
wenzelm@22695
   209
  in fold (fn (t, u) => f t #> f u) tpairs #> f prop #> fold f hyps end;
wenzelm@22695
   210
wenzelm@22695
   211
wenzelm@30564
   212
(* collections of theorems in canonical order *)
wenzelm@24048
   213
wenzelm@24048
   214
val add_thm = update eq_thm_prop;
wenzelm@24048
   215
val del_thm = remove eq_thm_prop;
wenzelm@24048
   216
val merge_thms = merge eq_thm_prop;
wenzelm@24048
   217
wenzelm@30560
   218
val intro_rules = Item_Net.init eq_thm_prop Thm.concl_of;
wenzelm@30560
   219
val elim_rules = Item_Net.init eq_thm_prop Thm.major_prem_of;
wenzelm@30560
   220
wenzelm@30560
   221
wenzelm@22682
   222
wenzelm@24980
   223
(** basic derived rules **)
wenzelm@24980
   224
wenzelm@24980
   225
(*Elimination of implication
wenzelm@24980
   226
  A    A ==> B
wenzelm@24980
   227
  ------------
wenzelm@24980
   228
        B
wenzelm@24980
   229
*)
wenzelm@24980
   230
fun elim_implies thA thAB = Thm.implies_elim thAB thA;
wenzelm@24980
   231
wenzelm@26653
   232
wenzelm@26653
   233
(* forall_elim_var(s) *)
wenzelm@26653
   234
wenzelm@26653
   235
local
wenzelm@26653
   236
wenzelm@26653
   237
fun forall_elim_vars_aux strip_vars i th =
wenzelm@26653
   238
  let
wenzelm@26653
   239
    val thy = Thm.theory_of_thm th;
wenzelm@26653
   240
    val {tpairs, prop, ...} = Thm.rep_thm th;
wenzelm@26653
   241
    val add_used = Term.fold_aterms
wenzelm@26653
   242
      (fn Var ((x, j), _) => if i = j then insert (op =) x else I | _ => I);
wenzelm@26653
   243
    val used = fold (fn (t, u) => add_used t o add_used u) tpairs (add_used prop []);
wenzelm@26653
   244
    val vars = strip_vars prop;
wenzelm@26653
   245
    val cvars = (Name.variant_list used (map #1 vars), vars)
wenzelm@26653
   246
      |> ListPair.map (fn (x, (_, T)) => Thm.cterm_of thy (Var ((x, i), T)));
wenzelm@26653
   247
  in fold Thm.forall_elim cvars th end;
wenzelm@26653
   248
wenzelm@26653
   249
in
wenzelm@26653
   250
wenzelm@26653
   251
val forall_elim_vars = forall_elim_vars_aux Term.strip_all_vars;
wenzelm@26653
   252
wenzelm@26653
   253
fun forall_elim_var i th = forall_elim_vars_aux
wenzelm@26653
   254
  (fn Const ("all", _) $ Abs (a, T, _) => [(a, T)]
wenzelm@26653
   255
  | _ => raise THM ("forall_elim_vars", i, [th])) i th;
wenzelm@26653
   256
wenzelm@26653
   257
end;
wenzelm@26653
   258
wenzelm@26653
   259
wenzelm@26653
   260
(* unvarify: global schematic variables *)
wenzelm@26653
   261
wenzelm@24980
   262
fun unvarify th =
wenzelm@24980
   263
  let
wenzelm@24980
   264
    val thy = Thm.theory_of_thm th;
wenzelm@24980
   265
    val cert = Thm.cterm_of thy;
wenzelm@24980
   266
    val certT = Thm.ctyp_of thy;
wenzelm@24980
   267
wenzelm@24980
   268
    val prop = Thm.full_prop_of th;
wenzelm@24980
   269
    val _ = map Logic.unvarify (prop :: Thm.hyps_of th)
wenzelm@24980
   270
      handle TERM (msg, _) => raise THM (msg, 0, [th]);
wenzelm@24980
   271
wenzelm@24980
   272
    val instT0 = rev (Term.add_tvars prop []) |> map (fn v as ((a, _), S) => (v, TFree (a, S)));
wenzelm@24980
   273
    val instT = map (fn (v, T) => (certT (TVar v), certT T)) instT0;
wenzelm@24980
   274
    val inst = rev (Term.add_vars prop []) |> map (fn ((a, i), T) =>
wenzelm@24980
   275
      let val T' = TermSubst.instantiateT instT0 T
wenzelm@24980
   276
      in (cert (Var ((a, i), T')), cert (Free ((a, T')))) end);
wenzelm@24980
   277
  in Thm.instantiate (instT, inst) th end;
wenzelm@24980
   278
wenzelm@26653
   279
wenzelm@26653
   280
(* close_derivation *)
wenzelm@26653
   281
wenzelm@26628
   282
fun close_derivation thm =
wenzelm@26628
   283
  if Thm.get_name thm = "" then Thm.put_name "" thm
wenzelm@26628
   284
  else thm;
wenzelm@26628
   285
wenzelm@24980
   286
wenzelm@24980
   287
wenzelm@24980
   288
(** specification primitives **)
wenzelm@24980
   289
wenzelm@30342
   290
(* rules *)
wenzelm@30342
   291
haftmann@29579
   292
fun add_axiom (b, prop) thy =
wenzelm@24980
   293
  let
haftmann@29579
   294
    val b' = if Binding.is_empty b
haftmann@29579
   295
      then Binding.name ("axiom_" ^ serial_string ()) else b;
haftmann@29579
   296
    val thy' = thy |> Theory.add_axioms_i [(b', prop)];
haftmann@29579
   297
    val axm = unvarify (Thm.axiom thy' (Sign.full_name thy' b'));
wenzelm@28116
   298
  in (axm, thy') end;
wenzelm@24980
   299
haftmann@29579
   300
fun add_def unchecked overloaded (b, prop) thy =
wenzelm@24980
   301
  let
wenzelm@24980
   302
    val tfrees = rev (map TFree (Term.add_tfrees prop []));
wenzelm@24980
   303
    val tfrees' = map (fn a => TFree (a, [])) (Name.invents Name.context Name.aT (length tfrees));
wenzelm@24980
   304
    val strip_sorts = tfrees ~~ tfrees';
wenzelm@24980
   305
    val recover_sorts = map (pairself (Thm.ctyp_of thy o Logic.varifyT)) (tfrees' ~~ tfrees);
wenzelm@24980
   306
wenzelm@24980
   307
    val prop' = Term.map_types (Term.map_atyps (perhaps (AList.lookup (op =) strip_sorts))) prop;
haftmann@29579
   308
    val thy' = Theory.add_defs_i unchecked overloaded [(b, prop')] thy;
haftmann@29579
   309
    val axm' = Thm.axiom thy' (Sign.full_name thy' b);
wenzelm@24980
   310
    val thm = unvarify (Thm.instantiate (recover_sorts, []) axm');
wenzelm@24980
   311
  in (thm, thy') end;
wenzelm@24980
   312
wenzelm@27866
   313
wenzelm@27866
   314
wenzelm@27866
   315
(** attributes **)
wenzelm@27866
   316
wenzelm@30210
   317
type binding = binding * attribute list;
wenzelm@30210
   318
val empty_binding: binding = (Binding.empty, []);
wenzelm@30210
   319
wenzelm@27866
   320
fun rule_attribute f (x, th) = (x, f x th);
wenzelm@27866
   321
fun declaration_attribute f (x, th) = (f th x, th);
wenzelm@27866
   322
wenzelm@27866
   323
fun apply_attributes mk dest =
wenzelm@27866
   324
  let
wenzelm@27866
   325
    fun app [] = I
wenzelm@27866
   326
      | app ((f: attribute) :: fs) = fn (x, th) => f (mk x, th) |>> dest |> app fs;
wenzelm@27866
   327
  in app end;
wenzelm@27866
   328
wenzelm@27866
   329
val theory_attributes = apply_attributes Context.Theory Context.the_theory;
wenzelm@27866
   330
val proof_attributes = apply_attributes Context.Proof Context.the_proof;
wenzelm@27866
   331
wenzelm@27866
   332
fun no_attributes x = (x, []);
wenzelm@27866
   333
fun simple_fact x = [(x, [])];
wenzelm@27866
   334
wenzelm@27866
   335
wenzelm@27866
   336
wenzelm@27866
   337
(*** theorem tags ***)
wenzelm@27866
   338
wenzelm@27866
   339
(* add / delete tags *)
wenzelm@27866
   340
wenzelm@27866
   341
fun tag_rule tg = Thm.map_tags (insert (op =) tg);
wenzelm@27866
   342
fun untag_rule s = Thm.map_tags (filter_out (fn (s', _) => s = s'));
wenzelm@27866
   343
wenzelm@27866
   344
fun tag tg x = rule_attribute (K (tag_rule tg)) x;
wenzelm@27866
   345
fun untag s x = rule_attribute (K (untag_rule s)) x;
wenzelm@27866
   346
wenzelm@27866
   347
wenzelm@27866
   348
(* position *)
wenzelm@27866
   349
wenzelm@27866
   350
val position_of = Position.of_properties o Thm.get_tags;
wenzelm@27866
   351
wenzelm@27866
   352
fun default_position pos = Thm.map_tags (Position.default_properties pos);
wenzelm@27866
   353
val default_position_of = default_position o position_of;
wenzelm@27866
   354
wenzelm@27866
   355
wenzelm@30342
   356
(* def_name *)
wenzelm@30342
   357
wenzelm@30342
   358
fun def_name c = c ^ "_def";
wenzelm@30342
   359
wenzelm@30342
   360
fun def_name_optional c "" = def_name c
wenzelm@30342
   361
  | def_name_optional _ name = name;
wenzelm@30342
   362
wenzelm@30433
   363
fun def_binding_optional b name =
wenzelm@30433
   364
  if Binding.is_empty name then Binding.map_name def_name b else name;
wenzelm@30433
   365
wenzelm@30342
   366
wenzelm@27866
   367
(* unofficial theorem names *)
wenzelm@27866
   368
wenzelm@27866
   369
fun the_name_hint thm = the (AList.lookup (op =) (Thm.get_tags thm) Markup.nameN);
wenzelm@27866
   370
wenzelm@27866
   371
val has_name_hint = can the_name_hint;
wenzelm@27866
   372
val get_name_hint = the_default "??.unknown" o try the_name_hint;
wenzelm@27866
   373
wenzelm@27866
   374
fun put_name_hint name = untag_rule Markup.nameN #> tag_rule (Markup.nameN, name);
wenzelm@27866
   375
wenzelm@27866
   376
wenzelm@27866
   377
(* theorem groups *)
wenzelm@27866
   378
wenzelm@28017
   379
fun get_group thm = Properties.get (Thm.get_tags thm) Markup.groupN;
wenzelm@27866
   380
wenzelm@28017
   381
fun put_group name = if name = "" then I else Thm.map_tags (Properties.put (Markup.groupN, name));
wenzelm@27866
   382
wenzelm@27866
   383
fun group name = rule_attribute (K (put_group name));
wenzelm@27866
   384
wenzelm@27866
   385
wenzelm@27866
   386
(* theorem kinds *)
wenzelm@27866
   387
wenzelm@27866
   388
val axiomK = "axiom";
wenzelm@27866
   389
val assumptionK = "assumption";
wenzelm@27866
   390
val definitionK = "definition";
wenzelm@27866
   391
val theoremK = "theorem";
haftmann@31177
   392
val generatedK = "generatedK"
wenzelm@27866
   393
val lemmaK = "lemma";
wenzelm@27866
   394
val corollaryK = "corollary";
wenzelm@27866
   395
val internalK = Markup.internalK;
wenzelm@27866
   396
wenzelm@28017
   397
fun the_kind thm = the (Properties.get (Thm.get_tags thm) Markup.kindN);
wenzelm@27866
   398
wenzelm@27866
   399
val has_kind = can the_kind;
wenzelm@27866
   400
val get_kind = the_default "" o try the_kind;
wenzelm@27866
   401
wenzelm@27866
   402
fun kind_rule k = tag_rule (Markup.kindN, k) o untag_rule Markup.kindN;
wenzelm@27866
   403
fun kind k x = if k = "" then x else rule_attribute (K (kind_rule k)) x;
wenzelm@27866
   404
fun kind_internal x = kind internalK x;
wenzelm@27866
   405
fun has_internal tags = exists (fn tg => tg = (Markup.kindN, internalK)) tags;
wenzelm@27866
   406
val is_internal = has_internal o Thm.get_tags;
wenzelm@27866
   407
wenzelm@27866
   408
wenzelm@22362
   409
open Thm;
wenzelm@22362
   410
wenzelm@22362
   411
end;
wenzelm@22362
   412
wenzelm@23170
   413
val op aconvc = Thm.aconvc;
wenzelm@23170
   414
wenzelm@22362
   415
structure Thmtab = TableFun(type key = thm val ord = Thm.thm_ord);