src/Pure/Isar/isar_cmd.ML
author wenzelm
Thu Apr 16 13:48:10 2015 +0200 (2015-04-16 ago)
changeset 60095 c48d536231fe
parent 60082 d3573eb7728f
child 60096 96a4765ba7d1
permissions -rw-r--r--
clarified thy_deps;
wenzelm@5831
     1
(*  Title:      Pure/Isar/isar_cmd.ML
wenzelm@5831
     2
    Author:     Markus Wenzel, TU Muenchen
wenzelm@5831
     3
wenzelm@30805
     4
Miscellaneous Isar commands.
wenzelm@5831
     5
*)
wenzelm@5831
     6
wenzelm@5831
     7
signature ISAR_CMD =
wenzelm@5831
     8
sig
wenzelm@59930
     9
  val setup: Input.source -> theory -> theory
wenzelm@59064
    10
  val local_setup: Input.source -> Proof.context -> Proof.context
wenzelm@59064
    11
  val parse_ast_translation: Input.source -> theory -> theory
wenzelm@59064
    12
  val parse_translation: Input.source -> theory -> theory
wenzelm@59064
    13
  val print_translation: Input.source -> theory -> theory
wenzelm@59064
    14
  val typed_print_translation: Input.source -> theory -> theory
wenzelm@59064
    15
  val print_ast_translation: Input.source -> theory -> theory
wenzelm@42204
    16
  val translations: (xstring * string) Syntax.trrule list -> theory -> theory
wenzelm@42204
    17
  val no_translations: (xstring * string) Syntax.trrule list -> theory -> theory
wenzelm@59064
    18
  val oracle: bstring * Position.range -> Input.source -> theory -> theory
wenzelm@58011
    19
  val add_defs: (bool * bool) * ((binding * string) * Token.src list) list -> theory -> theory
wenzelm@59064
    20
  val declaration: {syntax: bool, pervasive: bool} -> Input.source -> local_theory -> local_theory
wenzelm@59064
    21
  val simproc_setup: string * Position.T -> string list -> Input.source ->
wenzelm@42464
    22
    string list -> local_theory -> local_theory
wenzelm@28084
    23
  val have: (Attrib.binding * (string * string list) list) list -> bool -> Proof.state -> Proof.state
wenzelm@28084
    24
  val hence: (Attrib.binding * (string * string list) list) list -> bool -> Proof.state -> Proof.state
wenzelm@28084
    25
  val show: (Attrib.binding * (string * string list) list) list -> bool -> Proof.state -> Proof.state
wenzelm@28084
    26
  val thus: (Attrib.binding * (string * string list) list) list -> bool -> Proof.state -> Proof.state
wenzelm@49889
    27
  val qed: Method.text_range option -> Toplevel.transition -> Toplevel.transition
wenzelm@49889
    28
  val terminal_proof: Method.text_range * Method.text_range option ->
wenzelm@21350
    29
    Toplevel.transition -> Toplevel.transition
wenzelm@21350
    30
  val default_proof: Toplevel.transition -> Toplevel.transition
wenzelm@21350
    31
  val immediate_proof: Toplevel.transition -> Toplevel.transition
wenzelm@21350
    32
  val done_proof: Toplevel.transition -> Toplevel.transition
wenzelm@21350
    33
  val skip_proof: Toplevel.transition -> Toplevel.transition
wenzelm@59064
    34
  val ml_diag: bool -> Input.source -> Toplevel.transition -> Toplevel.transition
wenzelm@48776
    35
  val diag_state: Proof.context -> Toplevel.state
wenzelm@48776
    36
  val diag_goal: Proof.context -> {context: Proof.context, facts: thm list, goal: thm}
wenzelm@57605
    37
  val pretty_theorems: bool -> Toplevel.state -> Pretty.T list
wenzelm@49569
    38
  val locale_deps: Toplevel.transition -> Toplevel.transition
wenzelm@58011
    39
  val print_stmts: string list * (Facts.ref * Token.src list) list
wenzelm@19268
    40
    -> Toplevel.transition -> Toplevel.transition
wenzelm@58011
    41
  val print_thms: string list * (Facts.ref * Token.src list) list
wenzelm@10581
    42
    -> Toplevel.transition -> Toplevel.transition
wenzelm@58011
    43
  val print_prfs: bool -> string list * (Facts.ref * Token.src list) list option
berghofe@11524
    44
    -> Toplevel.transition -> Toplevel.transition
