本文整理汇总了C#中Microsoft.Z3.Context.MkSimpleSolver方法的典型用法代码示例。如果您正苦于以下问题:C# Context.MkSimpleSolver方法的具体用法?C# Context.MkSimpleSolver怎么用?C# Context.MkSimpleSolver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Z3.Context
的用法示例。
在下文中一共展示了Context.MkSimpleSolver方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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)"
}
示例2: Solve
internal ObjectTheoremResult Solve()
{
var settings = new Dictionary<string, string> {
{ "model", "true" },
{ "unsat_core", "true" }
};
using (var context = new Context(settings))
{
var stopwatch = Stopwatch.StartNew();
Environment environment = GenerateEnvironment(context);
BoolExpr[] assertions = GenerateConstraints(context, environment, _assertions);
BoolExpr[] allAssertions = GenerateAllConstraints(context, environment, _allAssertions);
Solver solver = context.MkSimpleSolver();
int assertionCount = 0;
foreach (var assertion in assertions.Concat(allAssertions))
{
assertionCount++;
solver.Assert(assertion);
}
int assumptionCount = 0;
var assumptions = new Dictionary<LambdaExpression, BoolExpr>();
foreach (var assumption in _assumptions)
{
var generator = new LambdaExpressionToConstraintGenerator(context, environment);
var assumptionExpr = generator.Visit(assumption);
var assumptionCheck = context.MkBoolConst(Guid.NewGuid().ToString());
solver.Assert(context.MkEq(assumptionExpr, assumptionCheck));
assumptionCount++;
assumptions.Add(assumption, assumptionCheck);
}
stopwatch.Stop();
var constraintGenerationTimeSpan = stopwatch.Elapsed;
var solverString = solver.ToString();
var totalConstraintsCount = solverString.Split('\n').Count(l => l.StartsWith(" ("));
Trace.WriteLine("Statistics:");
Trace.WriteLine("assertionCount: " + assertionCount);
Trace.WriteLine("assumptionCount: " + assumptionCount);
Trace.WriteLine("totalConstraintsCount: " + totalConstraintsCount);
Trace.WriteLine("constraintGenerationTimeSpan: " + constraintGenerationTimeSpan);
var classCount = environment.Types.Count(t => !t.Key.IsValueType && t.Key.Name != "String");
var propertyCount = environment.Types
.Where(t => !t.Key.IsValueType && t.Key.Name != "String")
.Select(p => p.Key.GetProperties())
.Count();
stopwatch.Restart();
Microsoft.Z3.Status status = solver.Check(assumptions.Values.ToArray());
stopwatch.Stop();
var solvingTimeSpan = stopwatch.Elapsed;
Trace.WriteLine("solvingTimeSpan: " + solvingTimeSpan);
if (status != Microsoft.Z3.Status.SATISFIABLE)
{
if (solver.UnsatCore.Length > 0)
{
var result = new ObjectTheoremResult(context, environment, solver, status);
result.SetUnsatCore(assumptions, solver.UnsatCore);
return result;
}
return null;
}
var modelString = solver.Model.ToString();
return new ObjectTheoremResult(context, environment, solver, status);
}
}