mirror of
https://github.com/Z3Prover/z3
synced 2026-02-24 01:01:19 +00:00
Java type generics (#4832)
* Generify, needs some testing and review * Remove unnecessary change * Whoops, ? capture that type * Misread the docs, whoops * More permissible arithmetic operations * Implement believed Optimize generics * Missed a few generics * More permissible expr for arrays in parameters * More permissible expr for bitvecs in parameters * More permissible expr for bools in parameters * More permissible expr for fps in parameters * More permissible expr for fprms in parameters * More permissible expr for ints in parameters * More permissible expr for reals in parameters * Undo breaking name conflict due to type erasure; see notes * Whoops, fix typing of ReExpr * Sort corrections for Re, Seq * More permissible expr for regular expressions in parameters * Fix name conflict between sequences and regular expressions; see notes * Minor typo, big implications! * Make Constructor consistent, associate captured types with other unknown capture types for datatype consistency * More expressive; outputs of multiple datatype definitions are only known to be sort, not capture, and Constructor.of should make a capture * Be less dumb and just type it a little differently * Update examples, make sure to type Expr and FuncDecl sort returns * General fixups * Downgrade java version, make it only for the generic support, remove var and Expr[]::new construction * Turns out Java 8 hadn't figured out how to do stream generics yet. Didn't even show up in my IDE, weird
This commit is contained in:
parent
bb24b3f2be
commit
3bca1fbcd8
45 changed files with 2724 additions and 588 deletions
|
|
@ -24,6 +24,7 @@ import java.util.*;
|
|||
/**
|
||||
* Solvers.
|
||||
**/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class Solver extends Z3Object {
|
||||
/**
|
||||
* A string that describes all available solver parameters.
|
||||
|
|
@ -122,10 +123,10 @@ public class Solver extends Z3Object {
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void add(BoolExpr... constraints)
|
||||
public void add(Expr<BoolSort>... constraints)
|
||||
{
|
||||
getContext().checkContextMatch(constraints);
|
||||
for (BoolExpr a : constraints)
|
||||
for (Expr<BoolSort> a : constraints)
|
||||
{
|
||||
Native.solverAssert(getContext().nCtx(), getNativeObject(),
|
||||
a.getNativeObject());
|
||||
|
|
@ -147,7 +148,7 @@ public class Solver extends Z3Object {
|
|||
* and the Boolean literals
|
||||
* provided using {@link #check()} with assumptions.
|
||||
**/
|
||||
public void assertAndTrack(BoolExpr[] constraints, BoolExpr[] ps)
|
||||
public void assertAndTrack(Expr<BoolSort>[] constraints, Expr<BoolSort>[] ps)
|
||||
{
|
||||
getContext().checkContextMatch(constraints);
|
||||
getContext().checkContextMatch(ps);
|
||||
|
|
@ -174,7 +175,7 @@ public class Solver extends Z3Object {
|
|||
* and the Boolean literals
|
||||
* provided using {@link #check} with assumptions.
|
||||
*/
|
||||
public void assertAndTrack(BoolExpr constraint, BoolExpr p)
|
||||
public void assertAndTrack(Expr<BoolSort> constraint, Expr<BoolSort> p)
|
||||
{
|
||||
getContext().checkContextMatch(constraint);
|
||||
getContext().checkContextMatch(p);
|
||||
|
|
@ -229,7 +230,8 @@ public class Solver extends Z3Object {
|
|||
* @see #getUnsatCore
|
||||
* @see #getProof
|
||||
**/
|
||||
public Status check(Expr... assumptions)
|
||||
@SafeVarargs
|
||||
public final Status check(Expr<BoolSort>... assumptions)
|
||||
{
|
||||
Z3_lbool r;
|
||||
if (assumptions == null) {
|
||||
|
|
@ -250,6 +252,7 @@ public class Solver extends Z3Object {
|
|||
* @see #getUnsatCore
|
||||
* @see #getProof
|
||||
**/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Status check()
|
||||
{
|
||||
return check((Expr[]) null);
|
||||
|
|
@ -266,13 +269,13 @@ public class Solver extends Z3Object {
|
|||
* is fixed.
|
||||
*
|
||||
*/
|
||||
public Status getConsequences(BoolExpr[] assumptions, Expr[] variables, List<BoolExpr> consequences)
|
||||
public Status getConsequences(Expr<BoolSort>[] assumptions, Expr<?>[] variables, List<Expr<BoolSort>> consequences)
|
||||
{
|
||||
ASTVector result = new ASTVector(getContext());
|
||||
ASTVector asms = new ASTVector(getContext());
|
||||
ASTVector vars = new ASTVector(getContext());
|
||||
for (BoolExpr asm : assumptions) asms.push(asm);
|
||||
for (Expr v : variables) vars.push(v);
|
||||
for (Expr<BoolSort> asm : assumptions) asms.push(asm);
|
||||
for (Expr<?> v : variables) vars.push(v);
|
||||
int r = Native.solverGetConsequences(getContext().nCtx(), getNativeObject(), asms.getNativeObject(), vars.getNativeObject(), result.getNativeObject());
|
||||
for (int i = 0; i < result.size(); ++i) consequences.add((BoolExpr) Expr.create(getContext(), result.get(i).getNativeObject()));
|
||||
return lboolToStatus(Z3_lbool.fromInt(r));
|
||||
|
|
@ -307,7 +310,7 @@ public class Solver extends Z3Object {
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr getProof()
|
||||
public Expr<?> getProof()
|
||||
{
|
||||
long x = Native.solverGetProof(getContext().nCtx(), getNativeObject());
|
||||
if (x == 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue