Beispiel #1
0
        public Term MakeLabel(string labelName, bool pos, Term child)
        {
            Symbol labelSymbol = this.GetSymbol(labelName);
            Term   labeledExpr = z3.MkLabel(labelSymbol, pos, child);

            labels.Add(labelName, labeledExpr);
            return(labeledExpr);
        }
Beispiel #2
0
        private void DeclareConstant(string constantName, Type boogieType)
        {
            Symbol symbolAst = GetSymbol(constantName);
            Sort   typeAst   = tm.GetType(boogieType);

            Term constAst = z3.MkConst(symbolAst, typeAst);

            constants.Add(constantName, constAst);
            log("(declare-funs (({0} {1})))", constAst, typeAst);
        }
Beispiel #3
0
        private Symbol GetSymbol(string symbolName)
        {
            if (!symbols.ContainsKey(symbolName))
            {
                Symbol symbolAst = z3.MkSymbol(symbolName);
                symbols.Add(symbolName, symbolAst);
            }
            Symbol result;

            if (!symbols.TryGetValue(symbolName, out result))
            {
                throw new Exception("symbol " + symbolName + " is undefined");
            }
            return(result);
        }
Beispiel #4
0
        public override void DeclareFunction(Function f, string attributes)
        {
            base.DeclareFunction(f, attributes);
            List <Type> domain = new List <Type>();

            foreach (Variable v in f.InParams)
            {
                domain.Add(v.TypedIdent.Type);
            }
            if (f.OutParams.Length != 1)
            {
                throw new Exception("Cannot handle functions with " + f.OutParams + " out parameters.");
            }
            Type range = f.OutParams[0].TypedIdent.Type;

            string      functionName = f.Name;
            Symbol      symbolAst    = GetSymbol(functionName);
            var         domainStr    = "";
            List <Sort> domainAst    = new List <Sort>();

            foreach (Type domainType in domain)
            {
                Sort type = tm.GetType(domainType);
                domainAst.Add(type);
                domainStr += type.ToString() + " ";
            }
            Sort     rangeAst     = tm.GetType(range);
            FuncDecl constDeclAst = z3.MkFuncDecl(symbolAst, domainAst.ToArray(), rangeAst);

            functions.Add(functionName, constDeclAst);
            if (functions_inv != null)
            {
                functions_inv.Add(constDeclAst, f);
            }
            log("(declare-funs (({0} {1} {2})))", functionName, domainStr, rangeAst);
        }
Beispiel #5
0
        public Term GetConstant(string constantName, Type constantType, VCExpr node)
        {
            Term typeSafeTerm;

            if (!constants.ContainsKey(constantName))
            {
                this.DeclareConstant(constantName, constantType);
            }

            if (!constants.TryGetValue(constantName, out typeSafeTerm))
            {
                throw new Exception("constant " + constantName + " is not defined");
            }

            if (constants_inv != null && !constants_inv.ContainsKey(typeSafeTerm))
            {
                constants_inv.Add(typeSafeTerm, node);
            }

            return(typeSafeTerm);
        }