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


C# Context.MkUninterpretedSort方法代码示例

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


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

示例1: Run

    public void Run()
    {
        Dictionary<string, string> cfg = new Dictionary<string, string>() {
            { "AUTO_CONFIG", "true" } };

        using (Context ctx = new Context(cfg))
        {
            Sort A = ctx.MkUninterpretedSort("A");
            Sort B = ctx.MkUninterpretedSort("B");

            FuncDecl f = ctx.MkFuncDecl("f", A, B);

            Expr a1 = ctx.MkConst("a1", A);
            Expr a2 = ctx.MkConst("a2", A);
            Expr b = ctx.MkConst("b", B);
            Expr x = ctx.MkConst("x", A);
            Expr y = ctx.MkConst("y", A);

            Solver s = ctx.MkSolver();

            s.Assert(ctx.MkNot(ctx.MkEq(a1, a2)));
            s.Assert(ctx.MkEq(f[a1], b));
            s.Assert(ctx.MkEq(f[a2], b));
            s.Assert(ctx.MkForall(new Expr[] { x, y }, ctx.MkImplies(ctx.MkEq(f[x], f[y]),
                                                                     ctx.MkEq(x, y)),
                                                       1,
                                                       new Pattern[] { ctx.MkPattern(f[x], f[y]) }));
            Console.WriteLine(s);
            Console.WriteLine(s.Check());
        }
    }
开发者ID:ahorn,项目名称:z3test,代码行数:31,代码来源:quant.7.cs

