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

MkConstructor() public méthode

Create a datatype constructor.
public MkConstructor ( Symbol name, Symbol recognizer, Symbol fieldNames = null, Microsoft.Z3.Sort sorts = null, uint sortRefs = null ) : Microsoft.Z3.Constructor
name Symbol constructor name
recognizer Symbol name of recognizer function.
fieldNames Symbol names of the constructor fields.
sorts Microsoft.Z3.Sort field sorts, 0 if the field sort refers to a recursive sort.
sortRefs uint reference to datatype sort that is an argument to the constructor; /// if the corresponding sort reference is 0, then the value in sort_refs should be an index /// referring to one of the recursive datatypes that is declared.
Résultat Microsoft.Z3.Constructor
        public Constructor MkConstructor(Symbol name, Symbol recognizer, Symbol[] fieldNames = null, Sort[] sorts = null, uint[] sortRefs = null)
        {
            Contract.Requires(name != null);
            Contract.Requires(recognizer != null);
            Contract.Ensures(Contract.Result<Constructor>() != null);

            return new Constructor(this, name, recognizer, fieldNames, sorts, sortRefs);
        }

Same methods

Context::MkConstructor ( string name, string recognizer, string fieldNames = null, Microsoft.Z3.Sort sorts = null, uint sortRefs = null ) : Microsoft.Z3.Constructor

Usage Example

Exemple #1
0
    public void Run()
    {
        Dictionary<string, string> cfg = new Dictionary<string, string>() {
            { "AUTO_CONFIG", "true" },
            { "MODEL", "true" } };

        using (Context ctx = new Context(cfg))
        {
            Constructor c_leaf = ctx.MkConstructor("leaf", "is_leaf", new string[] { "val" }, new Sort[] { ctx.IntSort });
            Constructor c_node = ctx.MkConstructor("node", "is_node", new string[] { "left", "right" }, new Sort[] { null, null }, new uint[] { 1, 1 });
            Constructor[] constr_1 = new Constructor[] { c_leaf, c_node };

            Constructor c_nil = ctx.MkConstructor("nil", "is_nil");
            Constructor c_cons = ctx.MkConstructor("cons", "is_cons", new string[] { "car", "cdr" }, new Sort[] { null, null }, new uint[] { 0, 1 });
            Constructor[] constr_2 = new Constructor[] { c_nil, c_cons };

            DatatypeSort[] ts = ctx.MkDatatypeSorts(new string[] { "Tree", "TreeList" },
                                                    new Constructor[][] { constr_1, constr_2 });

            DatatypeSort Tree = ts[0];
            DatatypeSort TreeList = ts[1];

            FuncDecl leaf = Tree.Constructors[0];
            FuncDecl node = Tree.Constructors[1];
            FuncDecl val = Tree.Accessors[0][0];

            FuncDecl nil = TreeList.Constructors[0];
            FuncDecl cons = TreeList.Constructors[1];

            Expr t1 = leaf[ctx.MkInt(10)];
            Expr tl1 = cons[t1, nil.Apply()];
            Expr t2 = node[tl1, nil.Apply()];

            Console.WriteLine(t2);
            Console.WriteLine(val.Apply(t1).Simplify());

            t1 = ctx.MkConst("t1", TreeList);
            t2 = ctx.MkConst("t2", TreeList);
            Expr t3 = ctx.MkConst("t3", TreeList);

            Solver s = ctx.MkSolver();
            s.Assert(ctx.MkDistinct(t1, t2, t3));
            Console.WriteLine(s.Check());
            Console.WriteLine(s.Model);
        }
    }
All Usage Examples Of Microsoft.Z3.Context::MkConstructor
Context