wenzelm@12876
    45
  val print_prop: (string list * string) -> Toplevel.transition -> Toplevel.transition
wenzelm@12876
    46
  val print_term: (string list * string) -> Toplevel.transition -> Toplevel.transition
wenzelm@48792
    47
  val print_type: (string list * (string * string option)) ->
wenzelm@48792
    48
    Toplevel.transition -> Toplevel.transition
wenzelm@5831
    49
end;
wenzelm@5831
    50
wenzelm@37216
    51
structure Isar_Cmd: ISAR_CMD =
wenzelm@5831
    52
struct
wenzelm@5831
    53
wenzelm@5831
    54
wenzelm@22116
    55
(** theory declarations **)
wenzelm@22116
    56
wenzelm@30461
    57
(* generic setup *)
wenzelm@22116
    58
wenzelm@59930
    59
fun setup source =
wenzelm@56278
    60
  ML_Lex.read_source false source
wenzelm@59064
    61
  |> ML_Context.expression (Input.range_of source) "setup" "theory -> theory"
wenzelm@58991
    62
    "Context.map_theory setup"
wenzelm@26435
    63
  |> Context.theory_map;
wenzelm@22116
    64
wenzelm@55828
    65
fun local_setup source =
wenzelm@56278
    66
  ML_Lex.read_source false source
wenzelm@59064
    67
  |> ML_Context.expression (Input.range_of source) "local_setup" "local_theory -> local_theory"
wenzelm@58991
    68
    "Context.map_proof local_setup"
wenzelm@30461
    69
  |> Context.proof_map;
wenzelm@30461
    70
wenzelm@22116
    71
wenzelm@22116
    72
(* translation functions *)
wenzelm@22116
    73
wenzelm@55828
    74
fun parse_ast_translation source =
wenzelm@56278
    75
  ML_Lex.read_source false source
wenzelm@59064
    76
  |> ML_Context.expression (Input.range_of source) "parse_ast_translation"
wenzelm@58991
    77
    "(string * (Proof.context -> Ast.ast list -> Ast.ast)) list"
wenzelm@52143
    78
    "Context.map_theory (Sign.parse_ast_translation parse_ast_translation)"
wenzelm@22116
    79
  |> Context.theory_map;
wenzelm@22116
    80
wenzelm@55828
    81
fun parse_translation source =
wenzelm@56278
    82
  ML_Lex.read_source false source
wenzelm@59064
    83
  |> ML_Context.expression (Input.range_of source) "parse_translation"
wenzelm@58991
    84
    "(string * (Proof.context -> term list -> term)) list"
wenzelm@52143
    85
    "Context.map_theory (Sign.parse_translation parse_translation)"
wenzelm@52143
    86
  |> Context.theory_map;
wenzelm@52143
    87
wenzelm@55828
    88
fun print_translation source =
wenzelm@56278
    89
  ML_Lex.read_source false source
wenzelm@59064
    90
  |> ML_Context.expression (Input.range_of source) "print_translation"
wenzelm@58991
    91
    "(string * (Proof.context -> term list -> term)) list"
wenzelm@52143
    92
    "Context.map_theory (Sign.print_translation print_translation)"
wenzelm@22116
    93
  |> Context.theory_map;
wenzelm@22116
    94
wenzelm@55828
    95
fun typed_print_translation source =
wenzelm@56278
    96
  ML_Lex.read_source false source
wenzelm@59064
    97
  |> ML_Context.expression (Input.range_of source) "typed_print_translation"
wenzelm@58991
    98
    "(string * (Proof.context -> typ -> term list -> term)) list"
wenzelm@52143
    99
    "Context.map_theory (Sign.typed_print_translation typed_print_translation)"
wenzelm@22116
   100
  |> Context.theory_map;
wenzelm@22116
   101
wenzelm@55828
   102
fun print_ast_translation source =
wenzelm@56278
   103
  ML_Lex.read_source false source
wenzelm@59064
   104
  |> ML_Context.expression (Input.range_of source) "print_ast_translation"
wenzelm@58991
   105
    "(string * (Proof.context -> Ast.ast list -> Ast.ast)) list"
wenzelm@52143
   106
    "Context.map_theory (Sign.print_ast_translation print_ast_translation)"
wenzelm@22116
   107
  |> Context.theory_map;
wenzelm@22116
   108
wenzelm@22116
   109
wenzelm@42204
   110
