src/Pure/ROOT.ML
author wenzelm
Mon Aug 17 19:34:15 2015 +0200 (2015-08-17)
changeset 60957 574254152856
parent 60956 10d463883dc2
child 60958 5d70b5c509f8
permissions -rw-r--r--
support for ML files with/without debugger information;
wenzelm@56288
     1
(*** Isabelle/Pure bootstrap from "RAW" environment ***)
wenzelm@56288
     2
wenzelm@56288
     3
(** bootstrap phase 0: towards secure ML barrier *)
clasohm@0
     4
wenzelm@26109
     5
structure Distribution =     (*filled-in by makedist*)
wenzelm@26109
     6
struct
wenzelm@32361
     7
  val version = "unidentified repository version";
wenzelm@57649
     8
  val is_identified = false;
wenzelm@27642
     9
  val is_official = false;
wenzelm@26109
    10
end;
wenzelm@11835
    11
wenzelm@31432
    12
wenzelm@31432
    13
(* library of general tools *)
wenzelm@31432
    14
wenzelm@21396
    15
use "General/basics.ML";
clasohm@0
    16
use "library.ML";
wenzelm@31432
    17
use "General/print_mode.ML";
wenzelm@31432
    18
use "General/alist.ML";
wenzelm@31432
    19
use "General/table.ML";
wenzelm@43684
    20
wenzelm@43684
    21
use "Concurrent/synchronized.ML";
wenzelm@43684
    22
if Multithreading.available then ()
wenzelm@43684
    23
else use "Concurrent/synchronized_sequential.ML";
wenzelm@52537
    24
use "Concurrent/counter.ML";
wenzelm@59172
    25
use "Concurrent/random.ML";
wenzelm@43684
    26
wenzelm@43746
    27
use "General/properties.ML";
wenzelm@31432
    28
use "General/output.ML";
wenzelm@45670
    29
use "PIDE/markup.ML";
wenzelm@31432
    30
use "General/scan.ML";
wenzelm@31432
    31
use "General/source.ML";
wenzelm@31432
    32
use "General/symbol.ML";
wenzelm@31432
    33
use "General/position.ML";
wenzelm@31432
    34
use "General/symbol_pos.ML";
wenzelm@59064
    35
use "General/input.ML";
wenzelm@31432
    36
use "General/antiquote.ML";
wenzelm@31432
    37
use "ML/ml_lex.ML";
wenzelm@31432
    38
use "ML/ml_parse.ML";
wenzelm@31432
    39
use "General/secure.ML";
wenzelm@56288
    40
wenzelm@56434
    41
val use_text = Secure.use_text;
wenzelm@56434
    42
val use_file = Secure.use_file;
wenzelm@56434
    43
wenzelm@60957
    44
fun use_fns default_debug_option =
wenzelm@60957
    45
  let
wenzelm@60957
    46
    fun use_ debug_option file =
wenzelm@60957
    47
      let
wenzelm@60957
    48
        val debug =
wenzelm@60957
    49
          (case debug_option of
wenzelm@60957
    50
            SOME debug => debug
wenzelm@60957
    51
          | NONE => default_debug_option ());
wenzelm@60957
    52
      in
wenzelm@60957
    53
        Position.setmp_thread_data (Position.file_only file)
wenzelm@60957
    54
          (fn () =>
wenzelm@60957
    55
            Secure.use_file ML_Parse.global_context {verbose = true, debug = debug} file
wenzelm@60957
    56
              handle ERROR msg => (writeln msg; error "ML error")) ()
wenzelm@60957
    57
      end;
wenzelm@60957
    58
  in {use = use_ NONE, use_debug = use_ (SOME true), use_no_debug = use_ (SOME false)} end;
wenzelm@60957
    59
wenzelm@60957
    60
val {use, use_debug, use_no_debug} = use_fns (K false);
wenzelm@56434
    61
wenzelm@56434
    62
val toplevel_pp = Secure.toplevel_pp;
wenzelm@56288
    63
wenzelm@56288
    64
wenzelm@59054
    65
wenzelm@56288
    66
(** bootstrap phase 1: towards ML within Isar context *)
wenzelm@56288
    67
wenzelm@56288
    68
(* library of general tools *)
wenzelm@56288
    69
