Package org.xcsp.common.predicates
Class XNodeParent<V extends IVar>
- java.lang.Object
-
- org.xcsp.common.predicates.XNode<V>
-
- org.xcsp.common.predicates.XNodeParent<V>
-
- 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 Summary
Constructors Constructor Description 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(Types.TypeExpr type, XNode<V> son)
Builds a parent node for a syntactic tree, with the specified type and the specified son.XNodeParent(Types.TypeExpr type, XNode<V>[] sons)
Builds a parent node for a syntactic tree, with the specified type and the specified sons.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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static XNodeParent<IVar>
abs(Object operand)
XNode<V>
abstraction(List<Object> args, boolean abstractIntegers, boolean multiOccurrences)
Returns a new tree representing an abstraction of the tree rooted by this node.static XNodeParent<IVar>
add(Object... operands)
LinkedList<XNode<V>>
allNodesSuchThat(java.util.function.Predicate<XNode<V>> p, LinkedList<XNode<V>> list)
Adds to the specified list all nodes accepted by the specified predicate in the tree rooted by this node.static XNodeParent<IVar>
and(Object... operands)
static XNodeParent<IVar>
build(Types.TypeExpr type, Object... os)
XNode<V>
canonization()
Returns a new tree, equivalent to the tree rooted by this node, and in canonical form.int
compareTo(XNode<V> obj)
XNode<V>
concretization(Object[] args)
Returns a new tree representing a concretization of the tree rooted by this node.static XNodeParent<IVar>
dist(Object operand1, Object operand2)
static XNodeParent<IVar>
div(Object operand1, Object operand2)
static XNodeParent<IVar>
eq(Object... operands)
boolean
equals(Object obj)
XNode<V>
firstNodeSuchThat(java.util.function.Predicate<XNode<V>> p)
Returns the first node accepted by the specified predicate in the tree rooted by this node, ornull
otherwise.static XNodeParent<IVar>
ge(Object operand1, Object operand2)
static XNodeParent<IVar>
gt(Object operand1, Object operand2)
static XNodeParent<IVar>
iff(Object... operands)
static XNodeParent<IVar>
ifThenElse(Object operand1, Object operand2, Object operand3)
static XNodeParent<IVar>
imp(Object operand1, Object operand2)
static XNodeParent<IVar>
in(Object var, Object set)
boolean
isEqVar()
static XNodeParent<IVar>
le(Object operand1, Object operand2)
static XNodeParent<IVar>
lt(Object operand1, Object operand2)
static XNodeParent<IVar>
max(Object... operands)
int
maxParameterNumber()
Returns the maximum value of a parameter number in the tree rooted by this node, or -1 if there is none.static XNodeParent<IVar>
min(Object... operands)
static XNodeParent<IVar>
mod(Object operand1, Object operand2)
static XNodeParent<IVar>
mul(Object... operands)
static XNodeParent<IVar>
ne(Object... operands)
static XNodeParent<IVar>
neg(Object operand)
static XNodeParent<IVar>
not(Object operand)
static XNodeParent<IVar>
notin(Object var, Object set)
static XNodeParent<IVar>
or(Object... operands)
static XNodeParent<IVar>
pow(Object operand1, Object operand2)
XNode<V>
replaceLeafValues(java.util.function.Function<Object,Object> f)
a new tree, obtained from the tree rooted by this node by replacing values of leaves, as defined by the specified functionXNode<V>
replacePartiallyParameters(Object[] valueParameters)
XNode<V>
replaceSymbols(Map<String,Integer> mapOfSymbols)
Returns a new tree, obtained from the tree rooted by this node by replacing symbols with integers, as defined by the specified map.static XNodeParent<IVar>
scalar(int[] t1, Object[] t2)
static XNode<IVar>
set(int[] operands)
static XNode<IVar>
set(Object... operands)
int
size()
Returns the size of the tree rooted by this node, i.e., the number of nodes it contains.static XNodeParent<IVar>
sqr(Object operand)
static XNodeParent<IVar>
sub(Object operand1, Object operand2)
String
toFunctionalExpression(Object[] argsForConcretization)
Returns a string denoting the functional expression of the tree rooted by this node.String
toPostfixExpression(IVar[] scopeForAbstraction)
Returns a string denoting the post-fixed expression of the tree rooted by this node.static XNodeParent<IVar>
xor(Object... operands)
-
Methods inherited from class org.xcsp.common.predicates.XNode
allNodesSuchThat, ariop, arity, arrayOfVals, arrayOfVars, collectVarsToSet, exactlyVars, getType, listOfVals, listOfVars, logop, longLeaf, node, node, node, node, node, node, node, possibleValues, relop, specialLeaf, toString, unalop, val, var, vars
-
-
-
-
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
-
build
public static XNodeParent<IVar> build(Types.TypeExpr type, Object... os)
-
abs
public static XNodeParent<IVar> abs(Object operand)
-
neg
public static XNodeParent<IVar> neg(Object operand)
-
sqr
public static XNodeParent<IVar> sqr(Object operand)
-
add
public static XNodeParent<IVar> add(Object... operands)
-
sub
public static XNodeParent<IVar> sub(Object operand1, Object operand2)
-
mul
public static XNodeParent<IVar> mul(Object... operands)
-
div
public static XNodeParent<IVar> div(Object operand1, Object operand2)
-
mod
public static XNodeParent<IVar> mod(Object operand1, Object operand2)
-
pow
public static XNodeParent<IVar> pow(Object operand1, Object operand2)
-
min
public static XNodeParent<IVar> min(Object... operands)
-
max
public static XNodeParent<IVar> max(Object... operands)
-
dist
public static XNodeParent<IVar> dist(Object operand1, Object operand2)
-
lt
public static XNodeParent<IVar> lt(Object operand1, Object operand2)
-
le
public static XNodeParent<IVar> le(Object operand1, Object operand2)
-
ge
public static XNodeParent<IVar> ge(Object operand1, Object operand2)
-
gt
public static XNodeParent<IVar> gt(Object operand1, Object operand2)
-
ne
public static XNodeParent<IVar> ne(Object... operands)
-
eq
public static XNodeParent<IVar> eq(Object... operands)
-
in
public static XNodeParent<IVar> in(Object var, Object set)
-
notin
public static XNodeParent<IVar> notin(Object var, Object set)
-
not
public static XNodeParent<IVar> not(Object operand)
-
and
public static XNodeParent<IVar> and(Object... operands)
-
or
public static XNodeParent<IVar> or(Object... operands)
-
xor
public static XNodeParent<IVar> xor(Object... operands)
-
iff
public static XNodeParent<IVar> iff(Object... operands)
-
imp
public static XNodeParent<IVar> imp(Object operand1, Object operand2)
-
ifThenElse
public static XNodeParent<IVar> ifThenElse(Object operand1, Object operand2, Object operand3)
-
scalar
public static XNodeParent<IVar> scalar(int[] t1, Object[] t2)
-
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.
-
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 classXNode<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 inTypeExpr
is used. Some simplifications are also performed; for example,not(eq(x,y))
becomesne(x,y)
.- Specified by:
canonization
in classXNode<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 classXNode<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
- iftrue
, encountered integers are also abstractedmultiOccurrences
- iftrue
, 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 classXNode<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 classXNode<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 classXNode<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
-
replacePartiallyParameters
public XNode<V> replacePartiallyParameters(Object[] valueParameters)
- Specified by:
replacePartiallyParameters
in classXNode<V extends IVar>
-
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, ornull
otherwise.- Specified by:
firstNodeSuchThat
in classXNode<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 classXNode<V extends IVar>
- Parameters:
p
- a predicate to be applied on nodeslist
- 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 notnull
, variables that are present in the tree are replaced by their parameterized forms%i
.- Specified by:
toPostfixExpression
in classXNode<V extends IVar>
- Parameters:
scopeForAbstraction
- if notnull
, 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 notnull
, parameters that are present in the tree are replaced by their corresponding arguments.- Specified by:
toFunctionalExpression
in classXNode<V extends IVar>
- Parameters:
argsForConcretization
- if notnull
, 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
-
-