3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-23 00:37:36 +00:00

Merge pull request #8702 from Z3Prover/copilot/fix-issues-in-discussion-8701

Add missing solver/optimizer API bindings across language targets
This commit is contained in:
Nikolaj Bjorner 2026-02-20 09:28:50 -08:00 committed by GitHub
commit e2129a7b81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 399 additions and 0 deletions

View file

@ -1989,6 +1989,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