sidekick/src/smt/Clause.ml
Simon Cruanes e1717f3afe wip: heavy refactoring of SAT solver, making most things backtrackable
the idea is that most changes should be undone upon backtracking,
using the global `on_backtrack` command and `at_level_0` to
know when something is going to be permanent.

In particular, should be (possibly optionally) undone on backtracking:
- addition of clauses (clauses being attached)
- propagations of atoms
- addition of literals to the heap
- internalization of literals (tbd)

clauses should also be added immediately, not pushed into a queue
2018-02-11 22:58:24 -06:00

30 lines
636 B
OCaml
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

open Solver_types
type t = Lit.t list
let lits c = c
let pp out c = match lits c with
| [] -> Fmt.string out "false"
| [lit] -> Lit.pp out lit
| l ->
Format.fprintf out "[@[<hv>%a@]]"
(Util.pp_list ~sep:" " Lit.pp) l
(* canonical form: sorted list *)
let make =
fun l -> CCList.sort_uniq ~cmp:Lit.compare l
let equal_ c1 c2 = CCList.equal Lit.equal (lits c1) (lits c2)
let hash_ c = Hash.list Lit.hash (lits c)
module Tbl = CCHashtbl.Make(struct
type t_ = t
type t = t_
let equal = equal_
let hash = hash_
end)
let iter f c = List.iter f (lits c)
let to_seq c = Sequence.of_list (lits c)