wenzelm@31432
    70
use "General/integer.ML";
wenzelm@31432
    71
use "General/stack.ML";
wenzelm@31432
    72
use "General/queue.ML";
wenzelm@31432
    73
use "General/heap.ML";
wenzelm@32015
    74
use "General/same.ML";
wenzelm@31432
    75
use "General/ord_list.ML";
wenzelm@31432
    76
use "General/balanced_tree.ML";
wenzelm@38448
    77
use "General/linear_set.ML";
wenzelm@43593
    78
use "General/buffer.ML";
wenzelm@43791
    79
use "General/pretty.ML";
wenzelm@59363
    80
use "PIDE/xml.ML";
wenzelm@31432
    81
use "General/path.ML";
wenzelm@31432
    82
use "General/url.ML";
wenzelm@31432
    83
use "General/file.ML";
wenzelm@43547
    84
use "General/long_name.ML";
wenzelm@43547
    85
use "General/binding.ML";
wenzelm@50800
    86
use "General/socket_io.ML";
wenzelm@56287
    87
use "General/seq.ML";
wenzelm@56287
    88
use "General/timing.ML";
wenzelm@22592
    89
wenzelm@35628
    90
use "General/sha1.ML";
wenzelm@43948
    91
if ML_System.is_polyml then use "General/sha1_polyml.ML" else ();
wenzelm@53212
    92
use "General/sha1_samples.ML";
wenzelm@35628
    93
wenzelm@44698
    94
use "PIDE/yxml.ML";
wenzelm@56303
    95
use "PIDE/document_id.ML";
wenzelm@44698
    96
wenzelm@56053
    97
use "General/change_table.ML";
wenzelm@49560
    98
use "General/graph.ML";
wenzelm@49560
    99
wenzelm@60911
   100
wenzelm@60911
   101
(* fundamental structures *)
wenzelm@60911
   102
wenzelm@60911
   103
use "name.ML";
wenzelm@60911
   104
use "term.ML";
wenzelm@60911
   105
use "context.ML";
wenzelm@60911
   106
use "context_position.ML";
wenzelm@51947
   107
use "System/options.ML";
wenzelm@60911
   108
use "config.ML";
wenzelm@51947
   109
wenzelm@60957
   110
val {use, use_debug, use_no_debug} = use_fns (fn () => Options.default_bool "ML_debugger");
wenzelm@60957
   111
wenzelm@31432
   112
wenzelm@31432
   113
(* concurrency within the ML runtime *)
wenzelm@28120
   114
wenzelm@50911
   115
if ML_System.is_polyml
wenzelm@50911
   116
then use "ML/exn_properties_polyml.ML"
wenzelm@50911
   117
else use "ML/exn_properties_dummy.ML";
wenzelm@50911
   118
wenzelm@54717
   119
if ML_System.name = "polyml-5.5.0"
wenzelm@54717
   120
  orelse ML_System.name = "polyml-5.5.1"
wenzelm@54717
   121
  orelse ML_System.name = "polyml-5.5.2"
wenzelm@58470
   122
  orelse ML_System.name = "polyml-5.5.3"
wenzelm@50255
   123
then use "ML/ml_statistics_polyml-5.5.0.ML"
wenzelm@50255
   124
else use "ML/ml_statistics_dummy.ML";
wenzelm@50255
   125
wenzelm@59054
   126
use "Concurrent/simple_thread.ML";
wenzelm@59054
   127
wenzelm@35014
   128
use "Concurrent/single_assignment.ML";
wenzelm@35014
   129
if Multithreading.available then ()
wenzelm@35014
   130
else use "Concurrent/single_assignment_sequential.ML";
wenzelm@35014
   131
wenzelm@40748
   132
if Multithreading.available
wenzelm@40748
   133
then use "Concurrent/bash.ML"
wenzelm@40748
   134
else use "Concurrent/bash_sequential.ML";
wenzelm@40748
   135
wenzelm@44247
   136
use "Concurrent/par_exn.ML";
wenzelm@31432
   137
use "Concurrent/task_queue.ML";
wenzelm@31432
   138
use "Concurrent/future.ML";
wenzelm@52798
   139
use "Concurrent/event_timer.ML";
wenzelm@52798
   140
