mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-10 13:14:09 -05:00
refactor(th_bool): cache tseitin on absolute values
This commit is contained in:
parent
b9965ca709
commit
3cd79ee4c9
1 changed files with 13 additions and 9 deletions
|
|
@ -134,15 +134,19 @@ module Make(A : ARG) : S with module A = A = struct
|
||||||
(* TODO: polarity? *)
|
(* TODO: polarity? *)
|
||||||
let cnf (self:state) (_si:SI.t) ~mk_lit ~add_clause (t:T.t) : T.t option =
|
let cnf (self:state) (_si:SI.t) ~mk_lit ~add_clause (t:T.t) : T.t option =
|
||||||
let rec get_lit (t:T.t) : Lit.t =
|
let rec get_lit (t:T.t) : Lit.t =
|
||||||
match T.Tbl.find self.cnf t with
|
let t_abs, t_sign = T.abs self.tst t in
|
||||||
|
let lit =
|
||||||
|
match T.Tbl.find self.cnf t_abs with
|
||||||
| lit -> lit (* cached *)
|
| lit -> lit (* cached *)
|
||||||
| exception Not_found ->
|
| exception Not_found ->
|
||||||
(* compute and cache *)
|
(* compute and cache *)
|
||||||
let lit = get_lit_uncached t in
|
let lit = get_lit_uncached t_abs in
|
||||||
if not (T.equal (Lit.term lit) (T.abs self.tst t |> fst)) then (
|
if not (T.equal (Lit.term lit) t_abs) then (
|
||||||
T.Tbl.add self.cnf t lit;
|
T.Tbl.add self.cnf t_abs lit;
|
||||||
);
|
);
|
||||||
lit
|
lit
|
||||||
|
in
|
||||||
|
if t_sign then lit else Lit.neg lit
|
||||||
and get_lit_uncached t : Lit.t =
|
and get_lit_uncached t : Lit.t =
|
||||||
match A.view_as_bool t with
|
match A.view_as_bool t with
|
||||||
| B_bool b -> mk_lit (T.bool self.tst b)
|
| B_bool b -> mk_lit (T.bool self.tst b)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue