当前位置: 首页>>代码示例>>C#>>正文


C# Context.MkFixedpoint方法代码示例

本文整理汇总了C#中Microsoft.Z3.Context.MkFixedpoint方法的典型用法代码示例。如果您正苦于以下问题:C# Context.MkFixedpoint方法的具体用法?C# Context.MkFixedpoint怎么用?C# Context.MkFixedpoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Z3.Context的用法示例。


在下文中一共展示了Context.MkFixedpoint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

 public void Run()
 {
     using (Context ctx = new Context()) {
         var s = ctx.MkFixedpoint();
         BoolSort B = ctx.BoolSort;
         Sort BV8   = ctx.MkBitVecSort(8);
         FuncDecl edge = ctx.MkFuncDecl("edge", new Sort[]{BV8, BV8}, B);
         FuncDecl path = ctx.MkFuncDecl("path", new Sort[]{BV8, BV8}, B);
         BitVecExpr x = (BitVecExpr)ctx.MkBound(0,BV8);
         BitVecExpr y = (BitVecExpr)ctx.MkBound(1,BV8);
         BitVecExpr z = (BitVecExpr)ctx.MkBound(2,BV8);
         s.RegisterRelation(edge);
         s.RegisterRelation(path);
         s.AddRule(ctx.MkImplies((BoolExpr)edge[x,y],(BoolExpr)path[x,y]));
         s.AddRule(ctx.MkImplies(ctx.MkAnd((BoolExpr)path[x,y],(BoolExpr)path[y,z]),
                                 (BoolExpr)path[x,z]));
         for (uint i = 0; i < 128; ++i) {
            s.AddFact(edge, i, i+1);
         }
         Console.WriteLine(s.Query((BoolExpr)path[ctx.MkBV(0,8),ctx.MkBV(129,8)]));
         Console.WriteLine(s.GetAnswer());
         Console.WriteLine(s.Query((BoolExpr)path[ctx.MkBV(0,8),ctx.MkBV(128,8)]));
         Console.WriteLine(s.GetAnswer());
         Console.WriteLine(s.Query((BoolExpr)path[x,ctx.MkBV(20,8)]));
         Console.WriteLine(s.GetAnswer());
         Console.WriteLine(s.Query(ctx.MkAnd((BoolExpr)path[x,y],
                                             (BoolExpr)path[y,ctx.MkBV(20,8)])));
         Console.WriteLine(s.GetAnswer());
     }
 }
开发者ID:ahorn,项目名称:z3test,代码行数:30,代码来源:fixedpoint.7.cs