示例2: Run

    public void Run()
    {
        using (Context ctx = new Context())
        {
            Sort U = ctx.MkUninterpretedSort("U");
            Console.WriteLine(U);
            Expr a = ctx.MkConst("a", U);

            a = ctx.MkConst("a", U);
            Expr b = ctx.MkConst("b", U);
            Expr c = ctx.MkConst("c", U);

            IntExpr x = ctx.MkIntConst("x");
            IntExpr y = ctx.MkIntConst("y");

            Console.WriteLine(ctx.MkAnd(ctx.MkEq(a, b), ctx.MkEq(a, c)));
            Console.WriteLine(U == ctx.IntSort);

            Sort U2 = ctx.MkUninterpretedSort("U");
            Console.WriteLine(U == U2);

            U2 = ctx.MkUninterpretedSort("U2");
            Console.WriteLine(U == U2);
            Console.WriteLine(ctx.MkDistinct(a, b, c));

            FuncDecl f = ctx.MkFuncDecl("f", new Sort[] { U, U }, U);
            Console.WriteLine(ctx.MkEq(f[a,b], b));
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:29,代码来源:tst8.cs

示例3: Run

    public void Run()
    {
        using (Context ctx = new Context())
        {
            Sort U = ctx.MkUninterpretedSort("U");
            FuncDecl f = ctx.MkFuncDecl("f", U, U);
            Expr a = ctx.MkConst("a", U);
            Expr b = ctx.MkConst("b", U);
            Expr c = ctx.MkConst("c", U);

            Solver s = ctx.MkSolver();
            s.Assert(ctx.MkEq(f[f[a]], b),
                     ctx.MkNot(ctx.MkEq(f[b], c)),
                     ctx.MkEq(f[c], c));
            Console.WriteLine(s.Check());
            Model m = s.Model;
            foreach (FuncDecl d in m.Decls)
                if (d.DomainSize == 0)
                    Console.WriteLine(d.Name + " -> " + m.ConstInterp(d));
                else
                    Console.WriteLine(d.Name + " -> " + m.FuncInterp(d));

            Console.WriteLine(m.NumSorts);
            Console.WriteLine(m.Sorts[0]);

            foreach(Sort srt in m.Sorts)
                Console.WriteLine(srt);

            foreach (Expr v in m.SortUniverse(U))
                Console.WriteLine(v);
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:32,代码来源:tst16.cs

示例4: Run

    public void Run()
    {
        Dictionary<string, string> cfg = new Dictionary<string, string>() {
            { "AUTO_CONFIG", "true" } };

        using (Context ctx = new Context(cfg))
        {
            Sort A = ctx.MkUninterpretedSort("A");
            Expr x = ctx.MkConst("x", A);
            Expr y = ctx.MkConst("y", A);
            FuncDecl f = ctx.MkFuncDecl("f", A, A);

            Solver s = ctx.MkSolver();
            s.Assert(ctx.MkEq(f[f[x]], x),
                     ctx.MkEq(f[x], y),
                     ctx.MkNot(ctx.MkEq(x, y)));

            Console.WriteLine(s.Check());
            Model m = s.Model;
            Console.WriteLine(m);
            Console.WriteLine("interpretation assigned to A: ");
            foreach (Expr a in m.SortUniverse(A))
                Console.WriteLine(a);
        }
    }
开发者ID:ahorn,项目名称:z3test,代码行数:25,代码来源:uninterp.cs

示例5: Run

 public void Run()
 {
     using (Context ctx = new Context()) {
         Symbol s1 = ctx.MkSymbol(1);
         Symbol s2 = ctx.MkSymbol(1);
         Symbol s3 = ctx.MkSymbol(2);
         Sort[] domain = new Sort[0];
     Sort range = ctx.IntSort;
         TestDriver.CheckAssertion("a1", s1 == s2);
         TestDriver.CheckAssertion("a2", s1 != s3);
         TestDriver.CheckAssertion("a3", ctx.MkSymbol("x") != s1);
         TestDriver.CheckAssertion("a4", ctx.MkSymbol("x") == ctx.MkSymbol("x"));
         TestDriver.CheckAssertion("a5", ctx.MkFuncDecl("f", domain, range) == ctx.MkFuncDecl("f", domain, range));
         TestDriver.CheckAssertion("a6", ctx.MkFuncDecl("f", domain, range) != ctx.MkFuncDecl("g", domain, range));
         TestDriver.CheckAssertion("a7", ctx.MkUninterpretedSort("s") == ctx.MkUninterpretedSort("s"));
         TestDriver.CheckAssertion("a8", ctx.MkUninterpretedSort("s") != ctx.MkUninterpretedSort("t"));
         TestDriver.CheckAssertion("a9", ctx.MkUninterpretedSort("s") != ctx.IntSort);
         TestDriver.CheckAssertion("a10", ctx.MkConst("x", range) == ctx.MkConst("x", range));
         TestDriver.CheckAssertion("a11", ctx.MkConst("x", range) == ctx.MkConst(ctx.MkSymbol("x"), range));
         TestDriver.CheckAssertion("a12", ctx.MkConst("x", range) != ctx.MkConst("y", range));
     }
 }
开发者ID:ExiaHan,项目名称:z3test,代码行数:22,代码来源:compare.cs

示例6: Run

    public void Run()
    {
        Dictionary<string, string> cfg = new Dictionary<string, string>() {
            { "AUTO_CONFIG", "true" } };

        using (Context ctx = new Context(cfg))
        {
            Sort T = ctx.MkUninterpretedSort("Type");
            FuncDecl subtype = ctx.MkFuncDecl("subtype", new Sort[] { T, T }, ctx.BoolSort);
            FuncDecl array_of = ctx.MkFuncDecl("array_of", T, T);
            Expr root = ctx.MkConst("root", T);

            Expr x = ctx.MkConst("x", T);
            Expr y = ctx.MkConst("y", T);
            Expr z = ctx.MkConst("z", T);

            BoolExpr[] axioms = new BoolExpr[] {
                ctx.MkForall(new Expr[] { x }, subtype[x, x]),
                ctx.MkForall(new Expr[] { x, y , z }, ctx.MkImplies(ctx.MkAnd((BoolExpr)subtype[x,y], (BoolExpr)subtype[y,z]), (BoolExpr)subtype[x,z])),
                ctx.MkForall(new Expr[] { x, y }, ctx.MkImplies(ctx.MkAnd((BoolExpr)subtype[x, y], (BoolExpr)subtype[y,x]), ctx.MkEq(x, y))),
                ctx.MkForall(new Expr[] { x, y, z }, ctx.MkImplies(ctx.MkAnd((BoolExpr)subtype[x,y],(BoolExpr)subtype[x,z]),
                                                                   ctx.MkOr((BoolExpr)subtype[y,z], (BoolExpr)subtype[z,y]))),
                ctx.MkForall(new Expr[] { x, y }, ctx.MkImplies((BoolExpr)subtype[x,y], (BoolExpr)subtype[array_of[x], array_of[y]])),
                ctx.MkForall(new Expr[] { x }, (BoolExpr) subtype[root, x])
            };

            Solver s = ctx.MkSolver();
            s.Assert(axioms);
            Console.WriteLine(s);
            Console.WriteLine(s.Check());
            Expr[] universe = s.Model.SortUniverse(T);
            foreach (var e in universe)
                Console.WriteLine(e);
            Console.WriteLine(s.Model);
        }
    }
开发者ID:ExiaHan,项目名称:z3test,代码行数:36,代码来源:quant.3.cs

示例7: ProveExample1

        /// <summary>
        /// Prove <tt>x = y implies g(x) = g(y)</tt>, and
        /// disprove <tt>x = y implies g(g(x)) = g(y)</tt>.
        /// </summary>
        /// <remarks>This function demonstrates how to create uninterpreted
        /// types and functions.</remarks>
        public static void ProveExample1(Context ctx)
        {
            Console.WriteLine("ProveExample1");

            /* create uninterpreted type. */
            Sort U = ctx.MkUninterpretedSort(ctx.MkSymbol("U"));

            /* declare function g */
            FuncDecl g = ctx.MkFuncDecl("g", U, U);

            /* create x and y */
            Expr x = ctx.MkConst("x", U);
            Expr y = ctx.MkConst("y", U);
            /* create g(x), g(y) */
            Expr gx = g[x];
            Expr gy = g[y];

            /* assert x = y */
            BoolExpr eq = ctx.MkEq(x, y);

            /* prove g(x) = g(y) */
            BoolExpr f = ctx.MkEq(gx, gy);
            Console.WriteLine("prove: x = y implies g(x) = g(y)");
            Prove(ctx, ctx.MkImplies(eq, f));

            /* create g(g(x)) */
            Expr ggx = g[gx];

            /* disprove g(g(x)) = g(y) */
            f = ctx.MkEq(ggx, gy);
            Console.WriteLine("disprove: x = y implies g(g(x)) = g(y)");
            Disprove(ctx, ctx.MkImplies(eq, f));


            /* Print the model using the custom model printer */
            Model m = Check(ctx, ctx.MkNot(f), Status.SATISFIABLE);
            Console.WriteLine(m);
        }
开发者ID:perillaseed,项目名称:z3,代码行数:44,代码来源:Program.cs


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