wenzelm@52798
   141
if ML_System.is_polyml then use "Concurrent/time_limit.ML" else ();
wenzelm@32840
   142
wenzelm@32815
   143
use "Concurrent/lazy.ML";
wenzelm@32815
   144
if Multithreading.available then ()
wenzelm@32815
   145
else use "Concurrent/lazy_sequential.ML";
wenzelm@32840
   146
wenzelm@31432
   147
use "Concurrent/par_list.ML";
wenzelm@32815
   148
if Multithreading.available then ()
wenzelm@32816
   149
else use "Concurrent/par_list_sequential.ML";
wenzelm@31432
   150
wenzelm@44247
   151
use "Concurrent/mailbox.ML";
wenzelm@32840
   152
use "Concurrent/cache.ML";
wenzelm@32840
   153
wenzelm@50500
   154
use "PIDE/active.ML";
wenzelm@50500
   155
wenzelm@31432
   156
wenzelm@31432
   157
(* inner syntax *)
wenzelm@31432
   158
wenzelm@52211
   159
use "Syntax/type_annotation.ML";
wenzelm@42264
   160
use "Syntax/term_position.ML";
wenzelm@42264
   161
use "Syntax/lexicon.ML";
wenzelm@22679
   162
use "Syntax/ast.ML";
wenzelm@42288
   163
use "Syntax/syntax_ext.ML";
wenzelm@22679
   164
use "Syntax/parser.ML";
wenzelm@42284
   165
use "Syntax/syntax_trans.ML";
wenzelm@22679
   166
use "Syntax/mixfix.ML";
wenzelm@22679
   167
use "Syntax/printer.ML";
wenzelm@22679
   168
use "Syntax/syntax.ML";
wenzelm@22679
   169
wenzelm@31432
   170
wenzelm@31432
   171
(* core of tactical proof system *)
wenzelm@31432
   172
wenzelm@42382
   173
use "term_ord.ML";
wenzelm@42382
   174
use "term_subst.ML";
wenzelm@43729
   175
use "term_xml.ML";
wenzelm@55672
   176
use "General/completion.ML";
wenzelm@42382
   177
use "General/name_space.ML";
wenzelm@42382
   178
use "sorts.ML";
wenzelm@42382
   179
use "type.ML";
wenzelm@42382
   180
use "logic.ML";
wenzelm@42382
   181
use "Syntax/simple_syntax.ML";
wenzelm@30559
   182
use "net.ML";
wenzelm@30559
   183
use "item_net.ML";
wenzelm@18934
   184
use "envir.ML";
wenzelm@18059
   185
use "consts.ML";
wenzelm@24257
   186
use "primitive_defs.ML";
haftmann@27546
   187
use "defs.ML";
clasohm@0
   188
use "sign.ML";
wenzelm@43795
   189
use "term_sharing.ML";
clasohm@0
   190
use "pattern.ML";
clasohm@0
   191
use "unify.ML";
paulson@1528
   192
use "theory.ML";
berghofe@11511
   193
use "proofterm.ML";
clasohm@0
   194
use "thm.ML";
wenzelm@59026
   195
use "more_pattern.ML";
wenzelm@59026
   196
use "more_unify.ML";
wenzelm@22361
   197
use "more_thm.ML";
wenzelm@26279
   198
use "facts.ML";
wenzelm@39557
   199
use "global_theory.ML";
wenzelm@3986
   200
use "pure_thy.ML";
clasohm@0
   201
use "drule.ML";
wenzelm@22233
   202
use "morphism.ML";
wenzelm@19898
   203
use "variable.ML";
wenzelm@24833
   204
use "conv.ML";
wenzelm@32187
   205
use "goal_display.ML";
wenzelm@32169
   206
use "tactical.ML";
paulson@1582
   207
use "search.ML";
wenzelm@21708
   208
use "tactic.ML";
wenzelm@41228
   209
use "raw_simplifier.ML";
wenzelm@19417
   210
use "conjunction.ML";
wenzelm@20225
   211
use "assumption.ML";
wenzelm@32089
   212
use "display.ML";
clasohm@0
   213
wenzelm@31432
   214
wenzelm@31432
   215
(* Isar -- Intelligible Semi-Automated Reasoning *)
wenzelm@31432
   216
