本文整理汇总了C#中Microsoft.Z3.Context.MkPower方法的典型用法代码示例。如果您正苦于以下问题:C# Context.MkPower方法的具体用法?C# Context.MkPower怎么用?C# Context.MkPower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Z3.Context
的用法示例。
在下文中一共展示了Context.MkPower方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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))
{
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));
}
}
示例2: 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));
}
}
示例3: 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");
RatNum zero = ctx.MkReal(0);
RatNum two = ctx.MkReal(2);
Goal g = ctx.MkGoal();
g.Assert(ctx.MkGe(ctx.MkSub(ctx.MkPower(x, two), ctx.MkPower(y, two)), zero));
Probe p = ctx.MkProbe("num-consts");
Probe p2 = ctx.Gt(p, ctx.Const(2));
Tactic t = ctx.Cond(p2, ctx.MkTactic("simplify"), ctx.MkTactic("factor"));
Console.WriteLine(t[g]);
g = ctx.MkGoal();
g.Assert(ctx.MkGe(ctx.MkAdd(x, x, y, z), zero));
g.Assert(ctx.MkGe(ctx.MkSub(ctx.MkPower(x, two), ctx.MkPower(y, two)), zero));
Console.WriteLine(t[g]);
}
}
示例4: Run
public void Run()
{
using (Context ctx = new Context())
{
Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 2)).Simplify());
ctx.UpdateParamValue(":pp-decimal-precision", "50");
ctx.UpdateParamValue(":pp-decimal", "true");
Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 2)).Simplify());
ctx.UpdateParamValue(":pp-decimal-precision", "20");
Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 2)).Simplify());
}
}
示例5: 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))));
}
示例6: 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");
Params ps = ctx.MkParams();
ps.Add(":som", true);
Expr q = ctx.MkPower(ctx.MkAdd(x, y), ctx.MkReal(3));
q = q.Simplify(ps);
Console.WriteLine(ps);
Console.WriteLine(q);
ps = ctx.MkParams();
ps.Add(":mul-to-power", true);
q = q.Simplify(ps);
Console.WriteLine(ps);
Console.WriteLine(q);
}
}
示例7: 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");
RealExpr z = ctx.MkRealConst("z");
RatNum two = ctx.MkReal(2);
Console.WriteLine(ctx.MkAdd(ctx.MkSub(ctx.MkMul(x, y), ctx.MkPower(y, two)), ctx.MkPower(z, two)));
Console.WriteLine(ctx.MkSub(ctx.MkAdd(ctx.MkMul(x, y), ctx.MkPower(y, two)), ctx.MkPower(z, two)));
Console.WriteLine(ctx.MkMul(ctx.MkAdd(x, y), z));
}
示例8: Run
public void Run()
{
using (Context ctx = new Context())
{
RealExpr x = ctx.MkRealConst("x");
RealExpr y = ctx.MkRealConst("y");
Solver s = ctx.Then(ctx.MkTactic("simplify"), ctx.MkTactic("nlsat")).Solver;
s.Assert(ctx.MkEq(ctx.MkPower(x, ctx.MkReal(2)), ctx.MkReal(2)),
ctx.MkEq(ctx.MkPower(y, ctx.MkReal(3)), ctx.MkAdd(x, ctx.MkReal(1))));
Console.WriteLine(s.Check());
ctx.UpdateParamValue(":pp-decimal", "true");
Console.WriteLine(s.Model);
Console.WriteLine(s.Statistics);
foreach (string k in s.Statistics.Keys)
Console.WriteLine(k);
Console.WriteLine("NLSAT stages: " + s.Statistics["nlsat stages"].Value);
Console.WriteLine("NLSAT propagations: " + s.Statistics["nlsat propagations"].Value);
}
}
示例9: 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));
}
}
示例10: Run
public void Run()
{
using (Context ctx1 = new Context(new Dictionary<string, string>() { { ":relevancy", "0" } }))
using (Context ctx2 = new Context(new Dictionary<string, string>() { { ":model", "false" },
{ ":pp-decimal", "true" },
{ ":relevancy", "2" },
{ ":pp-decimal-precision", "50" } }))
{
IntExpr x = ctx1.MkIntConst("x");
IntExpr _x = (IntExpr) x.Translate(ctx2);
Console.WriteLine(ctx2.MkEq(_x, ctx1.MkAdd(x, ctx1.MkInt(1)).Translate(ctx2)));
Console.WriteLine(ctx2.MkPower(ctx2.MkReal(2), ctx2.MkReal(1, 2)).Simplify());
Console.WriteLine(ctx1.MkPower(ctx1.MkReal(2), ctx1.MkReal(1, 2)).Simplify());
Solver s = ctx1.MkSolver();
s.Assert(ctx1.MkEq(x, ctx1.MkInt(2)));
Console.WriteLine(s);
Console.WriteLine(s.Check());
Console.WriteLine(s.Model);
s = ctx2.MkSolver();
s.Assert(ctx2.MkEq(_x, ctx2.MkInt(2)));
Console.WriteLine(s.Check());
try
{
Console.WriteLine(s.Model);
}
catch (Z3Exception ex)
{
Console.WriteLine("failed: " + ex.Message);
}
}
}
示例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");
IntExpr a = ctx.MkIntConst("a");
IntExpr b = ctx.MkIntConst("b");
IntExpr c = ctx.MkIntConst("c");
ctx.UpdateParamValue(":pp-flat-assoc", "false");
Console.WriteLine(ctx.MkAdd(x, y, ctx.MkInt2Real(a)));
Console.WriteLine(ctx.MkAdd(x, ctx.MkReal(1)));
Console.WriteLine(ctx.MkAdd(ctx.MkReal(2), y));
Console.WriteLine(ctx.MkMul(x, y));
Console.WriteLine(ctx.MkAdd(ctx.MkInt(2), ctx.MkInt(3)));
Console.WriteLine(ctx.MkMul(ctx.MkReal(2), x));
Console.WriteLine(ctx.MkAdd(ctx.MkInt2Real((IntExpr)ctx.MkAdd(ctx.MkInt(2), ctx.MkInt(3))), x));
Console.WriteLine(ctx.MkAdd((RealExpr)ctx.MkInt2Real((IntExpr)ctx.MkAdd(ctx.MkInt(2), ctx.MkInt(3))).Simplify(), x));
Console.WriteLine(ctx.MkAdd(a, b, ctx.MkInt(1)));
Console.WriteLine(ctx.MkDiv(x, y));
Console.WriteLine(ctx.MkDiv(x, ctx.MkReal(2)));
Console.WriteLine(ctx.MkDiv(ctx.MkReal(2), y));
Console.WriteLine(ctx.MkDiv(a, ctx.MkInt(2)));
Console.WriteLine(ctx.MkDiv(ctx.MkAdd(a, b), ctx.MkInt(2)));
Console.WriteLine(ctx.MkDiv(ctx.MkInt(3), a));
Console.WriteLine(ctx.MkMod(a, b));
Console.WriteLine(ctx.MkMod(a, ctx.MkInt(2)));
Console.WriteLine(ctx.MkMod(ctx.MkInt(3), a));
Console.WriteLine(ctx.MkSub(a, ctx.MkInt(2)));
Console.WriteLine(ctx.MkUnaryMinus(a));
Console.WriteLine(ctx.MkUnaryMinus(x));
Console.WriteLine(ctx.MkSub(a, b));
Console.WriteLine(a.IsAdd);
Console.WriteLine(ctx.MkAdd(a, b).IsAdd);
Console.WriteLine(ctx.MkSub(a, b).IsAdd);
Console.WriteLine(ctx.MkInt(10).IsAdd);
Console.WriteLine(ctx.MkMul(a, b).IsMul);
Console.WriteLine(ctx.MkMul(x, ctx.MkInt2Real(b)).IsMul);
Console.WriteLine(ctx.MkAdd(a, b).IsMul);
Console.WriteLine(ctx.MkDiv(a, ctx.MkInt(2)).IsDiv);
Console.WriteLine(ctx.MkDiv(ctx.MkReal(3), x).IsDiv);
Console.WriteLine(ctx.MkDiv(x,y).IsDiv);
Console.WriteLine(ctx.MkDiv(a, ctx.MkInt(2)).IsIDiv);
Console.WriteLine(ctx.MkAdd(ctx.MkInt(2), ctx.MkInt(3)).Simplify().IsAdd);
Console.WriteLine();
Console.WriteLine(a is ArithExpr);
Console.WriteLine(ctx.MkInt(2) is ArithExpr);
Console.WriteLine(ctx.MkAdd(a, b) is ArithExpr);
Console.WriteLine(ctx.MkBoolConst("p") is ArithExpr);
Console.WriteLine(ctx.MkInt(2) is IntNum);
Console.WriteLine(ctx.MkInt(2) is RatNum);
Console.WriteLine(ctx.MkReal(2, 3));
Console.WriteLine(ctx.MkReal(2, 3).IsReal);
Console.WriteLine(ctx.MkReal(2, 3) is ArithExpr);
Console.WriteLine(ctx.MkReal(2, 3).IsConst);
Console.WriteLine(ctx.MkReal(2, 3).Simplify() is RatNum);
Console.WriteLine(ctx.MkReal(2, 3).Simplify().IsRatNum);
Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 2)).Simplify().IsAlgebraicNumber);
Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 2)).Simplify() is AlgebraicNum);
Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 2)).IsAlgebraicNumber);
Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 2)) is AlgebraicNum);
Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 2)));
Console.WriteLine(ctx.MkPower(ctx.MkReal(2), ctx.MkReal(1, 3)));
}
}