本文整理汇总了C#中Microsoft.Z3.Context.MkEq方法的典型用法代码示例。如果您正苦于以下问题:C# Context.MkEq方法的具体用法?C# Context.MkEq怎么用?C# Context.MkEq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Z3.Context
的用法示例。
在下文中一共展示了Context.MkEq方法的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()
{
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());
}
}
示例3: Run
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));
}
}
示例4: 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());
}
}
示例5: EeAndGt
public static Expr EeAndGt(String left1, int left2, String right1, int right2)
{
using (Context ctx = new Context())
{
Expr a = ctx.MkConst(left1, ctx.MkIntSort());
Expr b = ctx.MkNumeral(left2, ctx.MkIntSort());
Expr c = ctx.MkConst(right1, ctx.MkIntSort());
Expr d = ctx.MkNumeral(right2, ctx.MkIntSort());
Solver s = ctx.MkSolver();
s.Assert(ctx.MkAnd(ctx.MkEq((ArithExpr)a, (ArithExpr)b), ctx.MkGt((ArithExpr)c, (ArithExpr)d)));
s.Check();
BoolExpr testing = ctx.MkAnd(ctx.MkEq((ArithExpr)a, (ArithExpr)b), ctx.MkGt((ArithExpr)c, (ArithExpr)d));
Model model = Check(ctx, testing, Status.SATISFIABLE);
Expr result2;
Model m2 = s.Model;
foreach (FuncDecl d2 in m2.Decls)
{
result2 = m2.ConstInterp(d2);
return result2;
}
}
return null;
}
示例6: ArrayExample2
/// <summary>
/// Prove <tt>store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, i3))</tt>.
/// </summary>
/// <remarks>This example demonstrates how to use the array theory.</remarks>
public static void ArrayExample2(Context ctx)
{
Console.WriteLine("ArrayExample2");
Sort int_type = ctx.IntSort;
Sort array_type = ctx.MkArraySort(int_type, int_type);
ArrayExpr a1 = (ArrayExpr)ctx.MkConst("a1", array_type);
ArrayExpr a2 = ctx.MkArrayConst("a2", int_type, int_type);
Expr i1 = ctx.MkConst("i1", int_type);
Expr i2 = ctx.MkConst("i2", int_type);
Expr i3 = ctx.MkConst("i3", int_type);
Expr v1 = ctx.MkConst("v1", int_type);
Expr v2 = ctx.MkConst("v2", int_type);
Expr st1 = ctx.MkStore(a1, i1, v1);
Expr st2 = ctx.MkStore(a2, i2, v2);
Expr sel1 = ctx.MkSelect(a1, i3);
Expr sel2 = ctx.MkSelect(a2, i3);
/* create antecedent */
BoolExpr antecedent = ctx.MkEq(st1, st2);
/* create consequent: i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, i3) */
BoolExpr consequent = ctx.MkOr(new BoolExpr[] { ctx.MkEq(i1, i3), ctx.MkEq(i2, i3), ctx.MkEq(sel1, sel2) });
/* prove store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, i3)) */
BoolExpr thm = ctx.MkImplies(antecedent, consequent);
Console.WriteLine("prove: store(a1, i1, v1) = store(a2, i2, v2) implies (i1 = i3 or i2 = i3 or select(a1, i3) = select(a2, i3))");
Console.WriteLine("{0}", (thm));
Prove(ctx, thm);
}
示例7: 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 y = ctx.MkBVConst("y", 32);
BitVecExpr two = ctx.MkBV(2, 32);
BitVecExpr three = ctx.MkBV(3, 32);
BitVecExpr tf = ctx.MkBV(24, 32);
Solver s = ctx.MkSolver();
s.Assert(ctx.MkEq(ctx.MkBVLSHR(x, two), three));
Console.WriteLine(s.Check());
Console.WriteLine(s.Model);
s = ctx.MkSolver();
s.Assert(ctx.MkEq(ctx.MkBVSHL(x, two), three));
Console.WriteLine(s.Check());
s = ctx.MkSolver();
s.Assert(ctx.MkEq(ctx.MkBVRotateLeft(x, two), three));
Console.WriteLine(s.Check());
Console.WriteLine(s.Model);
s = ctx.MkSolver();
s.Assert(ctx.MkEq(ctx.MkBVSHL(x, two), tf));
Console.WriteLine(s.Check());
Console.WriteLine(s.Model);
}
}
示例8: 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);
}
}
示例9: 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));
}
}
示例10: 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);
}
}
示例11: Run
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());
}
}
示例12: 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);
}
}
示例13: 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));
}
}
示例14: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
RealExpr d = ctx.MkRealConst("d");
RealExpr a = ctx.MkRealConst("a");
RealExpr t = ctx.MkRealConst("t");
RealExpr v_i = ctx.MkRealConst("v_i");
RealExpr v_f = ctx.MkRealConst("v_f");
BoolExpr[] equations = new BoolExpr[] {
ctx.MkEq(d, ctx.MkAdd(ctx.MkMul(v_i, t),
ctx.MkDiv(ctx.MkMul(a, ctx.MkPower(t, ctx.MkReal(2))),
ctx.MkReal(2)))),
ctx.MkEq(v_f, ctx.MkAdd(v_i, ctx.MkMul(a, t)))
};
Console.WriteLine("Kinematic equations: ");
foreach (BoolExpr e in equations)
Console.WriteLine(e);
BoolExpr[] problem = new BoolExpr[] {
ctx.MkEq(v_i, ctx.MkReal(0)),
ctx.MkEq(t, ctx.MkReal("4.10")),
ctx.MkEq(a, ctx.MkReal(6))
};
Console.WriteLine("Problem: ");
foreach (BoolExpr p in problem)
Console.WriteLine(p);
Solver s = ctx.MkSolver();
s.Assert(equations);
s.Assert(problem);
if (s.Check() != Status.SATISFIABLE)
throw new Exception("BUG");
Console.WriteLine("Solution: ");
Console.WriteLine(s.Model);
Console.WriteLine("Decimal Solution: ");
foreach (FuncDecl f in s.Model.ConstDecls)
Console.WriteLine(f.Name + " = " + ((RatNum)s.Model.ConstInterp(f)).ToDecimalString(10));
}
}
示例15: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" },
{ "MODEL", "true" } };
using (Context ctx = new Context(cfg))
{
RealExpr x = ctx.MkRealConst("x");
RealExpr y = ctx.MkRealConst("y");
Solver s = ctx.MkSolver();
s.Assert(ctx.MkAnd(ctx.MkEq(ctx.MkAdd(x, ctx.MkReal("10000000000000000000000")), y),
ctx.MkGt(y, ctx.MkReal("20000000000000000"))));
s.Check();
Console.WriteLine(s.Model);
Expr q = ctx.MkAdd(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 2)),
ctx.MkPower(ctx.MkReal(3), ctx.MkReal(1, 2)));
Console.WriteLine(q);
AlgebraicNum an = (AlgebraicNum)q.Simplify();
Console.WriteLine(an);
Console.WriteLine("[" + an.ToLower(10) + "," + an.ToUpper(10) + "]");
Console.WriteLine(an.ToDecimal(10));
}
}