wenzelm@56303
   217
(*ML support and global execution*)
wenzelm@49041
   218
use "ML/ml_syntax.ML";
wenzelm@49041
   219
use "ML/ml_env.ML";
wenzelm@56303
   220
use "ML/ml_options.ML";
wenzelm@60957
   221
wenzelm@60957
   222
val {use, use_debug, use_no_debug} =
wenzelm@60957
   223
  use_fns (fn () => ML_Options.debugger_enabled (Context.thread_data ()));
wenzelm@60957
   224
wenzelm@56303
   225
use "ML/exn_output.ML";
wenzelm@56303
   226
if ML_System.is_polyml then use "ML/exn_output_polyml.ML" else ();
wenzelm@56303
   227
use "ML/ml_options.ML";
wenzelm@49041
   228
use "Isar/runtime.ML";
wenzelm@56303
   229
use "PIDE/execution.ML";
wenzelm@49041
   230
use "ML/ml_compiler.ML";
wenzelm@49041
   231
if ML_System.is_polyml then use "ML/ml_compiler_polyml.ML" else ();
wenzelm@49041
   232
wenzelm@51551
   233
use "skip_proof.ML";
wenzelm@49041
   234
use "goal.ML";
wenzelm@49041
   235
wenzelm@31432
   236
(*proof context*)
wenzelm@31432
   237
use "Isar/object_logic.ML";
wenzelm@31432
   238
use "Isar/rule_cases.ML";
wenzelm@31432
   239
use "Isar/auto_bind.ML";
wenzelm@42241
   240
use "type_infer.ML";
wenzelm@42240
   241
use "Syntax/local_syntax.ML";
wenzelm@31432
   242
use "Isar/proof_context.ML";
wenzelm@42405
   243
use "type_infer_context.ML";
wenzelm@42243
   244
use "Syntax/syntax_phases.ML";
wenzelm@31432
   245
use "Isar/local_defs.ML";
wenzelm@31432
   246
wenzelm@31432
   247
(*outer syntax*)
wenzelm@58903
   248
use "Isar/keyword.ML";
wenzelm@36959
   249
use "Isar/token.ML";
wenzelm@36949
   250
use "Isar/parse.ML";
wenzelm@31432
   251
use "Isar/args.ML";
wenzelm@31432
   252
wenzelm@57926
   253
(*theory specifications*)
wenzelm@57926
   254
use "Isar/local_theory.ML";
wenzelm@31432
   255
use "Thy/thy_header.ML";
wenzelm@57905
   256
use "PIDE/command_span.ML";
wenzelm@51265
   257
use "Thy/thy_syntax.ML";
wenzelm@31432
   258
use "Thy/html.ML";
wenzelm@31432
   259
use "Thy/latex.ML";
wenzelm@31432
   260
wenzelm@56203
   261
(*ML with context and antiquotations*)
wenzelm@56203
   262
use "ML/ml_context.ML";
wenzelm@56205
   263
use "ML/ml_antiquotation.ML";
wenzelm@56288
   264
wenzelm@60957
   265
local
wenzelm@60957
   266
  fun use_ debug file =
wenzelm@60957
   267
    let
wenzelm@60957
   268
      val flags =
wenzelm@60957
   269
        {SML = false, exchange = false, redirect = false, verbose = true,
wenzelm@60957
   270
          debug = debug, writeln = writeln, warning = warning};
wenzelm@60957
   271
    in
wenzelm@60957
   272
      ML_Context.eval_file (ML_Compiler.verbose true ML_Compiler.flags) (Path.explode file)
wenzelm@60957
   273
        handle ERROR msg => (writeln msg; error "ML error")
wenzelm@60957
   274
    end
wenzelm@60957
   275
in
wenzelm@60957
   276
  val use = use_ NONE;
wenzelm@60957
   277
  val use_debug = use_ (SOME true);
wenzelm@60957
   278
  val use_no_debug = use_ (SOME false);
wenzelm@60957
   279
end;
wenzelm@56434
   280
wenzelm@56288
   281
wenzelm@56288
   282
wenzelm@56288
   283
(** bootstrap phase 2: towards Pure.thy and final ML toplevel setup *)
wenzelm@56203
   284
wenzelm@31432
   285
