mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 20:18:18 +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:
parent
b76d588c28
commit
1c77ad00c3
|
@ -11,7 +11,7 @@ Version 4.4
|
||||||
|
|
||||||
- Upgrade: This release includes a brand new OCaml/ML API that is much better integrated with the build system, and hopefully also easier to use than the previous one.
|
- Upgrade: This release includes a brand new OCaml/ML API that is much better integrated with the build system, and hopefully also easier to use than the previous one.
|
||||||
|
|
||||||
- Fixed various bugs reported by Marc Brockschmidt, Venkatesh-Prasad Ranganath, Enric Carbonell, Morgan Deters, Tom Ball, Malte Schwerhoff, Amir Ebrahimi, Codeplex users rsas, clockish, Heizmann, susmitj, and Stackoverflow users user297886.
|
- Fixed various bugs reported by Marc Brockschmidt, Venkatesh-Prasad Ranganath, Enric Carbonell, Morgan Deters, Tom Ball, Malte Schwerhoff, Amir Ebrahimi, Codeplex users rsas, clockish, Heizmann, susmitj, steimann, and Stackoverflow users user297886.
|
||||||
|
|
||||||
|
|
||||||
Version 4.3.2
|
Version 4.3.2
|
||||||
|
|
|
@ -44,6 +44,16 @@ namespace Microsoft.Z3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the inx'th constant declaration in the enumeration.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inx"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public FuncDecl ConstDecl(uint inx)
|
||||||
|
{
|
||||||
|
return new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor(Context.nCtx, NativeObject, inx));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The constants in the enumeration.
|
/// The constants in the enumeration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -61,7 +71,17 @@ namespace Microsoft.Z3
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The test predicates for the constants in the enumeration.
|
/// Retrieves the inx'th constant in the enumeration.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inx"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Expr Const(uint inx)
|
||||||
|
{
|
||||||
|
return Context.MkApp(ConstDecl(inx));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The test predicates (recognizers) for the constants in the enumeration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FuncDecl[] TesterDecls
|
public FuncDecl[] TesterDecls
|
||||||
{
|
{
|
||||||
|
@ -76,6 +96,16 @@ namespace Microsoft.Z3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the inx'th tester/recognizer declaration in the enumeration.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inx"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public FuncDecl TesterDecl(uint inx)
|
||||||
|
{
|
||||||
|
return new FuncDecl(Context, Native.Z3_get_datatype_sort_recognizer(Context.nCtx, NativeObject, inx));
|
||||||
|
}
|
||||||
|
|
||||||
#region Internal
|
#region Internal
|
||||||
internal EnumSort(Context ctx, Symbol name, Symbol[] enumNames)
|
internal EnumSort(Context ctx, Symbol name, Symbol[] enumNames)
|
||||||
: base(ctx, IntPtr.Zero)
|
: base(ctx, IntPtr.Zero)
|
||||||
|
|
|
@ -35,10 +35,19 @@ public class EnumSort extends Sort
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the inx'th constant declaration in the enumeration.
|
||||||
|
* @throws Z3Exception on error
|
||||||
|
**/
|
||||||
|
public FuncDecl getConstDecl(int inx) throws Z3Exception
|
||||||
|
{
|
||||||
|
return new FuncDecl(getContext(), Native.getDatatypeSortConstructor(getContext().nCtx(), getNativeObject(), inx));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constants in the enumeration.
|
* The constants in the enumeration.
|
||||||
* @throws Z3Exception on error
|
* @throws Z3Exception on error
|
||||||
* @return an Expr
|
* @return an Expr[]
|
||||||
**/
|
**/
|
||||||
public Expr[] getConsts() throws Z3Exception
|
public Expr[] getConsts() throws Z3Exception
|
||||||
{
|
{
|
||||||
|
@ -49,6 +58,16 @@ public class EnumSort extends Sort
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the inx'th constant in the enumeration.
|
||||||
|
* @throws Z3Exception on error
|
||||||
|
* @return an Expr
|
||||||
|
**/
|
||||||
|
public Expr getConst(int inx) throws Z3Exception
|
||||||
|
{
|
||||||
|
return getContext().mkApp(getConstDecl(inx));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The test predicates for the constants in the enumeration.
|
* The test predicates for the constants in the enumeration.
|
||||||
* @throws Z3Exception on error
|
* @throws Z3Exception on error
|
||||||
|
@ -62,6 +81,15 @@ public class EnumSort extends Sort
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the inx'th tester/recognizer declaration in the enumeration.
|
||||||
|
* @throws Z3Exception on error
|
||||||
|
**/
|
||||||
|
public FuncDecl getTesterDecl(int inx) throws Z3Exception
|
||||||
|
{
|
||||||
|
return new FuncDecl(getContext(), Native.getDatatypeSortRecognizer(getContext().nCtx(), getNativeObject(), inx));
|
||||||
|
}
|
||||||
|
|
||||||
EnumSort(Context ctx, Symbol name, Symbol[] enumNames) throws Z3Exception
|
EnumSort(Context ctx, Symbol name, Symbol[] enumNames) throws Z3Exception
|
||||||
{
|
{
|
||||||
super(ctx, 0);
|
super(ctx, 0);
|
||||||
|
|
|
@ -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
|
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
|
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 get_tester_decls ( x : sort ) =
|
||||||
let n = Z3native.get_datatype_sort_num_constructors (Sort.gnc x) (Sort.gno x) in
|
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
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1091,8 +1091,20 @@ sig
|
||||||
(** The function declarations of the constants in the enumeration. *)
|
(** The function declarations of the constants in the enumeration. *)
|
||||||
val get_const_decls : Sort.sort -> FuncDecl.func_decl list
|
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. *)
|
(** The test predicates for the constants in the enumeration. *)
|
||||||
val get_tester_decls : Sort.sort -> FuncDecl.func_decl list
|
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
|
end
|
||||||
|
|
||||||
(** Functions to manipulate List expressions *)
|
(** Functions to manipulate List expressions *)
|
||||||
|
|
Loading…
Reference in a new issue