1 (* ========================================================================== *)
2 (* FLYSPECK - BOOK FORMALIZATION *)
4 (* Chapter: hypermap *)
5 (* Author: Thomas Hales *)
7 (* ========================================================================== *)
9 (* The tame archive from the Bauer-Nipkow classification.
10 The ML files in this directory are identical to those in Isabelle-HOL, Flyspeck-I. *)
14 HOL Light printer does not use ellipses in list printing.
15 Extremely slow processing and printing. Had to kill process .
16 Fix before executing outside module.
22 You have to open module for reflection to work.
23 But then printing of lists makes it impossible to look at tmrefK.
25 See development/thales/printer.ml for a fix to the term printer that
26 prints ellipses in long lists.
32 flyspeck_needs "../tame_archive/tame_archive.hl";;
33 open Tame_archive;; (* must open because of reflected references *)
34 time Tame_archive.arc3 ();; (* 0.18 secs *)
35 List.length !Tame_archive.ref3;; (* 9 *)
36 !Tame_archive.tmref3;;
37 time Tame_archive.arc4 ();; (* 22 secs *)
38 List.length !Tame_archive.ref4;; (* 1105 *)
40 time Tame_archive.arc5 ();; (* 676.555191 secs *)
41 List.length !Tame_archive.ref5;; (* 15991 *)
43 time Tame_archive.arc6 ();; (* 28 secs *)
44 List.length !Tame_archive.ref6;; (* 1657 *)
49 module Tame_archive = struct
52 (try Sys.getenv "FLYSPECK_DIR" with Not_found -> Sys.getcwd());;
55 Filename.concat (Filename.concat (flyspeck_dir) Filename.parent_dir_name)
59 let load_and_close_channel do_close ic =
62 lf ic (Pervasives.input_line ic::a)
63 with End_of_file -> a in
65 if do_close then Pervasives.close_in ic else ();
68 let save_stringarray filename xs =
69 let oc = open_out filename in
70 for i=0 to List.length xs -1
72 Pervasives.output_string oc (List.nth xs i ^ "\n");
76 let convert_archive filename ext = (* strip // comments, blank lines, quotation marks etc. *)
77 let (ic,oc) = Unix.open_process(sprintf "cat %s | sed 's/,/;/g' | sed 's/val [a-zA-Z]*/ref%d/g' | sed 's/]]];/]]];;/g' | sed 's/=/:=/g' | tr 'A-Z' 'a-z' " filename ext) in
78 let s = load_and_close_channel false ic in
79 let _ = Unix.close_process (ic,oc) in
82 let ocaml_of_ml (output_f,input_f,ext) =
83 save_stringarray output_f (convert_archive (Filename.concat archive_dir input_f) ext);;
86 let hol_of_smalllist =
89 let xs = map mk_small_numeral ls in
93 let ty = `:num list` in
94 fun ls -> let x = map hol_of_smalllist ls in mk_list (x,ty);;
97 let ty = `:(num list) list` in
98 fun ls -> let x = map hol_of_list2 ls in mk_list (x,ty);;
102 let tmp3 = Filename.temp_file "tmp3_" ".hl";;
103 let tmp4 = Filename.temp_file "tmp4_" ".hl";;
104 let tmp5 = Filename.temp_file "tmp5_" ".hl";;
105 let tmp6 = Filename.temp_file "tmp6_" ".hl";;
107 map ocaml_of_ml [(tmp3,"Tri.ML",3);(tmp4,"Quad.ML",4);
108 (tmp5,"Pent.ML",5);(tmp6,"Hex.ML",6)];;
113 HOL Light printer does not use ellipses in list printing.
114 Extremely slow processing and printing. Had to kill process .
115 Fix before executing outside module.
125 let tmref3 = ref `0`;;
126 let tmref4 = ref `0`;;
127 let tmref5 = ref `0`;;
128 let tmref6 = ref `0`;;
130 (* loading these files changes the references! *)
133 let _ = loadt tmp3 in
134 let _ = (tmref3 := hol_of_list3 (!ref3)) in ();;
137 let _ = loadt tmp4 in
138 let _ = (tmref4 := hol_of_list3 (!ref4)) in ();;
141 let _ = loadt tmp5 in
142 let _ = (tmref5 := hol_of_list3 (!ref5)) in ();;
145 let _ = loadt tmp6 in
146 let _ = (tmref6 := hol_of_list3 (!ref6)) in ();;
150 let archive3 = mk_eq (`archive3:((num list)list)list`, hol_of_list3 !ref3);;
152 let arc4 = mk_eq (`archive4:((num list)list)list`, hol_of_list3 !ref4);;
154 let arc5 = mk_eq (`archive5:((num list)list)list`, hol_of_list3 !ref5);;
156 let arc6 = mk_eq (`archive6:((num list)list)list`, hol_of_list3 !ref6);;
159 let archive3 = new_definition arc3;;
160 let archive4 = new_definition arc4;;
161 let archive5 = new_definition arc5;;
162 let archive6 = new_definition arc6;;
164 let bn_tame_archive = new_definition `bn_tame_archive =
165 APPEND arc3 (APPEND arc4 (APPEND arc5 arc6))`;;