mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-11 13:38:43 -05:00
fix(sat): level-0 resolution needs to be recursive
This commit is contained in:
parent
72d79d7c0a
commit
f500704905
1 changed files with 26 additions and 8 deletions
|
|
@ -2137,14 +2137,32 @@ module Make(Plugin : PLUGIN)
|
||||||
let resolve_with_lvl0 (self:t) (c:clause) : clause =
|
let resolve_with_lvl0 (self:t) (c:clause) : clause =
|
||||||
let lvl0 = ref [] in
|
let lvl0 = ref [] in
|
||||||
let res = ref [] in
|
let res = ref [] in
|
||||||
Clause.iter self.store c
|
let to_unmark = self.temp_atom_vec in
|
||||||
~f:(fun a ->
|
assert (AVec.is_empty to_unmark);
|
||||||
assert (Atom.is_false self.store a);
|
|
||||||
match Atom.reason self.store a with
|
(* resolve against the root cause of [a] being false *)
|
||||||
| None -> assert false
|
let rec resolve_with_a (a:atom) : unit =
|
||||||
| Some Decision -> res := a :: !res (* keep assumption *)
|
assert (Atom.is_false self.store a);
|
||||||
| Some (Bcp c2 | Bcp_lazy (lazy c2)) ->
|
if not (Var.marked self.store (Atom.var a)) then (
|
||||||
lvl0 := Clause.proof_step self.store c2 :: !lvl0);
|
AVec.push to_unmark a;
|
||||||
|
Var.mark self.store (Atom.var a);
|
||||||
|
|
||||||
|
match Atom.reason self.store a with
|
||||||
|
| None -> assert false
|
||||||
|
| Some Decision -> res := a :: !res (* keep assumption *)
|
||||||
|
| Some (Bcp c2 | Bcp_lazy (lazy c2)) ->
|
||||||
|
lvl0 := Clause.proof_step self.store c2 :: !lvl0;
|
||||||
|
(* recursively explain other literals of [c2] *)
|
||||||
|
Clause.iter self.store c2
|
||||||
|
~f:(fun a2 ->
|
||||||
|
let na2 = Atom.neg a2 in
|
||||||
|
if not (Atom.equal a na2) then resolve_with_a a2)
|
||||||
|
)
|
||||||
|
in
|
||||||
|
|
||||||
|
Clause.iter self.store c ~f:resolve_with_a;
|
||||||
|
AVec.iter to_unmark ~f:(fun a -> Var.unmark self.store (Atom.var a));
|
||||||
|
AVec.clear to_unmark;
|
||||||
|
|
||||||
if !lvl0 = [] then (
|
if !lvl0 = [] then (
|
||||||
c (* no resolution happened *)
|
c (* no resolution happened *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue