本文整理汇总了C#中Microsoft.Z3.Context.MkReal方法的典型用法代码示例。如果您正苦于以下问题:C# Context.MkReal方法的具体用法?C# Context.MkReal怎么用?C# Context.MkReal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Z3.Context
的用法示例。
在下文中一共展示了Context.MkReal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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]);
}
}
示例2: 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");
RatNum zero = ctx.MkReal(0);
RatNum two = ctx.MkReal(2);
Goal g = ctx.MkGoal();
g.Assert(ctx.MkGt(x, zero));
g.Assert(ctx.MkGt(y, zero));
g.Assert(ctx.MkEq(x, ctx.MkAdd(y, two)));
Console.WriteLine(g);
Tactic t1 = ctx.MkTactic("simplify");
Tactic t2 = ctx.MkTactic("solve-eqs");
Tactic t = ctx.AndThen(t1, t2);
Console.WriteLine(t[g]);
}
}
示例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[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));
}
}
示例4: 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");
Solver s = ctx.MkSolver();
s.Assert(ctx.MkGt(x, ctx.MkReal(1)),
ctx.MkGt(y, ctx.MkReal(1)),
ctx.MkOr(ctx.MkGt(ctx.MkAdd(x, y), ctx.MkReal(1)),
ctx.MkLt(ctx.MkSub(x, y), ctx.MkReal(2))));
Console.WriteLine("asserted constraints: ");
foreach (var c in s.Assertions)
Console.WriteLine(c);
Console.WriteLine(s.Check());
Console.WriteLine(s.Statistics);
Console.WriteLine("stats for last check: ");
foreach (Statistics.Entry e in s.Statistics.Entries)
Console.WriteLine(e);
}
}
示例5: 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")));
ApplyResult ar = t[g];
foreach (var sg in ar.Subgoals)
Console.WriteLine(sg);
}
}
示例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");
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]);
}
}
示例7: 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());
}
}
示例8: 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))));
}
示例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()
{
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);
}
}
示例11: Run
public void Run()
{
using (Context ctx = new Context())
{
RealExpr x = ctx.MkRealConst("x");
RealExpr y = ctx.MkRealConst("y");
Goal g = ctx.MkGoal();
g.Assert(ctx.MkGt(x, ctx.MkReal(10)), ctx.MkEq(y, ctx.MkAdd(x, ctx.MkReal(1))));
g.Assert(ctx.MkGt(y, ctx.MkReal(1)));
Console.WriteLine(ctx.MkProbe("num-consts").Apply(g));
Console.WriteLine(ctx.MkProbe("size").Apply(g));
Console.WriteLine(ctx.MkProbe("num-exprs").Apply(g));
}
}
示例12: 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));
}
}
示例13: Run
public void Run()
{
using (Context ctx = new Context())
{
RealExpr x = ctx.MkRealConst("x");
RealExpr y = ctx.MkRealConst("y");
Goal g = ctx.MkGoal();
g.Assert(ctx.MkGt(x, ctx.MkReal(10)), ctx.MkEq(y, ctx.MkAdd(x, ctx.MkReal(1))));
g.Assert(ctx.MkGt(y, ctx.MkReal(1)));
Tactic t = ctx.MkTactic("simplify");
ApplyResult r = t.Apply(g);
Console.WriteLine(r);
Console.WriteLine(g.Size);
foreach (Goal s in r.Subgoals)
Console.WriteLine(s);
Console.WriteLine("Old goal: ");
Console.WriteLine(g);
t = ctx.Then(ctx.MkTactic("simplify"), ctx.MkTactic("solve-eqs"));
r = t.Apply(g);
Console.WriteLine(r);
Solver solver = ctx.MkSolver();
foreach (BoolExpr f in r.Subgoals[0].Formulas)
solver.Assert(f);
Console.WriteLine(solver);
Console.WriteLine(solver.Check());
Console.WriteLine(solver.Model);
Console.WriteLine("applying model convert");
Console.WriteLine(r.ConvertModel(0, solver.Model));
Console.WriteLine("done");
}
}
示例14: 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));
}
}
示例15: 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);
}
}