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); } }
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); } }
public void Run() { using (Context ctx = new Context()) { BoolExpr p = ctx.MkBoolConst("p"); Console.WriteLine(ctx.MkNot(p)); Console.WriteLine(ctx.MkNot(p)); IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1))); Console.WriteLine(ctx.MkAdd(ctx.MkInt(1), x)); Console.WriteLine(ctx.MkAdd(x, y)); Console.WriteLine(ctx.MkMul(ctx.MkInt(2), x)); Console.WriteLine(ctx.MkMul(x, ctx.MkInt(2))); Console.WriteLine(ctx.MkMul(x, y)); Console.WriteLine(ctx.MkDiv(x, y)); Console.WriteLine(ctx.MkMod(x, y)); Console.WriteLine(ctx.MkEq(x, y)); Console.WriteLine(ctx.MkDistinct(x, y, x)); Console.WriteLine(ctx.MkNot(ctx.MkEq(x, y))); Console.WriteLine(ctx.MkEq(x, y)); Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1))); Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1))); BoolExpr q = ctx.MkBoolConst("q"); Console.WriteLine(ctx.MkNot(p)); Console.WriteLine(ctx.MkNot(p)); Console.WriteLine(ctx.MkAnd(p, q)); Console.WriteLine(ctx.MkAnd(p, q)); Console.WriteLine(ctx.MkEq(x, y)); } }
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()); } }
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); } }
public void Run() { Dictionary<string, string> cfg = new Dictionary<string, string>() { }; using (Context ctx = new Context(cfg)) { FuncDecl f = ctx.MkFuncDecl("f", ctx.IntSort, ctx.IntSort); FuncDecl g = ctx.MkFuncDecl("g", ctx.IntSort, ctx.IntSort); IntExpr a = ctx.MkIntConst("a"); IntExpr b = ctx.MkIntConst("b"); IntExpr c = ctx.MkIntConst("c"); IntExpr x = ctx.MkIntConst("x"); Solver s = ctx.MkSolver(); Params p = ctx.MkParams(); p.Add("AUTO_CONFIG", false); p.Add("MBQI", false); s.Parameters = p; s.Assert(ctx.MkForall(new Expr[] { x }, ctx.MkEq(f[g[x]], x), 1, new Pattern[] { ctx.MkPattern(f[g[x]]) })); s.Assert(ctx.MkEq(a, g[b])); s.Assert(ctx.MkEq(b, c)); s.Assert(ctx.MkDistinct(f[a], c)); Console.WriteLine(s); Console.WriteLine(s.Check()); } }
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")); } }
public void Run() { using (Context ctx = new Context()) { Sort U = ctx.MkUninterpretedSort("U"); Console.WriteLine(U); Expr a = ctx.MkConst("a", U); a = ctx.MkConst("a", U); Expr b = ctx.MkConst("b", U); Expr c = ctx.MkConst("c", U); IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); Console.WriteLine(ctx.MkAnd(ctx.MkEq(a, b), ctx.MkEq(a, c))); Console.WriteLine(U == ctx.IntSort); Sort U2 = ctx.MkUninterpretedSort("U"); Console.WriteLine(U == U2); U2 = ctx.MkUninterpretedSort("U2"); Console.WriteLine(U == U2); Console.WriteLine(ctx.MkDistinct(a, b, c)); FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { U, U }, U); Console.WriteLine(ctx.MkEq(f[a,b], b)); } }
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(); } } }
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"); Console.WriteLine(ctx.MkAdd(x, y).FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ADD); Console.WriteLine(ctx.MkAdd(x, y).FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SUB); } }
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); } }
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"); FuncDecl x_d = x.FuncDecl; Console.WriteLine("is_expr(x_d): " + x_d.IsExpr); Console.WriteLine("is_func_decl(x_d): " + x_d.IsFuncDecl); Console.WriteLine("x_d.Name: " + x_d.Name); Console.WriteLine("x_d.Range: " + x_d.Range); Console.WriteLine("x_d.Arity: " + x_d.Arity); Console.WriteLine("x_d() == x: " + (x_d.Apply() == x)); FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { ctx.IntSort, ctx.RealSort }, ctx.BoolSort); Console.WriteLine("f.Name: " + f.Name); Console.WriteLine("f.Range: " + f.Range); Console.WriteLine("f.Arity: " + f.Arity); for (uint i = 0; i < f.Arity; i++) Console.WriteLine("domain(" + i + "): " + f.Domain[i]); Console.WriteLine(f[x, ctx.MkInt2Real(x)]); Console.WriteLine(f[x, ctx.MkInt2Real(x)].FuncDecl == f); } }
public void Run() { Dictionary<string, string> cfg = new Dictionary<string, string>() { { "AUTO_CONFIG", "true" } }; using (Context ctx = new Context(cfg)) { IntExpr[] X = new IntExpr[5]; for (uint i = 0; i < 5; i++) X[i] = ctx.MkIntConst(string.Format("x_{0}", i)); RealExpr[] Y = new RealExpr[5]; for (uint i = 0; i < 5; i++) Y[i] = ctx.MkRealConst(string.Format("y_{0}", i)); BoolExpr[] P = new BoolExpr[5]; for (uint i = 0; i < 5; i++) P[i] = ctx.MkBoolConst(string.Format("p_{0}", i)); foreach (Expr x in X) Console.WriteLine(x); foreach (Expr x in Y) Console.WriteLine(x); foreach (Expr x in P) Console.WriteLine(x); foreach (ArithExpr y in Y) Console.WriteLine(ctx.MkPower(y, ctx.MkReal(2))); ArithExpr[] Yp = new ArithExpr[Y.Length]; for (uint i = 0; i < Y.Length; i++) Yp[i] = ctx.MkPower(Y[i], ctx.MkReal(2)); Console.WriteLine(ctx.MkAdd(Yp)); } }
public static void ProveExample2(Context ctx) { Console.WriteLine("ProveExample2"); /* declare function g */ Sort I = ctx.IntSort; FuncDecl g = ctx.MkFuncDecl("g", I, I); /* create x, y, and z */ IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); IntExpr z = ctx.MkIntConst("z"); /* create gx, gy, gz */ Expr gx = ctx.MkApp(g, x); Expr gy = ctx.MkApp(g, y); Expr gz = ctx.MkApp(g, z); /* create zero */ IntExpr zero = ctx.MkInt(0); /* assert not(g(g(x) - g(y)) = g(z)) */ ArithExpr gx_gy = ctx.MkSub((IntExpr)gx, (IntExpr)gy); Expr ggx_gy = ctx.MkApp(g, gx_gy); BoolExpr eq = ctx.MkEq(ggx_gy, gz); BoolExpr c1 = ctx.MkNot(eq); /* assert x + z <= y */ ArithExpr x_plus_z = ctx.MkAdd(x, z); BoolExpr c2 = ctx.MkLe(x_plus_z, y); /* assert y <= x */ BoolExpr c3 = ctx.MkLe(y, x); /* prove z < 0 */ BoolExpr f = ctx.MkLt(z, zero); Console.WriteLine("prove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < 0"); Prove(ctx, f, c1, c2, c3); /* disprove z < -1 */ IntExpr minus_one = ctx.MkInt(-1); f = ctx.MkLt(z, minus_one); Console.WriteLine("disprove: not(g(g(x) - g(y)) = g(z)), x + z <= y <= x implies z < -1"); Disprove(ctx, f, c1, c2, c3); }
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.MkTactic("smt").Solver; s.Assert(ctx.MkGt(x, ctx.MkAdd(y, ctx.MkInt(1)))); Console.WriteLine(s.Check()); Console.WriteLine(s.Model); } }
public void Run() { using (Context ctx = new Context()) { IntExpr x = ctx.MkIntConst("x"); Console.WriteLine(ctx.MkAdd(x, ctx.MkInt(1))); } }
public void Run() { Dictionary<string, string> cfg = new Dictionary<string, string>() { { "AUTO_CONFIG", "true" } }; using (Context ctx = new Context(cfg)) { FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { ctx.IntSort, ctx.IntSort }, ctx.IntSort); IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); Quantifier qf = ctx.MkForall(new Expr[] { x, y }, ctx.MkEq(f[x, y], ctx.MkInt(0))); Console.WriteLine(qf.Body); Expr v1 = qf.Body.Args[0].Args[0]; Console.WriteLine(v1); Console.WriteLine(v1 == ctx.MkBound(1, ctx.IntSort)); } }
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()); } }
public void Run() { Dictionary<string, string> cfg = new Dictionary<string, string>() { { "AUTO_CONFIG", "true" } }; using (Context ctx = new Context(cfg)) { RealExpr x = ctx.MkRealConst("x"); IntExpr y = ctx.MkIntConst("y"); RealExpr a, b, c; a = ctx.MkRealConst("a"); b = ctx.MkRealConst("b"); c = ctx.MkRealConst("c"); IntExpr s, r; s = ctx.MkIntConst("s"); r = ctx.MkIntConst("r"); TestDriver.CheckString(ctx.MkAdd(x, ctx.MkInt2Real(y), ctx.MkReal(1), ctx.MkAdd(a, ctx.MkInt2Real(s))), "(+ x (to_real y) 1.0 a (to_real s))"); TestDriver.CheckString(ctx.MkAdd(ctx.MkInt2Real(y), c), "(+ (to_real y) c)"); } }
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 s1 = ctx.MkSolver(); s1.Assert(new BoolExpr[] { ctx.MkGt(x, ctx.MkInt(10)), ctx.MkGt(y, ctx.MkInt(10)) }); Solver s2 = ctx.MkSolver(); Console.WriteLine(s2); s2.Assert(s1.Assertions); Console.WriteLine(s2); } }
public void Run() { Dictionary<string, string> cfg = new Dictionary<string, string>() { { "AUTO_CONFIG", "true" }, { "MODEL", "true" } }; using (Context ctx = new Context(cfg)) { ArrayExpr A = ctx.MkArrayConst("A", ctx.IntSort, ctx.IntSort); IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); Solver s = ctx.MkSolver(); s.Assert(ctx.MkEq(ctx.MkSelect(A, x), x)); s.Assert(ctx.MkEq(ctx.MkStore(A, x, y), A)); Console.WriteLine(s); Console.WriteLine(s.Check()); Console.WriteLine(s.Model); } }
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)))); } }
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()); } }
public void Run() { Dictionary<string, string> cfg = new Dictionary<string, string>() { { "AUTO_CONFIG", "true" } }; using (Context ctx = new Context(cfg)) { Tactic t = ctx.Then(ctx.MkTactic("simplify"), ctx.MkTactic("normalize-bounds"), ctx.MkTactic("solve-eqs")); IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); IntExpr z = ctx.MkIntConst("z"); Goal g = ctx.MkGoal(); g.Assert(ctx.MkGt(x, ctx.MkInt(10))); g.Assert(ctx.MkEq(y, ctx.MkAdd(x, ctx.MkInt(3)))); g.Assert(ctx.MkGt(z, y)); ApplyResult r = t[g]; Console.WriteLine(r); Solver s = ctx.MkSolver(); s.Assert(r.Subgoals[0].Formulas); Console.WriteLine(s.Check()); Console.WriteLine("subgoal model"); Model sgm = s.Model; Console.WriteLine(sgm); Console.WriteLine("converted model"); Model m = r.ConvertModel(0, sgm); Console.WriteLine(m); Console.WriteLine(m.Evaluate(x)); } }
public void Run() { Dictionary<string, string> cfg = new Dictionary<string, string>() { { "AUTO_CONFIG", "true" }, { "PROOF_MODE", "2" } }; using (Context ctx = new Context(cfg)) { ArrayExpr AllOne = ctx.MkConstArray(ctx.IntSort, ctx.MkInt(1)); IntExpr a = ctx.MkIntConst("a"); IntExpr i = ctx.MkIntConst("i"); Solver s = ctx.MkSolver(); s.Assert(ctx.MkEq(a, ctx.MkSelect(AllOne, i))); Console.WriteLine(s.Check()); s = ctx.MkSolver(); s.Assert(ctx.MkEq(a, ctx.MkSelect(AllOne, i))); s.Assert(ctx.MkNot(ctx.MkEq(a, ctx.MkInt(1)))); Console.WriteLine(s.Check()); } }
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); } }
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"); FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { ctx.IntSort, ctx.IntSort }, ctx.IntSort); FuncDecl g = ctx.MkFuncDecl("g", new Sort[] { ctx.IntSort }, ctx.IntSort); Expr n = f[f[g[x], g[g[x]]], g[g[y]]]; Console.WriteLine(n); Expr nn = n.Substitute(new Expr[] { g[g[x]], g[y] }, new Expr[] { y, ctx.MkAdd(x, ctx.MkInt(1)) } ); Console.WriteLine(nn); Console.WriteLine(n.Substitute(g[g[x]], y)); } }
public void Run() { Dictionary<string, string> cfg = new Dictionary<string, string>() { { "AUTO_CONFIG", "true" } }; using (Context ctx = new Context(cfg)) { FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { ctx.IntSort, ctx.IntSort }, ctx.IntSort); IntExpr x = ctx.MkIntConst("x"); IntExpr y = ctx.MkIntConst("y"); Console.WriteLine(ctx.MkForall(new Expr[] { x, y }, ctx.MkEq(f[x, y], ctx.MkInt(0)))); Console.WriteLine(ctx.MkExists(new Expr[] { x }, ctx.MkGe((ArithExpr)f[x, x], ctx.MkInt(0)))); IntExpr a = ctx.MkIntConst("a"); IntExpr b = ctx.MkIntConst("b"); Solver s = ctx.MkSolver(); s.Assert(ctx.MkForall(new Expr[] { x }, ctx.MkEq(f[x, x], ctx.MkInt(0)))); s.Assert(ctx.MkEq(f[a, b], ctx.MkInt(1))); Console.WriteLine(s.Check()); Console.WriteLine(s.Model); } }
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"); Console.WriteLine(ctx.MkAdd(x, y) == ctx.MkAdd(x, y)); Console.WriteLine(ctx.MkAdd(x, y) == ctx.MkAdd(y, x)); ArithExpr n = ctx.MkAdd(x, y); Console.WriteLine(n == ctx.MkAdd(x, y)); IntExpr x2 = ctx.MkIntConst("x"); Console.WriteLine(x == x2); Console.WriteLine(ctx.MkIntConst("x") == ctx.MkRealConst("x")); } }
public void Run() { Dictionary<string, string> cfg = new Dictionary<string, string>() { { "AUTO_CONFIG", "true" } }; using (Context ctx = new Context(cfg)) { Expr x = ctx.MkConst("x", ctx.IntSort); Console.WriteLine(x == ctx.MkIntConst("x")); BoolExpr a = (BoolExpr)ctx.MkConst("a", ctx.BoolSort); BoolExpr b = (BoolExpr)ctx.MkConst("b", ctx.BoolSort); Console.WriteLine(ctx.MkAnd(a, b)); } }
public static void intSymbolic(BigInteger i, out IntExpr e) { e = new IntExpr(ctx.MkIntConst("reg" + i.ToString())); }