parallel_proofs: more fine-grained control with optional parallel checking of nested Isar proofs;
1 (* Title: Pure/System/session.ML
2 Author: Markus Wenzel, TU Muenchen
4 Session management -- maintain state of logic images.
9 val id: unit -> string list
10 val name: unit -> string
11 val welcome: unit -> string
12 val use_dir: string -> string -> bool -> string list -> bool -> bool ->
13 string -> bool -> string list -> string -> string -> bool * string ->
14 string -> int -> bool -> bool -> int -> int -> int -> unit
15 val finish: unit -> unit
18 structure Session: SESSION =
24 val session = ref ([Context.PureN]: string list);
25 val session_path = ref ([]: string list);
26 val session_finished = ref false;
27 val remote_path = ref (NONE: Url.T option);
32 fun id () = ! session;
33 fun path () = ! session_path;
35 fun str_of [] = Context.PureN
36 | str_of elems = space_implode "/" elems;
38 fun name () = "Isabelle/" ^ str_of (path ());
44 if Distribution.is_official then
45 "Welcome to " ^ name () ^ " (" ^ Distribution.version ^ ")"
47 "Unofficial version of " ^ name () ^ " (" ^ Distribution.version ^ ")" ^
48 (if Distribution.changelog <> "" then "\nSee also " ^ Distribution.changelog else "");
51 OuterSyntax.improper_command "welcome" "print welcome message" OuterKeyword.diag
52 (Scan.succeed (Toplevel.no_timing o Toplevel.imperative (writeln o welcome)));
57 fun add_path reset s =
58 let val sess = ! session @ [s] in
59 (case duplicates (op =) sess of
60 [] => (session := sess; session_path := ((if reset then [] else ! session_path) @ [s]))
61 | dups => error ("Duplicate session identifiers " ^ commas_quote dups ^ " in " ^ str_of sess))
67 fun init reset parent name =
68 if not (member (op =) (! session) parent) orelse not (! session_finished) then
69 error ("Unfinished parent session " ^ quote parent ^ " for " ^ quote name)
70 else (add_path reset name; session_finished := false);
79 session_finished := true);
85 (if rpath = "" then () else
86 if is_some (! remote_path) then
87 error "Path for remote theory browsing information may only be set once"
89 remote_path := SOME (Url.explode rpath);
90 (! remote_path, rpath <> ""));
92 fun dumping (_, "") = NONE
93 | dumping (cp, path) = SOME (cp, Path.explode path);
95 fun use_dir item root build modes reset info doc doc_graph doc_versions parent
96 name dump rpath level timing verbose max_threads trace_threads parallel_proofs =
98 (init reset parent name;
99 Present.init build info doc doc_graph doc_versions (path ()) name
100 (dumping dump) (get_rpath rpath) verbose (map ThyInfo.get_theory (ThyInfo.get_names ()));
103 val start = start_timing ();
105 val stop = end_timing start;
107 Output.std_error ("Timing " ^ item ^ " (" ^
108 string_of_int (Multithreading.max_threads_value ()) ^ " threads, " ^
109 #message stop ^ ")\n");
113 |> setmp_noncritical Proofterm.proofs level
114 |> setmp_noncritical print_mode (modes @ print_mode_value ())
115 |> setmp_noncritical Goal.parallel_proofs parallel_proofs
116 |> setmp_noncritical Multithreading.trace trace_threads
117 |> setmp_noncritical Multithreading.max_threads
118 (if Multithreading.available then max_threads
119 else (if max_threads = 1 then () else warning "Multithreading support unavailable"; 1))) ()
120 handle exn => (Output.error_msg (ML_Compiler.exn_message exn); exit 1);