1
我想使用Z3(版本4.5.0.1).net,並想知道我是否可以使用SMTLIB文件。 所以我有我想在我的程序加載這個簡單的SMT文件:Microsoft Z3導入SMT文件
(declare-const x Int)
(declare-const y Int)
(assert (< x 4))
(assert (< (- y x) 1))
(assert (> y 1))
在C#中我tryed如下因素:
using(Context context = new Context(new Dictionary<string, string>() { { "model", "true" } })) {
context.ParseSMTLIB2String(Resources.SampleSMT2);
var solver = context.MkOptimize();
solver.Check();
Console.WriteLine($"model: {solver.Model}"); // empty
//BigInteger x = (solver.Model.Evaluate(...) as IntNum).BigInteger;
//BigInteger y = (solver.Model.Evaluate(...) as IntNum).BigInteger;
}
但我不知道如何解決在提供的問題smt文件,因爲在 這個例子中模型是空的。
感謝您的幫助,但我如何獲得ConstInt x和y,以便我可以評估它們? – MrWoffle
您必須運行約束並收集所有常量;請參閱此處以獲取類似問題的鏈接:https://stackoverflow.com/questions/39882992/how-to-get-the-declaration-from-a-z3-smtlib2-formula/40182248#40182248 –