本文整理汇总了C#中Microsoft.Z3.Context.Then方法的典型用法代码示例。如果您正苦于以下问题:C# Context.Then方法的具体用法?C# Context.Then怎么用?C# Context.Then使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Z3.Context
的用法示例。
在下文中一共展示了Context.Then方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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))
{
BitVecExpr x = ctx.MkBVConst("x", 16);
BitVecExpr y = ctx.MkBVConst("y", 16);
Params p = ctx.MkParams();
p.Add(":mul2concat", true);
Tactic t = ctx.Then(ctx.UsingParams(ctx.MkTactic("simplify"), p),
ctx.MkTactic("solve-eqs"),
ctx.MkTactic("bit-blast"),
ctx.MkTactic("aig"),
ctx.MkTactic("sat"));
Solver s = ctx.MkSolver(t);
s.Assert(ctx.MkEq(ctx.MkBVAdd(ctx.MkBVMul(x, ctx.MkBV(32, 16)), y), ctx.MkBV(13, 16)));
s.Assert(ctx.MkBVSLT(ctx.MkBVAND(x, y), ctx.MkBV(10, 16)));
s.Assert(ctx.MkBVSGT(y, ctx.MkBV(-100, 16)));
Console.WriteLine(s.Check());
Model m = s.Model;
Console.WriteLine(m);
Console.WriteLine(ctx.MkBVAdd(ctx.MkBVMul(x, ctx.MkBV(32, 16)), y) + " == " + m.Evaluate(ctx.MkBVAdd(ctx.MkBVMul(x, ctx.MkBV(32, 16)), y)));
Console.WriteLine(ctx.MkBVAND(x, y) + " == " + m.Evaluate(ctx.MkBVAND(x, y)) );
}
}
示例3: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
Params p = ctx.MkParams();
p.Add(":arith-lhs", true);
p.Add(":som", true);
Solver s = ctx.Then(ctx.With(ctx.MkTactic("simplify"), p),
ctx.MkTactic("normalize-bounds"),
ctx.MkTactic("lia2pb"),
ctx.MkTactic("pb2bv"),
ctx.MkTactic("bit-blast"),
ctx.MkTactic("sat")).Solver;
IntExpr x = ctx.MkIntConst("x");
IntExpr y = ctx.MkIntConst("y");
IntExpr z = ctx.MkIntConst("z");
s.Assert(new BoolExpr[] { ctx.MkGt(x, ctx.MkInt(0)),
ctx.MkLt(x, ctx.MkInt(10)),
ctx.MkGt(y, ctx.MkInt(0)),
ctx.MkLt(y, ctx.MkInt(10)),
ctx.MkGt(z, ctx.MkInt(0)),
ctx.MkLt(z, ctx.MkInt(10)),
ctx.MkEq(ctx.MkAdd(ctx.MkMul(ctx.MkInt(3), y),
ctx.MkMul(ctx.MkInt(2), x)), z) });
Console.WriteLine(s.Check());
Console.WriteLine(s.Model);
s.Reset();
s.Assert(ctx.MkEq(ctx.MkAdd(ctx.MkMul(ctx.MkInt(3), y),
ctx.MkMul(ctx.MkInt(2), x)), z));
Console.WriteLine(s.Check());
}
}
示例4: 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", 16);
BitVecExpr y = ctx.MkBVConst("y", 16);
Tactic t = ctx.Then(ctx.MkTactic("simplify"), ctx.MkTactic("solve-eqs"), ctx.MkTactic("bit-blast"), ctx.MkTactic("sat"));
Solver s = ctx.MkSolver(t);
s.Assert(ctx.MkEq(ctx.MkBVOR(x, y), ctx.MkBV(13, 16)));
s.Assert(ctx.MkBVSGT(x, y));
Console.WriteLine(s.Check());
Console.WriteLine(s.Model);
}
}
示例5: 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");
}
}
示例6: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
Tactic t = ctx.Then(ctx.MkTactic("simplify"),
ctx.MkTactic("normalize-bounds"),
ctx.MkTactic("solve-eqs"));
IntExpr x = ctx.MkIntConst("x");
IntExpr y = ctx.MkIntConst("y");
IntExpr z = ctx.MkIntConst("z");
Goal g = ctx.MkGoal();
g.Assert(ctx.MkGt(x, ctx.MkInt(10)));
g.Assert(ctx.MkEq(y, ctx.MkAdd(x, ctx.MkInt(3))));
g.Assert(ctx.MkGt(z, y));
ApplyResult r = t[g];
Console.WriteLine(r);
Solver s = ctx.MkSolver();
s.Assert(r.Subgoals[0].Formulas);
Console.WriteLine(s.Check());
Console.WriteLine("subgoal model");
Model sgm = s.Model;
Console.WriteLine(sgm);
Console.WriteLine("converted model");
Model m = r.ConvertModel(0, sgm);
Console.WriteLine(m);
Console.WriteLine(m.Evaluate(x));
}
}
示例7: 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);
}
}