本文整理汇总了C#中Microsoft.Z3.Context.MkParams方法的典型用法代码示例。如果您正苦于以下问题:C# Context.MkParams方法的具体用法?C# Context.MkParams怎么用?C# Context.MkParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Z3.Context
的用法示例。
在下文中一共展示了Context.MkParams方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
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);
}
}
示例2: 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());
}
}
示例3: 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)) );
}
}
示例4: Main
public static void Main()
{
Context ctx = new Context();
Params p = ctx.MkParams();
p.Add("blah", "blah"); // Invalid parameter.
Solver s = ctx.MkSolver();
s.Parameters = p;
s.Check(); // Complains by throwing an assertion (OK).
}
示例5: Main
public static void Main()
{
Context ctx = new Context();
Params p = ctx.MkParams();
p.Add("blah", "blah"); // invalid parameter name
Tactic t1 = ctx.MkTactic("smt");
Tactic t2 = ctx.UsingParams(t1, p);
Solver s = ctx.MkSolver(t2);
s.Check();
}
示例6: Main
public static void Main()
{
Context ctx = new Context();
Params p = ctx.MkParams();
p.Add("smt.arith.nl", true);
p.Add("smt.arith.nl.rounds", 42);
Solver s = ctx.MkSolver();
s.Parameters = p;
Console.WriteLine(s); // says "(solver)"
s = ctx.MkSimpleSolver();
s.Parameters = p;
Console.WriteLine(s); // should also say "(solver)"
}
示例7: 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(":arith-lhs", true);
Expr q = ctx.MkEq(x, ctx.MkAdd(y, ctx.MkReal(2)));
q = q.Simplify(ps);
Console.WriteLine(ps);
Console.WriteLine(q);
}
}
示例8: 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());
}
}
示例9: ConstructSolver
/// <summary>
/// Constructs a Z3 solver to be used.
/// </summary>
internal void ConstructSolver(Z3BaseParams parameters)
{
// If Z3 is there already, kill it
if (_context != null)
{
DestructSolver(false);
}
_context = new Context();
_optSolver = _context.MkOptimize();
var p = _context.MkParams();
switch (parameters.OptKind)
{
case OptimizationKind.BoundingBox:
p.Add("priority", _context.MkSymbol("box"));
break;
case OptimizationKind.Lexicographic:
p.Add("priority", _context.MkSymbol("lex"));
break;
case OptimizationKind.ParetoOptimal:
p.Add("priority", _context.MkSymbol("pareto"));
break;
default:
Debug.Assert(false, String.Format("Unknown optimization option {0}", parameters.OptKind));
break;
}
switch (parameters.CardinalityAlgorithm)
{
case CardinalityAlgorithm.FuMalik:
p.Add("maxsat_engine", _context.MkSymbol("fu_malik"));
break;
case CardinalityAlgorithm.CoreMaxSAT:
p.Add("maxsat_engine", _context.MkSymbol("core_maxsat"));
break;
default:
Debug.Assert(false, String.Format("Unknown cardinality algorithm option {0}", parameters.CardinalityAlgorithm));
break;
}
switch (parameters.PseudoBooleanAlgorithm)
{
case PseudoBooleanAlgorithm.WeightedMaxSAT:
p.Add("wmaxsat_engine", _context.MkSymbol("wmax"));
break;
case PseudoBooleanAlgorithm.IterativeWeightedMaxSAT:
p.Add("wmaxsat_engine", _context.MkSymbol("iwmax"));
break;
case PseudoBooleanAlgorithm.BisectionWeightedMaxSAT:
p.Add("wmaxsat_engine", _context.MkSymbol("bwmax"));
break;
case PseudoBooleanAlgorithm.WeightedPartialMaxSAT2:
p.Add("wmaxsat_engine", _context.MkSymbol("wpm2"));
break;
default:
Debug.Assert(false, String.Format("Unknown pseudo-boolean algorithm option {0}", parameters.PseudoBooleanAlgorithm));
break;
}
switch (parameters.ArithmeticStrategy)
{
case ArithmeticStrategy.Basic:
p.Add("engine", _context.MkSymbol("basic"));
break;
case ArithmeticStrategy.Farkas:
p.Add("engine", _context.MkSymbol("farkas"));
break;
default:
Debug.Assert(false, String.Format("Unknown arithmetic strategy option {0}", parameters.ArithmeticStrategy));
break;
}
_optSolver.Parameters = p;
}
示例10: Disprove
static void Disprove(Context ctx, BoolExpr f, bool useMBQI = false, params BoolExpr[] assumptions)
{
Console.WriteLine("Disproving: " + f);
Solver s = ctx.MkSolver();
Params p = ctx.MkParams();
p.Add("mbqi", useMBQI);
s.Parameters = p;
foreach (BoolExpr a in assumptions)
s.Assert(a);
s.Assert(ctx.MkNot(f));
Status q = s.Check();
switch (q)
{
case Status.UNKNOWN:
Console.WriteLine("Unknown because: " + s.ReasonUnknown);
break;
case Status.SATISFIABLE:
Console.WriteLine("OK, model: " + s.Model);
break;
case Status.UNSATISFIABLE:
throw new TestFailedException();
}
}