Class XNodeParent<V extends IVar>

  • All Implemented Interfaces:
    Comparable<XNode<V>>
    Direct Known Subclasses:
    XNodeParentSpecial

    public class XNodeParent<V extends IVar>
    extends XNode<V>
    The class used for representing a parent node in a syntactic tree.
    Author:
    Christophe Lecoutre
    • Constructor Detail

      • XNodeParent

        public XNodeParent​(Types.TypeExpr type,
                           XNode<V>[] sons)
        Builds a parent node for a syntactic tree, with the specified type and the specified sons.
      • XNodeParent

        public XNodeParent​(Types.TypeExpr type,
                           List<XNode<V>> sons)
        Builds a parent node for a syntactic tree, with the specified type and the specified sons.
      • XNodeParent

        public XNodeParent​(Types.TypeExpr type,
                           XNode<V> son)
        Builds a parent node for a syntactic tree, with the specified type and the specified son.
      • XNodeParent

        public XNodeParent​(Types.TypeExpr type,
                           XNode<V> son1,
                           XNode<V> son2)
        Builds a parent node for a syntactic tree, with the specified type and the two specified sons.
    • Method Detail

      • set

        public static XNode<IVar> set​(int[] operands)
      • compareTo

        public int compareTo​(XNode<V> obj)
      • size

        public int size()
        Description copied from class: XNode
        Returns the size of the tree rooted by this node, i.e., the number of nodes it contains.
        Specified by:
        size in class XNode<V extends IVar>
        Returns:
        the size of the tree rooted by this node
      • maxParameterNumber

        public int maxParameterNumber()
        Description copied from class: XNode
        Returns the maximum value of a parameter number in the tree rooted by this node, or -1 if there is none.
        Specified by:
        maxParameterNumber in class XNode<V extends IVar>
        Returns:
        the maximum value of a parameter number in the tree rooted by this node, or -1
      • canonization

        public XNode<V> canonization()
        Description copied from class: XNode
        Returns a new tree, equivalent to the tree rooted by this node, and in canonical form. For example, commutative operators will take variables before integers as operands; actually, the total ordinal order over constants in TypeExpr is used. Some simplifications are also performed; for example, not(eq(x,y)) becomes ne(x,y).
        Specified by:
        canonization in class XNode<V extends IVar>
        Returns:
        a new tree, equivalent to the tree rooted by this node, and in canonical form
      • abstraction

        public XNode<V> abstraction​(List<Object> args,
                                    boolean abstractIntegers,
                                    boolean multiOccurrences)
        Description copied from class: XNode
        Returns a new tree representing an abstraction of the tree rooted by this node. Variables are replaced by parameters, and integers are also replaced by parameters (if the first specified Boolean is true). Occurrences of the same variables are replaced by the same parameter (if the second specified Boolean is true). Values replaced by parameters are added to the specified list.
        Specified by:
        abstraction in class XNode<V extends IVar>
        Parameters:
        args - a list that is updated by adding the objects (variables, and possibly integers) that are abstracted (replaced by parameters)
        abstractIntegers - if true, encountered integers are also abstracted
        multiOccurrences - if true, occurrences of the same variables are replaced by the same parameter
        Returns:
        a new tree representing an abstraction of the tree rooted by this node
      • concretization

        public XNode<V> concretization​(Object[] args)
        Description copied from class: XNode
        Returns a new tree representing a concretization of the tree rooted by this node. Any parameter of value i is replaced by the ith object in the specified list of arguments.
        Specified by:
        concretization in class XNode<V extends IVar>
        Parameters:
        args - the list of arguments to be used as values for the parameters that are present in the tree rooted by this node
        Returns:
        a new tree representing a concretization of the tree rooted by this node
      • replaceSymbols

        public XNode<V> replaceSymbols​(Map<String,​Integer> mapOfSymbols)
        Description copied from class: XNode
        Returns a new tree, obtained from the tree rooted by this node by replacing symbols with integers, as defined by the specified map.
        Specified by:
        replaceSymbols in class XNode<V extends IVar>
        Parameters:
        mapOfSymbols - a map associating integers with strings (symbols)
        Returns:
        a new tree, obtained by replacing symbols with integers, as defined by the specified map
      • replaceLeafValues

        public XNode<V> replaceLeafValues​(java.util.function.Function<Object,​Object> f)
        Description copied from class: XNode
        a new tree, obtained from the tree rooted by this node by replacing values of leaves, as defined by the specified function
        Specified by:
        replaceLeafValues in class XNode<V extends IVar>
        Parameters:
        f - a function mapping objects to objects
        Returns:
        a new tree, obtained by replacing values of leaves, as defined by the specified function
      • firstNodeSuchThat

        public XNode<V> firstNodeSuchThat​(java.util.function.Predicate<XNode<V>> p)
        Description copied from class: XNode
        Returns the first node accepted by the specified predicate in the tree rooted by this node, or null otherwise.
        Specified by:
        firstNodeSuchThat in class XNode<V extends IVar>
        Parameters:
        p - a predicate to be applied on nodes
        Returns:
        the first node accepted by the specified predicate
      • allNodesSuchThat

        public LinkedList<XNode<V>> allNodesSuchThat​(java.util.function.Predicate<XNode<V>> p,
                                                     LinkedList<XNode<V>> list)
        Description copied from class: XNode
        Adds to the specified list all nodes accepted by the specified predicate in the tree rooted by this node. The specifies list is returned.
        Specified by:
        allNodesSuchThat in class XNode<V extends IVar>
        Parameters:
        p - a predicate to be applied on nodes
        list - a list in which nodes are added
        Returns:
        a list with all nodes accepted by the specified predicate in the tree rooted by this node
      • isEqVar

        public boolean isEqVar()
      • toPostfixExpression

        public String toPostfixExpression​(IVar[] scopeForAbstraction)
        Description copied from class: XNode
        Returns a string denoting the post-fixed expression of the tree rooted by this node. If the specified array is not null, variables that are present in the tree are replaced by their parameterized forms %i.
        Specified by:
        toPostfixExpression in class XNode<V extends IVar>
        Parameters:
        scopeForAbstraction - if not null, the scope on which an abstract post-fixed expression is built
        Returns:
        a string denoting the post-fixed expression of the tree rooted by this node.
      • toFunctionalExpression

        public String toFunctionalExpression​(Object[] argsForConcretization)
        Description copied from class: XNode
        Returns a string denoting the functional expression of the tree rooted by this node. If the specified array is not null, parameters that are present in the tree are replaced by their corresponding arguments.
        Specified by:
        toFunctionalExpression in class XNode<V extends IVar>
        Parameters:
        argsForConcretization - if not null, the list of arguments to be used as values for the parameters that are present in the tree rooted by this node
        Returns:
        a string denoting the functional expression of the tree rooted by this node