Example #1
0
        internal RankedAlphabet(
            TreeTheory tt,
            string[] symbols,
            Dictionary <string, int> idMap,
            Sort alphabetSort,
            Sort nodeSort,
            int[] ranks,
            FuncDecl[] constructors,
            FuncDecl[][] accessors,
            FuncDecl[] testers,
            FuncDecl acceptor,
            Expr[] vars
            )
        {
            this.tt            = tt;
            this.symbols       = new List <string>(symbols).AsReadOnly();
            this.idMap         = idMap;
            this.alphabetSort  = alphabetSort;
            this.nodeSort      = nodeSort;
            this.ranks         = ranks;
            this.constructors  = constructors;
            this.accessors     = accessors;
            this.testers       = testers;
            this.acceptor      = acceptor;
            this.vars          = vars;
            this.trans         = tt.GetTrans(alphabetSort, alphabetSort);
            this.emptyAcceptor = TreeTransducer.MkEmpty(this);
            this.fullAcceptor  = TreeTransducer.MkFull(this);
            this.idAut         = TreeTransducer.MkId(this);

            this.symbolsOfRank = new Dictionary <int, List <FuncDecl> >();
            for (int i = 0; i < ranks.Length; i++)
            {
                var r = ranks[i];
                if (!symbolsOfRank.ContainsKey(r))
                {
                    symbolsOfRank[r] = new List <FuncDecl>();
                }
                symbolsOfRank[r].Add(constructors[i]);
            }

            var attrDomain = tt.Z.MkFreshFuncDecl("_", new Sort[] { nodeSort }, tt.Z.BoolSort);

            this.attrExpr = tt.Z.MkApp(attrDomain, vars[0]);
            tt.Z.AssertAxiom(this.attrExpr, tt.Z.True, vars[0]);
        }