mirror of
https://github.com/c-cube/sidekick.git
synced 2026-01-28 12:24:50 -05:00
Better dimacs printing
This commit is contained in:
parent
42b4c00861
commit
b8d4ee198a
1 changed files with 32 additions and 12 deletions
|
|
@ -106,27 +106,47 @@ module Make
|
||||||
let get_tag cl = St.(cl.tag)
|
let get_tag cl = St.(cl.tag)
|
||||||
|
|
||||||
let export_dimacs fmt () =
|
let export_dimacs fmt () =
|
||||||
let n = St.nb_elt () in
|
(* Local assertions *)
|
||||||
let tmp = S.temp () in
|
let tmp = S.temp () in
|
||||||
|
assert (Vec.for_all (function
|
||||||
|
| { St.cpremise = St.Local; _} -> true | _ -> false
|
||||||
|
) tmp);
|
||||||
|
(* Problem hypothses *)
|
||||||
let hyps = S.hyps () in
|
let hyps = S.hyps () in
|
||||||
|
assert (Vec.for_all (function
|
||||||
|
| { St.cpremise = St.Hyp; _} -> true | _ -> false
|
||||||
|
) hyps);
|
||||||
|
(* Learnt clauses, then filtered to only keep only
|
||||||
|
the theory lemmas; all other learnt clauses should be logical
|
||||||
|
consequences of the rest. *)
|
||||||
let learnt = S.history () in
|
let learnt = S.history () in
|
||||||
let m = Vec.size hyps + Vec.size learnt in
|
let lemmas = Vec.make (Vec.size learnt) St.dummy_clause in
|
||||||
let aux fmt c =
|
Vec.iter (fun c ->
|
||||||
let c' = match c.St.cpremise with
|
match c.St.cpremise with
|
||||||
| St.Hyp | St.Lemma _ -> c
|
| St.Hyp | St.Local -> assert false
|
||||||
| St.History ( { St.cpremise = (St.Hyp | St.Lemma _) } as d :: _) -> d
|
| St.Lemma _ -> Vec.push lemmas c
|
||||||
| _ -> c (* FIXME *)
|
| St.History l ->
|
||||||
in
|
begin match l with
|
||||||
St.pp_dimacs fmt c'
|
| [] -> assert false
|
||||||
in
|
| d :: _ ->
|
||||||
|
begin match d.St.cpremise with
|
||||||
|
| St.Lemma _ -> Vec.push lemmas d
|
||||||
|
| St.Hyp | St.Local | St.History _ -> ()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
) learnt;
|
||||||
|
(* Number of atoms and clauses *)
|
||||||
|
let n = St.nb_elt () in
|
||||||
|
let m = Vec.size tmp + Vec.size hyps + Vec.size lemmas in
|
||||||
|
(* Actual printing *)
|
||||||
let pp s fmt vec =
|
let pp s fmt vec =
|
||||||
Format.fprintf fmt "c %s@,%a@," s (Vec.print ~sep:"" aux) vec
|
Format.fprintf fmt "c %s@,%a@," s (Vec.print ~sep:"" St.pp_dimacs) vec
|
||||||
in
|
in
|
||||||
Format.fprintf fmt
|
Format.fprintf fmt
|
||||||
"@[<v>p cnf %d %d@,%a%a%a@]@."
|
"@[<v>p cnf %d %d@,%a%a%a@]@."
|
||||||
n m
|
n m
|
||||||
(pp "Local assumptions") tmp
|
(pp "Local assumptions") tmp
|
||||||
(pp "Hypotheses") hyps
|
(pp "Hypotheses") hyps
|
||||||
(pp "Learnt") learnt
|
(pp "Lemmas") lemmas
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue