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


C# Context.ParseSMTLIBString方法代码示例

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


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

示例1: CommAxiom

        /// <summary>
        /// Assert the axiom: function f is commutative.
        /// </summary>
        /// <remarks>
        /// This example uses the SMT-LIB parser to simplify the axiom construction.
        /// </remarks>
        private static BoolExpr CommAxiom(Context ctx, FuncDecl f)
        {
            Sort t = f.Range;
            Sort[] dom = f.Domain;

            if (dom.Length != 2 ||
                !t.Equals(dom[0]) ||
                !t.Equals(dom[1]))
            {
                Console.WriteLine("{0} {1} {2} {3}", dom.Length, dom[0], dom[1], t);
                throw new Exception("function must be binary, and argument types must be equal to return type");
            }

            string bench = string.Format("(benchmark comm :formula (forall (x {0}) (y {1}) (= ({2} x y) ({3} y x))))",
                             t.Name, t.Name, f.Name, f.Name);
            ctx.ParseSMTLIBString(bench, new Symbol[] { t.Name }, new Sort[] { t }, new Symbol[] { f.Name }, new FuncDecl[] { f });
            return ctx.SMTLIBFormulas[0];
        }
开发者ID:perillaseed,项目名称:z3,代码行数:24,代码来源:Program.cs

示例2: ParserExample5

        /// <summary>
        /// Demonstrates how to handle parser errors using Z3 error handling support.
        /// </summary>
        /// <remarks></remarks>
        public static void ParserExample5(Context ctx)
        {
            Console.WriteLine("ParserExample5");

            try
            {
                ctx.ParseSMTLIBString(
                    /* the following string has a parsing error: missing parenthesis */
                         "(benchmark tst :extrafuns ((x Int (y Int)) :formula (> x y) :formula (> x 0))");
            }
            catch (Z3Exception e)
            {
                Console.WriteLine("Z3 error: {0}", e);
            }
        }
开发者ID:perillaseed,项目名称:z3,代码行数:19,代码来源:Program.cs

示例3: ParserExample4

        /// <summary>
        /// Display the declarations, assumptions and formulas in a SMT-LIB string.
        /// </summary>
        public static void ParserExample4(Context ctx)
        {
            Console.WriteLine("ParserExample4");

            ctx.ParseSMTLIBString
            ("(benchmark tst :extrafuns ((x Int) (y Int)) :assumption (= x 20) :formula (> x y) :formula (> x 0))");
            foreach (var decl in ctx.SMTLIBDecls)
            {
                Console.WriteLine("Declaration: {0}", decl);
            }
            foreach (var f in ctx.SMTLIBAssumptions)
            {
                Console.WriteLine("Assumption: {0}", f);
            }
            foreach (var f in ctx.SMTLIBFormulas)
            {
                Console.WriteLine("Formula: {0}", f);
            }
        }
开发者ID:perillaseed,项目名称:z3,代码行数:22,代码来源:Program.cs

示例4: ParserExample3

        /// <summary>
        /// Demonstrates how to initialize the parser symbol table.
        /// </summary>
        public static void ParserExample3(Context ctx)
        {
            Console.WriteLine("ParserExample3");

            /* declare function g */
            Sort I = ctx.MkIntSort();
            FuncDecl g = ctx.MkFuncDecl("g", new Sort[] { I, I }, I);

            BoolExpr ca = CommAxiom(ctx, g);

            ctx.ParseSMTLIBString("(benchmark tst :formula (forall (x Int) (y Int) (implies (= x y) (= (gg x 0) (gg 0 y)))))",
             null, null,
             new Symbol[] { ctx.MkSymbol("gg") },
             new FuncDecl[] { g });

            BoolExpr thm = ctx.SMTLIBFormulas[0];
            Console.WriteLine("formula: {0}", thm);
            Prove(ctx, thm, false, ca);
        }
开发者ID:perillaseed,项目名称:z3,代码行数:22,代码来源:Program.cs

示例5: ParserExample2

        /// <summary>
        /// Demonstrates how to initialize the parser symbol table.
        /// </summary>
        public static void ParserExample2(Context ctx)
        {
            Console.WriteLine("ParserExample2");

            Symbol[] declNames = { ctx.MkSymbol("a"), ctx.MkSymbol("b") };
            FuncDecl a = ctx.MkConstDecl(declNames[0], ctx.MkIntSort());
            FuncDecl b = ctx.MkConstDecl(declNames[1], ctx.MkIntSort());
            FuncDecl[] decls = new FuncDecl[] { a, b };

            ctx.ParseSMTLIBString("(benchmark tst :formula (> a b))",
                                 null, null, declNames, decls);
            BoolExpr f = ctx.SMTLIBFormulas[0];
            Console.WriteLine("formula: {0}", f);
            Check(ctx, f, Status.SATISFIABLE);
        }
开发者ID:perillaseed,项目名称:z3,代码行数:18,代码来源:Program.cs

示例6: ParserExample1

        /// <summary>
        /// Demonstrates how to use the SMTLIB parser.
        /// </summary>
        public static void ParserExample1(Context ctx)
        {
            Console.WriteLine("ParserExample1");

            ctx.ParseSMTLIBString("(benchmark tst :extrafuns ((x Int) (y Int)) :formula (> x y) :formula (> x 0))");
            foreach (BoolExpr f in ctx.SMTLIBFormulas)
                Console.WriteLine("formula {0}", f);

            Model m = Check(ctx, ctx.MkAnd(ctx.SMTLIBFormulas), Status.SATISFIABLE);
        }
开发者ID:perillaseed,项目名称:z3,代码行数:13,代码来源:Program.cs


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