mirror of
https://github.com/c-cube/sidekick.git
synced 2026-01-23 18:06:41 -05:00
Restored simple expressions for pure SAT
This commit is contained in:
parent
dfff903f8c
commit
fa8957784a
4 changed files with 74 additions and 2 deletions
64
src/sat/expr_sat.ml
Normal file
64
src/sat/expr_sat.ml
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
(*
|
||||
MSAT is free software, using the Apache license, see file LICENSE
|
||||
Copyright 2016 Guillaume Bury
|
||||
Copyright 2016 Simon Cruanes
|
||||
*)
|
||||
|
||||
exception Bad_atom
|
||||
|
||||
type t = int
|
||||
type proof = unit
|
||||
|
||||
let max_lit = max_int
|
||||
let max_fresh = ref (-1)
|
||||
let max_index = ref 0
|
||||
|
||||
let _make i =
|
||||
if i <> 0 && (abs i) < max_lit then begin
|
||||
max_index := max !max_index (abs i);
|
||||
i
|
||||
end else
|
||||
raise Bad_atom
|
||||
|
||||
let dummy = 0
|
||||
|
||||
let neg a = - a
|
||||
|
||||
let norm a =
|
||||
abs a, if a < 0 then
|
||||
Formula_intf.Negated
|
||||
else
|
||||
Formula_intf.Same_sign
|
||||
|
||||
let abs = abs
|
||||
|
||||
let sign i = i > 0
|
||||
|
||||
let apply_sign b i = if b then i else neg i
|
||||
|
||||
let set_sign b i = if b then abs i else neg (abs i)
|
||||
|
||||
let hash (a:int) = a land max_int
|
||||
let equal (a:int) b = a=b
|
||||
let compare (a:int) b = Pervasives.compare a b
|
||||
|
||||
let make i = _make (2 * i)
|
||||
|
||||
let fresh, iter =
|
||||
let create () =
|
||||
incr max_fresh;
|
||||
_make (2 * !max_fresh + 1)
|
||||
in
|
||||
let iter: (t -> unit) -> unit = fun f ->
|
||||
for j = 1 to !max_index do
|
||||
f j
|
||||
done
|
||||
in
|
||||
create, iter
|
||||
|
||||
let print fmt a =
|
||||
Format.fprintf fmt "%s%s%d"
|
||||
(if a < 0 then "~" else "")
|
||||
(if a mod 2 = 0 then "v" else "f")
|
||||
((abs a) / 2)
|
||||
|
||||
8
src/sat/expr_sat.mli
Normal file
8
src/sat/expr_sat.mli
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(*
|
||||
MSAT is free software, using the Apache license, see file LICENSE
|
||||
Copyright 2016 Guillaume Bury
|
||||
Copyright 2016 Simon Cruanes
|
||||
*)
|
||||
|
||||
include Formula_intf.S
|
||||
|
||||
|
|
@ -5,5 +5,5 @@ Copyright 2014 Simon Cruanes
|
|||
*)
|
||||
|
||||
module Make(Dummy : sig end) =
|
||||
Solver.Make(Expr.Atom)(Solver.DummyTheory(Expr.Atom))(struct end)
|
||||
Solver.Make(Expr_sat)(Solver.DummyTheory(Expr_sat))(struct end)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ Copyright 2014 Guillaume Bury
|
|||
Copyright 2014 Simon Cruanes
|
||||
*)
|
||||
|
||||
module Make(Dummy : sig end) : Solver.S with type St.formula = Expr.Atom.t
|
||||
module Make(Dummy : sig end) : Solver.S with type St.formula = Expr_sat.t
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue