3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-27 19:05:51 +00:00

Java API: a first version that compiles. This is still untested.

Signed-off-by: Christoph M. Wintersteiger <cwinter@microsoft.com>
This commit is contained in:
Christoph M. Wintersteiger 2012-11-27 16:36:50 +00:00
parent fb947f50fb
commit c6303fc8f5
153 changed files with 10063 additions and 9851 deletions

211
src/api/java/Goal.java Normal file
View file

@ -0,0 +1,211 @@
/**
* This file was automatically generated from Goal.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.Microsoft.Z3;
import com.Microsoft.Z3.Enumerations.*;
/**
* A goal (aka problem). A goal is essentially a set of formulas, that can be
* solved and/or transformed using tactics and solvers.
**/
public class Goal extends Z3Object
{
/**
* The precision of the goal. <remarks> Goals can be transformed using over
* and under approximations. An under approximation is applied when the
* objective is to find a model for a given goal. An over approximation is
* applied when the objective is to find a proof for a given goal.
* </remarks>
**/
public Z3_goal_prec Precision()
{
return Z3_goal_prec.fromInt(Native.goalPrecision(Context().nCtx(),
NativeObject()));
}
/**
* Indicates whether the goal is precise.
**/
public boolean IsPrecise()
{
return Precision() == Z3_goal_prec.Z3_GOAL_PRECISE;
}
/**
* Indicates whether the goal is an under-approximation.
**/
public boolean IsUnderApproximation()
{
return Precision() == Z3_goal_prec.Z3_GOAL_UNDER;
}
/**
* Indicates whether the goal is an over-approximation.
**/
public boolean IsOverApproximation()
{
return Precision() == Z3_goal_prec.Z3_GOAL_OVER;
}
/**
* Indicates whether the goal is garbage (i.e., the product of over- and
* under-approximations).
**/
public boolean IsGarbage()
{
return Precision() == Z3_goal_prec.Z3_GOAL_UNDER_OVER;
}
/**
* Adds the <paramref name="constraints"/> to the given goal.
* @throws Z3Exception
**/
public void Assert(BoolExpr[] constraints) throws Z3Exception
{
Context().CheckContextMatch(constraints);
for (BoolExpr c : constraints)
{
// It was an assume, now made an assert just to be sure we do not
// regress
Native.goalAssert(Context().nCtx(), NativeObject(),
c.NativeObject());
}
}
/**
* Indicates whether the goal contains `false'.
**/
public boolean Inconsistent()
{
return Native.goalInconsistent(Context().nCtx(), NativeObject());
}
/**
* The depth of the goal. <remarks> This tracks how many transformations
* were applied to it. </remarks>
**/
public int Depth()
{
return Native.goalDepth(Context().nCtx(), NativeObject());
}
/**
* Erases all formulas from the given goal.
**/
public void Reset()
{
Native.goalReset(Context().nCtx(), NativeObject());
}
/**
* The number of formulas in the goal.
**/
public int Size()
{
return Native.goalSize(Context().nCtx(), NativeObject());
}
/**
* The formulas in the goal.
* @throws Z3Exception
**/
public BoolExpr[] Formulas() throws Z3Exception
{
int n = Size();
BoolExpr[] res = new BoolExpr[n];
for (int i = 0; i < n; i++)
res[i] = new BoolExpr(Context(), Native.goalFormula(Context()
.nCtx(), NativeObject(), i));
return res;
}
/**
* The number of formulas, subformulas and terms in the goal.
**/
public int NumExprs()
{
return Native.goalNumExprs(Context().nCtx(), NativeObject());
}
/**
* Indicates whether the goal is empty, and it is precise or the product of
* an under approximation.
**/
public boolean IsDecidedSat()
{
return Native.goalIsDecidedSat(Context().nCtx(), NativeObject());
}
/**
* Indicates whether the goal contains `false', and it is precise or the
* product of an over approximation.
**/
public boolean IsDecidedUnsat()
{
return Native.goalIsDecidedUnsat(Context().nCtx(), NativeObject());
}
/**
* Translates (copies) the Goal to the target Context <paramref
* name="ctx"/>.
* @throws Z3Exception
**/
public Goal Translate(Context ctx) throws Z3Exception
{
return new Goal(ctx, Native.goalTranslate(Context().nCtx(),
NativeObject(), ctx.nCtx()));
}
/**
* Simplifies the goal. <remarks>Essentially invokes the `simplify' tactic
* on the goal.</remarks>
**/
public Goal Simplify(Params p) throws Z3Exception
{
Tactic t = Context().MkTactic("simplify");
ApplyResult res = t.Apply(this, p);
if (res.NumSubgoals() == 0)
throw new Z3Exception("No subgoals");
else
return res.Subgoals()[0];
}
/**
* Goal to string conversion.
*
* @return A string representation of the Goal.
**/
public String toString()
{
return Native.goalToString(Context().nCtx(), NativeObject());
}
Goal(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
Goal(Context ctx, boolean models, boolean unsatCores, boolean proofs) throws Z3Exception
{
super(ctx, Native.mkGoal(ctx.nCtx(), (models) ? true : false,
(unsatCores) ? true : false, (proofs) ? true : false));
}
void IncRef(long o) throws Z3Exception
{
Context().Goal_DRQ().IncAndClear(Context(), o);
super.IncRef(o);
}
void DecRef(long o) throws Z3Exception
{
Context().Goal_DRQ().Add(o);
super.DecRef(o);
}
}