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