wip: dump more steps to the trace file

This commit is contained in:
Simon Cruanes 2021-10-20 20:41:51 -04:00
parent f5172a7927
commit 63e7d6659e
No known key found for this signature in database
GPG key ID: 4AC01D0849AA62B6
6 changed files with 33 additions and 13 deletions

View file

@ -197,7 +197,18 @@ let emit_lit_ (self:t) (lit:Lit.t) : term_id =
let t = emit_term_ self (Lit.term lit) in
if sign then t else Int32.neg t
let emit_redundant_clause _ ~hyps:_ _ = dummy_step
let emit_redundant_clause lits ~hyps (self:t) =
if enabled self then (
let lits = Iter.map (emit_lit_ self) lits |> Iter.to_array in
let clause = Proof_ser.{Clause.lits} in
let hyps = Iter.to_array hyps in
let id = alloc_id self in
emit_step_ self (
Proof_ser.({Step.id; view=Step_view.Step_rup {res=clause; hyps}})
);
id
) else dummy_step
let emit_input_clause (lits:Lit.t Iter.t) (self:t) =
if enabled self then (
let lits = Iter.map (emit_lit_ self) lits |> Iter.to_array in

View file

@ -533,6 +533,6 @@ let pp_debug ~sharing out p =
M.pp_debug ~sharing p out
let of_proof _ _ : t = assert false
let of_proof _ _ : t = Sorry
let output = Quip.output

View file

@ -13,7 +13,7 @@ type Step_input {
# clause, RUP with previous steps
type Step_rup {
res: Clause
steps: []ID
hyps: []ID
}
# TODO: remove?

View file

@ -302,22 +302,22 @@ end
module Step_rup = struct
type t = {
res: Clause.t;
steps: ID.t array;
hyps: ID.t array;
}
(** @raise Bare.Decode.Error in case of error. *)
let decode (dec: Bare.Decode.t) : t =
let res = Clause.decode dec in
let steps =
let hyps =
(let len = Bare.Decode.uint dec in
if len>Int64.of_int Sys.max_array_length then raise (Bare.Decode.Error"array too big");
Array.init (Int64.to_int len) (fun _ -> ID.decode dec)) in
{res; steps; }
{res; hyps; }
let encode (enc: Bare.Encode.t) (self: t) : unit =
begin
Clause.encode enc self.res;
(let arr = self.steps in
(let arr = self.hyps in
Bare.Encode.uint enc (Int64.of_int (Array.length arr));
Array.iter (fun xi -> ID.encode enc xi) arr);
end

View file

@ -105,8 +105,12 @@ let main_smt () : _ result =
(* call [k] with the name of a temporary proof file, and cleanup if necessary *)
let run_with_tmp_file k =
if enable_proof_ then (
let file = ".sidekick-trace.dat" in
k file
(* TODO
CCIO.File.with_temp
~temp_dir:"." ~prefix:".sidekick-proof" ~suffix:".dat" k
*)
) else (
k "/dev/null"
)

View file

@ -71,16 +71,21 @@ module Writer = struct
let into_channel (oc:out_channel) : t =
let blen = Bytes.create 4 in
(* add len after chunk *)
let[@inline] emit_len_ len =
Bytes.set_int32_le blen 0 (Int32.of_int len);
output oc blen 0 4;
flush oc
in
let write b i len =
output oc b i len;
(* add len *)
Bytes.set_int32_le blen 0 (Int32.of_int len);
output oc blen 0 4
emit_len_ len
and write_buf buf =
Buffer.output_buffer oc buf;
(* add len *)
Bytes.set_int32_le blen 0 (Int32.of_int (Buffer.length buf));
output oc blen 0 4
emit_len_ (Buffer.length buf);
in
{ write; write_buf; }