Microsoft.Z3.Context.ParseSMTLIBString C# (CSharp) Méthode

ParseSMTLIBString() public méthode

Parse the given string using the SMT-LIB parser.
The symbol table of the parser can be initialized using the given sorts and declarations. The symbols in the arrays sortNames and declNames don't need to match the names of the sorts and declarations in the arrays sorts and decls. This is a useful feature since we can use arbitrary names to reference sorts and declarations.
public ParseSMTLIBString ( string str, Symbol sortNames = null, Microsoft.Z3.Sort sorts = null, Symbol declNames = null, FuncDecl decls = null ) : void
str string
sortNames Symbol
sorts Microsoft.Z3.Sort
declNames Symbol
decls FuncDecl
Résultat void
        public void ParseSMTLIBString(string str, Symbol[] sortNames = null, Sort[] sorts = null, Symbol[] declNames = null, FuncDecl[] decls = null)
        {
            uint csn = Symbol.ArrayLength(sortNames);
            uint cs = Sort.ArrayLength(sorts);
            uint cdn = Symbol.ArrayLength(declNames);
            uint cd = AST.ArrayLength(decls);
            if (csn != cs || cdn != cd)
                throw new Z3Exception("Argument size mismatch");
            Native.Z3_parse_smtlib_string(nCtx, str,
                AST.ArrayLength(sorts), Symbol.ArrayToNative(sortNames), AST.ArrayToNative(sorts),
                AST.ArrayLength(decls), Symbol.ArrayToNative(declNames), AST.ArrayToNative(decls));
        }

Usage Example

Exemple #1
0
        /// <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];
        }
All Usage Examples Of Microsoft.Z3.Context::ParseSMTLIBString
Context