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