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