本文整理汇总了C#中Microsoft.Z3.Context.MkNot方法的典型用法代码示例。如果您正苦于以下问题:C# Context.MkNot方法的具体用法?C# Context.MkNot怎么用?C# Context.MkNot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Z3.Context
的用法示例。
在下文中一共展示了Context.MkNot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" },
{ "MODEL", "true" } };
using (Context ctx = new Context(cfg))
{
EnumSort color = ctx.MkEnumSort("Color", new string[] { "red", "green", "blue" });
Expr red = color.Consts[0];
Expr green = color.Consts[1];
Expr blue = color.Consts[2];
Console.WriteLine(ctx.MkEq(green, blue));
Console.WriteLine(ctx.MkEq(green, blue).Simplify());
Expr c = ctx.MkConst("c", color);
Solver s = ctx.MkSolver();
s.Assert(ctx.MkNot(ctx.MkEq(c, green)));
s.Assert(ctx.MkNot(ctx.MkEq(c, blue)));
Console.WriteLine(s.Check());
Console.WriteLine(s.Model);
}
}
示例2: Run
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));
}
}
示例3: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
BitVecExpr x = ctx.MkBVConst("x", 32);
BitVecExpr[] powers = new BitVecExpr[32];
for (uint i = 0; i < 32; i++)
powers[i] = ctx.MkBVSHL(ctx.MkBV(1, 32), ctx.MkBV(i, 32));
BoolExpr step_zero = ctx.MkEq(ctx.MkBVAND(x, ctx.MkBVSub(x, ctx.MkBV(1, 32))), ctx.MkBV(0, 32));
BoolExpr fast = ctx.MkAnd(ctx.MkNot(ctx.MkEq(x, ctx.MkBV(0, 32))),
step_zero);
BoolExpr slow = ctx.MkFalse();
foreach (BitVecExpr p in powers)
slow = ctx.MkOr(slow, ctx.MkEq(x, p));
TestDriver.CheckString(fast, "(and (not (= x #x00000000)) (= (bvand x (bvsub x #x00000001)) #x00000000))");
Solver s = ctx.MkSolver();
s.Assert(ctx.MkNot(ctx.MkEq(fast, slow)));
TestDriver.CheckUNSAT(s.Check());
s = ctx.MkSolver();
s.Assert(ctx.MkNot(step_zero));
TestDriver.CheckSAT(s.Check());
}
}
示例4: Conflict
public BoolExpr Conflict(Context ctx, params BoolExpr[] packs)
{
BoolExpr q = ctx.MkFalse();
foreach (BoolExpr p in packs)
q = ctx.MkOr(q, ctx.MkNot(p));
return q;
}
示例5: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
Sort A = ctx.MkUninterpretedSort("A");
Sort B = ctx.MkUninterpretedSort("B");
FuncDecl f = ctx.MkFuncDecl("f", A, B);
Expr a1 = ctx.MkConst("a1", A);
Expr a2 = ctx.MkConst("a2", A);
Expr b = ctx.MkConst("b", B);
Expr x = ctx.MkConst("x", A);
Expr y = ctx.MkConst("y", A);
Solver s = ctx.MkSolver();
s.Assert(ctx.MkNot(ctx.MkEq(a1, a2)));
s.Assert(ctx.MkEq(f[a1], b));
s.Assert(ctx.MkEq(f[a2], b));
s.Assert(ctx.MkForall(new Expr[] { x, y }, ctx.MkImplies(ctx.MkEq(f[x], f[y]),
ctx.MkEq(x, y)),
1,
new Pattern[] { ctx.MkPattern(f[x], f[y]) }));
Console.WriteLine(s);
Console.WriteLine(s.Check());
}
}
示例6: 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);
}
示例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())
{
Sort U = ctx.MkUninterpretedSort("U");
FuncDecl f = ctx.MkFuncDecl("f", U, U);
Expr a = ctx.MkConst("a", U);
Expr b = ctx.MkConst("b", U);
Expr c = ctx.MkConst("c", U);
Solver s = ctx.MkSolver();
s.Assert(ctx.MkEq(f[f[a]], b),
ctx.MkNot(ctx.MkEq(f[b], c)),
ctx.MkEq(f[c], c));
Console.WriteLine(s.Check());
Model m = s.Model;
foreach (FuncDecl d in m.Decls)
if (d.DomainSize == 0)
Console.WriteLine(d.Name + " -> " + m.ConstInterp(d));
else
Console.WriteLine(d.Name + " -> " + m.FuncInterp(d));
Console.WriteLine(m.NumSorts);
Console.WriteLine(m.Sorts[0]);
foreach(Sort srt in m.Sorts)
Console.WriteLine(srt);
foreach (Expr v in m.SortUniverse(U))
Console.WriteLine(v);
}
}
示例9: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
Sort A = ctx.MkUninterpretedSort("A");
Expr x = ctx.MkConst("x", A);
Expr y = ctx.MkConst("y", A);
FuncDecl f = ctx.MkFuncDecl("f", A, A);
Solver s = ctx.MkSolver();
s.Assert(ctx.MkEq(f[f[x]], x),
ctx.MkEq(f[x], y),
ctx.MkNot(ctx.MkEq(x, y)));
Console.WriteLine(s.Check());
Model m = s.Model;
Console.WriteLine(m);
Console.WriteLine("interpretation assigned to A: ");
foreach (Expr a in m.SortUniverse(A))
Console.WriteLine(a);
}
}
示例10: 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);
}
}
示例11: Run
public void Run()
{
using (Context ctx = new Context())
{
RealExpr x = ctx.MkRealConst("x");
RealExpr y = ctx.MkRealConst("y");
RealExpr z = ctx.MkRealConst("z");
FuncDecl f = ctx.MkFuncDecl("f", ctx.RealSort, ctx.RealSort);
Solver s = ctx.MkSolver();
s.Assert(ctx.MkGt(x, ctx.MkReal(10)),
ctx.MkEq(y, ctx.MkAdd(x, ctx.MkReal(3))),
ctx.MkLt(y, ctx.MkReal(15)),
ctx.MkGt((RealExpr)f[x], ctx.MkReal(2)),
ctx.MkNot(ctx.MkEq(f[y], f[x])));
Console.WriteLine(s.Check());
Model m = s.Model;
foreach (FuncDecl fd in m.Decls)
Console.Write(" " + fd.Name);
Console.WriteLine();
foreach (FuncDecl fd in m.Decls)
{
if (fd.DomainSize == 0)
Console.WriteLine(fd.Name + " -> " + m.ConstInterp(fd));
else
Console.WriteLine(fd.Name + " -> " + m.FuncInterp(fd));
}
Console.WriteLine(m.Evaluate(ctx.MkAdd(z, ctx.MkReal(1))));
Console.WriteLine(m.Evaluate(ctx.MkAdd(z, ctx.MkReal(1)), true));
Console.WriteLine(m.Evaluate(z));
FuncInterp fi = m.FuncInterp(f);
Console.WriteLine(fi.Else);
Console.WriteLine(fi.NumEntries);
Console.WriteLine(fi.Entries[0]);
Console.WriteLine(fi.Entries[0].NumArgs);
Console.WriteLine(fi.Entries[0].Args[0]);
Console.WriteLine(fi.Entries[0].Value);
ArrayExpr a = ctx.MkArrayConst("a", ctx.RealSort, ctx.RealSort);
s.Assert(ctx.MkGt((RealExpr)ctx.MkSelect(a, x), ctx.MkReal(10)),
ctx.MkGt((RealExpr)ctx.MkSelect(a, y), ctx.MkReal(20)));
Console.WriteLine(s);
Console.WriteLine(s.Check());
Console.WriteLine(s.Model);
Console.WriteLine(s.Model.Evaluate(a));
Console.WriteLine(s.Model.FuncInterp(a.FuncDecl));
}
}
示例12: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
ArithExpr[] Q = new ArithExpr[8];
for (uint i = 0; i < 8; i++)
Q[i] = ctx.MkIntConst(string.Format("Q_{0}", i + 1));
BoolExpr[] val_c = new BoolExpr[8];
for (uint i = 0; i < 8; i++)
val_c[i] = ctx.MkAnd(ctx.MkLe(ctx.MkInt(1), Q[i]),
ctx.MkLe(Q[i], ctx.MkInt(8)));
BoolExpr col_c = ctx.MkDistinct(Q);
BoolExpr[][] diag_c = new BoolExpr[8][];
for (uint i = 0; i < 8; i++)
{
diag_c[i] = new BoolExpr[i];
for (uint j = 0; j < i; j++)
diag_c[i][j] = (BoolExpr)ctx.MkITE(ctx.MkEq(ctx.MkInt(i), ctx.MkInt(j)),
ctx.MkTrue(),
ctx.MkAnd(ctx.MkNot(ctx.MkEq(ctx.MkSub(Q[i], Q[j]),
ctx.MkSub(ctx.MkInt(i), ctx.MkInt(j)))),
ctx.MkNot(ctx.MkEq(ctx.MkSub(Q[i], Q[j]),
ctx.MkSub(ctx.MkInt(j), ctx.MkInt(i))))));
}
Solver s = ctx.MkSolver();
s.Assert(val_c);
s.Assert(col_c);
foreach (var c in diag_c)
s.Assert(c);
Console.WriteLine(s.Check());
Console.WriteLine(s.Model);
}
}
示例13: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" },
{ "MODEL", "true" } };
using (Context ctx = new Context(cfg))
{
Constructor cred = ctx.MkConstructor("red", "is_red");
Constructor cgreen = ctx.MkConstructor("green", "is_green");
Constructor cblue = ctx.MkConstructor("blue", "is_blue");
DatatypeSort color = ctx.MkDatatypeSort("Color", new Constructor[] { cred, cgreen, cblue });
Expr Red = ctx.MkConst(color.Constructors[0]);
Expr Green = ctx.MkConst(color.Constructors[1]);
Expr Blue = ctx.MkConst(color.Constructors[2]);
Expr c = ctx.MkConst("c", color);
Solver s = ctx.MkSolver();
s.Assert(ctx.MkNot(ctx.MkOr(ctx.MkEq(c, Red), ctx.MkEq(c, Green), ctx.MkEq(c, Blue))));
Console.WriteLine(s.Check()); // must be unsat
BoolExpr c_is_red = (BoolExpr)color.Recognizers[0][c];
BoolExpr c_is_green = (BoolExpr)color.Recognizers[1][c];
BoolExpr c_is_blue = (BoolExpr)color.Recognizers[2][c];
s = ctx.MkSolver();
s.Assert(ctx.MkOr(c_is_red, c_is_green, c_is_blue));
Console.WriteLine(s.Check()); // must be sat
s = ctx.MkSolver();
s.Assert(ctx.MkNot(ctx.MkOr(c_is_red, c_is_green, c_is_blue)));
Console.WriteLine(s.Check()); // must be unsat
}
}
示例14: ProveExample2
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);
}
示例15: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" },
{ "PROOF_MODE", "2" } };
using (Context ctx = new Context(cfg))
{
BoolExpr p = ctx.MkBoolConst("p");
Solver s = ctx.MkSolver();
s.Assert(p);
s.Assert(ctx.MkNot(p));
Console.WriteLine(s.Check());
Console.WriteLine(s.Proof);
}
}