本文整理汇总了C#中Microsoft.Z3.Context.MkInt方法的典型用法代码示例。如果您正苦于以下问题:C# Context.MkInt方法的具体用法?C# Context.MkInt怎么用?C# Context.MkInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Z3.Context
的用法示例。
在下文中一共展示了Context.MkInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
Dictionary<string, string> settings = new Dictionary<string, string>() { { "AUTO_CONFIG", "true" }, { "MODEL", "true" } };
using (Context ctx = new Context(settings))
{
IntExpr a = ctx.MkIntConst("a");
IntExpr b = ctx.MkIntConst("b");
IntExpr c = ctx.MkIntConst("c");
RealExpr d = ctx.MkRealConst("d");
RealExpr e = ctx.MkRealConst("e");
BoolExpr q = ctx.MkAnd(
ctx.MkGt(a, ctx.MkAdd(b, ctx.MkInt(2))),
ctx.MkEq(a, ctx.MkAdd(ctx.MkMul(ctx.MkInt(2), c), ctx.MkInt(10))),
ctx.MkLe(ctx.MkAdd(c, b), ctx.MkInt(1000)),
ctx.MkGe(d, e));
Solver s = ctx.MkSolver();
s.Assert(q);
Console.WriteLine(s.Check());
Console.WriteLine(s.Model);
}
}
示例2: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
BoolExpr p1 = ctx.MkBoolConst("p1");
BoolExpr p2 = ctx.MkBoolConst("p2");
BoolExpr p3 = ctx.MkBoolConst("p3");
IntExpr x = ctx.MkIntConst("x");
IntExpr y = ctx.MkIntConst("y");
Solver s = ctx.MkSolver();
s.Assert(ctx.MkImplies(p1, ctx.MkGt(x, ctx.MkInt(10))),
ctx.MkImplies(p1, ctx.MkGt(y, x)),
ctx.MkImplies(p2, ctx.MkLt(y, ctx.MkInt(5))),
ctx.MkImplies(p3, ctx.MkGt(y, ctx.MkInt(0))));
Console.WriteLine(s);
Console.WriteLine(s.Check(p1, p2, p3));
Console.WriteLine("Core: ");
foreach (Expr e in s.UnsatCore)
Console.WriteLine(e);
Console.WriteLine(s.Check(p1, p3));
Console.WriteLine(s.Model);
}
}
示例3: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
IntExpr x = ctx.MkIntConst("x");
IntExpr y = ctx.MkIntConst("y");
Solver s = ctx.MkSolver();
Console.WriteLine(s);
s.Assert(ctx.MkGt(x, ctx.MkInt(10)), ctx.MkEq(y, ctx.MkAdd(x, ctx.MkInt(2))));
Console.WriteLine(s);
Console.WriteLine("solving s");
Console.WriteLine(s.Check());
Console.WriteLine("creating new scope");
s.Push();
s.Assert(ctx.MkLt(y, ctx.MkInt(11)));
Console.WriteLine(s);
Console.WriteLine("solving updated constraints");
Console.WriteLine(s.Check());
Console.WriteLine("restoring");
s.Pop();
Console.WriteLine(s);
Console.WriteLine("solving restored constraints");
Console.WriteLine(s.Check());
}
}
示例4: MkRandomExpr
/// <summary>
/// Generates a slightly randomized expression.
/// </summary>
static BoolExpr MkRandomExpr(Context ctx, System.Random rng)
{
int limit = 1073741823;
Sort i = ctx.IntSort;
Sort b = ctx.BoolSort;
Symbol sr1 = ctx.MkSymbol(rng.Next(0, limit));
Symbol sr2 = ctx.MkSymbol(rng.Next(0, limit));
Symbol sr3 = ctx.MkSymbol(rng.Next(0, limit));
FuncDecl r1 = ctx.MkFuncDecl(sr1, i, b);
FuncDecl r2 = ctx.MkFuncDecl(sr2, i, b);
FuncDecl r3 = ctx.MkFuncDecl(sr3, i, b);
Symbol s = ctx.MkSymbol(rng.Next(0, limit));
Expr x = ctx.MkConst(s, i);
BoolExpr r1x = (BoolExpr)ctx.MkApp(r1, x);
BoolExpr r2x = (BoolExpr)ctx.MkApp(r2, x);
BoolExpr r3x = (BoolExpr)ctx.MkApp(r3, x);
Expr[] vars = { x };
BoolExpr rl1 = ctx.MkForall(vars, ctx.MkImplies(r1x, r2x));
BoolExpr rl2 = ctx.MkForall(vars, ctx.MkImplies(r2x, r1x));
BoolExpr rl3 = (BoolExpr)ctx.MkApp(r1, ctx.MkInt(3));
BoolExpr q = (BoolExpr)ctx.MkApp(r3, ctx.MkInt(2));
BoolExpr a1 = ctx.MkNot(q);
BoolExpr q1 = ctx.MkExists(vars, ctx.MkAnd(r3x, r2x));
BoolExpr q2 = ctx.MkExists(vars, ctx.MkAnd(r3x, r1x));
BoolExpr[] all = { a1, q1, q2 };
return ctx.MkAnd(all);
}
示例5: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
IntExpr[] x = new IntExpr[20];
IntExpr[] y = new IntExpr[20];
for (uint i = 0; i < 20; i++)
{
x[i] = ctx.MkIntConst(string.Format("x_{0}", i));
y[i] = ctx.MkIntConst(string.Format("y_{0}", i));
}
BoolExpr f = ctx.MkAnd(ctx.MkGe(ctx.MkAdd(x), ctx.MkInt(0)),
ctx.MkGe(ctx.MkAdd(y), ctx.MkInt(0)));
Console.WriteLine("now: " + ctx.GetParamValue("PP_MAX_DEPTH"));
ctx.UpdateParamValue("PP_MAX_DEPTH", "1");
Console.WriteLine(f);
ctx.UpdateParamValue("PP_MAX_DEPTH", "100");
ctx.UpdateParamValue("PP_MAX_NUM_LINES", "10");
Console.WriteLine(f);
ctx.UpdateParamValue("PP_MAX_NUM_LINES", "20");
ctx.UpdateParamValue("PP_MAX_WIDTH", "300");
Console.WriteLine(f);
Console.WriteLine("now: " + ctx.GetParamValue("PP_MAX_WIDTH"));
}
}
示例6: Run
public void Run()
{
using (Context ctx = new Context())
{
BoolExpr p = ctx.MkBoolConst("p");
BoolExpr q = ctx.MkBoolConst("q");
Console.WriteLine(ctx.MkAnd(p, q));
Console.WriteLine(ctx.MkOr(p, q));
Console.WriteLine(ctx.MkAnd(p, ctx.MkTrue()));
Console.WriteLine(ctx.MkOr(p, ctx.MkFalse()));
Console.WriteLine(ctx.MkNot(p));
Console.WriteLine(ctx.MkImplies(p, q));
Console.WriteLine(ctx.MkEq(p, q).Simplify());
Console.WriteLine(ctx.MkEq(p, q));
BoolExpr r = ctx.MkBoolConst("r");
Console.WriteLine(ctx.MkNot(ctx.MkEq(p, ctx.MkNot(ctx.MkEq(q, r)))));
Console.WriteLine(ctx.MkNot(ctx.MkEq(ctx.MkNot(ctx.MkEq(p, q)), r)));
Console.WriteLine(ctx.MkEq(p, ctx.MkTrue()));
Console.WriteLine(ctx.MkEq(p, ctx.MkFalse()));
Console.WriteLine(ctx.MkEq(p, ctx.MkTrue()).Simplify());
Console.WriteLine(ctx.MkEq(p, ctx.MkFalse()).Simplify());
Console.WriteLine(ctx.MkEq(p, p).Simplify());
Console.WriteLine(ctx.MkEq(p, q).Simplify());
Console.WriteLine(ctx.MkAnd(p, q, r));
Console.WriteLine(ctx.MkOr(p, q, r));
IntExpr x = ctx.MkIntConst("x");
Console.WriteLine(x is BoolExpr);
Console.WriteLine(p is BoolExpr);
Console.WriteLine(ctx.MkAnd(p, q) is BoolExpr);
Console.WriteLine(p is BoolExpr);
Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1)) is BoolExpr);
Console.WriteLine(p.IsAnd);
Console.WriteLine(ctx.MkOr(p, q).IsOr);
Console.WriteLine(ctx.MkAnd(p, q).IsAnd);
Console.WriteLine(x.IsNot);
Console.WriteLine(p.IsNot);
Console.WriteLine(ctx.MkNot(p));
Console.WriteLine(ctx.MkNot(p).IsDistinct);
Console.WriteLine(ctx.MkEq(p, q).IsDistinct);
Console.WriteLine(ctx.MkDistinct(p, q).IsDistinct);
Console.WriteLine(ctx.MkDistinct(x, ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkAdd(x, ctx.MkInt(2))).IsDistinct);
Console.WriteLine();
Console.WriteLine(ctx.MkBool(true));
Console.WriteLine(ctx.MkBool(false));
Console.WriteLine(ctx.BoolSort);
Context ctx1 = new Context();
Console.WriteLine(ctx1.MkBool(true));
Console.WriteLine(ctx1.BoolSort);
Console.WriteLine(ctx1.MkBool(true).Sort == ctx1.BoolSort);
Console.WriteLine(ctx1.MkBool(true).Sort == ctx.BoolSort);
Console.WriteLine(ctx1.MkBool(true).Sort != ctx.BoolSort);
}
}
示例7: Run
public void Run()
{
using (Context ctx = new Context()) {
ctx.UpdateParamValue("DL_ENGINE","1");
ctx.UpdateParamValue("DL_PDR_USE_FARKAS","true");
// ctx.UpdateParamValue("VERBOSE","2");
var s = ctx.MkFixedpoint();
BoolSort B = ctx.BoolSort;
IntSort I = ctx.IntSort;
FuncDecl mc = ctx.MkFuncDecl("mc", new Sort[]{I, I}, B);
ArithExpr x = (ArithExpr)ctx.MkBound(0,I);
ArithExpr y = (ArithExpr)ctx.MkBound(1,I);
ArithExpr z = (ArithExpr)ctx.MkBound(2,I);
s.RegisterRelation(mc);
BoolExpr gt = ctx.MkGt(x, ctx.MkInt(100));
s.AddRule(ctx.MkImplies(gt,(BoolExpr)mc[x,ctx.MkSub(x,ctx.MkInt(10))]));
s.AddRule(ctx.MkImplies(ctx.MkAnd(ctx.MkNot(gt),
(BoolExpr) mc[ctx.MkAdd(x,ctx.MkInt(11)),y],
(BoolExpr) mc[y,z]),
(BoolExpr) mc[x,z]));
Console.WriteLine(s.Query(ctx.MkAnd((BoolExpr)mc[x,y], ctx.MkGt(y,ctx.MkInt(100)))));
Console.WriteLine(s.GetAnswer());
Console.WriteLine(s.Query(ctx.MkAnd((BoolExpr)mc[x,y], ctx.MkLt(y,ctx.MkInt(91)))));
Console.WriteLine(s.GetAnswer());
}
}
示例8: Run
public void Run()
{
using (Context ctx = new Context())
{
FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { ctx.IntSort, ctx.RealSort }, ctx.IntSort);
try
{
Console.WriteLine(f.Domain[3]);
}
catch (IndexOutOfRangeException ex)
{
Console.WriteLine("failed: " + ex.Message);
}
IntExpr x = ctx.MkIntConst("x");
Console.WriteLine(f[ctx.MkInt(1), ctx.MkReal(1)]);
Console.WriteLine(f[ctx.MkInt(1), ctx.MkReal(1)].Sort);
Console.WriteLine(f[ctx.MkInt(1), ctx.MkReal(1)].NumArgs);
foreach (Expr e in f[ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkReal(1)].Args)
Console.WriteLine(e);
Console.WriteLine(f[ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkReal(1)].Args[0]);
Console.WriteLine(f[ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkReal(1)].Args[0].Equals(ctx.MkAdd(x, ctx.MkInt(1))));
Console.WriteLine(f[ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkReal(1)].FuncDecl[ctx.MkInt(2), ctx.MkInt2Real((IntExpr)ctx.MkAdd(x, ctx.MkInt(1)))]);
Console.WriteLine(ctx.MkInt(1).IsExpr);
Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1)).IsExpr);
Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).IsExpr);
Console.WriteLine(ctx.MkInt(1).IsConst);
Console.WriteLine(x.IsConst);
Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1)).IsConst);
Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).IsConst);
Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).Body.Args[0]);
Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).Body.Args[0].IsExpr);
Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).Body.Args[0].IsConst);
Console.WriteLine(ctx.MkForall(new Expr[] { x }, ctx.MkGt(x, ctx.MkInt(0))).Body.Args[0].IsVar);
Console.WriteLine(x.IsVar);
Console.WriteLine(ctx.MkITE(ctx.MkTrue(), x, ctx.MkAdd(x, ctx.MkInt(1))));
Context ctx1 = new Context();
Console.WriteLine(ctx1.MkITE(ctx1.MkTrue(), x.Translate(ctx1), ctx.MkAdd(x, ctx.MkInt(1)).Translate(ctx1)));
Console.WriteLine(ctx.MkITE(ctx.MkTrue(), ctx.MkInt(1), ctx.MkInt(1)));
Console.WriteLine(ctx.MkDistinct(x, ctx.MkAdd(x, ctx.MkInt(1)), ctx.MkAdd(x, ctx.MkInt(2))));
Console.WriteLine(ctx1.MkAnd(ctx1.MkDistinct(x.Translate(ctx1), ctx1.MkInt(1)),
ctx1.MkGt((IntExpr)x.Translate(ctx1), ctx1.MkInt(0))));
}
}
示例9: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
IntExpr x = ctx.MkIntConst("x");
Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1)).GetHashCode() == ctx.MkAdd(ctx.MkInt(1), x).GetHashCode());
Console.WriteLine(x.Sort.GetHashCode() == ctx.IntSort.GetHashCode());
}
}
示例10: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
IntExpr dog = ctx.MkIntConst("dog");
IntExpr cat = ctx.MkIntConst("cat");
IntExpr mouse = ctx.MkIntConst("mouse");
Solver s = ctx.MkSolver();
s.Assert(ctx.MkGe(dog, ctx.MkInt(1)));
s.Assert(ctx.MkGe(cat, ctx.MkInt(1)));
s.Assert(ctx.MkGe(mouse, ctx.MkInt(1)));
s.Assert(ctx.MkEq(ctx.MkAdd(dog, cat, mouse), ctx.MkInt(100)));
s.Assert(ctx.MkEq(ctx.MkAdd(ctx.MkMul(ctx.MkInt(1500), dog),
ctx.MkMul(ctx.MkInt(100), cat),
ctx.MkMul(ctx.MkInt(25), mouse)),
ctx.MkInt(10000)));
Console.WriteLine(s.Check());
Console.WriteLine(s.Model);
}
}
示例11: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
IntExpr x = ctx.MkIntConst("x");
RealExpr y = ctx.MkRealConst("y");
Console.WriteLine((ctx.MkAdd(x, ctx.MkInt(1))).Sort);
Console.WriteLine((ctx.MkAdd(y, ctx.MkReal(1))).Sort);
Console.WriteLine((ctx.MkGe(x, ctx.MkInt(2))).Sort);
}
}
示例12: Run
public void Run()
{
using (Context ctx = new Context())
{
IntExpr x = ctx.MkIntConst("x");
Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1)));
}
}
示例13: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
ArithExpr[] a = new ArithExpr[5];
for (uint x = 0; x < 5; x++)
a[x] = ctx.MkInt(x+1);
foreach (Expr e in a)
Console.WriteLine(e);
ArithExpr[] X = new ArithExpr[5];
for (uint i = 0; i < 5; i++)
X[i] = ctx.MkIntConst(string.Format("x{0}", i));
ArithExpr[] Y = new ArithExpr[5];
for (uint i = 0; i < 5; i++)
Y[i] = ctx.MkIntConst(string.Format("y{0}", i));
foreach (Expr e in X)
Console.WriteLine(e);
ArithExpr[] X_plus_Y = new ArithExpr[5];
for (uint i = 0; i < 5; i++)
X_plus_Y[i] = ctx.MkAdd(X[i], Y[i]);
foreach (Expr e in X_plus_Y)
Console.WriteLine(e);
BoolExpr[] X_gt_Y = new BoolExpr[5];
for (uint i = 0; i < 5; i++)
X_gt_Y[i] = ctx.MkGt(X[i], Y[i]);
foreach (Expr e in X_gt_Y)
Console.WriteLine(e);
Console.WriteLine(ctx.MkAnd(X_gt_Y));
Expr[][] matrix = new Expr[3][];
for (uint i = 0; i < 3; i++) {
matrix[i] = new Expr[3];
for (uint j = 0; j < 3; j++)
matrix[i][j] = ctx.MkIntConst(string.Format("x_{0}_{1}", i + 1, j + 1));
}
foreach(Expr[] row in matrix) {
foreach(Expr e in row)
Console.Write(" " + e);
Console.WriteLine();
}
}
}
示例14: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
Params p = ctx.MkParams();
p.Add(":arith-lhs", true);
p.Add(":som", true);
Solver s = ctx.Then(ctx.With(ctx.MkTactic("simplify"), p),
ctx.MkTactic("normalize-bounds"),
ctx.MkTactic("lia2pb"),
ctx.MkTactic("pb2bv"),
ctx.MkTactic("bit-blast"),
ctx.MkTactic("sat")).Solver;
IntExpr x = ctx.MkIntConst("x");
IntExpr y = ctx.MkIntConst("y");
IntExpr z = ctx.MkIntConst("z");
s.Assert(new BoolExpr[] { ctx.MkGt(x, ctx.MkInt(0)),
ctx.MkLt(x, ctx.MkInt(10)),
ctx.MkGt(y, ctx.MkInt(0)),
ctx.MkLt(y, ctx.MkInt(10)),
ctx.MkGt(z, ctx.MkInt(0)),
ctx.MkLt(z, ctx.MkInt(10)),
ctx.MkEq(ctx.MkAdd(ctx.MkMul(ctx.MkInt(3), y),
ctx.MkMul(ctx.MkInt(2), x)), z) });
Console.WriteLine(s.Check());
Console.WriteLine(s.Model);
s.Reset();
s.Assert(ctx.MkEq(ctx.MkAdd(ctx.MkMul(ctx.MkInt(3), y),
ctx.MkMul(ctx.MkInt(2), x)), z));
Console.WriteLine(s.Check());
}
}
示例15: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" },
{ "MODEL", "true" } };
using (Context ctx = new Context(cfg))
{
ArrayExpr X = ctx.MkArrayConst("A", ctx.IntSort, ctx.IntSort);
Expr q = ctx.MkGe(
ctx.MkAdd((IntExpr)ctx.MkSelect(X, ctx.MkInt(0)),
(IntExpr)ctx.MkSelect(X, ctx.MkInt(1)),
(IntExpr)ctx.MkSelect(X, ctx.MkInt(2))),
ctx.MkInt(0));
Console.WriteLine(q);
Console.WriteLine(q.Simplify());
}
}