本文整理汇总了C#中Microsoft.Z3.Context.MkExists方法的典型用法代码示例。如果您正苦于以下问题:C# Context.MkExists方法的具体用法?C# Context.MkExists怎么用?C# Context.MkExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Z3.Context
的用法示例。
在下文中一共展示了Context.MkExists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MkRandomExpr
/// <summary>
/// Generates a slightly randomized expression.
/// </summary>
static BoolExpr MkRandomExpr(Context ctx, System.Random rng)
{
int limit = 1073741823;
Sort i = ctx.IntSort;
Sort b = ctx.BoolSort;
Symbol sr1 = ctx.MkSymbol(rng.Next(0, limit));
Symbol sr2 = ctx.MkSymbol(rng.Next(0, limit));
Symbol sr3 = ctx.MkSymbol(rng.Next(0, limit));
FuncDecl r1 = ctx.MkFuncDecl(sr1, i, b);
FuncDecl r2 = ctx.MkFuncDecl(sr2, i, b);
FuncDecl r3 = ctx.MkFuncDecl(sr3, i, b);
Symbol s = ctx.MkSymbol(rng.Next(0, limit));
Expr x = ctx.MkConst(s, i);
BoolExpr r1x = (BoolExpr)ctx.MkApp(r1, x);
BoolExpr r2x = (BoolExpr)ctx.MkApp(r2, x);
BoolExpr r3x = (BoolExpr)ctx.MkApp(r3, x);
Expr[] vars = { x };
BoolExpr rl1 = ctx.MkForall(vars, ctx.MkImplies(r1x, r2x));
BoolExpr rl2 = ctx.MkForall(vars, ctx.MkImplies(r2x, r1x));
BoolExpr rl3 = (BoolExpr)ctx.MkApp(r1, ctx.MkInt(3));
BoolExpr q = (BoolExpr)ctx.MkApp(r3, ctx.MkInt(2));
BoolExpr a1 = ctx.MkNot(q);
BoolExpr q1 = ctx.MkExists(vars, ctx.MkAnd(r3x, r2x));
BoolExpr q2 = ctx.MkExists(vars, ctx.MkAnd(r3x, r1x));
BoolExpr[] all = { a1, q1, q2 };
return ctx.MkAnd(all);
}
示例2: Run
public void Run()
{
Dictionary<string, string> cfg = new Dictionary<string, string>() {
{ "AUTO_CONFIG", "true" } };
using (Context ctx = new Context(cfg))
{
FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { ctx.IntSort, ctx.IntSort }, ctx.IntSort);
IntExpr x = ctx.MkIntConst("x");
IntExpr y = ctx.MkIntConst("y");
Console.WriteLine(ctx.MkForall(new Expr[] { x, y }, ctx.MkEq(f[x, y], ctx.MkInt(0))));
Console.WriteLine(ctx.MkExists(new Expr[] { x }, ctx.MkGe((ArithExpr)f[x, x], ctx.MkInt(0))));
IntExpr a = ctx.MkIntConst("a");
IntExpr b = ctx.MkIntConst("b");
Solver s = ctx.MkSolver();
s.Assert(ctx.MkForall(new Expr[] { x }, ctx.MkEq(f[x, x], ctx.MkInt(0))));
s.Assert(ctx.MkEq(f[a, b], ctx.MkInt(1)));
Console.WriteLine(s.Check());
Console.WriteLine(s.Model);
}
}
示例3: toZ3Bool
public override BoolExpr toZ3Bool(Context ctx)
{
var qf = quantified_variables.Select(x => x.toZ3(ctx)).ToArray();
if (this.quantifier == Quantifier.Exists)
return ctx.MkExists(qf, inner.toZ3Bool(ctx));
else if (this.quantifier == Quantifier.Forall)
return ctx.MkForall(qf, inner.toZ3Bool(ctx));
else
throw new ArgumentException();
}