(* translation rules *)
wenzelm@42204
   111
wenzelm@42204
   112
fun read_trrules thy raw_rules =
wenzelm@42204
   113
  let
wenzelm@42360
   114
    val ctxt = Proof_Context.init_global thy;
wenzelm@56006
   115
    val read_root =
wenzelm@56006
   116
      #1 o dest_Type o Proof_Context.read_type_name {proper = true, strict = false} ctxt;
wenzelm@42204
   117
  in
wenzelm@56006
   118
    raw_rules
wenzelm@56006
   119
    |> map (Syntax.map_trrule (fn (r, s) => Syntax_Phases.parse_ast_pattern ctxt (read_root r, s)))
wenzelm@42204
   120
  end;
wenzelm@42204
   121
wenzelm@42204
   122
fun translations args thy = Sign.add_trrules (read_trrules thy args) thy;
wenzelm@42204
   123
fun no_translations args thy = Sign.del_trrules (read_trrules thy args) thy;
wenzelm@42204
   124
wenzelm@42204
   125
wenzelm@22116
   126
(* oracles *)
wenzelm@22116
   127
wenzelm@59029
   128
fun oracle (name, range) source =
wenzelm@27871
   129
  let
wenzelm@59064
   130
    val body_range = Input.range_of source;
wenzelm@56278
   131
    val body = ML_Lex.read_source false source;
wenzelm@59029
   132
wenzelm@37198
   133
    val ants =
wenzelm@59067
   134
      ML_Lex.read
