Skip to content

Commit

Permalink
details
Browse files Browse the repository at this point in the history
  • Loading branch information
fblanqui committed Jan 16, 2024
1 parent eaee414 commit e51b4ca
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 23 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ sti:

.PHONY: clean-sti
clean-sti:
find . -maxdepth 1 -name '*.sti' -exec rm -f {} `basename {}`.nbp `basename {}`.pos `basename {}`.use \;
find . -maxdepth 1 -name '*.sti' -delete
find . -maxdepth 1 -name '*.nbp' -delete
find . -maxdepth 1 -name '*.pos' -a ! -name $(BASE).pos -delete
find . -maxdepth 1 -name '*.use' -a ! -name $(BASE).use -delete
rm -f $(BASE).thp

BASE_FILES := $(BASE)_types $(BASE)_terms $(BASE)_axioms
Expand Down
6 changes: 4 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
TODO
----

- get rid of use file? in pos files, set pos to -1 for unused theorems
- use hashconsing for building map_term

- proofs can be simplified in parallel by working on the proof of each named theorem separately
- get rid of use file? in pos files, set pos to -1 for unused theorems?

- simplify/purge proofs in parallel?

- add commands for patch/unpatch/add-links ?

Expand Down
2 changes: 1 addition & 1 deletion add-links
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ then
exit 1
fi

for ext in prf sig thm pos use
for ext in prf nbp sig thm pos use
do
ln -f -s $HOLLIGHT_DIR/$1.$ext
done
Expand Down
2 changes: 1 addition & 1 deletion dune
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(executable
(public_name hol2dk)
(name main)
(libraries str unix)
(libraries str unix memtrace)
)

