1 (* ========================================================================= *)
4 (* Modern OCaml version of the HOL theorem prover *)
8 (* (c) Copyright, University of Cambridge 1998 *)
9 (* (c) Copyright, John Harrison 1998-2007 *)
10 (* ========================================================================= *)
12 let hol_version = "2.20++";;
15 (try Sys.getenv "HOLLIGHT_DIR" with Not_found -> Sys.getcwd());;
17 (* ------------------------------------------------------------------------- *)
18 (* Should eventually change to "ref(Filename.temp_dir_name)". *)
19 (* However that's not available in 3.08, which is still the default *)
20 (* in Cygwin, and I don't want to force people to upgrade Ocaml. *)
21 (* ------------------------------------------------------------------------- *)
23 let temp_path = ref "/tmp";;
25 (* ------------------------------------------------------------------------- *)
26 (* Load in parsing extensions. *)
27 (* For Ocaml < 3.10, use the built-in camlp4 *)
28 (* and for Ocaml >= 3.10, use camlp5 instead. *)
29 (* ------------------------------------------------------------------------- *)
31 if let v = String.sub Sys.ocaml_version 0 4 in
32 v = "3.10" or v = "3.11"
33 then (Topdirs.dir_directory "+camlp5";
34 Topdirs.dir_load Format.std_formatter "camlp5o.cma")
35 else (Topdirs.dir_load Format.std_formatter "camlp4o.cma");;
37 Topdirs.dir_load Format.std_formatter (Filename.concat (!hol_dir) "pa_j.cmo");;
39 (* ------------------------------------------------------------------------- *)
40 (* Load files from system and/or user-settable directories. *)
41 (* Paths map initial "$/" to !hol_dir dynamically; use $$ to get the actual *)
42 (* $ character at the start of a directory. *)
43 (* ------------------------------------------------------------------------- *)
46 if Toploop.use_file Format.std_formatter s then ()
47 else (Format.print_string("Error in included file "^s);
48 Format.print_newline());;
50 let hol_expand_directory s =
51 if s = "$" or s = "$/" then !hol_dir
52 else if s = "$$" then "$"
53 else if String.length s <= 2 then s
54 else if String.sub s 0 2 = "$$" then (String.sub s 1 (String.length s - 1))
55 else if String.sub s 0 2 = "$/"
56 then Filename.concat (!hol_dir) (String.sub s 2 (String.length s - 2))
59 let load_path = ref ["."; "$"];;
61 let loaded_files = ref [];;
63 let file_on_path p s =
64 if not (Filename.is_relative s) then s else
65 let p' = List.map hol_expand_directory p in
66 let d = List.find (fun d -> Sys.file_exists(Filename.concat d s)) p' in
67 Filename.concat (if d = "." then Sys.getcwd() else d) s;;
69 let load_on_path p s =
70 let s' = file_on_path p s in
71 let fileid = (Filename.basename s',Digest.file s') in
72 (use_file s'; loaded_files := fileid::(!loaded_files));;
74 let loads s = load_on_path ["$"] s;;
76 let loadt s = load_on_path (!load_path) s;;
79 let s' = file_on_path (!load_path) s in
80 let fileid = (Filename.basename s',Digest.file s') in
81 if List.mem fileid (!loaded_files)
82 then Format.print_string("File \""^s^"\" already loaded\n") else loadt s;;
84 (* ------------------------------------------------------------------------- *)
85 (* Various tweaks to OCaml and general library functions. *)
86 (* ------------------------------------------------------------------------- *)
88 loads "system.ml";; (* Set up proper parsing and load bignums *)
89 loads "lib.ml";; (* Various useful general library functions *)
91 (* ------------------------------------------------------------------------- *)
92 (* The logical core. *)
93 (* ------------------------------------------------------------------------- *)
95 loads "type.ml";; (* Abstract type of HOL types *)
96 loads "term.ml";; (* Abstract type of HOL terms *)
97 loads "proofobjects_init.ml";; (* Proof recording infrastructure *)
98 loads "thm.ml";; (* Abstract type of HOL theorems: deductive system! *)
100 (* ------------------------------------------------------------------------- *)
101 (* Some extra support stuff needed outside the core. *)
102 (* ------------------------------------------------------------------------- *)
104 loads "basics.ml";; (* Additional syntax operations and other utilities *)
105 loads "nets.ml";; (* Term nets for fast matchability-based lookup *)
107 (* ------------------------------------------------------------------------- *)
109 (* ------------------------------------------------------------------------- *)
111 loads "preterm.ml";; (* Preterms and their interconversion with terms *)
112 loads "parser.ml";; (* Lexer and parser *)
113 loads "printer.ml";; (* Crude prettyprinter *)
115 (* ------------------------------------------------------------------------- *)
116 (* Higher level deductive system. *)
117 (* ------------------------------------------------------------------------- *)
119 loads "equal.ml";; (* Basic equality reasoning and conversionals *)
120 loads "bool.ml";; (* Boolean theory and basic derived rules *)
121 loads "drule.ml";; (* Additional derived rules *)
122 loads "tactics.ml";; (* Tactics, tacticals and goal stack *)
123 loads "itab.ml";; (* Toy prover for intuitionistic logic *)
124 loads "simp.ml";; (* Basic rewriting and simplification tools. *)
125 loads "theorems.ml";; (* Additional theorems (mainly for quantifiers) etc. *)
126 loads "ind_defs.ml";; (* Derived rules for inductive definitions *)
127 loads "class.ml";; (* Classical reasoning: Choice and Extensionality *)
128 loads "trivia.ml";; (* Some very basic theories, e.g. type ":1" *)
129 loads "canon.ml";; (* Tools for putting terms in canonical forms *)
130 loads "meson.ml";; (* First order automation: MESON (model elimination) *)
131 loads "quot.ml";; (* Derived rules for defining quotient types *)
132 loads "recursion.ml";; (* Tools for primitive recursion on inductive types *)
134 (* ------------------------------------------------------------------------- *)
135 (* Mathematical theories and additional proof tools. *)
136 (* ------------------------------------------------------------------------- *)
138 loads "pair.ml";; (* Theory of pairs *)
139 loads "nums.ml";; (* Axiom of Infinity, definition of natural numbers *)
140 loads "arith.ml";; (* Natural number arithmetic *)
141 loads "wf.ml";; (* Theory of wellfounded relations *)
142 loads "calc_num.ml";; (* Calculation with natural numbers *)
143 loads "normalizer.ml";; (* Polynomial normalizer for rings and semirings *)
144 loads "grobner.ml";; (* Groebner basis procedure for most semirings. *)
145 loads "ind_types.ml";; (* Tools for defining inductive types *)
146 loads "lists.ml";; (* Theory of lists *)
147 loads "realax.ml";; (* Definition of real numbers *)
148 loads "calc_int.ml";; (* Calculation with integer-valued reals *)
149 loads "realarith.ml";; (* Universal linear real decision procedure *)
150 loads "real.ml";; (* Derived properties of reals *)
151 loads "calc_rat.ml";; (* Calculation with rational-valued reals *)
152 loads "int.ml";; (* Definition of integers *)
153 loads "sets.ml";; (* Basic set theory. *)
154 loads "iterate.ml"; (* Iterated operations *)
155 loads "cart.ml";; (* Finite Cartesian products *)
156 loads "define.ml";; (* Support for general recursive definitions *)
158 (* ------------------------------------------------------------------------- *)
159 (* The help system. *)
160 (* ------------------------------------------------------------------------- *)
162 loads "help.ml";; (* Online help using the entries in Help directory *)
163 loads "database.ml";; (* List of name-theorem pairs for search system *)