@@ -78,8 +78,8 @@ hol2dk $base.(dk|lp)
7878hol2dk $base.(dk|lp) $thm_id
7979 generate $base.(dk|lp) but with theorem index $thm_id only (for debug)
8080
81- Multi-threaded lp file generation by having a file for each named theorem
82- -------------------------------------------------------------------------
81+ Multi-threaded lp file generation with a file for each named theorem
82+ --------------------------------------------------------------------
8383
8484hol2dk config hollight_file.ml root_path [coq_module_or_file ...] [mappings.lp] [mappings.mk]
8585 create files and links to the files generated by hol2dk dump
@@ -91,6 +91,10 @@ hol2dk split $base
9191 generate $base.thp and the files $thm.sti, $thm.pos and $thm.use
9292 for each theorem $thm
9393
94+ hol2dk merge $base [$path/]$file.(dk|lp)
95+ generate a single lp file for the proofs of all the theorems (named or not)
96+ proved in [$path/]$file.(dk|lp)
97+
9498hol2dk theorem $base $thm.lp
9599 generate the lp proof of the theorem $thm
96100
@@ -148,7 +152,10 @@ hol2dk print use $base $x
148152 print the contents of $base.use for theorem index $x
149153
150154hol2dk print $base.thm
151- print the contents of $base.thm
155+ print the contents of $base.thm (named theorems with their indexes)
156+
157+ hol2dk thms $base [$path/]$file.(ml|hl)
158+ print the list of theorems (named or not) proved in [$path/]$file.(ml|hl)
152159
153160hol2dk stat $base [$thm]
154161 print statistics on proof steps
@@ -308,6 +315,24 @@ let print_env_var n =
308315
309316let wrong_nb_args() = err " wrong number of arguments\n " ; 1 ;;
310317
318+ (* compute the minimum and maximum theorem indexes in f *)
319+ let thid_range_of_file b f =
320+ let min_id = ref max_int and max_id = ref min_int in
321+ let map_thid_name = read_val (b^ " .thm" ) in
322+ let map_name_thid = (* inverse of map_thid_name *)
323+ MapInt. fold (fun k n map -> MapStr. add n k map) map_thid_name MapStr. empty
324+ in
325+ List. iter
326+ (fun n ->
327+ try
328+ let k = MapStr. find n map_name_thid in
329+ min_id := min ! min_id k;
330+ max_id := max ! max_id k
331+ with Not_found -> () )
332+ (thms_of_file f);
333+ ! min_id, ! max_id, map_thid_name
334+ ;;
335+
311336let rec log_command l =
312337 print_string " \n hol2dk" ;
313338 List. iter (fun s -> print_char ' ' ; print_string s) l;
@@ -337,12 +362,16 @@ and command = function
337362 | "--max-abbrev-size" ::k ::args ->
338363 Xlp. max_abbrev_part_size := integer k; command args
339364
365+ | [" --max-abbrev-size" ] -> wrong_nb_args()
366+
340367 | "--max-proof-size" ::k ::args ->
341368 Xlp. max_proof_part_size := integer k; command args
342369
370+ | [" --max-proof-size" ] -> wrong_nb_args()
371+
343372 | "--root-path" ::arg ::args -> Xlp. root_path := arg; command args
344373
345- | [" --root-path" ] -> err " missing root path \n " ; 1
374+ | [" --root-path" ] -> wrong_nb_args ()
346375
347376 | s ::_ when String. starts_with ~prefix: " --" s ->
348377 err " unknown option \" %s\"\n " s; 1
@@ -887,8 +916,9 @@ and command = function
887916
888917 | "axm" ::_ -> wrong_nb_args()
889918
890- (* Called in Makefile to generate a file f.lp with, for each named
891- theorem in f.ml, a declaration "symbol thm_name : type". *)
919+ (* Called in Makefile to generate, for each file n required by f, a
920+ file n.lp with a declaration "symbol thm_name : type" for each
921+ named theorem in n.ml. *)
892922 | [" files" ;f] ->
893923 let dk = is_dk f in
894924 let f = Filename. chop_extension f in
@@ -1047,6 +1077,98 @@ and command = function
10471077
10481078 | "theorem" ::_ -> wrong_nb_args()
10491079
1080+ (* List theorems proved in file f. *)
1081+ | [" thms" ;b;f] ->
1082+ let min_id, max_id, map_thid_name = thid_range_of_file b f in
1083+ let map,_,_ = MapInt. split (max_id + 1 ) (read_val (b^ " .thp" )) in
1084+ let _,_,map = MapInt. split (min_id - 1 ) map in
1085+ MapInt. iter
1086+ (fun k _ ->
1087+ try log " %s\n " (MapInt. find k map_thid_name)
1088+ with Not_found -> log " thm%d\n " k)
1089+ map;
1090+ 0
1091+
1092+ | "thms" ::_ -> wrong_nb_args()
1093+
1094+ (* Generate p.lp and its associated files, where
1095+ p=chop_extension(basename f), with all the theorems (named or
1096+ not) proved in f. *)
1097+ | [" merge" ;b;f] ->
1098+ let p = Filename. chop_extension (Filename. basename f) in
1099+ if Sys. file_exists (p^ " .lp" ) then
1100+ begin
1101+ err " \" %s.lp\" already exists. If you generated it using \" hol2dk merge\" , you cannot regenerate it again unless you remove it and do \" hol2dk split\" again.\n " p;
1102+ exit 1
1103+ end ;
1104+ (* update b.thp and set Xproof.map_thid_pos for export *)
1105+ let min_id, max_id, _ = thid_range_of_file b f
1106+ and thm_names = ref SetStr. empty
1107+ and map_thid_name = ref MapInt. empty in
1108+ Xproof. map_thid_pos :=
1109+ MapInt. mapi (fun k ((name ,pos ) as v ) ->
1110+ if min_id < = k && k < = max_id && name <> p then
1111+ begin
1112+ thm_names := SetStr. add name ! thm_names;
1113+ map_thid_name := MapInt. add k name ! map_thid_name;
1114+ (p,pos)
1115+ end
1116+ else v)
1117+ (read_val (b^ " .thp" ));
1118+ write_val (b^ " .thp" ) ! Xproof. map_thid_pos;
1119+ (* generate proof steps *)
1120+ read_sig b;
1121+ init_proof_reading b;
1122+ let deps = ref SetStr. empty in
1123+ let gen oc_spec n =
1124+ read_pos n;
1125+ read_use n;
1126+ the_start_idx := read_val (n^ " .sti" );
1127+ Xlib. remove [n^ " .pos" ;n^ " .use" ;n^ " .sti" ;n^ " .nbp" ];
1128+ (* part of Xlp.export_theorem_proof b n; *)
1129+ let thid = ! the_start_idx + Array. length ! prf_pos - 1 in
1130+ Xlp. export_proofs_in_interval n ! the_start_idx thid;
1131+ Xlib. rename (n^ part ! Xlp. proof_part^ " _proofs.lp" ) (n^ " _proofs.lp" );
1132+ (* record external dependencies *)
1133+ for i = 1 to ! Xlp. proof_part do
1134+ deps := SetStr. fold
1135+ (fun n acc ->
1136+ if SetStr. mem n ! thm_names then acc else SetStr. add n acc)
1137+ (Hashtbl. find Xlp. htbl_thm_deps i)
1138+ ! deps
1139+ done ;
1140+ (* generate corresponding spec *)
1141+ Xlp. theorem_as_axiom false oc_spec thid (proof_at thid)
1142+ in
1143+ Xlp. export (p^ " _spec" ) [b^ " _types" ;b^ " _terms" ]
1144+ (fun oc_spec -> SetStr. iter (gen oc_spec) ! thm_names);
1145+ close_in ! Xproof. ic_prf;
1146+ (* merge all proof files into [n_proofs.lp]. The order of proof
1147+ files is important. *)
1148+ let proof_files =
1149+ List. map (fun (_ ,n ) -> n^ " _proofs.lp" )
1150+ (MapInt. bindings ! map_thid_name) in
1151+ Xlib. concat proof_files (p^ " _proofs.lp" );
1152+ Xlib. remove proof_files;
1153+ Xlp. export_term_abbrevs_in_one_file b p;
1154+ write_val (p^ " .typ" ) ! Xlp. map_typ_abbrev;
1155+ (* export deps *)
1156+ let iter_deps f =
1157+ f (b^ " _types" );
1158+ f (b^ " _terms" );
1159+ f (b^ " _axioms" );
1160+ f (b^ " _type_abbrevs" );
1161+ if ! use_sharing then f (p^ " _subterm_abbrevs" );
1162+ f (p^ " _term_abbrevs" );
1163+ SetStr. iter (Xlp. spec f) ! deps
1164+ in
1165+ Xlp. create_file_with_deps (p^ " _deps" ) p iter_deps (fun _ -> () );
1166+ Xlib. concat [p^ " _deps.lp" ;p^ " _proofs.lp" ] (p^ " .lp" );
1167+ Xlib. remove [p^ " _deps.lp" ;p^ " _proofs.lp" ];
1168+ 0
1169+
1170+ | "merge" ::_ -> wrong_nb_args()
1171+
10501172 (* Merge all maps in typ files into a single map, give a unique
10511173 index to every entry in the obtained map, generate
10521174 b^"_type_abbrevs.lp" and a sed file for every typ file. *)
@@ -1152,9 +1274,7 @@ and command = function
11521274 List. map (fun s -> b^ " _" ^ s^ " .dk" )
11531275 (if r = All then deps @ [" theorems" ] else deps)
11541276 in
1155- exit
1156- (Sys. command
1157- (" cat theory_hol.dk " ^ String. concat " " infiles^ " > " ^ b^ " .dk" ))
1277+ Xlib. concat (" theory_hol.dk" ::infiles) (b^ " .dk" )
11581278 end
11591279 else
11601280 begin
0 commit comments