(*basic proof engine*)
wenzelm@58009
   286
use "par_tactical.ML";
wenzelm@31432
   287
use "Isar/proof_display.ML";
wenzelm@31432
   288
use "Isar/attrib.ML";
wenzelm@31432
   289
use "Isar/context_rules.ML";
wenzelm@31432
   290
use "Isar/method.ML";
wenzelm@31432
   291
use "Isar/proof.ML";
wenzelm@31432
   292
use "Isar/element.ML";
wenzelm@31432
   293
use "Isar/obtain.ML";
wenzelm@60630
   294
use "Isar/subgoal.ML";
wenzelm@31432
   295
wenzelm@31432
   296
(*local theories and targets*)
haftmann@52140
   297
use "Isar/locale.ML";
haftmann@38307
   298
use "Isar/generic_target.ML";
wenzelm@31432
   299
use "Isar/overloading.ML";
wenzelm@35669
   300
use "axclass.ML";
haftmann@38379
   301
use "Isar/class.ML";
haftmann@38350
   302
use "Isar/named_target.ML";
wenzelm@31432
   303
use "Isar/expression.ML";
haftmann@38379
   304
use "Isar/class_declaration.ML";
wenzelm@47057
   305
use "Isar/bundle.ML";
wenzelm@59901
   306
use "Isar/experiment.ML";
wenzelm@31432
   307
wenzelm@31432
   308
use "simplifier.ML";
wenzelm@58660
   309
use "Tools/plugin.ML";
wenzelm@31432
   310
wenzelm@31432
   311
(*executable theory content*)
wenzelm@31432
   312
use "Isar/code.ML";
wenzelm@31432
   313
wenzelm@31432
   314
(*specifications*)
wenzelm@36952
   315
use "Isar/parse_spec.ML";
wenzelm@33374
   316
use "Isar/spec_rules.ML";
wenzelm@31432
   317
use "Isar/specification.ML";
wenzelm@35626
   318
use "Isar/typedecl.ML";
wenzelm@31432
   319
wenzelm@31432
   320
(*toplevel transactions*)
wenzelm@31432
   321
use "Isar/proof_node.ML";
wenzelm@31432
   322
use "Isar/toplevel.ML";
wenzelm@31432
   323
wenzelm@56206
   324
(*proof term operations*)
wenzelm@56206
   325
use "Proof/reconstruct.ML";
wenzelm@56206
   326
use "Proof/proof_syntax.ML";
wenzelm@56206
   327
use "Proof/proof_rewrite_rules.ML";
wenzelm@56206
   328
use "Proof/proof_checker.ML";
wenzelm@56206
   329
use "Proof/extraction.ML";
wenzelm@56206
   330
wenzelm@38271
   331
(*theory documents*)
wenzelm@40743
   332
use "System/isabelle_system.ML";
wenzelm@31432
   333
use "Thy/term_style.ML";
wenzelm@58928
   334
use "Isar/outer_syntax.ML";
wenzelm@31432
   335
use "Thy/thy_output.ML";
wenzelm@49561
   336
use "General/graph_display.ML";
wenzelm@43712
   337
use "Thy/present.ML";
wenzelm@58928
   338
use "pure_syn.ML";
wenzelm@52510
   339
use "PIDE/command.ML";
wenzelm@52865
   340
use "PIDE/query_operation.ML";
wenzelm@56208
   341
use "PIDE/resources.ML";
wenzelm@31432
   342
use "Thy/thy_info.ML";
wenzelm@59086
   343
use "PIDE/session.ML";
wenzelm@59714
   344
use "PIDE/protocol_message.ML";
wenzelm@44185
   345
use "PIDE/document.ML";
wenzelm@31432
   346
wenzelm@31432
   347
(*theory and proof operations*)
wenzelm@31432
   348
use "Isar/isar_cmd.ML";
wenzelm@31432
   349
wenzelm@31432
   350
wenzelm@31432
   351
(* Isabelle/Isar system *)
wenzelm@31432
   352
wenzelm@48681
   353
use "System/command_line.ML";
wenzelm@45029
   354
use "System/system_channel.ML";
wenzelm@52584
   355
use "System/message_channel.ML";
wenzelm@38412
   356
use "System/isabelle_process.ML";
wenzelm@43748
   357
