mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-07 03:35:38 -05:00
wip: data-oriented clauses
This commit is contained in:
parent
97d87cc58f
commit
8b94e8404f
5 changed files with 505 additions and 292 deletions
|
|
@ -610,7 +610,7 @@ module Make(A : ARG)
|
|||
let proof_init = P.ref_by_name @@ find_proof_name init in
|
||||
let tr_step (pivot,p') : P.hres_step =
|
||||
(* unit resolution? *)
|
||||
let is_r1_step = Iter.length (SC.atoms store (SP.conclusion p')) = 1 in
|
||||
let is_r1_step = SC.n_atoms store (SP.conclusion p') = 1 in
|
||||
let proof_p' = P.ref_by_name @@ find_proof_name p' in
|
||||
if is_r1_step then (
|
||||
P.r1 proof_p'
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -284,12 +284,6 @@ module type PROOF = sig
|
|||
[f] is executed exactly once on each proof node in the tree, and that the execution of
|
||||
[f] on a proof node happens after the execution on the parents of the nodes. *)
|
||||
|
||||
val unsat_core : t -> clause list
|
||||
(** Returns the unsat_core of the given proof, i.e the lists of conclusions
|
||||
of all leafs of the proof.
|
||||
More efficient than using the [fold] function since it has
|
||||
access to the internal representation of proofs *)
|
||||
|
||||
(** {3 Misc} *)
|
||||
|
||||
val check_empty_conclusion : store -> t -> unit
|
||||
|
|
@ -359,7 +353,9 @@ module type S = sig
|
|||
val short_name : store -> t -> string
|
||||
(** Short name for a clause. Unspecified *)
|
||||
|
||||
val atoms : store -> t -> atom Iter.t
|
||||
val n_atoms : store -> t -> int
|
||||
|
||||
val atoms_iter : store -> t -> atom Iter.t
|
||||
(** Atoms of a clause *)
|
||||
|
||||
val atoms_a : store -> t -> atom array
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ type t = {
|
|||
|
||||
let mk_arr_ sz : int32arr = A.create Bigarray.int32 Bigarray.c_layout sz
|
||||
|
||||
let create () : t =
|
||||
{ sz=0; data=mk_arr_ 16 }
|
||||
let create ?(cap=16) () : t =
|
||||
{ sz=0; data=mk_arr_ cap }
|
||||
|
||||
let[@inline] clear self = self.sz <- 0
|
||||
let[@inline] shrink self n = if n < self.sz then self.sz <- n
|
||||
|
|
@ -25,22 +25,25 @@ let resize_cap_ self new_cap =
|
|||
A.blit self.data (A.sub new_data 0 (A.dim self.data));
|
||||
self.data <- new_data
|
||||
|
||||
let ensure_size self (n:int) =
|
||||
let ensure_cap self (n:int) =
|
||||
if n > A.dim self.data then (
|
||||
let new_cap = max n (A.dim self.data * 2 + 10) in
|
||||
resize_cap_ self new_cap;
|
||||
);
|
||||
)
|
||||
|
||||
let ensure_size self n =
|
||||
if n > self.sz then (
|
||||
ensure_cap self n;
|
||||
self.sz <- n
|
||||
)
|
||||
|
||||
let[@inline] push (self:t) i : unit =
|
||||
ensure_size self (self.sz+1);
|
||||
ensure_cap self (self.sz+1);
|
||||
self.data.{self.sz} <- Int32.of_int i;
|
||||
self.sz <- 1 + self.sz
|
||||
|
||||
let[@inline] push_i32 self i =
|
||||
ensure_size self (self.sz+1);
|
||||
ensure_cap self (self.sz+1);
|
||||
self.data.{self.sz} <- i;
|
||||
self.sz <- 1 + self.sz
|
||||
|
||||
|
|
@ -79,6 +82,22 @@ let[@inline] iteri ~f self =
|
|||
|
||||
let[@inline] to_iter self k = iter ~f:k self
|
||||
|
||||
module Slice = struct
|
||||
type t = int32arr
|
||||
|
||||
let size = A.dim
|
||||
let[@inline] get self i = Int32.to_int (A.get self i)
|
||||
let[@inline] set self i x = A.set self i (Int32.of_int x)
|
||||
let[@inline] swap self i j =
|
||||
let tmp = get self i in
|
||||
set self i (get self j);
|
||||
set self j tmp
|
||||
end
|
||||
|
||||
let[@inline] slice self ~off ~len =
|
||||
assert (off+len < self.sz);
|
||||
A.sub self.data off len
|
||||
|
||||
let pp out self =
|
||||
Format.fprintf out "[@[";
|
||||
iteri self ~f:(fun i x -> if i>0 then Format.fprintf out ",@ "; Format.pp_print_int out x);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
type t
|
||||
|
||||
val create : unit -> t
|
||||
val create : ?cap:int -> unit -> t
|
||||
|
||||
val ensure_size : t -> int -> unit
|
||||
|
||||
|
|
@ -34,6 +34,17 @@ val shrink : t -> int -> unit
|
|||
val iter : f:(int -> unit) -> t -> unit
|
||||
val iteri : f:(int -> int -> unit) -> t -> unit
|
||||
|
||||
module Slice : sig
|
||||
type t
|
||||
|
||||
val size : t -> int
|
||||
val get : t -> int -> int
|
||||
val set : t -> int -> int -> unit
|
||||
val swap : t -> int -> int -> unit
|
||||
end
|
||||
|
||||
val slice : t -> off:int -> len:int -> Slice.t
|
||||
|
||||
val to_iter : t -> int Iter.t
|
||||
|
||||
val pp : t CCFormat.printer
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue