Class FunctionCallNode

java.lang.Object
  |
  +--Node
        |
        +--FunctionCallNode

public class FunctionCallNode
extends Node

This class implements a function call node.

Author:
P. URSO
See Also:
Function, NodeList

Fields inherited from class Node
MAX_PRIORITY, MIN_PRIORITY
 
Constructor Summary
FunctionCallNode(Function id, NodeList parameters)
          Constructor of the function call node.
 
Method Summary
 Node applySubst(Substitution sigma)
          Applies a substitution to this term.
 Node argument(int index)
          Returns the argument of the call at the specified position.
 NodeList arguments()
          Returns the arguments of the call.
 Node bot(Path p)
          Computes bottom part of the term.
 Path botPath()
          Compute MAXIMUN BOTTOM PATH.
 boolean equals(Object node)
          Tests if some other object is "equal to" this one.
 Path find(Node node)
          Find the path to a substerm in a term.
 boolean getAsPart(Node node)
          Tests if this function call node as an other as part.
 int getNumber(Type t)
          Returns number of sub term with a specified type of this node.
 Node getSubterm(Path p)
          Get subterm at specified path.
 boolean getTwo(Type t)
          Tests if this term got two sub term of a specified type.
 Type getType()
          Returns the type of the term.
 void getVariables(Set vars)
          Extends the set of variables with the ones of this term.
 boolean greaterThan(Node node)
          Tests if this function call node is greater (in order) than an other term.
 Function identifier()
          Returns the identifier of the function.
 void inductionVariables(Map iv, int priority)
          Extends the map of induction variable with the ones of this term.
 boolean isConstant()
          Indicates if this term is a constant.
 boolean isConstructorRooted()
          Tests if this term is rooted by a constructor symbol.
 void makeFilter(Node node, Substitution sigma)
          Constructs a filter between this function call node and an other one.
 Node nbt(Path p)
          Computes nbt part of the term.
 Node ntp(Path p)
          Computes npt part of the term.
 int numAsPart(Node node)
          Counts how many times this term as an other as part.
 Node remplaceSubterm(Path p, Node n)
          Remplaces subterm at specified path by an other.
 Node top(Path p)
          Computes top part of the term.
 Path topPath()
          Compute MAXIMUN TOP PATH.
 String toString()
          Returns a string representation of this function call node.
protected  String toStringInfix()
          Returns a string representation of this function call node when it is an argument of an infix call.
 
Methods inherited from class Node
isGround, withNewVariables
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FunctionCallNode

public FunctionCallNode(Function id,
                        NodeList parameters)
Constructor of the function call node.
Parameters:
id - identifier of the function.
parameters - arguments of the call.
Method Detail

getType

public Type getType()
Returns the type of the term.
Overrides:
getType in class Node
Returns:
the return type of the identifier of the function.

arguments

public NodeList arguments()
Returns the arguments of the call.
Returns:
the arguments of the call.

argument

public Node argument(int index)
Returns the argument of the call at the specified position.
Parameters:
index - index of argument to return.
Returns:
the argument of the call at the specified position.

identifier

public Function identifier()
Returns the identifier of the function.
Returns:
the identifier of the function.

applySubst

public Node applySubst(Substitution sigma)
Applies a substitution to this term.
Overrides:
applySubst in class Node
Parameters:
sigma - the substitution map.
Returns:
a new function call node where the substitution is applied on each arguments.

makeFilter

public void makeFilter(Node node,
                       Substitution sigma)
                throws SubstitutionStop
Constructs a filter between this function call node and an other one. If making such a filter is not possible, throws a SubstitutionStop.
Overrides:
makeFilter in class Node
Parameters:
node - the other term.
sigma - the substitution map in construction.
Throws:
SubstitutionStop -  

greaterThan

public boolean greaterThan(Node node)
Tests if this function call node is greater (in order) than an other term. A function call node is greater than an other term if the other is a sub-term of this one, or if the other is a function call node and either they got the same identifier and its arguments are lower in lexicographic order, or if it is a lower function and all its arguments are lower of this term.
Overrides:
greaterThan in class Node
Parameters:
node - the other term.
Returns:
true if this term is greater.

