Class SyntacticRank


  • public class SyntacticRank
    extends java.lang.Object
    This class represents the rank of a SyntacticTerm. The rank is composed of four positive numbers referring respectively to the number of forward outputs, reverse outputs, forward inputs, and reverse inputs to the term. The reverse i/o, while supported in this type has not been completely assigned semantics. Currently, the forward elements are only used to characterize the compositionality of terms under combinational operations. At the least, the reverse versions follow an analogy from tensor ranks in linear algebra, where forward ranks refer to vector spaces and reverse ranks to co-vector spaces. I might use this concept to codify reverse propagation of feedback edges against the feed-forward edges that constitute the acyclic component of a term.
    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Chris Shaver
    Pt.AcceptedRating:
    Red
    Pt.ProposedRating:
    Red (shaver)
    • Constructor Detail

      • SyntacticRank

        public SyntacticRank​(int fo,
                             int ro,
                             int fi,
                             int ri)
        Construct a new rank. See the class description for an explanation of these ranks.
        Parameters:
        fo - Forward output rank.
        ro - Reverse output rank.
        fi - Forward input rank.
        ri - Reverse input rank.
      • SyntacticRank

        public SyntacticRank​(int fi,
                             int fo)
        Construct a new forward rank. Reverse ranks are set to 0. See the class description for an explanation of these ranks.
        Parameters:
        fo - Forward output rank.
        fi - Forward input rank.
    • Method Detail

      • copy

        public SyntacticRank copy()
        Copy a rank.
        Returns:
        new copied rank.
      • forwardOut

        public int forwardOut()
        Get the forward output rank. See the class description for an explanation of these ranks.
        Returns:
        forward output rank.
      • reverseOut

        public int reverseOut()
        Get the reverse output rank. See the class description for an explanation of these ranks.
        Returns:
        reverse output rank.
      • forwardIn

        public int forwardIn()
        Get the forward input rank. See the class description for an explanation of these ranks.
        Returns:
        forward input rank.
      • reverseIn

        public int reverseIn()
        Get the reverse input rank. See the class description for an explanation of these ranks.
        Returns:
        reverse input rank.
      • generateCode

        public java.lang.String generateCode()
        Generate code representation of rank. The form of this representation is as follows:
        <forward in (reverse out) -> forward out (reverse in)>
        or, if the reverse components are 0:
        <forward in -> forward out>
        Returns:
        code representation of rank.
      • noCode

        public static java.lang.String noCode()
        Generate code representation for no rank information.
        Returns:
        code representation of no rank.
      • compose

        public static SyntacticRank compose​(SyntacticRank a,
                                            SyntacticRank b)
        Compose two ranks if possible, else return null. Ranks A and B can be composed if the number of forward outputs of B is equal to the number of forward inputs of A. If reverse connections exist, the number of reverse outputs of B must be equal to the number of reverse inputs of A. (Note that this order is in fact opposite of the forward case since reverse connections form in the opposite direction.) Note that this composition operation should be interpreted as the first rank going into the second rank, rather than the first rank operating on the second as in function composition notation.
        Parameters:
        a - First rank.
        b - Second rank.
        Returns:
        composition of first and second rank.
      • add

        public static SyntacticRank add​(SyntacticRank a,
                                        SyntacticRank b)
        Add the two ranks if possible, else return null. Ranks are only able to be added if they are the same, and the result is simply the same rank as the operands. A copy is returned. This is a operation rather than just a check for purposes of modularity. An operation adding terms can call this to be symmetric with other operations.
        Parameters:
        a - First rank.
        b - Second rank.
        Returns:
        sum of first and second ranks.
      • product

        public static SyntacticRank product​(SyntacticRank a,
                                            SyntacticRank b)
        Multiply two ranks. This is always possible, following the analogy from tensor products. The product is simply the element-wise sum of the ranks.
        Parameters:
        a - First rank.
        b - Second rank.
        Returns:
        product of ranks.
      • product

        public static SyntacticRank product​(SyntacticTerm a,
                                            SyntacticTerm b)
        Multiply the ranks of two terms.
        Parameters:
        a - First term.
        b - Second term.
        Returns:
        product of the ranks of first and second term.
      • contract

        public static SyntacticRank contract​(SyntacticRank a,
                                             int n)
        Contract rank about a given number of input/output pairs. This is possible when the number of contracted pairs are fewer than then smaller of the numbers of inputs and outputs.
        Parameters:
        a - Rank to contract.
        n - Number of contractions.
        Returns:
        Contracted rank or null if not possible.