- All Superinterfaces:
SymbolicObject
- All Known Subinterfaces:
ArrayElementReference,BooleanExpression,BooleanSymbolicConstant,Constant,Monic,Monomial,NTReferenceExpression,NTValueSetReference,NumericExpression,NumericSymbolicConstant,OffsetReference,Polynomial,Primitive,PrimitivePower,RationalExpression,ReferenceExpression,SymbolicConstant,TupleComponentReference,UnionMemberReference,ValueSetReference,VSArrayElementReference,VSArraySectionReference,VSIdentityReference,VSOffsetReference,VSTupleComponentReference,VSUnionMemberReference
An instance SymbolicExpression represents a symbolic expression. This
is the root of the symbolic expression type hierarchy.
A SymbolicExpression is a kind of SymbolicObject. Like all
symbolic objects, symbolic expressions are immutable: they cannot be modified
after they are instantiated. (Or at least, not in a way visible to the user.)
A symbolic expression has an operator (instance of SymbolicExpression.SymbolicOperator),
a type (SymbolicType), and some number of arguments, which together
fully specify the expression. The arguments implement the
SymbolicObject interface. SymbolicExpression extends
SymbolicObject, so a symbolic expression can be used as an argument
(but so can other kinds of symbolic objects).
The difference between symbolic expressions and symbolic objects which are not symbolic expressions is that the latter may have essential fields that are not arguments. (An essential field is used in the "equals" method.) In contrast, a symbolic expression is completely determined by its operator, type, and arguments.
TO POSSIBLY DO: add IFF (if and only if), add IMPLIES, let quantifiers take multiple variables.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumAn enumerated type for the different kinds of symbolic expressions.Nested classes/interfaces inherited from interface dev.civl.sarl.IF.object.SymbolicObject
SymbolicObject.SymbolicObjectKind -
Method Summary
Modifier and TypeMethodDescriptionargument(int index) Returns the i-th argument (child) of the operator.A string representation appropriate for nesting in other expressions, typically by surrounding the normal string version with parentheses if necessary.Iterable<? extends SymbolicObject> Returns the sequence of arguments as anIterableobject.Get the set of free variables occurring in this symbolic expression.booleanisFalse()Is this the boolean "false" expression?booleanisNull()Is this the "NULL" symbolic expression? A NULL expression has operatorSymbolicExpression.SymbolicOperator.NULL, 0 arguments, andnulltype.booleanIs this a numeric expression, i.e., does this have integer or real type? If true, this may be safely cast toNumericExpression.booleanisOne()Is this the integer or real 1 expression?booleanisTrue()Is this the boolean "true" expression?booleanisZero()Is this the integer or real 0 expression?intThe number of arguments (children) of this symbolic expression.operator()The operator of this symbolic expression.voidprintCompressedTree(String prefix, StringBuffer out) Prints compressed tree representation of this expression.intsize()type()Returns the type of this symbolic expression.Methods inherited from interface dev.civl.sarl.IF.object.SymbolicObject
containsQuantifier, containsSubobject, containsSubobjectIgnoringType, equals, getOrder, hashCode, id, isCanonic, setInCanonic, setOrder, symbolicObjectKind, toString, toStringBuffer, toStringBufferLong
-
Method Details
-
argument
Returns the i-th argument (child) of the operator.- Parameters:
index- the index i- Returns:
- the i-th argument
-
getArguments
Iterable<? extends SymbolicObject> getArguments()Returns the sequence of arguments as anIterableobject.- Returns:
- the argument sequence as an
Iterable
-
atomString
String atomString()A string representation appropriate for nesting in other expressions, typically by surrounding the normal string version with parentheses if necessary. -
isFalse
boolean isFalse()Is this the boolean "false" expression?- Returns:
- true iff this is the boolean expression "false".
-
isNull
boolean isNull()Is this the "NULL" symbolic expression? A NULL expression has operatorSymbolicExpression.SymbolicOperator.NULL, 0 arguments, andnulltype.- Returns:
trueiff the operator of this expression isSymbolicExpression.SymbolicOperator.NULL.
-
isNumeric
boolean isNumeric()Is this a numeric expression, i.e., does this have integer or real type? If true, this may be safely cast toNumericExpression.- Returns:
- true iff type is integer or real
-
isOne
boolean isOne()Is this the integer or real 1 expression?- Returns:
- true iff this is the integer 1 or the real 1
-
isTrue
boolean isTrue()Is this the boolean "true" expression?- Returns:
- true iff this is the boolean expression "true".
-
isZero
boolean isZero()Is this the integer or real 0 expression?- Returns:
- true iff this is the integer 0 or the real 0
-
numArguments
int numArguments()The number of arguments (children) of this symbolic expression.- Returns:
- number of arguments
-
operator
SymbolicExpression.SymbolicOperator operator()The operator of this symbolic expression.- Returns:
- the operator of the symbolic expression
-
type
SymbolicType type()Returns the type of this symbolic expression.- Returns:
- the
SymbolicTypeof this expression
-
getFreeVars
Set<SymbolicConstant> getFreeVars()Get the set of free variables occurring in this symbolic expression. Do not attempt to modify the set returned or all future behavior is undefined.- Returns:
- the set of free (i.e., not bound) variables (symbolic constants) occurring in this expression
-
printCompressedTree
Prints compressed tree representation of this expression.- Parameters:
prefix- any string that callers of this method want to add before each lineout- the output StringBuffer
-
size
int size()- Returns:
- the size of this
SymbolicExpression. The size of a symbolic expression is the total number of "node"s in the "tree". A symbolic expression is essentially a tree of (sub-)symbolic expressions.
-