Esempio n. 1
0
            public override Function VisitFunction(Function node)
            {
                Debug.Assert(node != null);
                if (InAxiom)
                {
                    Debug.Assert(CurrentAxiom != null);

                    if (IgnoreInterpretedFunctionsInAxioms && ExprUtil.AsUninterpretedFunction(node) == null)
                    {
                        // This FunctionCall does not call an uninterpreted function. Therefore it must call an
                        // an interpreted function
                        return(node);
                    }

                    if (FuncsUsedInAxiom[CurrentAxiom].Contains(node))
                    {
                        // We've already visited this function before
                        // in the context of this axiom. So don't visit again.
                        // This means we might travserse the same function
                        // body multiple times in the context of different axioms.
                        // I think that means we'll never get stuck traversing
                        // recursive function bodies but I'm not sure.
                        return(node);
                    }

                    // Record the mapping both ways
                    if (!AxiomsUsingFunc.ContainsKey(node))
                    {
                        AxiomsUsingFunc[node] = new HashSet <Axiom>();
                    }
                    AxiomsUsingFunc[node].Add(CurrentAxiom);

                    // Assume Hash set has already been initialised
                    FuncsUsedInAxiom[CurrentAxiom].Add(node);
                }
                else
                {
                    if (FuncsUsedInCode.Contains(node))
                    {
                        // We've visited this function before in the context
                        // of code so we don't need to add it to `FuncsUsedInCode`
                        // or travserse its body again. Traversing again might
                        // get us stuck in a loop with recursive functions.
                        return(node);
                    }
                    FuncsUsedInCode.Add(node);
                }

                // Now if the function has a body traverse that because
                // this function depends on functions that this function calls
                if (node.Body != null)
                {
                    Visit(node.Body);
                }
                return(node);
            }
Esempio n. 2
0
        public void NotUninterpretedFunction()
        {
            var sb           = GetSimpleBuilder();
            var constant     = sb.ConstantBV(0, 32); // 0bv32
            var addConstants = sb.BVADD(constant, constant);
            var asUF         = ExprUtil.AsUninterpretedFunctionCall(addConstants);

            Assert.IsNull(asUF);

            // Yuck...
            var func = ((addConstants as NAryExpr).Fun as FunctionCall).Func;

            Assert.IsNull(ExprUtil.AsUninterpretedFunction(func));
        }
Esempio n. 3
0
        public void UninterpretedFunction()
        {
            var FCB      = new Symbooglix.FunctionCallBuilder();
            var funcCall = FCB.CreateCachedUninterpretedFunctionCall(
                "foo",
                BType.Bool, // Return type
                new List <Microsoft.Boogie.Type>()
            {
                BType.GetBvType(32), BType.GetBvType(32)
            }
                );

            Assert.IsNotNull(ExprUtil.AsUninterpretedFunction(funcCall.Func));

            var sb       = GetSimpleBuilder();
            var callFunc = sb.UFC(funcCall, sb.ConstantBV(0, 32), sb.ConstantBV(1, 32));
            var asUF     = ExprUtil.AsUninterpretedFunctionCall(callFunc);

            Assert.IsNotNull(asUF);
        }