3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-03-12 16:20:31 +00:00

Add missing API methods across language bindings (discussion #8701)

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-02-20 04:24:22 +00:00
parent 50f3051054
commit 8d79e21aa7
9 changed files with 406 additions and 1 deletions

View file

@ -1971,6 +1971,35 @@ struct
let from_string x = Z3native.solver_from_string (gc x) x
let set_initial_value x var value = Z3native.solver_set_initial_value (gc x) x var value
let cube x variables cutoff =
let av = Z3native.mk_ast_vector (gc x) in
List.iter (fun e -> Z3native.ast_vector_push (gc x) av e) variables;
let result = Z3native.solver_cube (gc x) x av cutoff in
AST.ASTVector.to_expr_list result
let get_consequences x assumptions variables =
let asms = Z3native.mk_ast_vector (gc x) in
let vars = Z3native.mk_ast_vector (gc x) in
let cons = Z3native.mk_ast_vector (gc x) in
List.iter (fun e -> Z3native.ast_vector_push (gc x) asms e) assumptions;
List.iter (fun e -> Z3native.ast_vector_push (gc x) vars e) variables;
let r = Z3native.solver_get_consequences (gc x) x asms vars cons in
let status = match lbool_of_int r with
| L_TRUE -> SATISFIABLE
| L_FALSE -> UNSATISFIABLE
| _ -> UNKNOWN
in
(status, AST.ASTVector.to_expr_list cons)
let solve_for x variables terms guards =
let var_vec = Z3native.mk_ast_vector (gc x) in
let term_vec = Z3native.mk_ast_vector (gc x) in
let guard_vec = Z3native.mk_ast_vector (gc x) in
List.iter (fun e -> Z3native.ast_vector_push (gc x) var_vec e) variables;
List.iter (fun e -> Z3native.ast_vector_push (gc x) term_vec e) terms;
List.iter (fun e -> Z3native.ast_vector_push (gc x) guard_vec e) guards;
Z3native.solver_solve_for (gc x) x var_vec term_vec guard_vec
end

View file

@ -3429,6 +3429,22 @@ sig
(** Provide an initial value hint for a variable to the solver.
This can help guide the solver to find solutions more efficiently. *)
val set_initial_value : solver -> Expr.expr -> Expr.expr -> unit
(** Extract cubes from the solver for cube-and-conquer parallel solving.
vars is a list of variables to use as cube variables; use an empty list for automatic selection.
cutoff is the backtrack level cutoff for cube generation.
Returns a list of expressions representing the cube literals. *)
val cube : solver -> Expr.expr list -> int -> Expr.expr list
(** Retrieve fixed assignments to variables as consequences given assumptions.
Returns the solver status and a list of consequence expressions.
Each consequence is an implication: assumptions => variable = value. *)
val get_consequences : solver -> Expr.expr list -> Expr.expr list -> solver_result * Expr.expr list
(** Solve constraints treating given variables symbolically.
variables are the variables to solve for, terms are the substitution terms,
and guards are Boolean guards for the substitutions. *)
val solve_for : solver -> Expr.expr list -> Expr.expr list -> Expr.expr list -> unit
end
(** Fixedpoint solving *)