mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 11:15:43 -05:00
chore: migrate from sequence to iter
This commit is contained in:
parent
d58759aa8c
commit
fadf76d944
26 changed files with 71 additions and 71 deletions
|
|
@ -13,7 +13,7 @@ build: [
|
||||||
depends: [
|
depends: [
|
||||||
"dune" {build}
|
"dune" {build}
|
||||||
"containers"
|
"containers"
|
||||||
"sequence"
|
"iter"
|
||||||
"zarith"
|
"zarith"
|
||||||
"menhir"
|
"menhir"
|
||||||
"msat" { >= "0.8" < "0.9" }
|
"msat" { >= "0.8" < "0.9" }
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ module type TERM = sig
|
||||||
val bool : state -> bool -> t
|
val bool : state -> bool -> t
|
||||||
|
|
||||||
(** View the term through the lens of the congruence closure *)
|
(** View the term through the lens of the congruence closure *)
|
||||||
val cc_view : t -> (Fun.t, t, t Sequence.t) view
|
val cc_view : t -> (Fun.t, t, t Iter.t) view
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ module Make(A: ARG) = struct
|
||||||
let[@inline] is_root (n:node) : bool = n.n_root == n
|
let[@inline] is_root (n:node) : bool = n.n_root == n
|
||||||
|
|
||||||
(* traverse the equivalence class of [n] *)
|
(* traverse the equivalence class of [n] *)
|
||||||
let iter_class_ (n:node) : node Sequence.t =
|
let iter_class_ (n:node) : node Iter.t =
|
||||||
fun yield ->
|
fun yield ->
|
||||||
let rec aux u =
|
let rec aux u =
|
||||||
yield u;
|
yield u;
|
||||||
|
|
@ -218,7 +218,7 @@ module Make(A: ARG) = struct
|
||||||
assert (is_root n);
|
assert (is_root n);
|
||||||
iter_class_ n
|
iter_class_ n
|
||||||
|
|
||||||
let[@inline] iter_parents (n:node) : node Sequence.t =
|
let[@inline] iter_parents (n:node) : node Iter.t =
|
||||||
assert (is_root n);
|
assert (is_root n);
|
||||||
Bag.to_seq n.n_parents
|
Bag.to_seq n.n_parents
|
||||||
|
|
||||||
|
|
@ -461,9 +461,9 @@ module Make(A: ARG) = struct
|
||||||
let c = List.rev_map A.Lit.neg e in
|
let c = List.rev_map A.Lit.neg e in
|
||||||
acts.Msat.acts_raise_conflict c A.Proof.default
|
acts.Msat.acts_raise_conflict c A.Proof.default
|
||||||
|
|
||||||
let[@inline] all_classes cc : repr Sequence.t =
|
let[@inline] all_classes cc : repr Iter.t =
|
||||||
T_tbl.values cc.tbl
|
T_tbl.values cc.tbl
|
||||||
|> Sequence.filter N.is_root
|
|> Iter.filter N.is_root
|
||||||
|
|
||||||
(* TODO: use markers and lockstep iteration instead *)
|
(* TODO: use markers and lockstep iteration instead *)
|
||||||
(* distance from [t] to its root in the proof forest *)
|
(* distance from [t] to its root in the proof forest *)
|
||||||
|
|
@ -634,12 +634,12 @@ module Make(A: ARG) = struct
|
||||||
return @@ Eq (a,b)
|
return @@ Eq (a,b)
|
||||||
| Not u -> return @@ Not (deref_sub u)
|
| Not u -> return @@ Not (deref_sub u)
|
||||||
| App_fun (f, args) ->
|
| App_fun (f, args) ->
|
||||||
let args = args |> Sequence.map deref_sub |> Sequence.to_list in
|
let args = args |> Iter.map deref_sub |> Iter.to_list in
|
||||||
if args<>[] then (
|
if args<>[] then (
|
||||||
return @@ App_fun (f, args)
|
return @@ App_fun (f, args)
|
||||||
) else None
|
) else None
|
||||||
| App_ho (f, args) ->
|
| App_ho (f, args) ->
|
||||||
let args = args |> Sequence.map deref_sub |> Sequence.to_list in
|
let args = args |> Iter.map deref_sub |> Iter.to_list in
|
||||||
return @@ App_ho (deref_sub f, args)
|
return @@ App_ho (deref_sub f, args)
|
||||||
| If (a,b,c) ->
|
| If (a,b,c) ->
|
||||||
return @@ If (deref_sub a, deref_sub b, deref_sub c)
|
return @@ If (deref_sub a, deref_sub b, deref_sub c)
|
||||||
|
|
@ -987,7 +987,7 @@ module Make(A: ARG) = struct
|
||||||
end
|
end
|
||||||
|
|
||||||
let[@inline] assert_lits cc lits : unit =
|
let[@inline] assert_lits cc lits : unit =
|
||||||
Sequence.iter (assert_lit cc) lits
|
Iter.iter (assert_lit cc) lits
|
||||||
|
|
||||||
let assert_eq cc t1 t2 (e:lit list) : unit =
|
let assert_eq cc t1 t2 (e:lit list) : unit =
|
||||||
let expl = Expl.mk_list @@ List.rev_map Expl.mk_lit e in
|
let expl = Expl.mk_list @@ List.rev_map Expl.mk_lit e in
|
||||||
|
|
@ -1052,7 +1052,7 @@ module Make(A: ARG) = struct
|
||||||
(* find a value in the class, if any *)
|
(* find a value in the class, if any *)
|
||||||
let v =
|
let v =
|
||||||
N.iter_class r
|
N.iter_class r
|
||||||
|> Sequence.find_map (fun n -> Model.eval m n.n_term)
|
|> Iter.find_map (fun n -> Model.eval m n.n_term)
|
||||||
in
|
in
|
||||||
let v = match v with
|
let v = match v with
|
||||||
| Some v -> v
|
| Some v -> v
|
||||||
|
|
@ -1066,7 +1066,7 @@ module Make(A: ARG) = struct
|
||||||
(* now map every term to its representative's value *)
|
(* now map every term to its representative's value *)
|
||||||
let pairs =
|
let pairs =
|
||||||
T_tbl.values cc.tbl
|
T_tbl.values cc.tbl
|
||||||
|> Sequence.map
|
|> Iter.map
|
||||||
(fun n ->
|
(fun n ->
|
||||||
let r = find_ n in
|
let r = find_ n in
|
||||||
let v =
|
let v =
|
||||||
|
|
@ -1076,7 +1076,7 @@ module Make(A: ARG) = struct
|
||||||
in
|
in
|
||||||
n.n_term, v)
|
n.n_term, v)
|
||||||
in
|
in
|
||||||
let m = Sequence.fold (fun m (t,v) -> Model.add t v m) m pairs in
|
let m = Iter.fold (fun m (t,v) -> Model.add t v m) m pairs in
|
||||||
Log.debugf 5 (fun k->k "(@[cc.model@ %a@])" Model.pp m);
|
Log.debugf 5 (fun k->k "(@[cc.model@ %a@])" Model.pp m);
|
||||||
m
|
m
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -73,11 +73,11 @@ module type S = sig
|
||||||
val is_root : t -> bool
|
val is_root : t -> bool
|
||||||
(** Is the node a root (ie the representative of its class)? *)
|
(** Is the node a root (ie the representative of its class)? *)
|
||||||
|
|
||||||
val iter_class : t -> t Sequence.t
|
val iter_class : t -> t Iter.t
|
||||||
(** Traverse the congruence class.
|
(** Traverse the congruence class.
|
||||||
Invariant: [is_root n] (see {!find} below) *)
|
Invariant: [is_root n] (see {!find} below) *)
|
||||||
|
|
||||||
val iter_parents : t -> t Sequence.t
|
val iter_parents : t -> t Iter.t
|
||||||
(** Traverse the parents of the class.
|
(** Traverse the parents of the class.
|
||||||
Invariant: [is_root n] (see {!find} below) *)
|
Invariant: [is_root n] (see {!find} below) *)
|
||||||
end
|
end
|
||||||
|
|
@ -173,10 +173,10 @@ module type S = sig
|
||||||
(** Current representative of the term.
|
(** Current representative of the term.
|
||||||
@raise Not_found if the term is not already {!add}-ed. *)
|
@raise Not_found if the term is not already {!add}-ed. *)
|
||||||
|
|
||||||
val add_seq : t -> term Sequence.t -> unit
|
val add_seq : t -> term Iter.t -> unit
|
||||||
(** Add a sequence of terms to the congruence closure *)
|
(** Add a sequence of terms to the congruence closure *)
|
||||||
|
|
||||||
val all_classes : t -> repr Sequence.t
|
val all_classes : t -> repr Iter.t
|
||||||
(** All current classes. This is costly, only use if there is no other solution *)
|
(** All current classes. This is costly, only use if there is no other solution *)
|
||||||
|
|
||||||
val assert_lit : t -> lit -> unit
|
val assert_lit : t -> lit -> unit
|
||||||
|
|
@ -185,7 +185,7 @@ module type S = sig
|
||||||
|
|
||||||
Useful for the theory combination or the SAT solver's functor *)
|
Useful for the theory combination or the SAT solver's functor *)
|
||||||
|
|
||||||
val assert_lits : t -> lit Sequence.t -> unit
|
val assert_lits : t -> lit Iter.t -> unit
|
||||||
(** Addition of many literals *)
|
(** Addition of many literals *)
|
||||||
|
|
||||||
val assert_eq : t -> term -> term -> lit list -> unit
|
val assert_eq : t -> term -> term -> lit list -> unit
|
||||||
|
|
|
||||||
|
|
@ -183,8 +183,8 @@ module Make(A: TERM) = struct
|
||||||
|
|
||||||
(* does this list contain a duplicate? *)
|
(* does this list contain a duplicate? *)
|
||||||
let has_dups (l:node list) : bool =
|
let has_dups (l:node list) : bool =
|
||||||
Sequence.diagonal (Sequence.of_list l)
|
Iter.diagonal (Iter.of_list l)
|
||||||
|> Sequence.exists (fun (n1,n2) -> Node.equal n1 n2)
|
|> Iter.exists (fun (n1,n2) -> Node.equal n1 n2)
|
||||||
|
|
||||||
exception E_unsat
|
exception E_unsat
|
||||||
|
|
||||||
|
|
@ -205,12 +205,12 @@ module Make(A: TERM) = struct
|
||||||
return @@ Eq (a,b)
|
return @@ Eq (a,b)
|
||||||
| Not u -> return @@ Not (find_t_ self u)
|
| Not u -> return @@ Not (find_t_ self u)
|
||||||
| App_fun (f, args) ->
|
| App_fun (f, args) ->
|
||||||
let args = args |> Sequence.map (find_t_ self) |> Sequence.to_list in
|
let args = args |> Iter.map (find_t_ self) |> Iter.to_list in
|
||||||
if args<>[] then (
|
if args<>[] then (
|
||||||
return @@ App_fun (f, args)
|
return @@ App_fun (f, args)
|
||||||
) else None
|
) else None
|
||||||
| App_ho (f, args) ->
|
| App_ho (f, args) ->
|
||||||
let args = args |> Sequence.map (find_t_ self) |> Sequence.to_list in
|
let args = args |> Iter.map (find_t_ self) |> Iter.to_list in
|
||||||
return @@ App_ho (find_t_ self f, args)
|
return @@ App_ho (find_t_ self f, args)
|
||||||
| If (a,b,c) ->
|
| If (a,b,c) ->
|
||||||
return @@ If(find_t_ self a, find_t_ self b, find_t_ self c)
|
return @@ If(find_t_ self a, find_t_ self b, find_t_ self c)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
(library
|
(library
|
||||||
(name Sidekick_cc)
|
(name Sidekick_cc)
|
||||||
(public_name sidekick.cc)
|
(public_name sidekick.cc)
|
||||||
(libraries containers containers.data msat sequence sidekick.util)
|
(libraries containers containers.data msat iter sidekick.util)
|
||||||
(flags :standard -warn-error -a+8
|
(flags :standard -warn-error -a+8
|
||||||
-color always -safe-string -short-paths -open Sidekick_util)
|
-color always -safe-string -short-paths -open Sidekick_util)
|
||||||
(ocamlopt_flags :standard -O3 -color always
|
(ocamlopt_flags :standard -O3 -color always
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
(name main)
|
(name main)
|
||||||
(public_name sidekick)
|
(public_name sidekick)
|
||||||
(package sidekick)
|
(package sidekick)
|
||||||
(libraries containers sequence result msat sidekick.smt sidekick.smtlib
|
(libraries containers iter result msat sidekick.smt sidekick.smtlib
|
||||||
sidekick.smt.th-ite sidekick.dimacs)
|
sidekick.smt.th-ite sidekick.dimacs)
|
||||||
(flags :standard -w +a-4-42-44-48-50-58-32-60@8
|
(flags :standard -w +a-4-42-44-48-50-58-32-60@8
|
||||||
-safe-string -color always -open Sidekick_util)
|
-safe-string -color always -open Sidekick_util)
|
||||||
|
|
|
||||||
|
|
@ -487,7 +487,7 @@ let env_add_statement env st =
|
||||||
-> env
|
-> env
|
||||||
|
|
||||||
let env_of_statements seq =
|
let env_of_statements seq =
|
||||||
Sequence.fold env_add_statement env_empty seq
|
Iter.fold env_add_statement env_empty seq
|
||||||
|
|
||||||
let env_find_def env id =
|
let env_find_def env id =
|
||||||
try Some (ID.Map.find id env.defs)
|
try Some (ID.Map.find id env.defs)
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ val env_empty : env
|
||||||
|
|
||||||
val env_add_statement : env -> statement -> env
|
val env_add_statement : env -> statement -> env
|
||||||
|
|
||||||
val env_of_statements: statement Sequence.t -> env
|
val env_of_statements: statement Iter.t -> env
|
||||||
|
|
||||||
val env_find_def : env -> ID.t -> env_entry option
|
val env_find_def : env -> ID.t -> env_entry option
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ val opt : 'a t -> 'a option t
|
||||||
val list : 'a t -> 'a list t
|
val list : 'a t -> 'a list t
|
||||||
val array : 'a t -> 'a array t
|
val array : 'a t -> 'a array t
|
||||||
val iarray : 'a t -> 'a IArray.t t
|
val iarray : 'a t -> 'a IArray.t t
|
||||||
val seq : 'a t -> 'a Sequence.t t
|
val seq : 'a t -> 'a Iter.t t
|
||||||
|
|
||||||
val combine2 : int -> int -> int
|
val combine2 : int -> int -> int
|
||||||
val combine3 : int -> int -> int -> int
|
val combine3 : int -> int -> int -> int
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ module Make(A : ARG): sig
|
||||||
type t
|
type t
|
||||||
val create : ?size:int -> unit -> t
|
val create : ?size:int -> unit -> t
|
||||||
val hashcons : t -> A.t -> A.t
|
val hashcons : t -> A.t -> A.t
|
||||||
val to_seq : t -> A.t Sequence.t
|
val to_seq : t -> A.t Iter.t
|
||||||
end = struct
|
end = struct
|
||||||
module W = Weak.Make(A)
|
module W = Weak.Make(A)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ module Fun_interpretation = struct
|
||||||
}
|
}
|
||||||
|
|
||||||
let default fi = fi.default
|
let default fi = fi.default
|
||||||
let cases_list fi = Val_map.to_seq fi.cases |> Sequence.to_rev_list
|
let cases_list fi = Val_map.to_seq fi.cases |> Iter.to_rev_list
|
||||||
|
|
||||||
let make ~default l : t =
|
let make ~default l : t =
|
||||||
let m = List.fold_left (fun m (k,v) -> Val_map.add k v m) Val_map.empty l in
|
let m = List.fold_left (fun m (k,v) -> Val_map.add k v m) Val_map.empty l in
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ let flush_progress (): unit =
|
||||||
|
|
||||||
module Top_goals: sig
|
module Top_goals: sig
|
||||||
val push : term -> unit
|
val push : term -> unit
|
||||||
val to_seq : term Sequence.t
|
val to_seq : term Iter.t
|
||||||
val check: unit -> unit
|
val check: unit -> unit
|
||||||
end = struct
|
end = struct
|
||||||
(* list of terms to fully evaluate *)
|
(* list of terms to fully evaluate *)
|
||||||
|
|
@ -147,9 +147,9 @@ type res =
|
||||||
(** {2 Main} *)
|
(** {2 Main} *)
|
||||||
|
|
||||||
(* convert unsat-core *)
|
(* convert unsat-core *)
|
||||||
let clauses_of_unsat_core (core:Sat_solver.clause list): Lit.t IArray.t Sequence.t =
|
let clauses_of_unsat_core (core:Sat_solver.clause list): Lit.t IArray.t Iter.t =
|
||||||
Sequence.of_list core
|
Iter.of_list core
|
||||||
|> Sequence.map clause_of_mclause
|
|> Iter.map clause_of_mclause
|
||||||
|
|
||||||
(* print all terms reachable from watched literals *)
|
(* print all terms reachable from watched literals *)
|
||||||
let pp_term_graph _out (_:t) =
|
let pp_term_graph _out (_:t) =
|
||||||
|
|
@ -173,12 +173,12 @@ let do_on_exit ~on_exit =
|
||||||
(* map boolean subterms to literals *)
|
(* map boolean subterms to literals *)
|
||||||
let add_bool_subterms_ (self:t) (t:Term.t) : unit =
|
let add_bool_subterms_ (self:t) (t:Term.t) : unit =
|
||||||
Term.iter_dag t
|
Term.iter_dag t
|
||||||
|> Sequence.filter (fun t -> Ty.is_prop @@ Term.ty t)
|
|> Iter.filter (fun t -> Ty.is_prop @@ Term.ty t)
|
||||||
|> Sequence.filter
|
|> Iter.filter
|
||||||
(fun t -> match Term.view t with
|
(fun t -> match Term.view t with
|
||||||
| Term.Not _ -> false (* will process the subterm just later *)
|
| Term.Not _ -> false (* will process the subterm just later *)
|
||||||
| _ -> true)
|
| _ -> true)
|
||||||
|> Sequence.iter
|
|> Iter.iter
|
||||||
(fun sub ->
|
(fun sub ->
|
||||||
Log.debugf 5 (fun k->k "(@[solver.map-to-lit@ :subterm %a@])" Term.pp sub);
|
Log.debugf 5 (fun k->k "(@[solver.map-to-lit@ :subterm %a@])" Term.pp sub);
|
||||||
ignore (mk_atom_t self sub : Sat_solver.atom))
|
ignore (mk_atom_t self sub : Sat_solver.atom))
|
||||||
|
|
@ -250,8 +250,8 @@ let solve ?(on_exit=[]) ?(check=true) () =
|
||||||
(* assume all literals [expanded t] are false *)
|
(* assume all literals [expanded t] are false *)
|
||||||
let assumptions =
|
let assumptions =
|
||||||
Terms_to_expand.to_seq
|
Terms_to_expand.to_seq
|
||||||
|> Sequence.map (fun {Terms_to_expand.lit; _} -> Lit.neg lit)
|
|> Iter.map (fun {Terms_to_expand.lit; _} -> Lit.neg lit)
|
||||||
|> Sequence.to_rev_list
|
|> Iter.to_rev_list
|
||||||
in
|
in
|
||||||
incr n_iter;
|
incr n_iter;
|
||||||
Log.debugf 2
|
Log.debugf 2
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,10 @@ val abs : state -> t -> t * bool
|
||||||
module Iter_dag : sig
|
module Iter_dag : sig
|
||||||
type t
|
type t
|
||||||
val create : unit -> t
|
val create : unit -> t
|
||||||
val iter_dag : t -> term -> term Sequence.t
|
val iter_dag : t -> term -> term Iter.t
|
||||||
end
|
end
|
||||||
|
|
||||||
val iter_dag : t -> t Sequence.t
|
val iter_dag : t -> t Iter.t
|
||||||
|
|
||||||
val pp : t Fmt.printer
|
val pp : t Fmt.printer
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ val is_true : t -> bool
|
||||||
val is_false : t -> bool
|
val is_false : t -> bool
|
||||||
val is_const : t -> bool
|
val is_const : t -> bool
|
||||||
|
|
||||||
val cc_view : t -> (cst,t,t Sequence.t) Sidekick_cc.view
|
val cc_view : t -> (cst,t,t Iter.t) Sidekick_cc.view
|
||||||
|
|
||||||
(* return [Some] iff the term is an undefined constant *)
|
(* return [Some] iff the term is an undefined constant *)
|
||||||
val as_cst_undef : t -> (cst * Ty.Fun.t) option
|
val as_cst_undef : t -> (cst * Ty.Fun.t) option
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,14 @@ module type S = sig
|
||||||
val on_merge: t -> actions -> CC_eq_class.t -> CC_eq_class.t -> CC_expl.t -> unit
|
val on_merge: t -> actions -> CC_eq_class.t -> CC_eq_class.t -> CC_expl.t -> unit
|
||||||
(** Called when two classes are merged *)
|
(** Called when two classes are merged *)
|
||||||
|
|
||||||
val partial_check : t -> actions -> Lit.t Sequence.t -> unit
|
val partial_check : t -> actions -> Lit.t Iter.t -> unit
|
||||||
(** Called when a literal becomes true *)
|
(** Called when a literal becomes true *)
|
||||||
|
|
||||||
val final_check: t -> actions -> Lit.t Sequence.t -> unit
|
val final_check: t -> actions -> Lit.t Iter.t -> unit
|
||||||
(** Final check, must be complete (i.e. must raise a conflict
|
(** Final check, must be complete (i.e. must raise a conflict
|
||||||
if the set of literals is not satisfiable) *)
|
if the set of literals is not satisfiable) *)
|
||||||
|
|
||||||
val mk_model : t -> Lit.t Sequence.t -> Model.t -> Model.t
|
val mk_model : t -> Lit.t Iter.t -> Model.t -> Model.t
|
||||||
(** Make a model for this theory's terms *)
|
(** Make a model for this theory's terms *)
|
||||||
|
|
||||||
val push_level : t -> unit
|
val push_level : t -> unit
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,13 @@ type t = {
|
||||||
|
|
||||||
let[@inline] cc (t:t) = Lazy.force t.cc
|
let[@inline] cc (t:t) = Lazy.force t.cc
|
||||||
let[@inline] tst t = t.tst
|
let[@inline] tst t = t.tst
|
||||||
let[@inline] theories (self:t) : theory_state Sequence.t =
|
let[@inline] theories (self:t) : theory_state Iter.t =
|
||||||
fun k -> List.iter k self.theories
|
fun k -> List.iter k self.theories
|
||||||
|
|
||||||
(** {2 Interface with the SAT solver} *)
|
(** {2 Interface with the SAT solver} *)
|
||||||
|
|
||||||
(* handle a literal assumed by the SAT solver *)
|
(* handle a literal assumed by the SAT solver *)
|
||||||
let assert_lits_ ~final (self:t) acts (lits:Lit.t Sequence.t) : unit =
|
let assert_lits_ ~final (self:t) acts (lits:Lit.t Iter.t) : unit =
|
||||||
Msat.Log.debugf 2
|
Msat.Log.debugf 2
|
||||||
(fun k->k "(@[<hv1>@{<green>th_combine.assume_lits@}%s@ %a@])"
|
(fun k->k "(@[<hv1>@{<green>th_combine.assume_lits@}%s@ %a@])"
|
||||||
(if final then "[final]" else "") (Util.pp_seq ~sep:"; " Lit.pp) lits);
|
(if final then "[final]" else "") (Util.pp_seq ~sep:"; " Lit.pp) lits);
|
||||||
|
|
@ -69,7 +69,7 @@ let assert_lits_ ~final (self:t) acts (lits:Lit.t Sequence.t) : unit =
|
||||||
if final then Th.final_check st acts lits else Th.partial_check st acts lits);
|
if final then Th.final_check st acts lits else Th.partial_check st acts lits);
|
||||||
()
|
()
|
||||||
|
|
||||||
let[@inline] iter_atoms_ acts : _ Sequence.t =
|
let[@inline] iter_atoms_ acts : _ Iter.t =
|
||||||
fun f ->
|
fun f ->
|
||||||
acts.Msat.acts_iter_assumptions
|
acts.Msat.acts_iter_assumptions
|
||||||
(function
|
(function
|
||||||
|
|
@ -80,7 +80,7 @@ let[@inline] iter_atoms_ acts : _ Sequence.t =
|
||||||
let check_ ~final (self:t) (acts:_ Msat.acts) =
|
let check_ ~final (self:t) (acts:_ Msat.acts) =
|
||||||
let iter = iter_atoms_ acts in
|
let iter = iter_atoms_ acts in
|
||||||
(* TODO if Config.progress then print_progress(); *)
|
(* TODO if Config.progress then print_progress(); *)
|
||||||
Msat.Log.debugf 5 (fun k->k "(th_combine.assume :len %d)" (Sequence.length iter));
|
Msat.Log.debugf 5 (fun k->k "(th_combine.assume :len %d)" (Iter.length iter));
|
||||||
assert_lits_ ~final self acts iter
|
assert_lits_ ~final self acts iter
|
||||||
|
|
||||||
let add_formula (self:t) (lit:Lit.t) =
|
let add_formula (self:t) (lit:Lit.t) =
|
||||||
|
|
@ -108,7 +108,7 @@ let pop_levels (self:t) n : unit =
|
||||||
|
|
||||||
let mk_model (self:t) lits : Model.t =
|
let mk_model (self:t) lits : Model.t =
|
||||||
let m =
|
let m =
|
||||||
Sequence.fold
|
Iter.fold
|
||||||
(fun m (Th_state ((module Th),st)) -> Th.mk_model st lits m)
|
(fun m (Th_state ((module Th),st)) -> Th.mk_model st lits m)
|
||||||
Model.empty (theories self)
|
Model.empty (theories self)
|
||||||
in
|
in
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ val tst : t -> Term.state
|
||||||
type theory_state =
|
type theory_state =
|
||||||
| Th_state : ('a Theory.t1 * 'a) -> theory_state
|
| Th_state : ('a Theory.t1 * 'a) -> theory_state
|
||||||
|
|
||||||
val theories : t -> theory_state Sequence.t
|
val theories : t -> theory_state Iter.t
|
||||||
|
|
||||||
val mk_model : t -> Lit.t Sequence.t -> Model.t
|
val mk_model : t -> Lit.t Iter.t -> Model.t
|
||||||
|
|
||||||
val add_theory : t -> Theory.t -> unit
|
val add_theory : t -> Theory.t -> unit
|
||||||
(** How to add new theories *)
|
(** How to add new theories *)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
(library
|
(library
|
||||||
(name Sidekick_smt)
|
(name Sidekick_smt)
|
||||||
(public_name sidekick.smt)
|
(public_name sidekick.smt)
|
||||||
(libraries containers containers.data sequence
|
(libraries containers containers.data iter
|
||||||
sidekick.util sidekick.cc msat zarith)
|
sidekick.util sidekick.cc msat zarith)
|
||||||
(flags :standard -warn-error -a+8
|
(flags :standard -warn-error -a+8
|
||||||
-color always -safe-string -short-paths -open Sidekick_util)
|
-color always -safe-string -short-paths -open Sidekick_util)
|
||||||
|
|
|
||||||
|
|
@ -506,7 +506,7 @@ end = struct
|
||||||
let rhs = conv_term_rec env' rhs in
|
let rhs = conv_term_rec env' rhs in
|
||||||
let depends_on_vars =
|
let depends_on_vars =
|
||||||
Term.to_seq_depth rhs
|
Term.to_seq_depth rhs
|
||||||
|> Sequence.exists
|
|> Iter.exists
|
||||||
(fun (t,k) -> match t.term_cell with
|
(fun (t,k) -> match t.term_cell with
|
||||||
| DB db ->
|
| DB db ->
|
||||||
DB.level db < n_vars + k (* [k]: number of intermediate binders *)
|
DB.level db < n_vars + k (* [k]: number of intermediate binders *)
|
||||||
|
|
@ -521,9 +521,9 @@ end = struct
|
||||||
(* TODO: do the closedness check during conversion, above *)
|
(* TODO: do the closedness check during conversion, above *)
|
||||||
let rhs_l =
|
let rhs_l =
|
||||||
ID.Map.values m
|
ID.Map.values m
|
||||||
|> Sequence.map snd
|
|> Iter.map snd
|
||||||
|> Sequence.sort_uniq ~cmp:Term.compare
|
|> Iter.sort_uniq ~cmp:Term.compare
|
||||||
|> Sequence.to_rev_list
|
|> Iter.to_rev_list
|
||||||
in
|
in
|
||||||
begin match rhs_l with
|
begin match rhs_l with
|
||||||
| [x] when not (!any_rhs_depends_vars) ->
|
| [x] when not (!any_rhs_depends_vars) ->
|
||||||
|
|
|
||||||
|
|
@ -86,10 +86,10 @@ module Make(Term : ARG) = struct
|
||||||
| B_atom _ -> ()
|
| B_atom _ -> ()
|
||||||
| v -> tseitin ~final self acts lit t v)
|
| v -> tseitin ~final self acts lit t v)
|
||||||
|
|
||||||
let partial_check (self:t) acts (lits:Lit.t Sequence.t) =
|
let partial_check (self:t) acts (lits:Lit.t Iter.t) =
|
||||||
check_ ~final:false self acts lits
|
check_ ~final:false self acts lits
|
||||||
|
|
||||||
let final_check (self:t) acts (lits:Lit.t Sequence.t) =
|
let final_check (self:t) acts (lits:Lit.t Iter.t) =
|
||||||
check_ ~final:true self acts lits
|
check_ ~final:true self acts lits
|
||||||
|
|
||||||
let th =
|
let th =
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ module type ARG = sig
|
||||||
val pp : t Fmt.printer
|
val pp : t Fmt.printer
|
||||||
val equal : t -> t -> bool
|
val equal : t -> t -> bool
|
||||||
val hash : t -> int
|
val hash : t -> int
|
||||||
val as_distinct : t -> t Sequence.t option
|
val as_distinct : t -> t Iter.t option
|
||||||
val mk_eq : state -> t -> t -> t
|
val mk_eq : state -> t -> t -> t
|
||||||
end
|
end
|
||||||
module Lit : sig
|
module Lit : sig
|
||||||
|
|
@ -113,7 +113,7 @@ module Make(A : ARG with type Lit.t = Sidekick_smt.Lit.t
|
||||||
|
|
||||||
module CC = Sidekick_smt.CC
|
module CC = Sidekick_smt.CC
|
||||||
|
|
||||||
let process_lit (st:st) (acts:Theory.actions) (lit:Lit.t) (lit_t:term) (subs:term Sequence.t) : unit =
|
let process_lit (st:st) (acts:Theory.actions) (lit:Lit.t) (lit_t:term) (subs:term Iter.t) : unit =
|
||||||
let (module A) = acts in
|
let (module A) = acts in
|
||||||
Log.debugf 5 (fun k->k "(@[th_distinct.process@ %a@])" Lit.pp lit);
|
Log.debugf 5 (fun k->k "(@[th_distinct.process@ %a@])" Lit.pp lit);
|
||||||
let add_axiom c = A.add_persistent_axiom c in
|
let add_axiom c = A.add_persistent_axiom c in
|
||||||
|
|
@ -129,11 +129,11 @@ module Make(A : ARG with type Lit.t = Sidekick_smt.Lit.t
|
||||||
) else if not @@ T_tbl.mem st.expanded lit_t then (
|
) else if not @@ T_tbl.mem st.expanded lit_t then (
|
||||||
(* add clause [distinct t1…tn ∨ ∨_{i,j>i} t_i=j] *)
|
(* add clause [distinct t1…tn ∨ ∨_{i,j>i} t_i=j] *)
|
||||||
T_tbl.add st.expanded lit_t ();
|
T_tbl.add st.expanded lit_t ();
|
||||||
let l = Sequence.to_list subs in
|
let l = Iter.to_list subs in
|
||||||
let c =
|
let c =
|
||||||
Sequence.diagonal_l l
|
Iter.diagonal_l l
|
||||||
|> Sequence.map (fun (t,u) -> Lit.atom st.tst @@ T.mk_eq st.tst t u)
|
|> Iter.map (fun (t,u) -> Lit.atom st.tst @@ T.mk_eq st.tst t u)
|
||||||
|> Sequence.to_rev_list
|
|> Iter.to_rev_list
|
||||||
in
|
in
|
||||||
let c = Lit.neg lit :: c in
|
let c = Lit.neg lit :: c in
|
||||||
Log.debugf 5 (fun k->k "(@[tseitin.distinct.case-split@ %a@])" pp_c c);
|
Log.debugf 5 (fun k->k "(@[tseitin.distinct.case-split@ %a@])" pp_c c);
|
||||||
|
|
@ -182,8 +182,8 @@ module Arg = struct
|
||||||
let eval args =
|
let eval args =
|
||||||
let module Value = Sidekick_smt.Value in
|
let module Value = Sidekick_smt.Value in
|
||||||
if
|
if
|
||||||
Sequence.diagonal (IArray.to_seq args)
|
Iter.diagonal (IArray.to_seq args)
|
||||||
|> Sequence.for_all (fun (x,y) -> not @@ Value.equal x y)
|
|> Iter.for_all (fun (x,y) -> not @@ Value.equal x y)
|
||||||
then Value.true_
|
then Value.true_
|
||||||
else Value.false_
|
else Value.false_
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ module type ARG = sig
|
||||||
val pp : t Fmt.printer
|
val pp : t Fmt.printer
|
||||||
val equal : t -> t -> bool
|
val equal : t -> t -> bool
|
||||||
val hash : t -> int
|
val hash : t -> int
|
||||||
val as_distinct : t -> t Sequence.t option
|
val as_distinct : t -> t Iter.t option
|
||||||
val mk_eq : state -> t -> t -> t
|
val mk_eq : state -> t -> t -> t
|
||||||
end
|
end
|
||||||
module Lit : sig
|
module Lit : sig
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ val cons : 'a -> 'a t -> 'a t
|
||||||
|
|
||||||
val append : 'a t -> 'a t -> 'a t
|
val append : 'a t -> 'a t -> 'a t
|
||||||
|
|
||||||
val to_seq : 'a t -> 'a Sequence.t
|
val to_seq : 'a t -> 'a Iter.t
|
||||||
|
|
||||||
val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
|
val fold : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,8 @@ let of_seq s =
|
||||||
|
|
||||||
(*$Q
|
(*$Q
|
||||||
Q.(list int) (fun l -> \
|
Q.(list int) (fun l -> \
|
||||||
let g = Sequence.of_list l in \
|
let g = Iter.of_list l in \
|
||||||
of_seq g |> to_seq |> Sequence.to_list = l)
|
of_seq g |> to_seq |> Iter.to_list = l)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
let rec gen_to_list_ acc g = match g() with
|
let rec gen_to_list_ acc g = match g() with
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ type 'a printer = 'a CCFormat.printer
|
||||||
|
|
||||||
val pp_list : ?sep:string -> 'a printer -> 'a list printer
|
val pp_list : ?sep:string -> 'a printer -> 'a list printer
|
||||||
|
|
||||||
val pp_seq : ?sep:string -> 'a printer -> 'a Sequence.t printer
|
val pp_seq : ?sep:string -> 'a printer -> 'a Iter.t printer
|
||||||
|
|
||||||
val pp_array : ?sep:string -> 'a printer -> 'a array printer
|
val pp_array : ?sep:string -> 'a printer -> 'a array printer
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
(library
|
(library
|
||||||
(name sidekick_util)
|
(name sidekick_util)
|
||||||
(public_name sidekick.util)
|
(public_name sidekick.util)
|
||||||
(libraries containers sequence msat)
|
(libraries containers iter msat)
|
||||||
(flags :standard -w +a-4-42-44-48-50-58-32-60@8 -color always -safe-string)
|
(flags :standard -w +a-4-42-44-48-50-58-32-60@8 -color always -safe-string)
|
||||||
(ocamlopt_flags :standard -O3 -bin-annot
|
(ocamlopt_flags :standard -O3 -bin-annot
|
||||||
-unbox-closures -unbox-closures-factor 20)
|
-unbox-closures -unbox-closures-factor 20)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue