Esempio n. 1
0
        private void RegisterSelect(VCExprNAry node)
        {
            RegisterType(node[0].Type);

            if (CommandLineOptions.Clo.UseArrayTheory)
            {
                return;
            }

            string name = SimplifyLikeExprLineariser.SelectOpName(node);

            name = Namer.GetQuotedName(name, name);

            if (!KnownSelectFunctions.Contains(name))
            {
                string decl = "(declare-fun " + name + " (" + node.MapConcat(n => TypeToString(n.Type), " ") + ") " + TypeToString(node.Type) + ")";
                AddDeclaration(decl);
                KnownSelectFunctions.Add(name);
            }
        }
Esempio n. 2
0
        private void RegisterStore(VCExprNAry node)
        {
            RegisterType(node.Type);  // this is the map type, registering it should register also the index and value types

            if (CommandLineOptions.Clo.UseArrayTheory)
            {
                return;
            }

            string name = SimplifyLikeExprLineariser.StoreOpName(node);

            name = Namer.GetQuotedName(name, name);

            if (!KnownStoreFunctions.Contains(name))
            {
                string decl = "(declare-fun " + name + " (" + node.MapConcat(n => TypeToString(n.Type), " ") + ") " + TypeToString(node.Type) + ")";
                AddDeclaration(decl);

                if (CommandLineOptions.Clo.TypeEncodingMethod == CommandLineOptions.TypeEncoding.Monomorphic)
                {
                    var sel = SimplifyLikeExprLineariser.SelectOpName(node);
                    sel = Namer.GetQuotedName(sel, sel);

                    if (!KnownSelectFunctions.Contains(sel))
                    {
                        // need to declare it before reference
                        var    args    = node.SkipEnd(1);
                        var    ret     = node.Last();
                        string seldecl = "(declare-fun " + sel + " (" + args.MapConcat(n => TypeToString(n.Type), " ") + ") " + TypeToString(ret.Type) + ")";
                        AddDeclaration(seldecl);
                        KnownSelectFunctions.Add(sel);
                    }

                    string ax1 = "(assert (forall (";
                    string ax2 = "(assert (forall (";

                    string argX = "", argY = "";
                    string dist = "";
                    for (int i = 0; i < node.Arity; i++)
                    {
                        var t = " " + TypeToString(node[i].Type);
                        var x = " ?x" + i;
                        var y = " ?y" + i;
                        ax1 += " (" + x + t + ")";
                        ax2 += " (" + x + t + ")";
                        if (i != 0 && i != node.Arity - 1)
                        {
                            argX += x;
                            argY += y;
                            ax2  += " (" + y + t + ")";
                            dist += " (not (=" + x + y + "))";
                        }
                    }
                    string v = " ?x" + (node.Arity - 1);
                    ax1 += ") (= (" + sel + " (" + name + " ?x0" + argX + v + ")" + argX + ") " + v + ")";
                    ax1 += "))";

                    if (node.Arity > 3)
                    {
                        dist = "(or " + dist + ")";
                    }
                    ax2 += ") (=> " + dist + " (= (" + sel + " (" + name + " ?x0" + argX + v + ")" + argY + ") (" + sel + " ?x0" + argY + ")))";
                    ax2 += "))";

                    AddDeclaration(ax1);
                    AddDeclaration(ax2);
                }

                KnownStoreFunctions.Add(name);
            }
            //
        }