示例2: Run

    public void Run()
    {
        using (Context ctx = new Context()) {
            ctx.UpdateParamValue("DL_ENGINE","1");
            ctx.UpdateParamValue("DL_PDR_USE_FARKAS","true");
        //          ctx.UpdateParamValue("VERBOSE","2");
            var s = ctx.MkFixedpoint();
            BoolSort B = ctx.BoolSort;
            IntSort I = ctx.IntSort;
            FuncDecl mc = ctx.MkFuncDecl("mc", new Sort[]{I, I}, B);
            ArithExpr x = (ArithExpr)ctx.MkBound(0,I);
            ArithExpr y = (ArithExpr)ctx.MkBound(1,I);
            ArithExpr z = (ArithExpr)ctx.MkBound(2,I);
            s.RegisterRelation(mc);
            BoolExpr gt = ctx.MkGt(x, ctx.MkInt(100));
            s.AddRule(ctx.MkImplies(gt,(BoolExpr)mc[x,ctx.MkSub(x,ctx.MkInt(10))]));
            s.AddRule(ctx.MkImplies(ctx.MkAnd(ctx.MkNot(gt),
                                      (BoolExpr) mc[ctx.MkAdd(x,ctx.MkInt(11)),y],
                                      (BoolExpr) mc[y,z]),
                                      (BoolExpr) mc[x,z]));
            Console.WriteLine(s.Query(ctx.MkAnd((BoolExpr)mc[x,y], ctx.MkGt(y,ctx.MkInt(100)))));
            Console.WriteLine(s.GetAnswer());

            Console.WriteLine(s.Query(ctx.MkAnd((BoolExpr)mc[x,y], ctx.MkLt(y,ctx.MkInt(91)))));
            Console.WriteLine(s.GetAnswer());
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:27,代码来源:fixedpoint4.cs

示例3: Run

 public void Run()
 {
     using (Context ctx = new Context()) {
         var s = ctx.MkFixedpoint();
         BoolExpr a = ctx.MkBoolConst("a");
         BoolExpr b = ctx.MkBoolConst("b");
         BoolExpr c = ctx.MkBoolConst("c");
         s.RegisterRelation(a.FuncDecl);
         s.RegisterRelation(b.FuncDecl);
         s.RegisterRelation(c.FuncDecl);
         s.AddRule(ctx.MkImplies(a, b));
         s.AddRule(ctx.MkImplies(b, c));
         Console.WriteLine(s.Query(c));
         s.AddRule(a);
         Console.WriteLine(s.Query(c));
     }
 }
开发者ID:ahorn,项目名称:z3test,代码行数:17,代码来源:fixedpoint1.cs

示例4: Run

    public void Run()
    {
        using (Context ctx = new Context())
        {
            Console.WriteLine("Simplify");
            Symbol[] sp = ctx.SimplifyParameterDescriptions.Names;
            foreach (var s in sp) {
                Console.WriteLine("{0}",s);
            }

            Console.WriteLine("Fixedpoint");
        Fixedpoint fp = ctx.MkFixedpoint();
            sp = fp.ParameterDescriptions.Names;
            foreach (var s in sp) {
                Console.WriteLine("{0}",s);
            }

        }
    }
开发者ID:ahorn,项目名称:z3test,代码行数:19,代码来源:param_descrs.cs

示例5: Run

 public void Run()
 {
     using (Context ctx = new Context()) {
         var s = ctx.MkFixedpoint();
         BoolSort B = ctx.BoolSort;
         Sort BV8     = ctx.MkBitVecSort(8);
         FuncDecl f = ctx.MkFuncDecl("f", BV8, B);
         FuncDecl g = ctx.MkFuncDecl("g", BV8, B);
         BitVecExpr b0 = (BitVecExpr)ctx.MkBound(0,BV8);
         s.RegisterRelation(f);
         s.RegisterRelation(g);
         s.AddRule((BoolExpr)f[b0]);
         BitVecExpr mask0 = ctx.MkBV(0xFE,8);
         BoolExpr even = ctx.MkEq(b0,ctx.MkBVAND(b0,mask0));
         s.AddRule(ctx.MkImplies(ctx.MkAnd((BoolExpr)f[b0],even), (BoolExpr)g[b0]));
         Console.WriteLine(s.Query((BoolExpr)g[b0]));
         Console.WriteLine(s.GetAnswer());
     }
 }
开发者ID:ExiaHan,项目名称:z3test,代码行数:19,代码来源:fixedpoint2.cs

示例6: Run

    public void Run()
    {
        using (Context ctx = new Context())
        {
            this.ctx = ctx;
            ctx.UpdateParamValue("DL_GENERATE_EXPLANATIONS", "true");

            red_car = new Car(false, 2, 2, 3, "red");
            cars = new Car[]{
                new Car(true, 0, 3, 0, "yellow"),
                new Car(false, 3, 3, 0, "blue"),
                new Car(false, 5, 2, 0, "brown"),
                new Car(false, 0, 2, 1, "lgreen"),
                new Car(true,  1, 2, 1, "light blue"),
                new Car(true,  2, 2, 1, "pink"),
                new Car(true,  2, 2, 4, "dark green"),
                red_car,
                new Car(true,  3, 2, 3, "purple"),
                new Car(false, 5, 2, 3, "light yellow"),
                new Car(true,  4, 2, 0, "orange"),
                new Car(false, 4, 2, 4, "black"),
                new Car(true,  5, 3, 1, "light purple")
                };

            this.num_cars = cars.Length;
            this.B = ctx.MkBoolSort();
            this.bv3 = ctx.MkBitVecSort(3);
            List<Sort> domain = new List<Sort>();
            foreach (var c in cars) domain.Add(bv3);
            this.state = ctx.MkFuncDecl("state", domain.ToArray(), B);
            this.fp = ctx.MkFixedpoint();
            this.fp.RegisterRelation(state);

            // Initial state:

            Expr[] args = new Expr[num_cars];
            for (int i = 0; i < num_cars; ++i) args[i] = num(cars[i].start);
            fp.AddRule((BoolExpr)state[args]);

            // Transitions:
            for (int pos = 0; pos < num_cars; ++pos)
            {
                Car car = cars[pos];
                for (int i = 0; i < dimension; ++i)
                    if (car.is_vertical)
                    {
                        move_down(i, pos, car);
                        move_up(i, pos, car);
                    }
                    else
                    {
                        move_left(i, pos, car);
                        move_right(i, pos, car);
                    }
            }

            // Print the current context:
            Console.WriteLine("{0}", fp);

            // Prepare the query:
            for (int i = 0; i < num_cars; ++i) args[i] = (cars[i] == red_car) ? num(4) : bound(i);
            BoolExpr goal = (BoolExpr)state[args];
            fp.Query(goal);

            // Extract a path:
            get_instructions(fp.GetAnswer());
        }
    }
开发者ID:ahorn,项目名称:z3test,代码行数:68,代码来源:fixedpoint.6.cs


注:本文中的Microsoft.Z3.Context.MkFixedpoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。