有人知道如何在Z3中将签名的bitvector转换为signed int吗?

时间:2016-11-23 20:15:44

标签: z3 smt reliability



(>  (bv2int (bvxor ((_ int2bv 32) x1) ((_ int2bv 32) y1))) 0)




x1和y1是两个有符号的int,后面是xor。我怎样才能将它们转换为带符号的int?

1 个答案:

答案 0 :(得分:0)

您可以使用public class Day implements Cloneable,Comparable<Day>{ private int year; private int month; private int day; private static final String MonthNames="JanFebMarMayJunJulAugSepOctNovDec"; //Constructor public Day(int y, int m, int d) { this.year=y; this.month=m; this.day=d; } public void set(String sDay) { String[] sDayParts = sDay.split("-"); this.year = Integer.parseInt(sDayParts[2]); this.day = Integer.parseInt(sDayParts[0]); this.month = MonthNames.indexOf(sDayParts[1])/3+1; } public Day(String sDay) { set(sDay); } // Return a string for the day like dd MMM yyyy public String toString() { return day+"-"+ MonthNames.substring((month-1)*3,month*3)+ "-"+ year; } @Override public int compareTo(Day another) { return this.compareTo(another); } int2bv,但在大多数情况下,这些功能将被视为未解释(请参阅例如API doc)。如果您需要实际的语义,则必须自己实现它们。它根本不是很难(仅仅是bv2int项的if-then-elses的一大部分),但是你通过这种方式得到的约束是高度非线性的,所以它很可能是整数理论会放弃并返回未知数。例如,请参阅Z3 Performance with Non-Linear ArithmeticHow does Z3 handle non-linear integer arithmetic?Z3 : Questions About Z3 int2bv?