wenzelm@37198
   135
       ("local\n\
wenzelm@59029
   136
        \  val binding = " ^ ML_Syntax.make_binding (name, #1 range) ^ ";\n\
wenzelm@59067
   137
        \  val") @ ML_Lex.read_set_range body_range "oracle" @ ML_Lex.read "=" @ body @
wenzelm@59067
   138
        ML_Lex.read (";\nin\n\
wenzelm@59067
   139
        \  val") @ ML_Lex.read_set_range range name @ ML_Lex.read "=\
wenzelm@59029
   140
        \ snd (Context.>>> (Context.map_theory_result (Thm.add_oracle (binding, oracle))));\n\
wenzelm@59029
   141
        \end;\n";
wenzelm@56304
   142
  in
wenzelm@56304
   143
    Context.theory_map
wenzelm@59029
   144
      (ML_Context.exec (fn () => ML_Context.eval ML_Compiler.flags (#1 body_range) ants))
wenzelm@56304
   145
  end;
wenzelm@22116
   146
wenzelm@22116
   147
wenzelm@50737
   148
(* old-style defs *)
wenzelm@21350
   149
wenzelm@35852
   150
fun add_defs ((unchecked, overloaded), args) thy =
wenzelm@57683
   151
 (legacy_feature "Old 'defs' command -- use 'definition' (with 'overloading') instead";
wenzelm@39557
   152
  thy |>
wenzelm@39557
   153
    (if unchecked then Global_Theory.add_defs_unchecked_cmd else Global_Theory.add_defs_cmd)
wenzelm@47815
   154
      overloaded
wenzelm@47815
   155
      (map (fn ((b, ax), srcs) => ((b, ax), map (Attrib.attribute_cmd_global thy) srcs)) args)
wenzelm@57683
   156
  |> snd);
wenzelm@21350
   157
wenzelm@21350
   158
wenzelm@22087
   159
(* declarations *)
wenzelm@22087
   160
wenzelm@55828
   161
fun declaration {syntax, pervasive} source =
wenzelm@56278
   162
  ML_Lex.read_source false source
wenzelm@59064
   163
  |> ML_Context.expression (Input.range_of source) "declaration" "Morphism.declaration"
wenzelm@45291
   164
    ("Context.map_proof (Local_Theory.declaration {syntax = " ^ Bool.toString syntax ^ ", \
wenzelm@45291
   165
      \pervasive = " ^ Bool.toString pervasive ^ "} declaration)")
wenzelm@26385
   166
  |> Context.proof_map;
wenzelm@22087
   167
wenzelm@22087
   168
wenzelm@22202
   169
(* simprocs *)
wenzelm@22202
   170
wenzelm@55828
   171
fun simproc_setup name lhss source identifier =
wenzelm@56278
   172
  ML_Lex.read_source false source
wenzelm@59064
   173
  |> ML_Context.expression (Input.range_of source) "proc"
wenzelm@58991
   174
    "Morphism.morphism -> Proof.context -> cterm -> thm option"
wenzelm@42464
   175
    ("Context.map_proof (Simplifier.def_simproc_cmd {name = " ^ ML_Syntax.make_binding name ^ ", \
wenzelm@37198
   176
      \lhss = " ^ ML_Syntax.print_strings lhss ^ ", proc = proc, \
wenzelm@37198
   177
      \identifier = Library.maps ML_Context.thms " ^ ML_Syntax.print_strings identifier ^ "})")
wenzelm@22202
   178
  |> Context.proof_map;
wenzelm@22202
   179
wenzelm@22202
   180
wenzelm@21350
   181
(* goals *)
wenzelm@21350
   182
wenzelm@21350
   183
fun goal opt_chain goal stmt int =
wenzelm@29383
   184
  opt_chain #> goal NONE (K I) stmt int;
wenzelm@21350
   185
wenzelm@36323
   186
val have = goal I Proof.have_cmd;
wenzelm@36323
   187
val hence = goal Proof.chain Proof.have_cmd;
wenzelm@36323
   188
val show = goal I Proof.show_cmd;
wenzelm@36323
   189
val thus = goal Proof.chain Proof.show_cmd;
wenzelm@21350
   190
wenzelm@21350
   191
wenzelm@21350
   192
(* local endings *)
wenzelm@21350
   193
wenzelm@29383
   194
fun local_qed m = Toplevel.proof (Proof.local_qed (m, true));
wenzelm@32061
   195
val local_terminal_proof = Toplevel.proof' o Proof.local_future_terminal_proof;
wenzelm@29383
   196
val local_default_proof = Toplevel.proof Proof.local_default_proof;
wenzelm@29383
   197
val local_immediate_proof = Toplevel.proof Proof.local_immediate_proof;
wenzelm@29383
   198
val local_done_proof = Toplevel.proof Proof.local_done_proof;
wenzelm@29383
   199
val local_skip_proof = Toplevel.proof' Proof.local_skip_proof;
wenzelm@21350
   200
wenzelm@27562
   201
val skip_local_qed = Toplevel.skip_proof (fn i => if i > 1 then i - 1 else raise Toplevel.UNDEF);
wenzelm@21350
   202
wenzelm@21350
   203
wenzelm@21350
   204
(* global endings *)
wenzelm@21350
   205
wenzelm@21350
   206
fun global_qed m = Toplevel.end_proof (K (Proof.global_qed (m, true)));
wenzelm@49012
   207
val global_terminal_proof = Toplevel.end_proof o Proof.global_future_terminal_proof;
wenzelm@21350
   208
val global_default_proof = Toplevel.end_proof (K Proof.global_default_proof);
wenzelm@21350
   209
val global_immediate_proof = Toplevel.end_proof (K Proof.global_immediate_proof);
wenzelm@21350
   210
val global_skip_proof = Toplevel.end_proof Proof.global_skip_proof;
wenzelm@21350
   211
val global_done_proof = Toplevel.end_proof (K Proof.global_done_proof);
wenzelm@21350
   212
wenzelm@28375
   213
val skip_global_qed = Toplevel.skip_proof_to_theory (fn n => n = 1);
wenzelm@21350
   214
wenzelm@21350
   215
wenzelm@21350
   216
(* common endings *)
wenzelm@21350
   217
wenzelm@21350
   218
fun qed m = local_qed m o global_qed m o skip_local_qed o skip_global_qed;
wenzelm@21350
   219
fun terminal_proof m = local_terminal_proof m o global_terminal_proof m;
wenzelm@21350
   220
val default_proof = local_default_proof o global_default_proof;
wenzelm@21350
   221
val immediate_proof = local_immediate_proof o global_immediate_proof;
wenzelm@21350
   222
val done_proof = local_done_proof o global_done_proof;
wenzelm@21350
   223
val skip_proof = local_skip_proof o global_skip_proof;
wenzelm@21350
   224
wenzelm@21350
   225
wenzelm@26489
   226
(* diagnostic ML evaluation *)
wenzelm@5831
   227
wenzelm@37305
   228
structure Diag_State = Proof_Data
wenzelm@37305
   229
(
wenzelm@37305
   230
  type T = Toplevel.state;
wenzelm@37305
   231
  fun init _ = Toplevel.toplevel;
wenzelm@37305
   232
);
wenzelm@37305
   233
wenzelm@55828
   234
fun ml_diag verbose source = Toplevel.keep (fn state =>
wenzelm@56304
   235
  let
wenzelm@56304
   236
    val opt_ctxt =
wenzelm@56304
   237
      try Toplevel.generic_theory_of state
wenzelm@56304
   238
      |> Option.map (Context.proof_of #> Diag_State.put state);
wenzelm@56304
   239
    val flags = ML_Compiler.verbose verbose ML_Compiler.flags;
wenzelm@56304
   240
  in ML_Context.eval_source_in opt_ctxt flags source end);
wenzelm@37305
   241
wenzelm@48776
   242
val diag_state = Diag_State.get;
wenzelm@37305
   243
wenzelm@48776
   244
fun diag_goal ctxt =
wenzelm@48776
   245
  Proof.goal (Toplevel.proof_of (diag_state ctxt))
wenzelm@37305
   246
    handle Toplevel.UNDEF => error "No goal present";
wenzelm@37305
   247
wenzelm@53171
   248
val _ = Theory.setup
wenzelm@56204
   249
  (ML_Antiquotation.value (Binding.qualify true "Isar" @{binding state})
wenzelm@53171
   250
    (Scan.succeed "Isar_Cmd.diag_state ML_context") #>
wenzelm@56204
   251
   ML_Antiquotation.value (Binding.qualify true "Isar" @{binding goal})
wenzelm@53171
   252
    (Scan.succeed "Isar_Cmd.diag_goal ML_context"));
wenzelm@5831
   253
wenzelm@5831
   254
wenzelm@56868
   255
(* theorems of theory or proof context *)
wenzelm@17066
   256
wenzelm@56868
   257
fun pretty_theorems verbose st =
wenzelm@56868
   258
  if Toplevel.is_proof st then
wenzelm@59917
   259
    Proof_Context.pretty_local_facts verbose (Toplevel.context_of st)
wenzelm@56868
   260
  else
wenzelm@56868
   261
    let
wenzelm@56868
   262
      val thy = Toplevel.theory_of st;
wenzelm@56868
   263
      val prev_thys =
wenzelm@56868
   264
        (case Toplevel.previous_context_of st of
wenzelm@56868
   265
          SOME prev => [Proof_Context.theory_of prev]
wenzelm@56868
   266
        | NONE => Theory.parents_of thy);
wenzelm@56868
   267
    in Proof_Display.pretty_theorems_diff verbose prev_thys thy end;
wenzelm@9513
   268
wenzelm@12060
   269
wenzelm@50737
   270
(* display dependencies *)
wenzelm@5831
   271
wenzelm@60082
   272
val locale_deps =
wenzelm@60082
   273
  Toplevel.unknown_theory o
wenzelm@60082
   274
  Toplevel.keep (Toplevel.theory_of #> (fn thy =>
wenzelm@59210
   275
    Locale.pretty_locale_deps thy
wenzelm@59210
   276
    |> map (fn {name, parents, body} =>
wenzelm@59210
   277
      ((name, Graph_Display.content_node (Locale.extern thy name) [body]), parents))
wenzelm@60082
   278
    |> Graph_Display.display_graph));
wenzelm@49569
   279
berghofe@26184
   280
wenzelm@19268
   281
(* print theorems, terms, types etc. *)
wenzelm@19268
   282
wenzelm@19385
   283
local
wenzelm@19385
   284
wenzelm@38331
   285
fun string_of_stmts ctxt args =
wenzelm@38331
   286
  Attrib.eval_thms ctxt args
wenzelm@38331
   287
  |> map (Element.pretty_statement ctxt Thm.theoremK)
wenzelm@19385
   288
  |> Pretty.chunks2 |> Pretty.string_of;
wenzelm@5880
   289
wenzelm@38331
   290
fun string_of_thms ctxt args =
wenzelm@51583
   291
  Pretty.string_of (Proof_Context.pretty_fact ctxt ("", Attrib.eval_thms ctxt args));
wenzelm@5895
   292
wenzelm@19385
   293
fun string_of_prfs full state arg =
wenzelm@32859
   294
  Pretty.string_of
wenzelm@32859
   295
    (case arg of
skalberg@15531
   296
      NONE =>
berghofe@12125
   297
        let
wenzelm@38331
   298
          val {context = ctxt, goal = thm} = Proof.simple_goal (Toplevel.proof_of state);
wenzelm@42360
   299
          val thy = Proof_Context.theory_of ctxt;
wenzelm@28814
   300
          val prf = Thm.proof_of thm;
wenzelm@17066
   301
          val prop = Thm.full_prop_of thm;
wenzelm@32859
   302
          val prf' = Proofterm.rewrite_proof_notypes ([], []) prf;
berghofe@12125
   303
        in
wenzelm@33388
   304
          Proof_Syntax.pretty_proof ctxt
wenzelm@17066
   305
            (if full then Reconstruct.reconstruct_proof thy prop prf' else prf')
berghofe@12125
   306
        end
wenzelm@38331
   307
    | SOME srcs =>
wenzelm@38331
   308
        let val ctxt = Toplevel.context_of state
wenzelm@38331
   309
        in map (Proof_Syntax.pretty_proof_of ctxt full) (Attrib.eval_thms ctxt srcs) end
wenzelm@38331
   310
        |> Pretty.chunks);
berghofe@11524
   311
wenzelm@38331
   312
fun string_of_prop ctxt s =
wenzelm@5831
   313
  let
wenzelm@24508
   314
    val prop = Syntax.read_prop ctxt s;
wenzelm@26704
   315
    val ctxt' = Variable.auto_fixes prop ctxt;
wenzelm@26704
   316
  in Pretty.string_of (Pretty.quote (Syntax.pretty_term ctxt' prop)) end;
wenzelm@5831
   317
wenzelm@38331
   318
fun string_of_term ctxt s =
wenzelm@5831
   319
  let
wenzelm@24508
   320
    val t = Syntax.read_term ctxt s;
wenzelm@5831
   321
    val T = Term.type_of t;
wenzelm@26704
   322
    val ctxt' = Variable.auto_fixes t ctxt;
wenzelm@5831
   323
  in
wenzelm@19385
   324
    Pretty.string_of
wenzelm@26704
   325
      (Pretty.block [Pretty.quote (Syntax.pretty_term ctxt' t), Pretty.fbrk,
wenzelm@26704
   326
        Pretty.str "::", Pretty.brk 1, Pretty.quote (Syntax.pretty_typ ctxt' T)])
wenzelm@9128
   327
  end;
wenzelm@5831
   328
wenzelm@48792
   329
fun string_of_type ctxt (s, NONE) =
wenzelm@48792
   330
      let val T = Syntax.read_typ ctxt s
wenzelm@48792
   331
      in Pretty.string_of (Pretty.quote (Syntax.pretty_typ ctxt T)) end
wenzelm@48792
   332
  | string_of_type ctxt (s1, SOME s2) =
wenzelm@48792
   333
      let
wenzelm@48792
   334
        val ctxt' = Config.put show_sorts true ctxt;
wenzelm@48792
   335
        val raw_T = Syntax.parse_typ ctxt' s1;
wenzelm@48792
   336
        val S = Syntax.read_sort ctxt' s2;
wenzelm@48792
   337
        val T =
wenzelm@48792
   338
          Syntax.check_term ctxt'
wenzelm@48792
   339
            (Logic.mk_type raw_T |> Type.constraint (Term.itselfT (Type_Infer.anyT S)))
wenzelm@48792
   340
          |> Logic.dest_type;
wenzelm@48792
   341
      in Pretty.string_of (Pretty.quote (Syntax.pretty_typ ctxt' T)) end;
wenzelm@9128
   342
wenzelm@23935
   343
fun print_item string_of (modes, arg) = Toplevel.keep (fn state =>
wenzelm@38331
   344
  Print_Mode.with_modes modes (fn () => writeln (string_of state arg)) ());
wenzelm@19385
   345
wenzelm@19385
   346
in
wenzelm@9128
   347
wenzelm@38331
   348
val print_stmts = print_item (string_of_stmts o Toplevel.context_of);
wenzelm@38331
   349
val print_thms = print_item (string_of_thms o Toplevel.context_of);
wenzelm@19385
   350
val print_prfs = print_item o string_of_prfs;
wenzelm@38331
   351
val print_prop = print_item (string_of_prop o Toplevel.context_of);
wenzelm@38331
   352
val print_term = print_item (string_of_term o Toplevel.context_of);
wenzelm@38331
   353
val print_type = print_item (string_of_type o Toplevel.context_of);
wenzelm@5831
   354
wenzelm@19385
   355
end;
wenzelm@19385
   356
wenzelm@5831
   357
end;