Interface SymbolicExpression

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

public interface SymbolicExpression extends SymbolicObject

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.

  • Method Details

    • argument

      SymbolicObject argument(int index)
      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 an Iterable object.
      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 operator SymbolicExpression.SymbolicOperator.NULL, 0 arguments, and null type.
      Returns:
      true iff the operator of this expression is SymbolicExpression.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 to NumericExpression.
      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

      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 SymbolicType of 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

      void printCompressedTree(String prefix, StringBuffer out)
      Prints compressed tree representation of this expression.
      Parameters:
      prefix - any string that callers of this method want to add before each line
      out - 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.