コード例 #1
0
        /// <summary>
        /// Make an output term of applying the given state to the given child subtree.
        /// </summary>
        /// <param name="outputAlphabet">the output alphabet sort</param>
        /// <param name="state">the state from which the child is transduced</param>
        /// <param name="child">the accessor of the child, must be a positive integer between 1 and MaxRank</param>
        public Expr MkTrans(RankedAlphabet outputAlphabet, int state, int child)
        {
            var f = tt.GetTrans(AlphabetSort, outputAlphabet.AlphabetSort);
            var s = tt.Z.MkInt(state);

            if (child < 1 || child > MaxRank)
            {
                throw new AutomataException(AutomataExceptionKind.RankedAlphabet_ChildAccessorIsOutOufBounds);
            }
            var x   = ChildVar(child);
            var res = tt.Z.MkApp(f, s, x);

            return(res);
        }
コード例 #2
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]);
        }