MkExists() public method

Create an existential Quantifier.
public MkExists ( Expr boundConstants, Expr body, uint weight = 1, Pattern patterns = null, Expr noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null ) : Quantifier
boundConstants Expr
body Expr
weight uint
patterns Pattern
noPatterns Expr
quantifierID Symbol
skolemID Symbol
return Quantifier
コード例 #1
0
ファイル: memory.cs プロジェクト: ExiaHan/z3test
 /// <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
0
ファイル: quant.1.cs プロジェクト: ahorn/z3test
    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
0
 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();
 }