3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-08 10:25:18 +00:00

Regenerate ml api

This commit is contained in:
Josh Berdine 2012-12-06 00:42:30 +00:00
parent 79be6ee6c2
commit 6a5de3384c
3 changed files with 1196 additions and 3107 deletions

View file

@ -293,13 +293,12 @@ let reset_memory () = ()
(** Exceptions raised by Z3. It is safe to continue interacting with Z3 after
catching [Error] exceptions.
- {b See also}: {!get_error_msg}
*)
exception Error of context * error_code
(* Register dynamically-generated exception tag for use from C *)
let _ = Callback.register_exception "Z3.Error" (Error (Obj.magic None, OK))
external mk_context: (string * string) list -> context = "caml_z3_mk_context"
@ -349,7 +348,6 @@ external param_descrs_to_string : context -> param_descrs -> string
(**
Refined view of a {!symbol}.
- {b See also}: {!mk_symbol}
- {b See also}: {!symbol_refine}
*)
@ -368,33 +366,28 @@ external mk_string_symbol : context -> string -> symbol
A datatype constructor descriptor.
*)
type datatype_constructor_desc = {
constructor_desc : symbol; (** name of the constructor function *)
recognizer_desc : symbol; (** name of the recognizer function *)
accessor_descs : (symbol * sort) array; (** names and sorts of the fields *)
constructor_desc : symbol; (** name of the constructor function *)
recognizer_desc : symbol; (** name of the recognizer function *)
accessor_descs : (symbol * sort) array; (** names and sorts of the fields *)
}
(**
A datatype is described by a name and constructor descriptors.
*)
type datatype_desc = symbol * datatype_constructor_desc array
(**
A datatype constructor representation.
*)
type datatype_constructor = {
constructor : func_decl; (** constructor function *)
recognizer : func_decl; (** recognizer function *)
accessors : func_decl array; (** field accessor functions *)
constructor : func_decl; (** constructor function *)
recognizer : func_decl; (** recognizer function *)
accessors : func_decl array; (** field accessor functions *)
}
(**
A datatype is represented by a sort and constructors.
*)
type datatype = sort * datatype_constructor array
(**
Refined view of a {!sort}.
- {b See also}: {!mk_sort}
- {b See also}: {!sort_refine}
*)
@ -751,9 +744,9 @@ external mk_set_subset : context -> ast -> ast -> ast
Summary: \[ [ numeral_refined ] \] is the refined view of a numeral .
*)
type numeral_refined =
| Numeral_int of int * sort
| Numeral_int64 of int64 * sort
| Numeral_large of string * sort
| Numeral_int of int * sort
| Numeral_int64 of int64 * sort
| Numeral_large of string * sort
| Numeral_rational of numeral_refined * numeral_refined
external mk_numeral : context -> string -> sort -> ast
@ -930,21 +923,18 @@ external get_app_arg : context -> app -> int -> ast
(**
Summary: \[ [ binder_type ] \] is a universal or existential quantifier.
- {b See also}: {!term_refined}
*)
type binder_type = Forall | Exists
(**
Summary: \[ [ term_refined ] \] is the refinement of a {!ast} .
- {b See also}: {!term_refine}
*)
type term_refined =
| Term_numeral of numeral_refined
| Term_app of decl_kind * func_decl * ast array
| Term_numeral of numeral_refined
| Term_app of decl_kind * func_decl * ast array
| Term_quantifier of binder_type * int * ast array array * (symbol * sort) array * ast
| Term_var of int * sort
| Term_var of int * sort
external is_eq_ast : context -> ast -> ast -> bool
= "camlidl_z3_Z3_is_eq_ast"
@ -1220,12 +1210,6 @@ external get_smtlib_sort : context -> int -> sort
external get_smtlib_error : context -> string
= "camlidl_z3_Z3_get_smtlib_error"
external parse_z3_string : context -> string -> ast
= "camlidl_z3_Z3_parse_z3_string"
external parse_z3_file : context -> string -> ast
= "camlidl_z3_Z3_parse_z3_file"
external set_error : context -> error_code -> unit
= "camlidl_z3_Z3_set_error"
@ -1235,6 +1219,12 @@ external get_error_msg_ex : context -> error_code -> string
external get_version : unit -> int * int * int * int
= "camlidl_z3_Z3_get_version"
external enable_trace : string -> unit
= "camlidl_z3_Z3_enable_trace"
external disable_trace : string -> unit
= "camlidl_z3_Z3_disable_trace"
external mk_fixedpoint : context -> fixedpoint
= "camlidl_z3_Z3_mk_fixedpoint"
@ -1280,8 +1270,11 @@ external fixedpoint_register_relation : context -> fixedpoint -> func_decl -> un
external fixedpoint_set_predicate_representation : context -> fixedpoint -> func_decl -> symbol array -> unit
= "camlidl_z3_Z3_fixedpoint_set_predicate_representation"
external fixedpoint_simplify_rules : context -> fixedpoint -> ast array -> func_decl array -> ast_vector
= "camlidl_z3_Z3_fixedpoint_simplify_rules"
external fixedpoint_get_rules : context -> fixedpoint -> ast_vector
= "camlidl_z3_Z3_fixedpoint_get_rules"
external fixedpoint_get_assertions : context -> fixedpoint -> ast_vector
= "camlidl_z3_Z3_fixedpoint_get_assertions"
external fixedpoint_set_params : context -> fixedpoint -> params -> unit
= "camlidl_z3_Z3_fixedpoint_set_params"
@ -1295,6 +1288,12 @@ external fixedpoint_get_param_descrs : context -> fixedpoint -> param_descrs
external fixedpoint_to_string : context -> fixedpoint -> ast array -> string
= "camlidl_z3_Z3_fixedpoint_to_string"
external fixedpoint_from_string : context -> fixedpoint -> string -> ast_vector
= "camlidl_z3_Z3_fixedpoint_from_string"
external fixedpoint_from_file : context -> fixedpoint -> string -> ast_vector
= "camlidl_z3_Z3_fixedpoint_from_file"
external fixedpoint_push : context -> fixedpoint -> unit
= "camlidl_z3_Z3_fixedpoint_push"
@ -1544,6 +1543,9 @@ external solver_get_num_scopes : context -> solver -> int
external solver_assert : context -> solver -> ast -> unit
= "camlidl_z3_Z3_solver_assert"
external solver_assert_and_track : context -> solver -> ast -> ast -> unit
= "camlidl_z3_Z3_solver_assert_and_track"
external solver_get_assertions : context -> solver -> ast_vector
= "camlidl_z3_Z3_solver_get_assertions"
@ -1597,18 +1599,15 @@ external stats_get_double_value : context -> stats -> int -> float
= "camlidl_z3_Z3_stats_get_double_value"
(* Internal auxiliary functions: *)
(*
(* Transform a pair of arrays into an array of pairs *)
let array_combine a b =
if Array.length a <> Array.length b then raise (Invalid_argument "array_combine");
Array.init (Array.length a) (fun i -> (a.(i), b.(i)))
(* [a |> b] is the pipeline operator for [b(a)] *)
let ( |> ) x f = f x
*)
(* Find the index of an element in an array, raises Not_found is missing *)
let find equal x a =
let len = Array.length a in
@ -1622,24 +1621,17 @@ let find equal x a =
find_ (i+1)
in
find_ 0
(* Symbols *)
let symbol_refine c s =
match get_symbol_kind c s with
| INT_SYMBOL -> Symbol_int (get_symbol_int c s)
| STRING_SYMBOL -> Symbol_string (get_symbol_string c s)
let mk_symbol c = function
| Symbol_int(i) -> mk_int_symbol c i
| Symbol_string(s) -> mk_string_symbol c s
(* Sorts *)
let get_datatype_sort c s =
Array.init (get_datatype_sort_num_constructors c s) (fun i ->
let get_datatype_sort c s =
Array.init (get_datatype_sort_num_constructors c s) (fun i ->
let constructor = get_datatype_sort_constructor c s i in
let recognizer = get_datatype_sort_recognizer c s i in
let accessors =
@ -1648,7 +1640,6 @@ let get_datatype_sort c s =
) in
{constructor; recognizer; accessors}
)
let sort_refine c s =
match get_sort_kind c s with
| UNINTERPRETED_SORT -> Sort_uninterpreted (get_sort_name c s)
@ -1665,7 +1656,6 @@ let sort_refine c s =
| DATATYPE_SORT -> Sort_datatype (get_datatype_sort c s)
| RELATION_SORT -> Sort_relation (Array.init (get_relation_arity c s) (fun i -> get_relation_column c s i))
| UNKNOWN_SORT -> Sort_unknown
let mk_sort c = function
| Sort_uninterpreted(s) -> mk_uninterpreted_sort c s
| Sort_bool -> mk_bool_sort c
@ -1677,10 +1667,7 @@ let mk_sort c = function
| Sort_datatype(constructors) -> get_range c constructors.(0).constructor
| Sort_relation(_) -> invalid_arg "Z3.mk_sort: cannot construct relation sorts"
| Sort_unknown(_) -> invalid_arg "Z3.mk_sort: cannot construct unknown sorts"
(* Replacement datatypes creation API *)
let mk_datatypes ctx generator =
let usort0 = mk_uninterpreted_sort ctx (mk_int_symbol ctx 0)
in
@ -1749,19 +1736,16 @@ let mk_datatypes ctx generator =
) ctorss
;
datatypes
(* Numerals *)
let rec numeral_refine c t =
assert( get_ast_kind c t = NUMERAL_AST );
let sort = get_sort c t in
let is_int, i = get_numeral_int c t in
if is_int then
if is_int then
Numeral_int (i, sort)
else
let is_int64, i = get_numeral_int64 c t in
if is_int64 then
if is_int64 then
Numeral_int64 (i, sort)
else
if get_sort_kind c sort <> REAL_SORT then
@ -1770,14 +1754,11 @@ let rec numeral_refine c t =
let n = numeral_refine c (get_numerator c t) in
let d = numeral_refine c (get_denominator c t) in
Numeral_rational (n, d)
let to_real c x =
if get_sort_kind c (get_sort c x) = REAL_SORT then
x
else
mk_int2real c x
let rec embed_numeral c = function
| Numeral_int (i, s) -> mk_int c i s
| Numeral_int64 (i, s) -> mk_int64 c i s
@ -1790,21 +1771,14 @@ let rec embed_numeral c = function
let d_str = get_numeral_string c (embed_numeral c d) in
mk_numeral c (n_str ^ " / " ^ d_str) (mk_real_sort c)
*)
(* Terms *)
let get_app_args c a =
Array.init (get_app_num_args c a) (get_app_arg c a);;
let get_domains c d =
Array.init (get_domain_size c d) (get_domain c d);;
let get_pattern_terms c p =
let get_pattern_terms c p =
Array.init (get_pattern_num_terms c p) (get_pattern c p)
let term_refine c t =
let term_refine c t =
match get_ast_kind c t with
| NUMERAL_AST ->
Term_numeral (numeral_refine c t)
@ -1815,35 +1789,29 @@ let term_refine c t =
let args = Array.init num_args (get_app_arg c t') in
let k = get_decl_kind c f in
Term_app (k, f, args)
| QUANTIFIER_AST ->
| QUANTIFIER_AST ->
let bt = if is_quantifier_forall c t then Forall else Exists in
let w = get_quantifier_weight c t in
let np = get_quantifier_num_patterns c t in
let pats = Array.init np (get_quantifier_pattern_ast c t) in
let pats = Array.map (get_pattern_terms c) pats in
let nb = get_quantifier_num_bound c t in
let w = get_quantifier_weight c t in
let np = get_quantifier_num_patterns c t in
let pats = Array.init np (get_quantifier_pattern_ast c t) in
let pats = Array.map (get_pattern_terms c) pats in
let nb = get_quantifier_num_bound c t in
let bound =
Array.init nb (fun i ->
(get_quantifier_bound_name c t i, get_quantifier_bound_sort c t i)
) in
let body = get_quantifier_body c t in
Term_quantifier (bt, w, pats, bound, body)
| VAR_AST ->
| VAR_AST ->
Term_var (get_index_value c t, get_sort c t)
| _ ->
assert false
(* let mk_term c = function *)
(* | Term_numeral (numeral, sort) -> mk_numeral c numeral sort *)
(* | Term_app (kind, decl, args) -> *)
(* | Term_quantifier (strength, weight, pats, bound, body) -> *)
(* | Term_var (index, sort) -> *)
(* | Term_numeral (numeral, sort) -> mk_numeral c numeral sort *)
(* | Term_app (kind, decl, args) -> *)
(* | Term_quantifier (strength, weight, pats, bound, body) -> *)
(* | Term_var (index, sort) -> *)
(* Refined model API *)
let model_refine c m =
let num_sorts = model_get_num_sorts c m in
let sorts = Hashtbl.create num_sorts in
@ -1903,49 +1871,33 @@ let model_refine c m =
()
done;
{sorts; consts; arrays; funcs}
(* Extended parser API *)
let get_smtlib_formulas c =
let get_smtlib_formulas c =
Array.init (get_smtlib_num_formulas c) (get_smtlib_formula c)
let get_smtlib_assumptions c =
let get_smtlib_assumptions c =
Array.init (get_smtlib_num_assumptions c) (get_smtlib_assumption c)
let get_smtlib_decls c =
Array.init (get_smtlib_num_decls c) (get_smtlib_decl c)
let get_smtlib_parse_results c =
(get_smtlib_formulas c, get_smtlib_assumptions c, get_smtlib_decls c)
let parse_smtlib_string_x c a1 a2 a3 a4 a5 =
let parse_smtlib_string_x c a1 a2 a3 a4 a5 =
parse_smtlib_string c a1 a2 a3 a4 a5 ;
get_smtlib_parse_results c
let parse_smtlib_file_x c a1 a2 a3 a4 a5 =
let parse_smtlib_file_x c a1 a2 a3 a4 a5 =
parse_smtlib_file c a1 a2 a3 a4 a5 ;
get_smtlib_parse_results c
let parse_smtlib_string_formula c a1 a2 a3 a4 a5 =
let parse_smtlib_string_formula c a1 a2 a3 a4 a5 =
parse_smtlib_string c a1 a2 a3 a4 a5 ;
match get_smtlib_formulas c with [|f|] -> f | _ -> failwith "Z3: parse_smtlib_string_formula"
let parse_smtlib_file_formula c a1 a2 a3 a4 a5 =
let parse_smtlib_file_formula c a1 a2 a3 a4 a5 =
parse_smtlib_file c a1 a2 a3 a4 a5 ;
match get_smtlib_formulas c with [|f|] -> f | _ -> failwith "Z3: parse_smtlib_file_formula"
(* Error handling *)
let get_error_msg c e =
match e with
| PARSER_ERROR -> (get_error_msg_ex c e) ^ ": " ^ (get_smtlib_error c)
| _ -> get_error_msg_ex c e
(* Refined stats API *)
let stats_refine c s =
let num_stats = stats_size c s in
let tbl = Hashtbl.create num_stats in
@ -1970,7 +1922,7 @@ let _ =
module V3 = struct
(* File generated from z3.idl *)
(* File generated from z3V3.idl *)
type symbol
and literals
@ -2205,6 +2157,15 @@ and ast_print_mode =
| PRINT_SMTLIB2_COMPLIANT
external global_param_set : string -> string -> unit
= "camlidl_z3V3_Z3_global_param_set"
external global_param_reset_all : unit -> unit
= "camlidl_z3V3_Z3_global_param_reset_all"
external global_param_get : string -> string option
= "camlidl_z3V3_Z3_global_param_get"
external mk_config : unit -> config
= "camlidl_z3V3_Z3_mk_config"
@ -2263,7 +2224,7 @@ external mk_list_sort : context -> symbol -> sort -> sort * func_decl * func_dec
= "camlidl_z3V3_Z3_mk_list_sort"
external mk_constructor : context -> symbol -> symbol -> symbol array -> sort array -> int array -> constructor
= "camlidl_z3_Z3_mk_constructor_bytecode" "camlidl_z3V3_Z3_mk_constructor"
= "camlidl_z3V3_Z3_mk_constructor_bytecode" "camlidl_z3V3_Z3_mk_constructor"
external del_constructor : context -> constructor -> unit
= "camlidl_z3V3_Z3_del_constructor"
@ -2587,16 +2548,16 @@ external mk_bound : context -> int -> sort -> ast
= "camlidl_z3V3_Z3_mk_bound"
external mk_forall : context -> int -> pattern array -> sort array -> symbol array -> ast -> ast
= "camlidl_z3_Z3_mk_forall_bytecode" "camlidl_z3V3_Z3_mk_forall"
= "camlidl_z3V3_Z3_mk_forall_bytecode" "camlidl_z3V3_Z3_mk_forall"
external mk_exists : context -> int -> pattern array -> sort array -> symbol array -> ast -> ast
= "camlidl_z3_Z3_mk_exists_bytecode" "camlidl_z3V3_Z3_mk_exists"
= "camlidl_z3V3_Z3_mk_exists_bytecode" "camlidl_z3V3_Z3_mk_exists"
external mk_quantifier : context -> bool -> int -> pattern array -> sort array -> symbol array -> ast -> ast
= "camlidl_z3_Z3_mk_quantifier_bytecode" "camlidl_z3V3_Z3_mk_quantifier"
= "camlidl_z3V3_Z3_mk_quantifier_bytecode" "camlidl_z3V3_Z3_mk_quantifier"
external mk_quantifier_ex : context -> bool -> int -> symbol -> symbol -> pattern array -> ast array -> sort array -> symbol array -> ast -> ast
= "camlidl_z3_Z3_mk_quantifier_ex_bytecode" "camlidl_z3V3_Z3_mk_quantifier_ex"
= "camlidl_z3V3_Z3_mk_quantifier_ex_bytecode" "camlidl_z3V3_Z3_mk_quantifier_ex"
external mk_forall_const : context -> int -> app array -> pattern array -> ast -> ast
= "camlidl_z3V3_Z3_mk_forall_const"
@ -2605,10 +2566,10 @@ external mk_exists_const : context -> int -> app array -> pattern array -> ast -
= "camlidl_z3V3_Z3_mk_exists_const"
external mk_quantifier_const : context -> bool -> int -> app array -> pattern array -> ast -> ast
= "camlidl_z3_Z3_mk_quantifier_const_bytecode" "camlidl_z3V3_Z3_mk_quantifier_const"
= "camlidl_z3V3_Z3_mk_quantifier_const_bytecode" "camlidl_z3V3_Z3_mk_quantifier_const"
external mk_quantifier_const_ex : context -> bool -> int -> symbol -> symbol -> app array -> pattern array -> ast array -> ast -> ast
= "camlidl_z3_Z3_mk_quantifier_const_ex_bytecode" "camlidl_z3V3_Z3_mk_quantifier_const_ex"
= "camlidl_z3V3_Z3_mk_quantifier_const_ex_bytecode" "camlidl_z3V3_Z3_mk_quantifier_const_ex"
external get_symbol_kind : context -> symbol -> symbol_kind
= "camlidl_z3V3_Z3_get_symbol_kind"
@ -2890,19 +2851,19 @@ external model_to_string : context -> model -> string
= "camlidl_z3V3_Z3_model_to_string"
external benchmark_to_smtlib_string : context -> string -> string -> string -> string -> ast array -> ast -> string
= "camlidl_z3_Z3_benchmark_to_smtlib_string_bytecode" "camlidl_z3V3_Z3_benchmark_to_smtlib_string"
= "camlidl_z3V3_Z3_benchmark_to_smtlib_string_bytecode" "camlidl_z3V3_Z3_benchmark_to_smtlib_string"
external parse_smtlib2_string : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast
= "camlidl_z3_Z3_parse_smtlib2_string_bytecode" "camlidl_z3V3_Z3_parse_smtlib2_string"
= "camlidl_z3V3_Z3_parse_smtlib2_string_bytecode" "camlidl_z3V3_Z3_parse_smtlib2_string"
external parse_smtlib2_file : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> ast
= "camlidl_z3_Z3_parse_smtlib2_file_bytecode" "camlidl_z3V3_Z3_parse_smtlib2_file"
= "camlidl_z3V3_Z3_parse_smtlib2_file_bytecode" "camlidl_z3V3_Z3_parse_smtlib2_file"
external parse_smtlib_string : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> unit
= "camlidl_z3_Z3_parse_smtlib_string_bytecode" "camlidl_z3V3_Z3_parse_smtlib_string"
= "camlidl_z3V3_Z3_parse_smtlib_string_bytecode" "camlidl_z3V3_Z3_parse_smtlib_string"
external parse_smtlib_file : context -> string -> symbol array -> sort array -> symbol array -> func_decl array -> unit
= "camlidl_z3_Z3_parse_smtlib_file_bytecode" "camlidl_z3V3_Z3_parse_smtlib_file"
= "camlidl_z3V3_Z3_parse_smtlib_file_bytecode" "camlidl_z3V3_Z3_parse_smtlib_file"
external get_smtlib_num_formulas : context -> int
= "camlidl_z3V3_Z3_get_smtlib_num_formulas"
@ -2931,15 +2892,15 @@ external get_smtlib_sort : context -> int -> sort
external get_smtlib_error : context -> string
= "camlidl_z3V3_Z3_get_smtlib_error"
external parse_z3_string : context -> string -> ast
= "camlidl_z3_Z3_parse_z3V3_string"
external parse_z3_file : context -> string -> ast
= "camlidl_z3_Z3_parse_z3V3_file"
external get_version : unit -> int * int * int * int
= "camlidl_z3V3_Z3_get_version"
external enable_trace : string -> unit
= "camlidl_z3V3_Z3_enable_trace"
external disable_trace : string -> unit
= "camlidl_z3V3_Z3_disable_trace"
external reset_memory : unit -> unit
= "camlidl_z3V3_Z3_reset_memory"
@ -3121,114 +3082,85 @@ external get_context_assignment : context -> ast
= "camlidl_z3V3_Z3_get_context_assignment"
(* Internal auxillary functions: *)
(* Transform a pair of arrays into an array of pairs *)
let array_combine a b =
if Array.length a <> Array.length b then raise (Invalid_argument "array_combine");
Array.init (Array.length a) (fun i->(a.(i),b.(i)));;
(* [a |> b] is the pipeline operator for [b(a)] *)
let ( |> ) x f = f x;;
(* Extensions, except for refinement: *)
let mk_context_x configs =
let mk_context_x configs =
let config = mk_config() in
let f(param_id,param_value) = set_param_value config param_id param_value in
Array.iter f configs;
let context = mk_context config in
del_config config;
context;;
let get_app_args c a =
Array.init (get_app_num_args c a) (get_app_arg c a);;
let get_domains c d =
Array.init (get_domain_size c d) (get_domain c d);;
let get_array_sort c t = (get_array_sort_domain c t, get_array_sort_range c t);;
let get_tuple_sort c ty =
let get_tuple_sort c ty =
(get_tuple_sort_mk_decl c ty,
Array.init (get_tuple_sort_num_fields c ty) (get_tuple_sort_field_decl c ty));;
type datatype_constructor_refined = {
constructor : func_decl;
recognizer : func_decl;
accessors : func_decl array
type datatype_constructor_refined = {
constructor : func_decl;
recognizer : func_decl;
accessors : func_decl array
}
let get_datatype_sort c ty =
let get_datatype_sort c ty =
Array.init (get_datatype_sort_num_constructors c ty)
(fun idx_c ->
(fun idx_c ->
let constr = get_datatype_sort_constructor c ty idx_c in
let recog = get_datatype_sort_recognizer c ty idx_c in
let recog = get_datatype_sort_recognizer c ty idx_c in
let num_acc = get_domain_size c constr in
{ constructor = constr;
recognizer = recog;
accessors = Array.init num_acc (get_datatype_sort_constructor_accessor c ty idx_c);
})
let get_model_constants c m =
Array.init (get_model_num_constants c m) (get_model_constant c m);;
let get_model_func_entry c m i j =
(Array.init
(get_model_func_entry_num_args c m i j)
(get_model_func_entry_arg c m i j),
get_model_func_entry_value c m i j);;
let get_model_func_entries c m i =
Array.init (get_model_func_num_entries c m i) (get_model_func_entry c m i);;
let get_model_funcs c m =
Array.init (get_model_num_funcs c m)
(fun i->(get_model_func_decl c m i |> get_decl_name c,
get_model_func_entries c m i,
get_model_func_else c m i));;
let get_smtlib_formulas c =
let get_smtlib_formulas c =
Array.init (get_smtlib_num_formulas c) (get_smtlib_formula c);;
let get_smtlib_assumptions c =
let get_smtlib_assumptions c =
Array.init (get_smtlib_num_assumptions c) (get_smtlib_assumption c);;
let get_smtlib_decls c =
Array.init (get_smtlib_num_decls c) (get_smtlib_decl c);;
let get_smtlib_parse_results c =
(get_smtlib_formulas c, get_smtlib_assumptions c, get_smtlib_decls c);;
let parse_smtlib_string_formula c a1 a2 a3 a4 a5 =
let parse_smtlib_string_formula c a1 a2 a3 a4 a5 =
(parse_smtlib_string c a1 a2 a3 a4 a5;
match get_smtlib_formulas c with [|f|] -> f | _ -> failwith "Z3: parse_smtlib_string_formula");;
let parse_smtlib_file_formula c a1 a2 a3 a4 a5 =
let parse_smtlib_file_formula c a1 a2 a3 a4 a5 =
(parse_smtlib_file c a1 a2 a3 a4 a5;
match get_smtlib_formulas c with [|f|] -> f | _ -> failwith "Z3: parse_smtlib_file_formula");;
let parse_smtlib_string_x c a1 a2 a3 a4 a5 =
let parse_smtlib_string_x c a1 a2 a3 a4 a5 =
(parse_smtlib_string c a1 a2 a3 a4 a5; get_smtlib_parse_results c);;
let parse_smtlib_file_x c a1 a2 a3 a4 a5 =
let parse_smtlib_file_x c a1 a2 a3 a4 a5 =
(parse_smtlib_file c a1 a2 a3 a4 a5; get_smtlib_parse_results c);;
(* Refinement: *)
type symbol_refined =
| Symbol_int of int
| Symbol_string of string
| Symbol_unknown;;
let symbol_refine c s =
match get_symbol_kind c s with
| INT_SYMBOL -> Symbol_int (get_symbol_int c s)
| STRING_SYMBOL -> Symbol_string (get_symbol_string c s);;
type sort_refined =
| Sort_uninterpreted of symbol
| Sort_bool
@ -3240,7 +3172,6 @@ type sort_refined =
| Sort_relation
| Sort_finite_domain
| Sort_unknown of symbol;;
let sort_refine c ty =
match get_sort_kind c ty with
| UNINTERPRETED_SORT -> Sort_uninterpreted (get_sort_name c ty)
@ -3250,56 +3181,50 @@ let sort_refine c ty =
| BV_SORT -> Sort_bv (get_bv_sort_size c ty)
| ARRAY_SORT -> Sort_array (get_array_sort_domain c ty, get_array_sort_range c ty)
| DATATYPE_SORT -> Sort_datatype (get_datatype_sort c ty)
| RELATION_SORT -> Sort_relation
| RELATION_SORT -> Sort_relation
| FINITE_DOMAIN_SORT -> Sort_finite_domain
| UNKNOWN_SORT -> Sort_unknown (get_sort_name c ty);;
let get_pattern_terms c p =
let get_pattern_terms c p =
Array.init (get_pattern_num_terms c p) (get_pattern c p)
type binder_type = | Forall | Exists
type numeral_refined =
| Numeral_small of int64 * int64
| Numeral_large of string
type term_refined =
| Term_app of decl_kind * func_decl * ast array
type binder_type = | Forall | Exists
type numeral_refined =
| Numeral_small of int64 * int64
| Numeral_large of string
type term_refined =
| Term_app of decl_kind * func_decl * ast array
| Term_quantifier of binder_type * int * ast array array * (symbol *sort) array * ast
| Term_numeral of numeral_refined * sort
| Term_var of int * sort
let term_refine c t =
| Term_numeral of numeral_refined * sort
| Term_var of int * sort
let term_refine c t =
match get_ast_kind c t with
| NUMERAL_AST ->
| NUMERAL_AST ->
let (is_small, n, d) = get_numeral_small c t in
if is_small then
Term_numeral(Numeral_small(n,d), get_sort c t)
if is_small then
Term_numeral(Numeral_small(n,d), get_sort c t)
else
Term_numeral(Numeral_large(get_numeral_string c t), get_sort c t)
| APP_AST ->
Term_numeral(Numeral_large(get_numeral_string c t), get_sort c t)
| APP_AST ->
let t' = to_app c t in
let f = get_app_decl c t' in
let f = get_app_decl c t' in
let num_args = get_app_num_args c t' in
let args = Array.init num_args (get_app_arg c t') in
let k = get_decl_kind c f in
Term_app (k, f, args)
| QUANTIFIER_AST ->
| QUANTIFIER_AST ->
let bt = if is_quantifier_forall c t then Forall else Exists in
let w = get_quantifier_weight c t in
let np = get_quantifier_num_patterns c t in
let pats = Array.init np (get_quantifier_pattern_ast c t) in
let pats = Array.map (get_pattern_terms c) pats in
let nb = get_quantifier_num_bound c t in
let bound = Array.init nb
(fun i -> (get_quantifier_bound_name c t i, get_quantifier_bound_sort c t i)) in
let w = get_quantifier_weight c t in
let np = get_quantifier_num_patterns c t in
let pats = Array.init np (get_quantifier_pattern_ast c t) in
let pats = Array.map (get_pattern_terms c) pats in
let nb = get_quantifier_num_bound c t in
let bound = Array.init nb
(fun i -> (get_quantifier_bound_name c t i, get_quantifier_bound_sort c t i)) in
let body = get_quantifier_body c t in
Term_quantifier(bt, w, pats, bound, body)
| VAR_AST ->
| VAR_AST ->
Term_var(get_index_value c t, get_sort c t)
| _ -> assert false
type theory_callbacks =
type theory_callbacks =
{
mutable delete_theory : unit -> unit;
mutable reduce_eq : ast -> ast -> ast option;
@ -3318,8 +3243,7 @@ type theory_callbacks =
mutable new_assignment: ast -> bool -> unit;
mutable new_relevant : ast -> unit;
}
let mk_theory_callbacks() =
let mk_theory_callbacks() =
{
delete_theory = (fun () -> ());
reduce_eq = (fun _ _ -> None);
@ -3338,8 +3262,6 @@ let mk_theory_callbacks() =
new_assignment = (fun _ _ -> ());
new_relevant = (fun _ -> ());
}
external get_theory_callbacks : theory -> theory_callbacks = "get_theory_callbacks"
external mk_theory_register : context -> string -> theory_callbacks -> theory = "mk_theory_register"
external set_delete_callback_register : theory -> unit = "set_delete_callback_register"
@ -3358,146 +3280,116 @@ external set_new_eq_callback_register : theory -> unit = "set_new_eq_callback_re
external set_new_diseq_callback_register : theory -> unit = "set_new_diseq_callback_register"
external set_new_assignment_callback_register : theory -> unit = "set_new_assignment_callback_register"
external set_new_relevant_callback_register : theory -> unit = "set_new_relevant_callback_register"
let is_some opt =
let is_some opt =
match opt with
| Some v -> true
| None -> false
let get_some opt =
| None -> false
let get_some opt =
match opt with
| Some v -> v
| None -> failwith "None unexpected"
| None -> failwith "None unexpected"
let apply_delete (th:theory_callbacks) = th.delete_theory ()
let set_delete_callback th cb =
let set_delete_callback th cb =
let cbs = get_theory_callbacks th in
cbs.delete_theory <- cb;
set_delete_callback_register th
let mk_theory context name =
let mk_theory context name =
Callback.register "is_some" is_some;
Callback.register "get_some" get_some;
Callback.register "apply_delete" apply_delete;
let cbs = mk_theory_callbacks() in
mk_theory_register context name cbs
let apply_reduce_app (th:theory_callbacks) f args = th.reduce_app f args
let set_reduce_app_callback th cb =
let set_reduce_app_callback th cb =
Callback.register "apply_reduce_app" apply_reduce_app;
let cbs = get_theory_callbacks th in
cbs.reduce_app <- cb;
set_reduce_app_callback_register th
let apply_reduce_eq (th:theory_callbacks) a b = th.reduce_eq a b
let set_reduce_eq_callback th cb =
let set_reduce_eq_callback th cb =
Callback.register "apply_reduce_eq" apply_reduce_eq;
let cbs = get_theory_callbacks th in
cbs.reduce_eq <- cb;
set_reduce_eq_callback_register th
let apply_reduce_distinct (th:theory_callbacks) args = th.reduce_distinct args
let set_reduce_distinct_callback th cb =
let set_reduce_distinct_callback th cb =
Callback.register "apply_reduce_distinct" apply_reduce_distinct;
let cbs = get_theory_callbacks th in
cbs.reduce_distinct <- cb;
set_reduce_distinct_callback_register th
let apply_new_app (th:theory_callbacks) a = th.new_app a
let set_new_app_callback th cb =
let set_new_app_callback th cb =
Callback.register "apply_new_app" apply_new_app;
let cbs = get_theory_callbacks th in
cbs.new_app <- cb;
set_new_app_callback_register th
let apply_new_elem (th:theory_callbacks) a = th.new_elem a
let set_new_elem_callback th cb =
let set_new_elem_callback th cb =
Callback.register "apply_new_elem" apply_new_elem;
let cbs = get_theory_callbacks th in
cbs.new_elem <- cb;
set_new_elem_callback_register th
let apply_init_search (th:theory_callbacks) = th.init_search()
let set_init_search_callback th cb =
let set_init_search_callback th cb =
Callback.register "apply_init_search" apply_init_search;
let cbs = get_theory_callbacks th in
cbs.init_search <- cb;
set_init_search_callback_register th
let apply_push (th:theory_callbacks) = th.push()
let set_push_callback th cb =
let set_push_callback th cb =
Callback.register "apply_push" apply_push;
let cbs = get_theory_callbacks th in
cbs.push <- cb;
set_push_callback_register th
let apply_pop (th:theory_callbacks) = th.pop()
let set_pop_callback th cb =
let set_pop_callback th cb =
Callback.register "apply_pop" apply_pop;
let cbs = get_theory_callbacks th in
cbs.pop <- cb;
set_pop_callback_register th
let apply_restart (th:theory_callbacks) = th.restart()
let set_restart_callback th cb =
let set_restart_callback th cb =
Callback.register "apply_restart" apply_restart;
let cbs = get_theory_callbacks th in
cbs.restart <- cb;
set_restart_callback_register th
let apply_reset (th:theory_callbacks) = th.reset()
let set_reset_callback th cb =
let set_reset_callback th cb =
Callback.register "apply_reset" apply_reset;
let cbs = get_theory_callbacks th in
cbs.reset <- cb;
set_reset_callback_register th
let apply_final_check (th:theory_callbacks) = th.final_check()
let set_final_check_callback th cb =
let set_final_check_callback th cb =
Callback.register "apply_final_check" apply_final_check;
let cbs = get_theory_callbacks th in
cbs.final_check <- cb;
set_final_check_callback_register th
let apply_new_eq (th:theory_callbacks) a b = th.new_eq a b
let set_new_eq_callback th cb =
let set_new_eq_callback th cb =
Callback.register "apply_new_eq" apply_new_eq;
let cbs = get_theory_callbacks th in
cbs.new_eq <- cb;
set_new_eq_callback_register th
let apply_new_diseq (th:theory_callbacks) a b = th.new_diseq a b
let set_new_diseq_callback th cb =
let set_new_diseq_callback th cb =
Callback.register "apply_new_diseq" apply_new_diseq;
let cbs = get_theory_callbacks th in
cbs.new_diseq <- cb;
set_new_diseq_callback_register th
let apply_new_assignment (th:theory_callbacks) a b = th.new_assignment a b
let set_new_assignment_callback th cb =
let set_new_assignment_callback th cb =
Callback.register "apply_new_assignment" apply_new_assignment;
let cbs = get_theory_callbacks th in
cbs.new_assignment <- cb;
set_new_assignment_callback_register th
let apply_new_relevant (th:theory_callbacks) a = th.new_relevant a
let set_new_relevant_callback th cb =
let set_new_relevant_callback th cb =
Callback.register "apply_new_relevant" apply_new_relevant;
let cbs = get_theory_callbacks th in
cbs.new_relevant <- cb;
set_new_relevant_callback_register th
end

File diff suppressed because it is too large Load diff

View file

@ -18,16 +18,13 @@
#define xstr(s) str(s)
#define str(s) #s
#pragma warning(disable:4090)
void check_error_code (Z3_context c);
Z3_context last_ctx;
// caml_final_register is the implementation of Gc.finalize
value caml_final_register (value f, value v);
void register_finalizer(value** closure, char* name, Z3_context ctx, value v)
{
if (*closure == NULL) {
@ -39,7 +36,6 @@ Z3_context last_ctx;
}
caml_final_register(**closure, v);
}
value c2ml_Z3_context (Z3_context* c)
{
static value* finalize_Z3_context_closure = NULL;
@ -50,13 +46,11 @@ Z3_context last_ctx;
(Z3_context) *c, v);
return v;
}
void ml2c_Z3_context (value v, Z3_context* c)
{
*c = (Z3_context) Field(v, 0);
last_ctx = *c;
}
value finalize_Z3_context (value v)
{
Z3_context c;
@ -87,17 +81,15 @@ typedef struct _Z3_ast_context {
Z3_ast ast;
Z3_context ctx;
} Z3_ast_context;
void ml2c_Z3_ast (value v, Z3_ast* c)
{
*c = ((Z3_ast_context*) Data_custom_val(v))->ast;
}
static int compare_Z3_ast (value v1, value v2)
{
Z3_ast_context* ac1;
Z3_ast_context* ac2;
unsigned int id1, id2;
unsigned id1, id2;
ac1 = Data_custom_val(v1);
ac2 = Data_custom_val(v2);
id1 = Z3_get_ast_id(ac1->ctx, ac1->ast);
@ -106,11 +98,10 @@ static int compare_Z3_ast (value v1, value v2)
check_error_code(ac2->ctx);
return id2 - id1;
}
static intnat hash_Z3_ast (value v)
{
Z3_ast_context* ac;
unsigned int hash;
unsigned hash;
ac = Data_custom_val(v);
hash = Z3_get_ast_hash(ac->ctx, ac->ast);
check_error_code(ac->ctx);
@ -126,7 +117,6 @@ static intnat hash_Z3_ast (value v)
check_error_code(ac->ctx);
return Val_unit;
}
static struct custom_operations cops_Z3_ast = {
NULL,
custom_finalize_default,
@ -135,7 +125,6 @@ static intnat hash_Z3_ast (value v)
custom_serialize_default,
custom_deserialize_default
};
value c2ml_Z3_ast (Z3_ast* c)
{
static value* finalize_Z3_ast_closure = NULL;
@ -156,7 +145,7 @@ static intnat hash_Z3_ast (value v)
#define camlidl_c2ml_z3_Z3_ast(c,ctx) c2ml_Z3_ast(c)
#define DEFINE_SUBAST_OPS(T) void ml2c_ ## T (value v, T * a) { ml2c_Z3_ast(v, (Z3_ast*) a); } value c2ml_ ## T (T * a) { return c2ml_Z3_ast((Z3_ast*) a); }
#define DEFINE_SUBAST_OPS(T) void ml2c_ ## T (value v, T * a) { ml2c_Z3_ast(v, (Z3_ast*) a); } value c2ml_ ## T (T * a) { return c2ml_Z3_ast((Z3_ast*) a); }
DEFINE_SUBAST_OPS(Z3_sort)
#define camlidl_ml2c_z3_Z3_sort(v,c,ctx) ml2c_Z3_sort(v,c)
@ -177,7 +166,7 @@ DEFINE_SUBAST_OPS(Z3_pattern)
#define camlidl_c2ml_z3_Z3_pattern(c,ctx) c2ml_Z3_pattern(c)
#define DEFINE_RC_OPS(T) value c2ml_ ## T (T * c) { static value* finalize_ ## T ## _closure = NULL; value v; check_error_code(last_ctx); v = caml_alloc_small(2, Abstract_tag); Field(v, 0) = (value) *c; Field(v, 1) = (value) last_ctx; register_finalizer(&finalize_ ## T ## _closure, xstr(finalize_ ## T), (Z3_context) *c, v); T ## _inc_ref(last_ctx, *c); return v; } void ml2c_ ## T (value v, T * c) { *c = (T) Field(v, 0); } value finalize_ ## T (value v) { Z3_context c; c = (Z3_context) Field(v, 1); T ## _dec_ref(c, (T) Field(v, 0)); check_error_code(c); return Val_unit; }
#define DEFINE_RC_OPS(T) value c2ml_ ## T (T * c) { static value* finalize_ ## T ## _closure = NULL; value v; check_error_code(last_ctx); v = caml_alloc_small(2, Abstract_tag); Field(v, 0) = (value) *c; Field(v, 1) = (value) last_ctx; register_finalizer(&finalize_ ## T ## _closure, xstr(finalize_ ## T), (Z3_context) *c, v); T ## _inc_ref(last_ctx, *c); return v; } void ml2c_ ## T (value v, T * c) { *c = (T) Field(v, 0); } value finalize_ ## T (value v) { Z3_context c; c = (Z3_context) Field(v, 1); T ## _dec_ref(c, (T) Field(v, 0)); check_error_code(c); return Val_unit; }
DEFINE_RC_OPS(Z3_params)
#define camlidl_ml2c_z3_Z3_params(v,c,ctx) ml2c_Z3_params(v,c)
@ -248,7 +237,7 @@ DEFINE_RC_OPS(Z3_stats)
#define camlidl_c2ml_z3_Z3_stats(c,ctx) c2ml_Z3_stats(c)
#define DEFINE_OPT_OPS(T) void ml2c_ ## T ## _opt (value v, T* c) { struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; if (v != Val_int(0)) { camlidl_ml2c_z3_ ## T(Field(v, 0), c, _ctx); } else { *c = NULL; } } value c2ml_ ## T ## _opt (T* c) { struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; value v; value a; if (*c) { a = camlidl_c2ml_z3_ ## T(c, _ctx); Begin_root(a) v = caml_alloc_small(1, 0); Field(v, 0) = a; End_roots(); } else { v = Val_int(0); } return v; }
#define DEFINE_OPT_OPS(T) void ml2c_ ## T ## _opt (value v, T* c) { struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; if (v != Val_int(0)) { camlidl_ml2c_z3_ ## T(Field(v, 0), c, _ctx); } else { *c = NULL; } } value c2ml_ ## T ## _opt (T* c) { struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; value v; value a; if (*c) { a = camlidl_c2ml_z3_ ## T(c, _ctx); Begin_root(a) v = caml_alloc_small(1, 0); Field(v, 0) = a; End_roots(); } else { v = Val_int(0); } return v; }
DEFINE_OPT_OPS(Z3_ast)
#define camlidl_ml2c_z3_Z3_ast_opt(v,c,ctx) ml2c_Z3_ast_opt(v,c)
@ -682,9 +671,12 @@ value _v1;
}
/* All contexts share the same handler */
static value caml_z3_error_handler = 0;
value camlidl_c2ml_z3_Z3_error_code(Z3_error_code * _c2, camlidl_ctx _ctx);
/* Error checking routine that raises OCaml Error exceptions */
void check_error_code (Z3_context c)
{
static struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
@ -703,8 +695,7 @@ void check_error_code (Z3_context c)
caml_raise_with_args(*exn_tag, 2, ctx_err);
}
}
/* Disable default error handler, all error checking is done by check_error_code */
void* error_handler_static = NULL;
int camlidl_transl_table_z3_enum_11[4] = {
@ -743,9 +734,7 @@ value caml_z3_mk_context(value key_val_list)
Z3_context _res;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
cfg = Z3_mk_config();
while (key_val_list != Val_emptylist)
{
item = Field(key_val_list, 0);
@ -756,7 +745,6 @@ value caml_z3_mk_context(value key_val_list)
Z3_set_param_value(cfg, ckey, cval);
key_val_list = Field(key_val_list, 1);
}
_res = Z3_mk_context_rc(cfg);
Z3_del_config(cfg);
_vres = camlidl_c2ml_z3_Z3_context(&_res, _ctx);
@ -1238,7 +1226,7 @@ value camlidl_z3_Z3_mk_finite_domain_sort(
{
Z3_context c; /*in*/
Z3_symbol name; /*in*/
__int64 size; /*in*/
unsigned long long size; /*in*/
Z3_sort _res;
value _vres;
@ -4286,7 +4274,7 @@ value camlidl_z3_Z3_mk_int64(
value _v_ty)
{
Z3_context c; /*in*/
__int64 v; /*in*/
long long v; /*in*/
Z3_sort ty; /*in*/
Z3_ast _res;
value _vres;
@ -5105,8 +5093,8 @@ value camlidl_z3_Z3_get_finite_domain_sort_size(
{
Z3_context c; /*in*/
Z3_sort s; /*in*/
__int64 *r; /*out*/
__int64 _c1;
unsigned long long *r; /*out*/
unsigned long long _c1;
value _v2;
value _vres;
@ -6273,13 +6261,13 @@ value camlidl_z3_Z3_get_numeral_small(
{
Z3_context c; /*in*/
Z3_ast a; /*in*/
__int64 *num; /*out*/
__int64 *den; /*out*/
long long *num; /*out*/
long long *den; /*out*/
int _res;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
__int64 _c1;
__int64 _c2;
long long _c1;
long long _c2;
value _vresult;
value _vres[3] = { 0, 0, 0, };
@ -6342,11 +6330,11 @@ value camlidl_z3_Z3_get_numeral_int64(
{
Z3_context c; /*in*/
Z3_ast v; /*in*/
__int64 *i; /*out*/
long long *i; /*out*/
int _res;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
__int64 _c1;
long long _c1;
value _vresult;
value _vres[2] = { 0, 0, };
@ -6374,13 +6362,13 @@ value camlidl_z3_Z3_get_numeral_rational_int64(
{
Z3_context c; /*in*/
Z3_ast v; /*in*/
__int64 *num; /*out*/
__int64 *den; /*out*/
long long *num; /*out*/
long long *den; /*out*/
int _res;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
__int64 _c1;
__int64 _c2;
long long _c1;
long long _c2;
value _vresult;
value _vres[3] = { 0, 0, 0, };
@ -8170,50 +8158,6 @@ check_error_code(c);
return _vres;
}
value camlidl_z3_Z3_parse_z3_string(
value _v_c,
value _v_str)
{
Z3_context c; /*in*/
Z3_string str; /*in*/
Z3_ast _res;
value _vres;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3_Z3_context(_v_c, &c, _ctx);
camlidl_ml2c_z3_Z3_string(_v_str, &str, _ctx);
_res = Z3_parse_z3_string(c, str);
_vres = camlidl_c2ml_z3_Z3_ast(&_res, _ctx);
camlidl_free(_ctx);
/* begin user-supplied deallocation sequence */
check_error_code(c);
/* end user-supplied deallocation sequence */
return _vres;
}
value camlidl_z3_Z3_parse_z3_file(
value _v_c,
value _v_file_name)
{
Z3_context c; /*in*/
Z3_string file_name; /*in*/
Z3_ast _res;
value _vres;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3_Z3_context(_v_c, &c, _ctx);
camlidl_ml2c_z3_Z3_string(_v_file_name, &file_name, _ctx);
_res = Z3_parse_z3_file(c, file_name);
_vres = camlidl_c2ml_z3_Z3_ast(&_res, _ctx);
camlidl_free(_ctx);
/* begin user-supplied deallocation sequence */
check_error_code(c);
/* end user-supplied deallocation sequence */
return _vres;
}
value camlidl_z3_Z3_set_error(
value _v_c,
value _v_e)
@ -8286,6 +8230,30 @@ value camlidl_z3_Z3_get_version(value _unit)
return _vresult;
}
value camlidl_z3_Z3_enable_trace(
value _v_tag)
{
Z3_string tag; /*in*/
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3_Z3_string(_v_tag, &tag, _ctx);
Z3_enable_trace(tag);
camlidl_free(_ctx);
return Val_unit;
}
value camlidl_z3_Z3_disable_trace(
value _v_tag)
{
Z3_string tag; /*in*/
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3_Z3_string(_v_tag, &tag, _ctx);
Z3_disable_trace(tag);
camlidl_free(_ctx);
return Val_unit;
}
value camlidl_z3_Z3_mk_fixedpoint(
value _v_c)
{
@ -8669,46 +8637,42 @@ check_error_code(c);
return Val_unit;
}
value camlidl_z3_Z3_fixedpoint_simplify_rules(
value camlidl_z3_Z3_fixedpoint_get_rules(
value _v_c,
value _v_f,
value _v_rules,
value _v_outputs)
value _v_f)
{
Z3_context c; /*in*/
Z3_fixedpoint f; /*in*/
unsigned int num_rules; /*in*/
Z3_ast *rules; /*in*/
unsigned int num_outputs; /*in*/
Z3_func_decl *outputs; /*in*/
Z3_ast_vector _res;
mlsize_t _c1;
mlsize_t _c2;
value _v3;
mlsize_t _c4;
mlsize_t _c5;
value _v6;
value _vres;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3_Z3_context(_v_c, &c, _ctx);
camlidl_ml2c_z3_Z3_fixedpoint(_v_f, &f, _ctx);
_c1 = Wosize_val(_v_rules);
rules = camlidl_malloc(_c1 * sizeof(Z3_ast ), _ctx);
for (_c2 = 0; _c2 < _c1; _c2++) {
_v3 = Field(_v_rules, _c2);
camlidl_ml2c_z3_Z3_ast(_v3, &rules[_c2], _ctx);
}
num_rules = _c1;
_c4 = Wosize_val(_v_outputs);
outputs = camlidl_malloc(_c4 * sizeof(Z3_func_decl ), _ctx);
for (_c5 = 0; _c5 < _c4; _c5++) {
_v6 = Field(_v_outputs, _c5);
camlidl_ml2c_z3_Z3_func_decl(_v6, &outputs[_c5], _ctx);
}
num_outputs = _c4;
_res = Z3_fixedpoint_simplify_rules(c, f, num_rules, rules, num_outputs, outputs);
_res = Z3_fixedpoint_get_rules(c, f);
_vres = camlidl_c2ml_z3_Z3_ast_vector(&_res, _ctx);
camlidl_free(_ctx);
/* begin user-supplied deallocation sequence */
check_error_code(c);
/* end user-supplied deallocation sequence */
return _vres;
}
value camlidl_z3_Z3_fixedpoint_get_assertions(
value _v_c,
value _v_f)
{
Z3_context c; /*in*/
Z3_fixedpoint f; /*in*/
Z3_ast_vector _res;
value _vres;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3_Z3_context(_v_c, &c, _ctx);
camlidl_ml2c_z3_Z3_fixedpoint(_v_f, &f, _ctx);
_res = Z3_fixedpoint_get_assertions(c, f);
_vres = camlidl_c2ml_z3_Z3_ast_vector(&_res, _ctx);
camlidl_free(_ctx);
/* begin user-supplied deallocation sequence */
@ -8817,6 +8781,56 @@ check_error_code(c);
return _vres;
}
value camlidl_z3_Z3_fixedpoint_from_string(
value _v_c,
value _v_f,
value _v_s)
{
Z3_context c; /*in*/
Z3_fixedpoint f; /*in*/
Z3_string s; /*in*/
Z3_ast_vector _res;
value _vres;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3_Z3_context(_v_c, &c, _ctx);
camlidl_ml2c_z3_Z3_fixedpoint(_v_f, &f, _ctx);
camlidl_ml2c_z3_Z3_string(_v_s, &s, _ctx);
_res = Z3_fixedpoint_from_string(c, f, s);
_vres = camlidl_c2ml_z3_Z3_ast_vector(&_res, _ctx);
camlidl_free(_ctx);
/* begin user-supplied deallocation sequence */
check_error_code(c);
/* end user-supplied deallocation sequence */
return _vres;
}
value camlidl_z3_Z3_fixedpoint_from_file(
value _v_c,
value _v_f,
value _v_s)
{
Z3_context c; /*in*/
Z3_fixedpoint f; /*in*/
Z3_string s; /*in*/
Z3_ast_vector _res;
value _vres;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3_Z3_context(_v_c, &c, _ctx);
camlidl_ml2c_z3_Z3_fixedpoint(_v_f, &f, _ctx);
camlidl_ml2c_z3_Z3_string(_v_s, &s, _ctx);
_res = Z3_fixedpoint_from_file(c, f, s);
_vres = camlidl_c2ml_z3_Z3_ast_vector(&_res, _ctx);
camlidl_free(_ctx);
/* begin user-supplied deallocation sequence */
check_error_code(c);
/* end user-supplied deallocation sequence */
return _vres;
}
value camlidl_z3_Z3_fixedpoint_push(
value _v_c,
value _v_d)
@ -10692,6 +10706,30 @@ check_error_code(c);
return Val_unit;
}
value camlidl_z3_Z3_solver_assert_and_track(
value _v_c,
value _v_s,
value _v_a,
value _v_p)
{
Z3_context c; /*in*/
Z3_solver s; /*in*/
Z3_ast a; /*in*/
Z3_ast p; /*in*/
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3_Z3_context(_v_c, &c, _ctx);
camlidl_ml2c_z3_Z3_solver(_v_s, &s, _ctx);
camlidl_ml2c_z3_Z3_ast(_v_a, &a, _ctx);
camlidl_ml2c_z3_Z3_ast(_v_p, &p, _ctx);
Z3_solver_assert_and_track(c, s, a, p);
camlidl_free(_ctx);
/* begin user-supplied deallocation sequence */
check_error_code(c);
/* end user-supplied deallocation sequence */
return Val_unit;
}
value camlidl_z3_Z3_solver_get_assertions(
value _v_c,
value _v_s)
@ -11072,7 +11110,6 @@ check_error_code(c);
return _vres;
}
void caml_z3_error_handler(Z3_context c, Z3_error_code e) { static char buffer[128]; char * msg = Z3_get_error_msg_ex(c, e); if (strlen(msg) > 100) { failwith("Z3: error message is too big to fit in buffer"); } else { sprintf(buffer, "Z3: %s", msg); failwith(buffer); } }
void camlidl_ml2c_z3V3_Z3_symbol(value _v1, Z3_symbol * _c2, camlidl_ctx _ctx)
{
*_c2 = *((Z3_symbol *) Bp_val(_v1));
@ -11604,6 +11641,54 @@ value _v1;
return _v1;
}
value camlidl_z3V3_Z3_global_param_set(
value _v_param_id,
value _v_param_value)
{
Z3_string param_id; /*in*/
Z3_string param_value; /*in*/
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3V3_Z3_string(_v_param_id, &param_id, _ctx);
camlidl_ml2c_z3V3_Z3_string(_v_param_value, &param_value, _ctx);
Z3_global_param_set(param_id, param_value);
camlidl_free(_ctx);
return Val_unit;
}
value camlidl_z3V3_Z3_global_param_reset_all(value _unit)
{
Z3_global_param_reset_all();
return Val_unit;
}
value camlidl_z3V3_Z3_global_param_get(
value _v_param_id)
{
Z3_string param_id; /*in*/
Z3_string *param_value; /*out*/
Z3_string _c1;
value _v2;
value _vres;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3V3_Z3_string(_v_param_id, &param_id, _ctx);
param_value = &_c1;
Z3_global_param_get(param_id, param_value);
if (param_value == NULL) {
_vres = Val_int(0);
} else {
_v2 = camlidl_c2ml_z3V3_Z3_string(&*param_value, _ctx);
Begin_root(_v2)
_vres = camlidl_alloc_small(1, 0);
Field(_vres, 0) = _v2;
End_roots();
}
camlidl_free(_ctx);
return _vres;
}
value camlidl_z3V3_Z3_mk_config(value _unit)
{
Z3_config _res;
@ -11661,7 +11746,7 @@ value camlidl_z3V3_Z3_mk_context(
_vres = camlidl_c2ml_z3V3_Z3_context(&_res, _ctx);
camlidl_free(_ctx);
/* begin user-supplied deallocation sequence */
Z3_set_error_handler(_res, caml_z3_error_handler);
Z3_set_error_handler(_res, (void*)caml_z3_error_handler);
/* end user-supplied deallocation sequence */
return _vres;
}
@ -11857,7 +11942,7 @@ value camlidl_z3V3_Z3_mk_finite_domain_sort(
{
Z3_context c; /*in*/
Z3_symbol name; /*in*/
__int64 size; /*in*/
unsigned long long size; /*in*/
Z3_sort _res;
value _vres;
@ -14575,7 +14660,7 @@ value camlidl_z3V3_Z3_mk_int64(
value _v_ty)
{
Z3_context c; /*in*/
__int64 v; /*in*/
long long v; /*in*/
Z3_sort ty; /*in*/
Z3_ast _res;
value _vres;
@ -15334,8 +15419,8 @@ value camlidl_z3V3_Z3_get_finite_domain_sort_size(
{
Z3_context c; /*in*/
Z3_sort s; /*in*/
__int64 *r; /*out*/
__int64 _c1;
unsigned long long *r; /*out*/
unsigned long long _c1;
value _v2;
value _vres;
@ -16352,13 +16437,13 @@ value camlidl_z3V3_Z3_get_numeral_small(
{
Z3_context c; /*in*/
Z3_ast a; /*in*/
__int64 *num; /*out*/
__int64 *den; /*out*/
long long *num; /*out*/
long long *den; /*out*/
int _res;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
__int64 _c1;
__int64 _c2;
long long _c1;
long long _c2;
value _vresult;
value _vres[3] = { 0, 0, 0, };
@ -16415,11 +16500,11 @@ value camlidl_z3V3_Z3_get_numeral_int64(
{
Z3_context c; /*in*/
Z3_ast v; /*in*/
__int64 *i; /*out*/
long long *i; /*out*/
int _res;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
__int64 _c1;
long long _c1;
value _vresult;
value _vres[2] = { 0, 0, };
@ -16444,13 +16529,13 @@ value camlidl_z3V3_Z3_get_numeral_rational_int64(
{
Z3_context c; /*in*/
Z3_ast v; /*in*/
__int64 *num; /*out*/
__int64 *den; /*out*/
long long *num; /*out*/
long long *den; /*out*/
int _res;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
__int64 _c1;
__int64 _c2;
long long _c1;
long long _c2;
value _vresult;
value _vres[3] = { 0, 0, 0, };
@ -17570,44 +17655,6 @@ value camlidl_z3V3_Z3_get_smtlib_error(
return _vres;
}
value camlidl_z3_Z3_parse_z3V3_string(
value _v_c,
value _v_str)
{
Z3_context c; /*in*/
Z3_string str; /*in*/
Z3_ast _res;
value _vres;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3V3_Z3_context(_v_c, &c, _ctx);
camlidl_ml2c_z3V3_Z3_string(_v_str, &str, _ctx);
_res = Z3_parse_z3_string(c, str);
_vres = camlidl_c2ml_z3V3_Z3_ast(&_res, _ctx);
camlidl_free(_ctx);
return _vres;
}
value camlidl_z3_Z3_parse_z3V3_file(
value _v_c,
value _v_file_name)
{
Z3_context c; /*in*/
Z3_string file_name; /*in*/
Z3_ast _res;
value _vres;
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3V3_Z3_context(_v_c, &c, _ctx);
camlidl_ml2c_z3V3_Z3_string(_v_file_name, &file_name, _ctx);
_res = Z3_parse_z3_file(c, file_name);
_vres = camlidl_c2ml_z3V3_Z3_ast(&_res, _ctx);
camlidl_free(_ctx);
return _vres;
}
value camlidl_z3V3_Z3_get_version(value _unit)
{
unsigned int *major; /*out*/
@ -17640,6 +17687,30 @@ value camlidl_z3V3_Z3_get_version(value _unit)
return _vresult;
}
value camlidl_z3V3_Z3_enable_trace(
value _v_tag)
{
Z3_string tag; /*in*/
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3V3_Z3_string(_v_tag, &tag, _ctx);
Z3_enable_trace(tag);
camlidl_free(_ctx);
return Val_unit;
}
value camlidl_z3V3_Z3_disable_trace(
value _v_tag)
{
Z3_string tag; /*in*/
struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };
camlidl_ctx _ctx = &_ctxs;
camlidl_ml2c_z3V3_Z3_string(_v_tag, &tag, _ctx);
Z3_disable_trace(tag);
camlidl_free(_ctx);
return Val_unit;
}
value camlidl_z3V3_Z3_reset_memory(value _unit)
{
Z3_reset_memory();