本文整理汇总了C#中Microsoft.Z3.Context.MkAdd方法的典型用法代码示例。如果您正苦于以下问题:C# Context.MkAdd方法的具体用法?C# Context.MkAdd怎么用?C# Context.MkAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Z3.Context
的用法示例。
在下文中一共展示了Context.MkAdd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: 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"));
}
}
示例4: 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);
}
}
示例5: 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));
}
}
示例6: 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));
}
}
示例7: 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));
}
}
示例8: Run
public void Run()
{
using (Context ctx = new Context())
{
Expr a1 = ctx.MkAdd(ctx.MkRealConst("x"), ctx.MkReal(1));
Expr a2 = ctx.MkAdd(ctx.MkRealConst("x"), ctx.MkReal(1));
Console.WriteLine(a1.GetHashCode() == a2.GetHashCode());
Expr a3 = ctx.MkAdd(ctx.MkRealConst("x"), ctx.MkReal(2));
Console.WriteLine(a3.GetHashCode() == a1.GetHashCode());
}
}
示例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 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);
}
}
示例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");
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);
}
}
示例12: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
Context ctx = new Context(cfg);
RealExpr x = ctx.MkRealConst("x");
RealExpr y = ctx.MkRealConst("y");
Console.WriteLine(ctx.MkPower(ctx.MkAdd(x, y), ctx.MkReal(3)));
Console.WriteLine(ctx.MkPower(x, ctx.MkAdd(y, ctx.MkReal(3))));
}
示例13: 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));
}
}
示例14: 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[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));
}
}
示例15: Run
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");
RealExpr y = ctx.MkRealConst("y");
RealExpr z = ctx.MkRealConst("z");
RealExpr zero = ctx.MkReal(0);
RealExpr one = ctx.MkReal(1);
Goal g = ctx.MkGoal();
g.Assert(ctx.MkOr(ctx.MkEq(x, zero), ctx.MkEq(x, one)));
g.Assert(ctx.MkOr(ctx.MkEq(y, zero), ctx.MkEq(y, one)));
g.Assert(ctx.MkOr(ctx.MkEq(z, zero), ctx.MkEq(z, one)));
g.Assert(ctx.MkGt(ctx.MkAdd(x, y, z), ctx.MkReal(2)));
Tactic t = ctx.Repeat(ctx.OrElse(ctx.MkTactic("split-clause"), ctx.MkTactic("skip")));
Console.WriteLine(t[g]);
t = ctx.Repeat(ctx.OrElse(ctx.MkTactic("split-clause"), ctx.MkTactic("skip")), 1);
Console.WriteLine(t[g]);
t = ctx.Then(ctx.Repeat(ctx.OrElse(ctx.MkTactic("split-clause"), ctx.MkTactic("skip"))), ctx.MkTactic("solve-eqs"));
Console.WriteLine(t[g]);
}
}