use "System/invoke_scala.ML";
wenzelm@45709
   358
use "PIDE/protocol.ML";
wenzelm@30173
   359
wenzelm@31432
   360
wenzelm@31432
   361
(* miscellaneous tools and packages for Pure Isabelle *)
wenzelm@31432
   362
wenzelm@50686
   363
use "Tools/build.ML";
wenzelm@31432
   364
use "Tools/named_thms.ML";
wenzelm@31432
   365
wenzelm@55387
   366
structure Output: OUTPUT = Output;  (*seal system channels!*)
wenzelm@55387
   367
wenzelm@31432
   368
wenzelm@48732
   369
(* ML toplevel pretty printing *)
wenzelm@48732
   370
wenzelm@48732
   371
toplevel_pp ["Pretty", "T"] "(fn _: Pretty.T => Pretty.str \"<pretty>\")";
wenzelm@59196
   372
toplevel_pp ["Scan", "lexicon"] "Lexicon.pp_lexicon";
wenzelm@48732
   373
toplevel_pp ["Task_Queue", "task"] "Pretty.str o Task_Queue.str_of_task";
wenzelm@48732
   374
toplevel_pp ["Task_Queue", "group"] "Pretty.str o Task_Queue.str_of_group";
wenzelm@48732
   375
toplevel_pp ["Position", "T"] "Pretty.position";
wenzelm@58032
   376
toplevel_pp ["Binding", "binding"] "Binding.pp";
wenzelm@60937
   377
toplevel_pp ["Thm", "thm"] "Proof_Display.pp_thm Thy_Info.pure_theory";
wenzelm@60937
   378
toplevel_pp ["Thm", "cterm"] "Proof_Display.pp_cterm Thy_Info.pure_theory";
wenzelm@60937
   379
toplevel_pp ["Thm", "ctyp"] "Proof_Display.pp_ctyp Thy_Info.pure_theory";
wenzelm@60937
   380
toplevel_pp ["typ"] "Proof_Display.pp_typ Thy_Info.pure_theory";
wenzelm@48732
   381
toplevel_pp ["Context", "theory"] "Context.pretty_thy";
wenzelm@48732
   382
toplevel_pp ["Context", "Proof", "context"] "Proof_Display.pp_context";
wenzelm@48732
   383
toplevel_pp ["Ast", "ast"] "Ast.pretty_ast";
wenzelm@48732
   384
toplevel_pp ["Path", "T"] "Path.pretty";
wenzelm@48732
   385
toplevel_pp ["SHA1", "digest"] "Pretty.str o quote o SHA1.rep";
wenzelm@48732
   386
toplevel_pp ["Proof", "state"] "(fn _: Proof.state => Pretty.str \"<Proof.state>\")";
wenzelm@48732
   387
toplevel_pp ["Toplevel", "state"] "Toplevel.pretty_abstract";
wenzelm@54740
   388
toplevel_pp ["Morphism", "morphism"] "Morphism.pretty";
wenzelm@48732
   389
wenzelm@48732
   390
if ML_System.is_polyml then use "ML/install_pp_polyml.ML" else ();
wenzelm@48732
   391
wenzelm@48732
   392
wenzelm@49862
   393
(* the Pure theory *)
wenzelm@49862
   394
wenzelm@58928
   395
use "ML/ml_file.ML";
wenzelm@56303
   396
Runtime.toplevel_program (fn () => Thy_Info.use_thy ("Pure", Position.none));
wenzelm@49862
   397
Context.set_thread_data NONE;
wenzelm@60937
   398
structure Pure = struct val thy = Thy_Info.pure_theory () end;
wenzelm@49862
   399
wenzelm@49862
   400
wenzelm@48879
   401
(* ML toplevel commands *)
wenzelm@48879
   402
wenzelm@56303
   403
fun use_thys args =
wenzelm@56303
   404
  Runtime.toplevel_program (fn () => Thy_Info.use_thys (map (rpair Position.none) args));
wenzelm@48927
   405
val use_thy = use_thys o single;
wenzelm@48732
   406
wenzelm@48732
   407
val cd = File.cd o Path.explode;
wenzelm@48732
   408
wenzelm@52487
   409
Proofterm.proofs := 0;