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