Gt() public method

Create a probe that evaluates to "true" when the value returned by p1 is greater than the value returned by p2
public Gt ( Probe p1, Probe p2 ) : Probe
p1 Probe
p2 Probe
return Probe
Exemplo n.º 1
0
    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");
            RatNum zero = ctx.MkReal(0);
            RatNum two = ctx.MkReal(2);

            Goal g = ctx.MkGoal();

            g.Assert(ctx.MkGe(ctx.MkSub(ctx.MkPower(x, two), ctx.MkPower(y, two)), zero));

            Probe p = ctx.MkProbe("num-consts");
            Probe p2 = ctx.Gt(p, ctx.Const(2));
            Tactic t = ctx.Cond(p2, ctx.MkTactic("simplify"), ctx.MkTactic("factor"));

            Console.WriteLine(t[g]);

            g = ctx.MkGoal();
            g.Assert(ctx.MkGe(ctx.MkAdd(x, x, y, z), zero));
            g.Assert(ctx.MkGe(ctx.MkSub(ctx.MkPower(x, two), ctx.MkPower(y, two)), zero));

            Console.WriteLine(t[g]);
        }
    }
Exemplo n.º 2
0
    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");

            Goal g = ctx.MkGoal();
            g.Assert(ctx.MkGt(ctx.MkAdd(x, y, z), ctx.MkReal(0)));

            Probe p = ctx.MkProbe("num-consts");
            Console.WriteLine("num-consts: " + p.Apply(g));

            Tactic t = ctx.FailIf(ctx.Gt(p, ctx.Const(2)));

            try
            {
                t.Apply(g);
            }
            catch (Z3Exception ex)
            {
                Console.WriteLine("Tactic failed: " + ex.Message);
            }

            Console.WriteLine("trying again...");

            g = ctx.MkGoal();
            g.Assert(ctx.MkGt(ctx.MkAdd(x, y), ctx.MkReal(0)));

            Console.WriteLine(t[g]);

        }
    }