3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-14 01:46:15 +00:00

Added finite domain expressions and numerals to the .NET, Java, and Python APIs.

Relates to #318
This commit is contained in:
Christoph M. Wintersteiger 2015-12-02 17:01:52 +00:00
parent 9e756fb6db
commit cbda38ee80
10 changed files with 380 additions and 12 deletions

View file

@ -2165,6 +2165,8 @@ public class Expr extends AST
return new FPNum(ctx, obj);
case Z3_ROUNDING_MODE_SORT:
return new FPRMNum(ctx, obj);
case Z3_FINITE_DOMAIN_SORT:
return new FiniteDomainNum(ctx, obj);
default: ;
}
}
@ -2187,6 +2189,8 @@ public class Expr extends AST
return new FPExpr(ctx, obj);
case Z3_ROUNDING_MODE_SORT:
return new FPRMExpr(ctx, obj);
case Z3_FINITE_DOMAIN_SORT:
return new FiniteDomainExpr(ctx, obj);
default: ;
}

View file

@ -0,0 +1,33 @@
/**
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
FiniteDomainExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2015-12-02
Notes:
**/
package com.microsoft.z3;
/**
* Finite-domain expressions
**/
public class FiniteDomainExpr extends Expr
{
/**
* Constructor for FiniteDomainExpr
* @throws Z3Exception on error
**/
FiniteDomainExpr(Context ctx, long obj)
{
super(ctx, obj);
}
}

View file

@ -0,0 +1,76 @@
/**
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
FiniteDomainNum.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2015-12-02
Notes:
**/
package com.microsoft.z3;
import java.math.BigInteger;
/**
* Finite-domain Numerals
**/
public class FiniteDomainNum extends FiniteDomainExpr
{
FiniteDomainNum(Context ctx, long obj)
{
super(ctx, obj);
}
/**
* Retrieve the int value.
**/
public int getInt()
{
Native.IntPtr res = new Native.IntPtr();
if (Native.getNumeralInt(getContext().nCtx(), getNativeObject(), res) ^ true)
throw new Z3Exception("Numeral is not an int");
return res.value;
}
/**
* Retrieve the 64-bit int value.
**/
public long getInt64()
{
Native.LongPtr res = new Native.LongPtr();
if (Native.getNumeralInt64(getContext().nCtx(), getNativeObject(), res) ^ true)
throw new Z3Exception("Numeral is not an int64");
return res.value;
}
/**
* Retrieve the BigInteger value.
**/
public BigInteger getBigInteger()
{
return new BigInteger(this.toString());
}
/**
* Returns a string representation of the numeral.
**/
public String toString()
{
try
{
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
}
}