getAsPart

public boolean getAsPart(Node node)
Tests if this function call node as an other as part.
Overrides:
getAsPart in class Node
Parameters:
node - the other term.
Returns:
true if the terms are equal or if this term contains the other.

numAsPart

public int numAsPart(Node node)
Counts how many times this term as an other as part.
Overrides:
numAsPart in class Node
Parameters:
node - the other term.
Returns:
1 if the terms are "equals", 0 otherwise.

find

public Path find(Node node)
Find the path to a substerm in a term. !Eavy algorithm!.
Overrides:
find in class Node
Parameters:
node - the subterm.

topPath

public Path topPath()
Compute MAXIMUN TOP PATH.
Overrides:
topPath in class Node
Returns:
the top path (Empty by default).

botPath

public Path botPath()
Compute MAXIMUN BOTTOM PATH.
Overrides:
botPath in class Node
Returns:
the bottom path (Empty by default).

top

public Node top(Path p)
Computes top part of the term.
Overrides:
top in class Node
Parameters:
p - a top path.
Returns:
top(t) -- this if p is Empty.

ntp

public Node ntp(Path p)
Computes npt part of the term.
Overrides:
ntp in class Node
Parameters:
p - a top path.
Returns:
npt(t) -- constant of node's type if p is Empty.

bot

public Node bot(Path p)
Computes bottom part of the term.
Overrides:
bot in class Node
Parameters:
p - a bottom path.
Returns:
bot(t) -- this if p is Empty.

nbt

public Node nbt(Path p)
Computes nbt part of the term.
Overrides:
nbt in class Node
Parameters:
p - a bottom path.
Returns:
nbt(t) -- constant of node's type if p is Empty, null otherwise (error).

inductionVariables

public void inductionVariables(Map iv,
                               int priority)
Extends the map of induction variable with the ones of this term. Variables are mapped with their maximum induction priority. Updates priority for its arguments with induction position of the function.
Overrides:
inductionVariables in class Node
Parameters:
iv - the map in construction.
priority - the current priority.

getVariables

public void getVariables(Set vars)
Extends the set of variables with the ones of this term.
Overrides:
getVariables in class Node
Parameters:
vars - the set of variables in construction.

getSubterm

public Node getSubterm(Path p)
Get subterm at specified path.
Overrides:
getSubterm in class Node
Parameters:
p - path to subterm.
Returns:
t / p = this node if p == null, the p.num argument otherwise.

remplaceSubterm

public Node remplaceSubterm(Path p,
                            Node n)
Remplaces subterm at specified path by an other.
Overrides:
remplaceSubterm in class Node
Parameters:
p - path to subterm.
n - node to put at path.
Returns:
t[n]_p = n if p == null, remplace applied to p.num argument.

isConstructorRooted

public boolean isConstructorRooted()
Tests if this term is rooted by a constructor symbol.
Overrides:
isConstructorRooted in class Node
Returns:
true if the function is a constructor.

isConstant

public boolean isConstant()
Indicates if this term is a constant.
Overrides:
isConstant in class Node
Returns:
true if the function is a constructor and if it as no arguments.

getNumber

public int getNumber(Type t)
Returns number of sub term with a specified type of this node.
Overrides:
getNumber in class Node
Parameters:
t - the type.

getTwo

public boolean getTwo(Type t)
Tests if this term got two sub term of a specified type.
Parameters:
t - the type.
Returns:
true if , by default.

equals

public boolean equals(Object node)
Tests if some other object is "equal to" this one.
Overrides:
equals in class Object
Parameters:
node - the term with which to compare.
Returns:
true if the other is a function call node and their identifiers and arguments are equal; false otherwise.

toString

public String toString()
Returns a string representation of this function call node. The string representation consists of either the name of function and enclosed by "()", the list of arguments separated by ", ", either the two arguments of an infix operator separated by the representation of the operator.
Overrides:
toString in class Object
Returns:
a string representation of this term.

toStringInfix

protected String toStringInfix()
Returns a string representation of this function call node when it is an argument of an infix call. If the node is itself infix it will be enclosed by paranthesis "()".
Overrides:
toStringInfix in class Node
Returns:
a string representation of this node.