(install
Expand Down
35 changes: 21 additions & 14 deletions main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ let read_sig b =
update_map_const_typ_vars_pos();
update_reserved()

let read_thm b =
let map = read_val (b ^ ".thm") in
log "%d named theorems\n%!" (MapInt.cardinal map);
map

let integer s = try int_of_string s with Failure _ -> wrong_arg()

(* [make nb_proofs dg b] generates a makefile for translating the
Expand Down Expand Up @@ -456,7 +451,7 @@ and command = function
read_pos b;
init_proof_reading b;
read_use b;
let map_thid_name = read_thm b in
let map_thid_name = read_val (b ^ ".thm") in
for k = x to y do
log "%8d: %a" k proof (proof_at k);
begin match Array.get !Xproof.last_use k with
Expand Down Expand Up @@ -561,7 +556,7 @@ and command = function
(* compute useful theorems *)
read_pos b;
init_proof_reading b;
let map_thid_name = read_thm b in
let map_thid_name = read_val (b ^ ".thm") in
let nb_proofs = Array.length !prf_pos in
let useful = Array.make nb_proofs false in
let rec mark_as_useful = function
Expand Down Expand Up @@ -604,7 +599,7 @@ and command = function
let last_use = Array.make nb_proofs (-1) in
read_prf b
(fun i p -> List.iter (fun k -> Array.set last_use k i) (deps p));
MapInt.iter (fun k _ -> Array.set last_use k 0) (read_thm b);
MapInt.iter (fun k _ -> Array.set last_use k 0) (read_val (b ^ ".thm"));
let dump_file = b ^ ".use" in
log "generate %s ...\n" dump_file;
let oc = open_out_bin dump_file in
Expand Down Expand Up @@ -695,7 +690,7 @@ and command = function
let dk = is_dk f in
let b = Filename.chop_extension f in
read_sig b;
let map_thid_name = read_thm b in
let map_thid_name = read_val (b ^ ".thm") in
read_pos b;
init_proof_reading b;
begin
Expand All @@ -710,7 +705,7 @@ and command = function
let dk = is_dk f in
let b = Filename.chop_extension f in
read_sig b;
let map_thid_name = read_thm b in
let map_thid_name = read_val (b ^ ".thm") in
read_pos b;
init_proof_reading b;
begin
Expand Down Expand Up @@ -757,7 +752,8 @@ and command = function
| ["split";b] ->
read_pos b;
read_use b;
let map_thid_name = read_thm b in
init_proof_reading b;
let map_thid_name = read_val (b ^ ".thm") in
let map = ref MapInt.empty in
let create_segment start_index end_index =
let n = try MapInt.find end_index map_thid_name
Expand All @@ -769,6 +765,15 @@ and command = function
write_val (n ^ ".use") (Array.sub !last_use start_index len);
let p = Array.get !prf_pos end_index in
map := MapInt.add end_index (n,p) !map;
(*let dump_file = n ^ ".prf" in
log "write %s ...\n%!" dump_file;
let oc = open_out_bin dump_file in
seek_in !ic_prf (get_pos start_index);
for _k = 1 to len do
let p : proof = input_value !ic_prf in
output_value oc p
done;
close_out oc*)
in
let end_idx = ref (Array.length !prf_pos - 1) in
while Array.get !last_use !end_idx < 0 do decr end_idx done;
Expand Down Expand Up @@ -873,7 +878,7 @@ and command = function
if dk then
begin
Xdk.export_proofs b r;
if r = All then Xdk.export_theorems b (read_thm b);
if r = All then Xdk.export_theorems b (read_val (b ^ ".thm"));
Xdk.export_term_abbrevs b "";
Xdk.export_type_abbrevs b "";
log "generate %s.dk ...\n%!" b;
Expand All @@ -890,11 +895,13 @@ and command = function
else
begin
Xlp.export_proofs b b r;
if r = All then Xlp.export_theorems b (read_thm b);
if r = All then Xlp.export_theorems b (read_val (b ^ ".thm"));
Xlp.export_term_abbrevs b b "";
Xlp.export_type_abbrevs b b ""
end;
close_in !Xproof.ic_prf;
0

let _ = exit (command (List.tl (Array.to_list Sys.argv)))
let _ =
Memtrace.trace_if_requested ();
exit (command (List.tl (Array.to_list Sys.argv)))
3 changes: 1 addition & 2 deletions xlib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ let add_var rmap v =
(* [renaming_map tvs vs] returns an association list giving names to
the term variables in [vs] that are distinct to one another and
distinct from the type variables in [tvs]. This is needed to
include type variables because HOL-Light may ave type variables and
include type variables because HOL-Light may have type variables and
term variables with the same name. *)
let renaming_map =
let tyvar = function Tyvar n -> mk_var(n,bool_ty),n | _ -> assert false in
Expand All @@ -380,7 +380,6 @@ let el b =
mk_comb(mk_const("@",[b,aty]),mk_abs(mk_var("_",b),mk_const("T",[])))
*)
(*if not(!el_added) then (new_constant("el",aty); el_added := true);;*)

let mk_el b = mk_const("el",[b,aty]);;

(* [canonical_term t] returns the type variables and term variables of
Expand Down
7 changes: 5 additions & 2 deletions xlp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ let unabbrev_term =
;;

let abbrev_term =
(*let oc_abbrevs = open_out "term_abbrevs" in*)
let idx = ref (-1) in
let abbrev oc t =
(* check whether the term is already abbreviated; add a new
Expand All @@ -219,6 +220,8 @@ let abbrev_term =
| Some (k,_,_) -> k
| None ->
let k = !idx + 1 in
(*if k mod 1000 = 0 then log "term abbrev %d\n%!" k;*)
(*out oc_abbrevs "%a\n\n" raw_term t;*)
idx := k;
let x = (k, List.length tvs, bs) in
map_term := MapTrm.add t x !map_term;
Expand Down Expand Up @@ -532,8 +535,8 @@ let theorem_as_axiom oc k p = decl_theorem oc k p Axiom;;
[x] .. [y]. *)
let proofs_in_interval oc x y =
for k = x to y do
(*log "proof %d\n%!" k;*)
if get_use k >= 0 then theorem oc k (proof_at k)
if get_use k >= 0 then
begin (*log "proof %d ...\n%!" k;*) theorem oc k (proof_at k) end
done

(* [proofs_in_range oc r] outputs on [oc] the proofs in range [r]. *)
Expand Down

0 comments on commit e51b4ca

Please sign in to comment.