83 val local_theory_markup: xstring option * (Symbol_Pos.text * Position.T) -> |
83 val local_theory_markup: xstring option * (Symbol_Pos.text * Position.T) -> |
84 Toplevel.transition -> Toplevel.transition |
84 Toplevel.transition -> Toplevel.transition |
85 val proof_markup: Symbol_Pos.text * Position.T -> Toplevel.transition -> Toplevel.transition |
85 val proof_markup: Symbol_Pos.text * Position.T -> Toplevel.transition -> Toplevel.transition |
86 end; |
86 end; |
87 |
87 |
88 structure IsarCmd: ISAR_CMD = |
88 structure Isar_Cmd: ISAR_CMD = |
89 struct |
89 struct |
90 |
90 |
91 |
91 |
92 (** theory declarations **) |
92 (** theory declarations **) |
93 |
93 |
270 |
270 |
271 |
271 |
272 (* init and exit *) |
272 (* init and exit *) |
273 |
273 |
274 fun init_theory (name, imports, uses) = |
274 fun init_theory (name, imports, uses) = |
275 Toplevel.init_theory name (ThyInfo.begin_theory name imports (map (apfst Path.explode) uses)) |
275 Toplevel.init_theory name (Thy_Info.begin_theory name imports (map (apfst Path.explode) uses)) |
276 (fn thy => |
276 (fn thy => |
277 if ThyInfo.check_known_thy (Context.theory_name thy) |
277 if Thy_Info.check_known_thy (Context.theory_name thy) |
278 then ThyInfo.end_theory thy else ()); |
278 then Thy_Info.end_theory thy else ()); |
279 |
279 |
280 val exit = Toplevel.keep (fn state => |
280 val exit = Toplevel.keep (fn state => |
281 (Context.set_thread_data (try Toplevel.generic_theory_of state); |
281 (Context.set_thread_data (try Toplevel.generic_theory_of state); |
282 raise Toplevel.TERMINATE)); |
282 raise Toplevel.TERMINATE)); |
283 |
283 |
382 Toplevel.keep (Calculation.print_rules o Toplevel.context_of); |
382 Toplevel.keep (Calculation.print_rules o Toplevel.context_of); |
383 |
383 |
384 val print_methods = Toplevel.unknown_theory o |
384 val print_methods = Toplevel.unknown_theory o |
385 Toplevel.keep (Method.print_methods o Toplevel.theory_of); |
385 Toplevel.keep (Method.print_methods o Toplevel.theory_of); |
386 |
386 |
387 val print_antiquotations = Toplevel.imperative ThyOutput.print_antiquotations; |
387 val print_antiquotations = Toplevel.imperative Thy_Output.print_antiquotations; |
388 |
388 |
389 val thy_deps = Toplevel.unknown_theory o Toplevel.keep (fn state => |
389 val thy_deps = Toplevel.unknown_theory o Toplevel.keep (fn state => |
390 let |
390 let |
391 val thy = Toplevel.theory_of state; |
391 val thy = Toplevel.theory_of state; |
392 val all_thys = sort ThyInfo.thy_ord (thy :: Theory.ancestors_of thy); |
392 val all_thys = sort Thy_Info.thy_ord (thy :: Theory.ancestors_of thy); |
393 val gr = all_thys |> map (fn node => |
393 val gr = all_thys |> map (fn node => |
394 let |
394 let |
395 val name = Context.theory_name node; |
395 val name = Context.theory_name node; |
396 val parents = map Context.theory_name (Theory.parents_of node); |
396 val parents = map Context.theory_name (Theory.parents_of node); |
397 val dir = Present.session_name node; |
397 val dir = Present.session_name node; |
398 val unfold = not (ThyInfo.known_thy name andalso ThyInfo.is_finished name); |
398 val unfold = not (Thy_Info.known_thy name andalso Thy_Info.is_finished name); |
399 in {name = name, ID = name, parents = parents, dir = dir, unfold = unfold, path = ""} end); |
399 in {name = name, ID = name, parents = parents, dir = dir, unfold = unfold, path = ""} end); |
400 in Present.display_graph gr end); |
400 in Present.display_graph gr end); |
401 |
401 |
402 val class_deps = Toplevel.unknown_theory o Toplevel.keep (fn state => |
402 val class_deps = Toplevel.unknown_theory o Toplevel.keep (fn state => |
403 let |
403 let |
425 fun pretty_thm (a, th) = ProofContext.pretty_fact ctxt (a, [th]); |
425 fun pretty_thm (a, th) = ProofContext.pretty_fact ctxt (a, [th]); |
426 in |
426 in |
427 Thm_Deps.unused_thms |
427 Thm_Deps.unused_thms |
428 (case opt_range of |
428 (case opt_range of |
429 NONE => (Theory.parents_of thy, [thy]) |
429 NONE => (Theory.parents_of thy, [thy]) |
430 | SOME (xs, NONE) => (map ThyInfo.get_theory xs, [thy]) |
430 | SOME (xs, NONE) => (map Thy_Info.get_theory xs, [thy]) |
431 | SOME (xs, SOME ys) => (map ThyInfo.get_theory xs, map ThyInfo.get_theory ys)) |
431 | SOME (xs, SOME ys) => (map Thy_Info.get_theory xs, map Thy_Info.get_theory ys)) |
432 |> map pretty_thm |> Pretty.chunks |> Pretty.writeln |
432 |> map pretty_thm |> Pretty.chunks |> Pretty.writeln |
433 end); |
433 end); |
434 |
434 |
435 |
435 |
436 (* print proof context contents *) |
436 (* print proof context contents *) |
515 |
515 |
516 (* markup commands *) |
516 (* markup commands *) |
517 |
517 |
518 fun check_text (txt, pos) state = |
518 fun check_text (txt, pos) state = |
519 (Position.report Markup.doc_source pos; |
519 (Position.report Markup.doc_source pos; |
520 ignore (ThyOutput.eval_antiquote (#1 (Keyword.get_lexicons ())) state (txt, pos))); |
520 ignore (Thy_Output.eval_antiquote (#1 (Keyword.get_lexicons ())) state (txt, pos))); |
521 |
521 |
522 fun header_markup txt = Toplevel.keep (fn state => |
522 fun header_markup txt = Toplevel.keep (fn state => |
523 if Toplevel.is_toplevel state then check_text txt state |
523 if Toplevel.is_toplevel state then check_text txt state |
524 else raise Toplevel.UNDEF); |
524 else raise Toplevel.UNDEF); |
525 |
525 |