src/Pure/ROOT.ML
author wenzelm
Thu Mar 17 10:54:28 2016 +0100 (2016-03-17)
changeset 62659 bb29cc00c31f
parent 62658 c27dabf438d6
child 62661 c23ff2f45a18
permissions -rw-r--r--
hide critical structures of Poly/ML, to make it harder to disrupt the ML environment;
     1 (*** Isabelle/Pure bootstrap ***)
     2 
     3 (** bootstrap phase 0: Poly/ML setup **)
     4 
     5 (* initial ML name space *)
     6 
     7 use "ML/ml_system.ML";
     8 use "ML/ml_name_space.ML";
     9 
    10 if List.exists (fn (a, _) => a = "FixedInt") (#allStruct ML_Name_Space.global ()) then ()
    11 else use "ML/fixed_int_dummy.ML";
    12 
    13 structure Distribution =     (*filled-in by makedist*)
    14 struct
    15   val version = "unidentified repository version";
    16   val is_identified = false;
    17   val is_official = false;
    18 end;
    19 
    20 
    21 (* multithreading *)
    22 
    23 use "General/exn.ML";
    24 
    25 val seconds = Time.fromReal;
    26 
    27 open Thread;
    28 use "Concurrent/multithreading.ML";
    29 
    30 use "Concurrent/unsynchronized.ML";
    31 val _ = ML_Name_Space.forget_val "ref";
    32 val _ = ML_Name_Space.forget_type "ref";
    33 
    34 
    35 (* pervasive environment *)
    36 
    37 val _ =
    38   List.app ML_Name_Space.forget_val
    39     ["isSome", "getOpt", "valOf", "foldl", "foldr", "print", "explode", "concat"];
    40 
    41 val ord = SML90.ord;
    42 val chr = SML90.chr;
    43 val raw_explode = SML90.explode;
    44 val implode = SML90.implode;
    45 
    46 
    47 (* ML runtime system *)
    48 
    49 use "ML/ml_heap.ML";
    50 use "ML/ml_profiling.ML";
    51 
    52 val pointer_eq = PolyML.pointerEq;
    53 
    54 
    55 (* ML toplevel pretty printing *)
    56 
    57 use "ML/ml_pretty.ML";
    58 
    59 local
    60   val depth = Unsynchronized.ref 10;
    61 in
    62   fun get_default_print_depth () = ! depth;
    63   fun default_print_depth n = (depth := n; PolyML.print_depth n);
    64   val _ = default_print_depth 10;
    65 end;
    66 
    67 val error_depth = PolyML.error_depth;
    68 
    69 
    70 (* ML compiler *)
    71 
    72 use "General/secure.ML";
    73 use "ML/ml_compiler0.ML";
    74 
    75 PolyML.Compiler.reportUnreferencedIds := true;
    76 PolyML.Compiler.reportExhaustiveHandlers := true;
    77 PolyML.Compiler.printInAlphabeticalOrder := false;
    78 PolyML.Compiler.maxInlineSize := 80;
    79 
    80 fun ml_make_string struct_name =
    81   "(fn x => Pretty.string_of (Pretty.from_ML (ML_Pretty.from_polyml (PolyML.prettyRepresentation (x, FixedInt.fromInt (" ^
    82     struct_name ^ ".ML_print_depth ()))))))";
    83 
    84 
    85 (* ML debugger *)
    86 
    87 use_no_debug "ML/ml_debugger.ML";
    88 
    89 
    90 
    91 (** bootstrap phase 1: towards ML within position context *)
    92 
    93 (* library of general tools *)
    94 
    95 use "General/basics.ML";
    96 use "library.ML";
    97 use "General/print_mode.ML";
    98 use "General/alist.ML";
    99 use "General/table.ML";
   100 
   101 use "Concurrent/synchronized.ML";
   102 use "Concurrent/counter.ML";
   103 
   104 use "General/random.ML";
   105 use "General/properties.ML";
   106 use "General/output.ML";
   107 use "PIDE/markup.ML";
   108 use "General/scan.ML";
   109 use "General/source.ML";
   110 use "General/symbol.ML";
   111 use "General/position.ML";
   112 use "General/symbol_pos.ML";
   113 use "General/input.ML";
   114 use "General/antiquote.ML";
   115 use "ML/ml_lex.ML";
   116 
   117 val {use, use_debug, use_no_debug} =
   118   let
   119     val context: ML_Compiler0.context =
   120      {name_space = ML_Name_Space.global,
   121       here = Position.here oo Position.line_file,
   122       print = writeln,
   123       error = error};
   124   in
   125     ML_Compiler0.use_operations (fn opt_debug => fn file =>
   126       Position.setmp_thread_data (Position.file_only file)
   127         (fn () =>
   128           ML_Compiler0.use_file context
   129             {verbose = true, debug = ML_Compiler0.debug_option opt_debug} file
   130           handle ERROR msg => (writeln msg; error "ML error")) ())
   131   end;
   132 
   133 
   134 
   135 (** bootstrap phase 2: towards ML within Isar context *)
   136 
   137 (* library of general tools *)
   138 
   139 use "General/integer.ML";
   140 use "General/stack.ML";
   141 use "General/queue.ML";
   142 use "General/heap.ML";
   143 use "General/same.ML";
   144 use "General/ord_list.ML";
   145 use "General/balanced_tree.ML";
   146 use "General/linear_set.ML";
   147 use "General/buffer.ML";
   148 use "General/pretty.ML";
   149 use "PIDE/xml.ML";
   150 use "General/path.ML";
   151 use "General/url.ML";
   152 use "General/file.ML";
   153 use "General/long_name.ML";
   154 use "General/binding.ML";
   155 use "General/socket_io.ML";
   156 use "General/seq.ML";
   157 use "General/timing.ML";
   158 
   159 use "General/sha1.ML";
   160 use "General/sha1_polyml.ML";
   161 use "General/sha1_samples.ML";
   162 
   163 val _ = List.app ML_Name_Space.forget_structure ML_Name_Space.critical_structures;
   164 
   165 use "PIDE/yxml.ML";
   166 use "PIDE/document_id.ML";
   167 
   168 use "General/change_table.ML";
   169 use "General/graph.ML";
   170 
   171 
   172 (* fundamental structures *)
   173 
   174 use "name.ML";
   175 use "term.ML";
   176 use "context.ML";
   177 use "context_position.ML";
   178 use "System/options.ML";
   179 use "config.ML";
   180 
   181 
   182 (* concurrency within the ML runtime *)
   183 
   184 use "ML/exn_properties.ML";
   185 
   186 use "ML/ml_statistics.ML";
   187 
   188 use "Concurrent/standard_thread.ML";
   189 use "Concurrent/single_assignment.ML";
   190 
   191 use "Concurrent/par_exn.ML";
   192 use "Concurrent/task_queue.ML";
   193 use "Concurrent/future.ML";
   194 use "Concurrent/event_timer.ML";
   195 use "Concurrent/timeout.ML";
   196 use "Concurrent/lazy.ML";
   197 use "Concurrent/par_list.ML";
   198 
   199 use "Concurrent/mailbox.ML";
   200 use "Concurrent/cache.ML";
   201 
   202 use "PIDE/active.ML";
   203 
   204 
   205 (* inner syntax *)
   206 
   207 use "Syntax/type_annotation.ML";
   208 use "Syntax/term_position.ML";
   209 use "Syntax/lexicon.ML";
   210 use "Syntax/ast.ML";
   211 use "Syntax/syntax_ext.ML";
   212 use "Syntax/parser.ML";
   213 use "Syntax/syntax_trans.ML";
   214 use "Syntax/mixfix.ML";
   215 use "Syntax/printer.ML";
   216 use "Syntax/syntax.ML";
   217 
   218 
   219 (* core of tactical proof system *)
   220 
   221 use "term_ord.ML";
   222 use "term_subst.ML";
   223 use "term_xml.ML";
   224 use "General/completion.ML";
   225 use "General/name_space.ML";
   226 use "sorts.ML";
   227 use "type.ML";
   228 use "logic.ML";
   229 use "Syntax/simple_syntax.ML";
   230 use "net.ML";
   231 use "item_net.ML";
   232 use "envir.ML";
   233 use "consts.ML";
   234 use "primitive_defs.ML";
   235 use "sign.ML";
   236 use "defs.ML";
   237 use "term_sharing.ML";
   238 use "pattern.ML";
   239 use "unify.ML";
   240 use "theory.ML";
   241 use "proofterm.ML";
   242 use "thm.ML";
   243 use "more_pattern.ML";
   244 use "more_unify.ML";
   245 use "more_thm.ML";
   246 use "facts.ML";
   247 use "global_theory.ML";
   248 use "pure_thy.ML";
   249 use "drule.ML";
   250 use "morphism.ML";
   251 use "variable.ML";
   252 use "conv.ML";
   253 use "goal_display.ML";
   254 use "tactical.ML";
   255 use "search.ML";
   256 use "tactic.ML";
   257 use "raw_simplifier.ML";
   258 use "conjunction.ML";
   259 use "assumption.ML";
   260 
   261 
   262 (* Isar -- Intelligible Semi-Automated Reasoning *)
   263 
   264 (*ML support and global execution*)
   265 use "ML/ml_syntax.ML";
   266 use "ML/ml_env.ML";
   267 use "ML/ml_options.ML";
   268 use_no_debug "ML/exn_debugger.ML";
   269 use "ML/ml_options.ML";
   270 use_no_debug "Isar/runtime.ML";
   271 use "PIDE/execution.ML";
   272 use "ML/ml_compiler.ML";
   273 
   274 use "skip_proof.ML";
   275 use "goal.ML";
   276 
   277 (*proof context*)
   278 use "Isar/object_logic.ML";
   279 use "Isar/rule_cases.ML";
   280 use "Isar/auto_bind.ML";
   281 use "type_infer.ML";
   282 use "Syntax/local_syntax.ML";
   283 use "Isar/proof_context.ML";
   284 use "type_infer_context.ML";
   285 use "Syntax/syntax_phases.ML";
   286 use "Isar/local_defs.ML";
   287 
   288 (*outer syntax*)
   289 use "Isar/keyword.ML";
   290 use "Isar/token.ML";
   291 use "Isar/parse.ML";
   292 use "Isar/args.ML";
   293 
   294 (*theory specifications*)
   295 use "Isar/local_theory.ML";
   296 use "Thy/thy_header.ML";
   297 use "PIDE/command_span.ML";
   298 use "Thy/thy_syntax.ML";
   299 use "Thy/markdown.ML";
   300 use "Thy/html.ML";
   301 use "Thy/latex.ML";
   302 
   303 (*ML with context and antiquotations*)
   304 use "ML/ml_context.ML";
   305 use "ML/ml_antiquotation.ML";
   306 
   307 val {use, use_debug, use_no_debug} =
   308   ML_Compiler0.use_operations (fn opt_debug => fn file =>
   309     let val flags = ML_Compiler.verbose true (ML_Compiler.debug_flags opt_debug) in
   310       ML_Context.eval_file flags (Path.explode file)
   311         handle ERROR msg => (writeln msg; error "ML error")
   312     end);
   313 
   314 
   315 
   316 (** bootstrap phase 3: towards Pure.thy and final ML toplevel setup *)
   317 
   318 (*basic proof engine*)
   319 use "par_tactical.ML";
   320 use "Isar/proof_display.ML";
   321 use "Isar/attrib.ML";
   322 use "Isar/context_rules.ML";
   323 use "Isar/method.ML";
   324 use "Isar/proof.ML";
   325 use "Isar/element.ML";
   326 use "Isar/obtain.ML";
   327 use "Isar/subgoal.ML";
   328 
   329 (*local theories and targets*)
   330 use "Isar/locale.ML";
   331 use "Isar/generic_target.ML";
   332 use "Isar/overloading.ML";
   333 use "axclass.ML";
   334 use "Isar/class.ML";
   335 use "Isar/named_target.ML";
   336 use "Isar/expression.ML";
   337 use "Isar/interpretation.ML";
   338 use "Isar/class_declaration.ML";
   339 use "Isar/bundle.ML";
   340 use "Isar/experiment.ML";
   341 
   342 use "simplifier.ML";
   343 use "Tools/plugin.ML";
   344 
   345 (*executable theory content*)
   346 use "Isar/code.ML";
   347 
   348 (*specifications*)
   349 use "Isar/parse_spec.ML";
   350 use "Isar/spec_rules.ML";
   351 use "Isar/specification.ML";
   352 use "Isar/typedecl.ML";
   353 
   354 (*toplevel transactions*)
   355 use "Isar/proof_node.ML";
   356 use "Isar/toplevel.ML";
   357 
   358 (*proof term operations*)
   359 use "Proof/reconstruct.ML";
   360 use "Proof/proof_syntax.ML";
   361 use "Proof/proof_rewrite_rules.ML";
   362 use "Proof/proof_checker.ML";
   363 use "Proof/extraction.ML";
   364 
   365 (*Isabelle system*)
   366 if ML_System.platform_is_windows
   367 then use "System/bash_windows.ML"
   368 else use "System/bash.ML";
   369 use "System/isabelle_system.ML";
   370 
   371 (*theory documents*)
   372 use "Thy/term_style.ML";
   373 use "Isar/outer_syntax.ML";
   374 use "Thy/thy_output.ML";
   375 use "Thy/document_antiquotations.ML";
   376 use "General/graph_display.ML";
   377 use "Thy/present.ML";
   378 use "pure_syn.ML";
   379 use "PIDE/command.ML";
   380 use "PIDE/query_operation.ML";
   381 use "PIDE/resources.ML";
   382 use "Thy/thy_info.ML";
   383 use "PIDE/session.ML";
   384 use "PIDE/protocol_message.ML";
   385 use "PIDE/document.ML";
   386 
   387 (*theory and proof operations*)
   388 use "Isar/isar_cmd.ML";
   389 
   390 
   391 (* Isabelle/Isar system *)
   392 
   393 use "System/command_line.ML";
   394 use "System/system_channel.ML";
   395 use "System/message_channel.ML";
   396 use "System/isabelle_process.ML";
   397 use "System/invoke_scala.ML";
   398 use "PIDE/protocol.ML";
   399 
   400 
   401 (* miscellaneous tools and packages for Pure Isabelle *)
   402 
   403 use "Tools/build.ML";
   404 use "Tools/named_thms.ML";
   405 
   406 structure Output: OUTPUT = Output;  (*seal system channels!*)
   407 
   408 
   409 use "ML/install_pp_polyml.ML";
   410 
   411 
   412 (* the Pure theory *)
   413 
   414 use "ML/ml_file.ML";
   415 Runtime.toplevel_program (fn () => Thy_Info.use_thy ("Pure", Position.none));
   416 Context.set_thread_data NONE;
   417 structure Pure = struct val thy = Thy_Info.pure_theory () end;
   418 
   419 
   420 (* ML toplevel commands *)
   421 
   422 fun use_thys args =
   423   Runtime.toplevel_program (fn () => Thy_Info.use_thys (map (rpair Position.none) args));
   424 val use_thy = use_thys o single;
   425 
   426 Proofterm.proofs := 0;