mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-10 05:03:59 -05:00
Fixed potential bug in vec.set
Removed some excessive logging messages
This commit is contained in:
parent
e748333693
commit
e059441347
4 changed files with 7 additions and 26 deletions
|
|
@ -572,7 +572,6 @@ module Make (L : Log_intf.S)(E : Expr_intf.S)
|
||||||
done;
|
done;
|
||||||
(* no watch lit found *)
|
(* no watch lit found *)
|
||||||
if first.neg.is_true || (th_eval first = Some false) then begin
|
if first.neg.is_true || (th_eval first = Some false) then begin
|
||||||
L.debug 100 "clause is false";
|
|
||||||
(* clause is false *)
|
(* clause is false *)
|
||||||
env.qhead <- Vec.size env.trail;
|
env.qhead <- Vec.size env.trail;
|
||||||
for k = i to Vec.size watched - 1 do
|
for k = i to Vec.size watched - 1 do
|
||||||
|
|
@ -582,7 +581,6 @@ module Make (L : Log_intf.S)(E : Expr_intf.S)
|
||||||
L.debug 3 "Conflict found : %a" St.pp_clause c;
|
L.debug 3 "Conflict found : %a" St.pp_clause c;
|
||||||
raise (Conflict c)
|
raise (Conflict c)
|
||||||
end else begin
|
end else begin
|
||||||
L.debug 100 "clause is unit";
|
|
||||||
(* clause is unit *)
|
(* clause is unit *)
|
||||||
Vec.set watched !new_sz c;
|
Vec.set watched !new_sz c;
|
||||||
incr new_sz;
|
incr new_sz;
|
||||||
|
|
@ -612,7 +610,6 @@ module Make (L : Log_intf.S)(E : Expr_intf.S)
|
||||||
|
|
||||||
(* Propagation (boolean and theory) *)
|
(* Propagation (boolean and theory) *)
|
||||||
let new_atom f =
|
let new_atom f =
|
||||||
L.debug 100 "New_atom";
|
|
||||||
let a = add_atom f in
|
let a = add_atom f in
|
||||||
L.debug 10 "New atom : %a" St.pp_atom a;
|
L.debug 10 "New atom : %a" St.pp_atom a;
|
||||||
ignore (th_eval a);
|
ignore (th_eval a);
|
||||||
|
|
@ -629,11 +626,8 @@ module Make (L : Log_intf.S)(E : Expr_intf.S)
|
||||||
add_clause (fresh_tname ()) atoms (Lemma lemma)
|
add_clause (fresh_tname ()) atoms (Lemma lemma)
|
||||||
|
|
||||||
let slice_propagate f lvl =
|
let slice_propagate f lvl =
|
||||||
L.debug 100 "entering slice.propagate";
|
|
||||||
let a = add_atom f in
|
let a = add_atom f in
|
||||||
L.debug 100 "atom added";
|
|
||||||
Iheap.grow_to_by_double env.order (St.nb_vars ());
|
Iheap.grow_to_by_double env.order (St.nb_vars ());
|
||||||
L.debug 100 "heap grown";
|
|
||||||
enqueue_bool a lvl (Semantic lvl)
|
enqueue_bool a lvl (Semantic lvl)
|
||||||
|
|
||||||
let current_slice () = Th.({
|
let current_slice () = Th.({
|
||||||
|
|
@ -792,7 +786,6 @@ module Make (L : Log_intf.S)(E : Expr_intf.S)
|
||||||
let conflictC = ref 0 in
|
let conflictC = ref 0 in
|
||||||
env.starts <- env.starts + 1;
|
env.starts <- env.starts + 1;
|
||||||
while (true) do
|
while (true) do
|
||||||
L.debug 100 "searching %d/%d (%d)" !conflictC n_of_conflicts n_of_learnts;
|
|
||||||
match propagate () with
|
match propagate () with
|
||||||
| Some confl -> (* Conflict *)
|
| Some confl -> (* Conflict *)
|
||||||
incr conflictC;
|
incr conflictC;
|
||||||
|
|
|
||||||
|
|
@ -102,8 +102,8 @@ module Make (L : Log_intf.S)(E : Expr_intf.S)(Th : Plugin_intf.S with
|
||||||
module MF = Hashtbl.Make(E.Formula)
|
module MF = Hashtbl.Make(E.Formula)
|
||||||
module MT = Hashtbl.Make(E.Term)
|
module MT = Hashtbl.Make(E.Term)
|
||||||
|
|
||||||
let f_map = MF.create 1007
|
let f_map = MF.create 4096
|
||||||
let t_map = MT.create 1007
|
let t_map = MT.create 4096
|
||||||
|
|
||||||
let vars = Vec.make 107 (Either.mk_right dummy_var)
|
let vars = Vec.make 107 (Either.mk_right dummy_var)
|
||||||
let nb_vars () = Vec.size vars
|
let nb_vars () = Vec.size vars
|
||||||
|
|
@ -130,11 +130,9 @@ module Make (L : Log_intf.S)(E : Expr_intf.S)(Th : Plugin_intf.S with
|
||||||
|
|
||||||
let make_boolean_var =
|
let make_boolean_var =
|
||||||
fun lit ->
|
fun lit ->
|
||||||
L.debug 100 "normalizing lit";
|
|
||||||
let lit, negated = E.norm lit in
|
let lit, negated = E.norm lit in
|
||||||
try MF.find f_map lit, negated
|
try MF.find f_map lit, negated
|
||||||
with Not_found ->
|
with Not_found ->
|
||||||
L.debug 100 "Lit not in table";
|
|
||||||
let cpt_fois_2 = !cpt_mk_var lsl 1 in
|
let cpt_fois_2 = !cpt_mk_var lsl 1 in
|
||||||
let rec var =
|
let rec var =
|
||||||
{ vid = !cpt_mk_var;
|
{ vid = !cpt_mk_var;
|
||||||
|
|
@ -159,22 +157,16 @@ module Make (L : Log_intf.S)(E : Expr_intf.S)(Th : Plugin_intf.S with
|
||||||
neg = pa;
|
neg = pa;
|
||||||
is_true = false;
|
is_true = false;
|
||||||
aid = cpt_fois_2 + 1 (* aid = vid*2+1 *) } in
|
aid = cpt_fois_2 + 1 (* aid = vid*2+1 *) } in
|
||||||
L.debug 100 "adding lit to table...";
|
|
||||||
MF.add f_map lit var;
|
MF.add f_map lit var;
|
||||||
L.debug 100 "done";
|
|
||||||
incr cpt_mk_var;
|
incr cpt_mk_var;
|
||||||
Vec.push vars (Either.mk_right var);
|
Vec.push vars (Either.mk_right var);
|
||||||
L.debug 100 "iterating on new lit...";
|
|
||||||
Th.iter_assignable (fun t -> ignore (make_semantic_var t)) lit;
|
Th.iter_assignable (fun t -> ignore (make_semantic_var t)) lit;
|
||||||
L.debug 100 "done";
|
|
||||||
var, negated
|
var, negated
|
||||||
|
|
||||||
let add_term t = make_semantic_var t
|
let add_term t = make_semantic_var t
|
||||||
|
|
||||||
let add_atom lit =
|
let add_atom lit =
|
||||||
L.debug 100 "entering add_atom";
|
|
||||||
let var, negated = make_boolean_var lit in
|
let var, negated = make_boolean_var lit in
|
||||||
L.debug 100 "found atom";
|
|
||||||
if negated then var.tag.na else var.tag.pa
|
if negated then var.tag.na else var.tag.pa
|
||||||
|
|
||||||
let make_clause name ali sz_ali is_learnt premise =
|
let make_clause name ali sz_ali is_learnt premise =
|
||||||
|
|
|
||||||
11
util/vec.ml
11
util/vec.ml
|
|
@ -48,6 +48,7 @@ let size t = t.sz
|
||||||
let is_empty t = t.sz = 0
|
let is_empty t = t.sz = 0
|
||||||
|
|
||||||
let grow_to t new_capa =
|
let grow_to t new_capa =
|
||||||
|
assert (new_capa >= Array.length t.data);
|
||||||
let data = t.data in
|
let data = t.data in
|
||||||
let capa = Array.length data in
|
let capa = Array.length data in
|
||||||
t.data <- Array.init new_capa (fun i -> if i < capa then data.(i) else t.dummy)
|
t.data <- Array.init new_capa (fun i -> if i < capa then data.(i) else t.dummy)
|
||||||
|
|
@ -85,12 +86,10 @@ let get t i =
|
||||||
|
|
||||||
let set t i v =
|
let set t i v =
|
||||||
if i < 0 || i > t.sz then invalid_arg "vec.set";
|
if i < 0 || i > t.sz then invalid_arg "vec.set";
|
||||||
t.sz <- max t.sz (i+1); (* can set first empty slot *)
|
if i = t.sz then begin
|
||||||
Array.unsafe_set t.data i v
|
grow_to_double_size t;
|
||||||
|
t.sz <- i + 1
|
||||||
let set_unsafe t i v =
|
end;
|
||||||
if i < 0 || i >= Array.length t.data then invalid_arg "vec.set_unsafe";
|
|
||||||
t.sz <- max t.sz (i+1);
|
|
||||||
Array.unsafe_set t.data i v
|
Array.unsafe_set t.data i v
|
||||||
|
|
||||||
let copy t =
|
let copy t =
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,6 @@ val set : 'a t -> int -> 'a -> unit
|
||||||
free slot if [not (is_full vec)], or
|
free slot if [not (is_full vec)], or
|
||||||
@raise Invalid_argument if the index is not valid *)
|
@raise Invalid_argument if the index is not valid *)
|
||||||
|
|
||||||
val set_unsafe : 'a t -> int -> 'a -> unit
|
|
||||||
(* undocumented. TODO remove asap *)
|
|
||||||
|
|
||||||
val copy : 'a t -> 'a t
|
val copy : 'a t -> 'a t
|
||||||
(** Fresh copy *)
|
(** Fresh copy *)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue