當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。