mirror of
https://github.com/Z3Prover/z3
synced 2025-10-23 16:04:35 +00:00
adding access to characters over API
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
3a402ca2c1
commit
7ae78da850
8 changed files with 128 additions and 26 deletions
|
@ -120,7 +120,7 @@ public class Context implements AutoCloseable {
|
|||
private BoolSort m_boolSort = null;
|
||||
private IntSort m_intSort = null;
|
||||
private RealSort m_realSort = null;
|
||||
private SeqSort<BitVecSort> m_stringSort = null;
|
||||
private SeqSort<CharSort> m_stringSort = null;
|
||||
|
||||
/**
|
||||
* Retrieves the Boolean sort of the context.
|
||||
|
@ -164,9 +164,18 @@ public class Context implements AutoCloseable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves the Integer sort of the context.
|
||||
* Creates character sort object.
|
||||
**/
|
||||
public SeqSort<BitVecSort> getStringSort()
|
||||
|
||||
public CharSort mkCharSort()
|
||||
{
|
||||
return new CharSort(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the String sort of the context.
|
||||
**/
|
||||
public SeqSort<CharSort> getStringSort()
|
||||
{
|
||||
if (m_stringSort == null) {
|
||||
m_stringSort = mkStringSort();
|
||||
|
@ -239,7 +248,7 @@ public class Context implements AutoCloseable {
|
|||
/**
|
||||
* Create a new string sort
|
||||
**/
|
||||
public SeqSort<BitVecSort> mkStringSort()
|
||||
public SeqSort<CharSort> mkStringSort()
|
||||
{
|
||||
return new SeqSort<>(this, Native.mkStringSort(nCtx()));
|
||||
}
|
||||
|
@ -2006,23 +2015,31 @@ public class Context implements AutoCloseable {
|
|||
/**
|
||||
* Create a string constant.
|
||||
*/
|
||||
public SeqExpr<BitVecSort> mkString(String s)
|
||||
public SeqExpr<CharSort> mkString(String s)
|
||||
{
|
||||
return (SeqExpr<BitVecSort>) Expr.create(this, Native.mkString(nCtx(), s));
|
||||
return (SeqExpr<CharSort>) Expr.create(this, Native.mkString(nCtx(), s));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an integer expression to a string.
|
||||
*/
|
||||
public SeqExpr<BitVecSort> intToString(Expr<IntSort> e)
|
||||
public SeqExpr<CharSort> intToString(Expr<IntSort> e)
|
||||
{
|
||||
return (SeqExpr<BitVecSort>) Expr.create(this, Native.mkIntToStr(nCtx(), e.getNativeObject()));
|
||||
return (SeqExpr<CharSort>) Expr.create(this, Native.mkIntToStr(nCtx(), e.getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an unsigned bitvector expression to a string.
|
||||
*/
|
||||
public SeqExpr<CharSort> ubvToString(Expr<BvSort> e)
|
||||
{
|
||||
return (SeqExpr<CharSort>) Expr.create(this, Native.mkUbvToStr(nCtx(), e.getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an integer expression to a string.
|
||||
*/
|
||||
public IntExpr stringToInt(Expr<SeqSort<BitVecSort>> e)
|
||||
public IntExpr stringToInt(Expr<SeqSort<CharSort>> e)
|
||||
{
|
||||
return (IntExpr) Expr.create(this, Native.mkStrToInt(nCtx(), e.getNativeObject()));
|
||||
}
|
||||
|
@ -2041,7 +2058,7 @@ public class Context implements AutoCloseable {
|
|||
/**
|
||||
* Retrieve the length of a given sequence.
|
||||
*/
|
||||
public <R extends Sort> IntExpr mkLength(Expr<SeqSort<BitVecSort>> s)
|
||||
public <R extends Sort> IntExpr mkLength(Expr<SeqSort<R>> s)
|
||||
{
|
||||
checkContextMatch(s);
|
||||
return (IntExpr) Expr.create(this, Native.mkSeqLength(nCtx(), s.getNativeObject()));
|
||||
|
@ -2050,7 +2067,7 @@ public class Context implements AutoCloseable {
|
|||
/**
|
||||
* Check for sequence prefix.
|
||||
*/
|
||||
public <R extends Sort> BoolExpr mkPrefixOf(Expr<SeqSort<BitVecSort>> s1, Expr<SeqSort<BitVecSort>> s2)
|
||||
public <R extends Sort> BoolExpr mkPrefixOf(Expr<SeqSort<R>> s1, Expr<SeqSort<R>> s2)
|
||||
{
|
||||
checkContextMatch(s1, s2);
|
||||
return (BoolExpr) Expr.create(this, Native.mkSeqPrefix(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
|
||||
|
@ -2059,7 +2076,7 @@ public class Context implements AutoCloseable {
|
|||
/**
|
||||
* Check for sequence suffix.
|
||||
*/
|
||||
public <R extends Sort> BoolExpr mkSuffixOf(Expr<SeqSort<BitVecSort>> s1, Expr<SeqSort<BitVecSort>> s2)
|
||||
public <R extends Sort> BoolExpr mkSuffixOf(Expr<SeqSort<R>> s1, Expr<SeqSort<R>> s2)
|
||||
{
|
||||
checkContextMatch(s1, s2);
|
||||
return (BoolExpr)Expr.create(this, Native.mkSeqSuffix(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
|
||||
|
@ -2068,7 +2085,7 @@ public class Context implements AutoCloseable {
|
|||
/**
|
||||
* Check for sequence containment of s2 in s1.
|
||||
*/
|
||||
public <R extends Sort> BoolExpr mkContains(Expr<SeqSort<BitVecSort>> s1, Expr<SeqSort<BitVecSort>> s2)
|
||||
public <R extends Sort> BoolExpr mkContains(Expr<SeqSort<R>> s1, Expr<SeqSort<R>> s2)
|
||||
{
|
||||
checkContextMatch(s1, s2);
|
||||
return (BoolExpr) Expr.create(this, Native.mkSeqContains(nCtx(), s1.getNativeObject(), s2.getNativeObject()));
|
||||
|
@ -2077,7 +2094,7 @@ public class Context implements AutoCloseable {
|
|||
/**
|
||||
* Retrieve sequence of length one at index.
|
||||
*/
|
||||
public <R extends Sort> SeqExpr<R> mkAt(Expr<SeqSort<BitVecSort>> s, Expr<IntSort> index)
|
||||
public <R extends Sort> SeqExpr<R> mkAt(Expr<SeqSort<R>> s, Expr<IntSort> index)
|
||||
{
|
||||
checkContextMatch(s, index);
|
||||
return (SeqExpr<R>) Expr.create(this, Native.mkSeqAt(nCtx(), s.getNativeObject(), index.getNativeObject()));
|
||||
|
@ -2086,7 +2103,7 @@ public class Context implements AutoCloseable {
|
|||
/**
|
||||
* Retrieve element at index.
|
||||
*/
|
||||
public <R extends Sort> Expr<R> MkNth(Expr<SeqSort<BitVecSort>> s, Expr<IntSort> index)
|
||||
public <R extends Sort> Expr<R> MkNth(Expr<SeqSort<R>> s, Expr<IntSort> index)
|
||||
{
|
||||
checkContextMatch(s, index);
|
||||
return (Expr<R>) Expr.create(this, Native.mkSeqNth(nCtx(), s.getNativeObject(), index.getNativeObject()));
|
||||
|
@ -2096,7 +2113,7 @@ public class Context implements AutoCloseable {
|
|||
/**
|
||||
* Extract subsequence.
|
||||
*/
|
||||
public <R extends Sort> SeqExpr<R> mkExtract(Expr<SeqSort<BitVecSort>> s, Expr<IntSort> offset, Expr<IntSort> length)
|
||||
public <R extends Sort> SeqExpr<R> mkExtract(Expr<SeqSort<R>> s, Expr<IntSort> offset, Expr<IntSort> length)
|
||||
{
|
||||
checkContextMatch(s, offset, length);
|
||||
return (SeqExpr<R>) Expr.create(this, Native.mkSeqExtract(nCtx(), s.getNativeObject(), offset.getNativeObject(), length.getNativeObject()));
|
||||
|
@ -2105,7 +2122,7 @@ public class Context implements AutoCloseable {
|
|||
/**
|
||||
* Extract index of sub-string starting at offset.
|
||||
*/
|
||||
public <R extends Sort> IntExpr mkIndexOf(Expr<SeqSort<BitVecSort>> s, Expr<SeqSort<BitVecSort>> substr, Expr<IntSort> offset)
|
||||
public <R extends Sort> IntExpr mkIndexOf(Expr<SeqSort<R>> s, Expr<SeqSort<R>> substr, Expr<IntSort> offset)
|
||||
{
|
||||
checkContextMatch(s, substr, offset);
|
||||
return (IntExpr)Expr.create(this, Native.mkSeqIndex(nCtx(), s.getNativeObject(), substr.getNativeObject(), offset.getNativeObject()));
|
||||
|
@ -2114,7 +2131,7 @@ public class Context implements AutoCloseable {
|
|||
/**
|
||||
* Replace the first occurrence of src by dst in s.
|
||||
*/
|
||||
public <R extends Sort> SeqExpr<R> mkReplace(Expr<SeqSort<BitVecSort>> s, Expr<SeqSort<BitVecSort>> src, Expr<SeqSort<BitVecSort>> dst)
|
||||
public <R extends Sort> SeqExpr<R> mkReplace(Expr<SeqSort<R>> s, Expr<SeqSort<R>> src, Expr<SeqSort<R>> dst)
|
||||
{
|
||||
checkContextMatch(s, src, dst);
|
||||
return (SeqExpr<R>) Expr.create(this, Native.mkSeqReplace(nCtx(), s.getNativeObject(), src.getNativeObject(), dst.getNativeObject()));
|
||||
|
@ -2123,7 +2140,7 @@ public class Context implements AutoCloseable {
|
|||
/**
|
||||
* Convert a regular expression that accepts sequence s.
|
||||
*/
|
||||
public <R extends Sort> ReExpr<R> mkToRe(Expr<SeqSort<BitVecSort>> s)
|
||||
public <R extends Sort> ReExpr<R> mkToRe(Expr<SeqSort<R>> s)
|
||||
{
|
||||
checkContextMatch(s);
|
||||
return (ReExpr<R>) Expr.create(this, Native.mkSeqToRe(nCtx(), s.getNativeObject()));
|
||||
|
@ -2133,7 +2150,7 @@ public class Context implements AutoCloseable {
|
|||
/**
|
||||
* Check for regular expression membership.
|
||||
*/
|
||||
public <R extends Sort> BoolExpr mkInRe(Expr<SeqSort<BitVecSort>> s, Expr<ReSort<R>> re)
|
||||
public <R extends Sort> BoolExpr mkInRe(Expr<SeqSort<R>> s, Expr<ReSort<R>> re)
|
||||
{
|
||||
checkContextMatch(s, re);
|
||||
return (BoolExpr) Expr.create(this, Native.mkSeqInRe(nCtx(), s.getNativeObject(), re.getNativeObject()));
|
||||
|
@ -2241,7 +2258,7 @@ public class Context implements AutoCloseable {
|
|||
/**
|
||||
* Create a range expression.
|
||||
*/
|
||||
public <R extends Sort> ReExpr<R> mkRange(Expr<SeqSort<BitVecSort>> lo, Expr<SeqSort<BitVecSort>> hi)
|
||||
public <R extends Sort> ReExpr<R> mkRange(Expr<SeqSort<CharSort>> lo, Expr<SeqSort<CharSort>> hi)
|
||||
{
|
||||
checkContextMatch(lo, hi);
|
||||
return (ReExpr<R>) Expr.create(this, Native.mkReRange(nCtx(), lo.getNativeObject(), hi.getNativeObject()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue