3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 17:45:32 +00:00

Added accessors to enumeration sorts. Thanks to codeplex user steimann for suggesting this.

(http://z3.codeplex.com/workitem/195)

Signed-off-by: Christoph M. Wintersteiger <cwinter@microsoft.com>
This commit is contained in:
Christoph M. Wintersteiger 2015-03-24 21:42:05 +00:00
parent b76d588c28
commit 1c77ad00c3
5 changed files with 87 additions and 4 deletions

View file

@ -1390,11 +1390,24 @@ struct
let f i = (func_decl_of_ptr (Sort.gc x) (Z3native.get_datatype_sort_constructor (Sort.gnc x) (Sort.gno x) i)) in
mk_list f n
let get_const_decl ( x : sort ) ( inx : int ) =
func_decl_of_ptr (Sort.gc x) (Z3native.get_datatype_sort_constructor (Sort.gnc x) (Sort.gno x) inx)
let get_consts ( x : sort ) =
let n = Z3native.get_datatype_sort_num_constructors (Sort.gnc x) (Sort.gno x) in
let f i = (Expr.mk_const_f (Sort.gc x) (get_const_decl x i)) in
mk_list f n
let get_const ( x : sort ) ( inx : int ) =
Expr.mk_const_f (Sort.gc x) (get_const_decl x inx)
let get_tester_decls ( x : sort ) =
let n = Z3native.get_datatype_sort_num_constructors (Sort.gnc x) (Sort.gno x) in
let f i = (func_decl_of_ptr (Sort.gc x) (Z3native.get_datatype_sort_recognizer (Sort.gnc x) (Sort.gno x) i)) in
let f i = (func_decl_of_ptr (Sort.gc x) (Z3native.get_datatype_sort_recognizer (Sort.gnc x) (Sort.gno x) i)) in
mk_list f n
let get_tester_decl ( x : sort ) ( inx : int ) =
func_decl_of_ptr (Sort.gc x) (Z3native.get_datatype_sort_recognizer (Sort.gnc x) (Sort.gno x) inx)
end

View file

@ -1091,8 +1091,20 @@ sig
(** The function declarations of the constants in the enumeration. *)
val get_const_decls : Sort.sort -> FuncDecl.func_decl list
(** Retrieves the inx'th constant declaration in the enumeration. *)
val get_const_decl : Sort.sort -> int -> FuncDecl.func_decl
(** The constants in the enumeration. *)
val get_consts : Sort.sort -> Expr.expr list
(** Retrieves the inx'th constant in the enumeration. *)
val get_const : Sort.sort -> int -> Expr.expr
(** The test predicates for the constants in the enumeration. *)
val get_tester_decls : Sort.sort -> FuncDecl.func_decl list
(** Retrieves the inx'th tester/recognizer declaration in the enumeration. *)
val get_tester_decl : Sort.sort -> int -> FuncDecl.func_decl
end
(** Functions to manipulate List expressions *)