Package io.github.cvc5
Class Term
java.lang.Object
io.github.cvc5.Term
- All Implemented Interfaces:
Comparable<Term>
,Iterable<Term>
A cvc5 Term.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
ConstIterator is an implementation of theIterator
interface for iterating over a collection ofTerm
objects. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBoolean and.int
Comparison for ordering on terms.void
Free the native resource associated with this pointer.protected void
deletePointer
(long pointer) Delete the native resource associated with the specified pointer.Equality.boolean
Syntactic equality operator.Asserts isBitVectorValue().getBitVectorValue
(int base) Get the string representation of a bit-vector value.boolean
Asserts isBooleanValue().Asserts isCardinalityConstraint().getChild
(int index) Get the child term at a given index.Asserts isConstArray().Get the string representation of a finite field value.Asserts isFloatingPointValue().long
getId()
Get the id of this term.Asserts isIntegerValue().getKind()
Get the kind of this term.int
Get the number of children of this term.getOp()
Get the Op used to create this term.long
Return the raw native pointer.Asserts isRealAlgebraicNumber().Asserts isRealAlgebraicNumber().Asserts isRealAlgebraicNumber().int
Get integer or real value sign.Asserts isRealValue().Asserts isRoundingModeValue().Term[]
Asserts isSequenceValue().Asserts isSetValue().Get skolem identifier of this term.Term[]
Get the skolem indices of this term.getSort()
Get the sort of this term.Get the stored string constant.Asserts hasSymbol().Term[]
Asserts isTupleValue().Asserts isUninterpretedSortValue().int
hashCode()
Get the hash value of a term.boolean
hasOp()
Determine if this term has an operator.boolean
Determine if the term has a symbol.Boolean implication.boolean
Determine if the term is a bit-vector value.boolean
Determine if the term is a Boolean value.boolean
Determine if the term is a cardinality constraint.boolean
Determine if the term is a constant array.boolean
Determine if the term is a finite field value.boolean
Determine if the term is the floating-point value for not a number.boolean
Determine if the term is the floating-point value for negative.boolean
Determine if the term is the floating-point value for negative zero.boolean
Determine if the term is the floating-point value for positive.boolean
Determine if the term is the floating-point value for positive zero.boolean
Determine if the term is a floating-point value.boolean
Determine if the term is an integer value.boolean
isNull()
Determine if this term is a null term.boolean
Determine if the term is a real algebraic number.boolean
Determine if the term is a rational value.boolean
Determine if the term is a floating-point rounding mode value.boolean
Determine if the term is a sequence value.boolean
Determine if the term is a set value.boolean
isSkolem()
Determine if this term is a skolem function.boolean
Determine if the term is a string constant.boolean
Determine if the term is a tuple value.boolean
Determine if the term is an uninterpreted sort value.iterator()
If-then-else with this term as the Boolean condition.notTerm()
Boolean negation.Boolean or.substitute
(Term[] terms, Term[] replacements) Simultaneously replaceterms
withreplacements
in this term.substitute
(Term term, Term replacement) Replaceterm
withreplacement
in this term.toString()
Return a string representation of the pointer.protected String
toString
(long pointer) Return a string representation of the specified native pointer.Boolean exclusive or.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
pointer
protected long pointerThe raw native pointer value.
-
-
Constructor Details
-
Term
public Term()Null term
-
-
Method Details
-
deletePointer
protected void deletePointer(long pointer) Delete the native resource associated with the specified pointer.Subclasses must implement this method to provide resource-specific cleanup logic.
- Parameters:
pointer
- the native pointer to delete
-
equals
Syntactic equality operator. Return true if both terms are syntactically identical. -
compareTo
Comparison for ordering on terms.- Specified by:
compareTo
in interfaceComparable<Term>
- Parameters:
t
- The term to compare to.- Returns:
- A negative integer, zero, or a positive integer as this term. is less than, equal to, or greater than the specified term.
-
getNumChildren
public int getNumChildren()Get the number of children of this term.- Returns:
- The number of children of this term.
-
getChild
Get the child term at a given index.- Parameters:
index
- The index of the child term to return.- Returns:
- The child term with the given index.
- Throws:
CVC5ApiException
- on error
-
getId
public long getId()Get the id of this term.- Returns:
- The id of this term.
-
getKind
Get the kind of this term.- Returns:
- The kind of this term.
- Throws:
CVC5ApiException
- on error
-
getSort
Get the sort of this term.- Returns:
- The sort of this term.
-
substitute
Replaceterm
withreplacement
in this term.- Parameters:
term
- The term to replace.replacement
- The term to replace it with.- Returns:
- The result of replacing
term
withreplacement
in this term. - Note:
- This replacement is applied during a pre-order traversal and only once (it is not run until fixed point).
-
substitute
Simultaneously replaceterms
withreplacements
in this term. In the case that terms contains duplicates, the replacement earliest in the vector takes priority. For example, calling substitute onf(x,y)
withterms = { x, z }
,replacements = { g(z), w }
results in the termf(g(z),y)
.- Parameters:
terms
- The terms to replace.replacements
- The replacement terms.- Returns:
- The result of simultaneously replacing
terms
withreplacements
in this term. - Note:
- This replacement is applied during a pre-order traversal and only once (it is not run until fixed point).
-
hasOp
public boolean hasOp()Determine if this term has an operator.- Returns:
- True iff this term has an operator.
-
getOp
Get the Op used to create this term.- Returns:
- The Op used to create this term.
- Note:
- This is safe to call when
hasOp()
returns true.
-
hasSymbol
public boolean hasSymbol()Determine if the term has a symbol.- Returns:
- True if the term has a symbol.
-
getSymbol
Asserts hasSymbol().- Returns:
- The raw symbol of the term.
-
isNull
public boolean isNull()Determine if this term is a null term.- Returns:
- True if this Term is a null term.
-
notTerm
Boolean negation.- Returns:
- The Boolean negation of this term.
-
andTerm
Boolean and.- Parameters:
t
- A Boolean term.- Returns:
- The conjunction of this term and the given term.
-
orTerm
Boolean or.- Parameters:
t
- A Boolean term.- Returns:
- The disjunction of this term and the given term.
-
xorTerm
Boolean exclusive or.- Parameters:
t
- A Boolean term.- Returns:
- The exclusive disjunction of this term and the given term.
-
eqTerm
Equality.- Parameters:
t
- A Boolean term.- Returns:
- The Boolean equivalence of this term and the given term.
-
impTerm
Boolean implication.- Parameters:
t
- A Boolean term.- Returns:
- The implication of this term and the given term.
-
iteTerm
If-then-else with this term as the Boolean condition.- Parameters:
thenTerm
- The 'then' term.elseTerm
- The 'else' term.- Returns:
- The if-then-else term with this term as the Boolean condition.
-
toString
Return a string representation of the specified native pointer.Subclasses must implement this method to convert the native pointer into a meaningful string.
- Parameters:
pointer
- the native pointer- Returns:
- A string representation of this term.
-
getRealOrIntegerValueSign
public int getRealOrIntegerValueSign()Get integer or real value sign. Must be called on integer or real values, or otherwise an exception is thrown.- Returns:
- 0 if this term is zero, -1 if this term is a negative real or integer value, 1 if this term is a positive real or integer value.
-
isIntegerValue
public boolean isIntegerValue()Determine if the term is an integer value.- Returns:
- True if the term is an integer value.
-
getIntegerValue
Asserts isIntegerValue().- Returns:
- The integer represented by this term.
-
isStringValue
public boolean isStringValue()Determine if the term is a string constant.- Returns:
- True if the term is a string constant.
-
getStringValue
Get the stored string constant.- Returns:
- The stored string constant. Asserts isString().
- Note:
- This method is not to be confused with
Object.toString()
) which returns the term in some string representation, whatever data it may hold.
-
isRealValue
public boolean isRealValue()Determine if the term is a rational value.- Returns:
- True if the term is a rational value.
-
getRealValue
Asserts isRealValue().- Returns:
- The representation of a rational value as a pair of its numerator. and denominator.
-
isConstArray
public boolean isConstArray()Determine if the term is a constant array.- Returns:
- True if the term is a constant array.
-
getConstArrayBase
Asserts isConstArray().- Returns:
- The base (element stored at all indices) of a constant array.
-
isBooleanValue
public boolean isBooleanValue()Determine if the term is a Boolean value.- Returns:
- True if the term is a Boolean value.
-
getBooleanValue
public boolean getBooleanValue()Asserts isBooleanValue().- Returns:
- The representation of a Boolean value as a native Boolean value.
-
isBitVectorValue
public boolean isBitVectorValue()Determine if the term is a bit-vector value.- Returns:
- True if the term is a bit-vector value.
-
getBitVectorValue
Asserts isBitVectorValue().- Returns:
- The representation of a bit-vector value in bit string representation.
- Throws:
CVC5ApiException
- on error
-
getBitVectorValue
Get the string representation of a bit-vector value. Supported values forbase
are2
(bit string),10
(decimal string) or16
(hexadecimal string).- Parameters:
base
-2
for binary,10
for decimal, and16
for hexadecimal.- Returns:
- The string representation of a bit-vector value.
- Throws:
CVC5ApiException
- on error- Note:
- Asserts
Term#isBitVectorValue()
.
-
isFiniteFieldValue
public boolean isFiniteFieldValue()Determine if the term is a finite field value.- Returns:
- True if the term is a finite field value.
-
getFiniteFieldValue
Get the string representation of a finite field value.- Returns:
- The string representation of a finite field value.
- Throws:
CVC5ApiException
- on error- Note:
- Asserts
Term#isFiniteFieldValue()
.
-
isUninterpretedSortValue
public boolean isUninterpretedSortValue()Determine if the term is an uninterpreted sort value.- Returns:
- True if the term is an uninterpreted sort value.
-
getUninterpretedSortValue
Asserts isUninterpretedSortValue().- Returns:
- The representation of an uninterpreted sort value as a string.
-
isRoundingModeValue
public boolean isRoundingModeValue()Determine if the term is a floating-point rounding mode value.- Returns:
- True if the term is a floating-point rounding mode value.
-
getRoundingModeValue
Asserts isRoundingModeValue().- Returns:
- The floating-point rounding mode value held by the term.
- Throws:
CVC5ApiException
- on error
-
isTupleValue
public boolean isTupleValue()Determine if the term is a tuple value.- Returns:
- True if the term is a tuple value.
-
getTupleValue
Asserts isTupleValue().- Returns:
- The representation of a tuple value as a vector of terms.
-
isFloatingPointPosZero
public boolean isFloatingPointPosZero()Determine if the term is the floating-point value for positive zero.- Returns:
- True if the term is the floating-point value for positive zero.
-
isFloatingPointNegZero
public boolean isFloatingPointNegZero()Determine if the term is the floating-point value for negative zero.- Returns:
- True if the term is the floating-point value for negative zero.
-
isFloatingPointPosInf
public boolean isFloatingPointPosInf()Determine if the term is the floating-point value for positive.- Returns:
- True if the term is the floating-point value for positive. infinity.
-
isFloatingPointNegInf
public boolean isFloatingPointNegInf()Determine if the term is the floating-point value for negative. infinity.- Returns:
- True if the term is the floating-point value for negative. infinity.
-
isFloatingPointNaN
public boolean isFloatingPointNaN()Determine if the term is the floating-point value for not a number.- Returns:
- True if the term is the floating-point value for not a number.
-
isFloatingPointValue
public boolean isFloatingPointValue()Determine if the term is a floating-point value.- Returns:
- True if the term is a floating-point value.
-
getFloatingPointValue
Asserts isFloatingPointValue().- Returns:
- The representation of a floating-point value as a tuple of the. exponent width, the significand width and a bit-vector value.
-
isSetValue
public boolean isSetValue()Determine if the term is a set value.- Returns:
- True if the term is a set value.
-
getSetValue
Asserts isSetValue().- Returns:
- The representation of a set value as a set of terms.
-
isSequenceValue
public boolean isSequenceValue()Determine if the term is a sequence value.- Returns:
- True if the term is a sequence value.
-
getSequenceValue
Asserts isSequenceValue().- Returns:
- The representation of a sequence value as a vector of terms.
- Note:
- It is usually necessary for sequences to call
Solver.simplify(Term)
to turn a sequence that is constructed by, e.g., concatenation of unit sequences, into a sequence value.
-
isCardinalityConstraint
public boolean isCardinalityConstraint()Determine if the term is a cardinality constraint.- Returns:
- True if the term is a cardinality constraint.
-
getCardinalityConstraint
Asserts isCardinalityConstraint().- Returns:
- The sort the cardinality constraint is for and its upper bound.
-
isRealAlgebraicNumber
public boolean isRealAlgebraicNumber()Determine if the term is a real algebraic number.- Returns:
- True if the term is a real algebraic number.
-
getRealAlgebraicNumberDefiningPolynomial
Asserts isRealAlgebraicNumber().- Parameters:
v
- The variable over which to express the polynomial.- Returns:
- The defining polynomial for the real algebraic number, expressed in terms of the given variable.
-
getRealAlgebraicNumberLowerBound
Asserts isRealAlgebraicNumber().- Returns:
- The lower bound for the value of the real algebraic number.
-
getRealAlgebraicNumberUpperBound
Asserts isRealAlgebraicNumber().- Returns:
- The upper bound for the value of the real algebraic number.
-
isSkolem
public boolean isSkolem()Determine if this term is a skolem function.- Returns:
- True if this term is a skolem function.
- Note:
- This method is experimental and may change in future versions.
-
getSkolemId
Get skolem identifier of this term.- Returns:
- The skolem identifier of this term.
- Throws:
CVC5ApiException
- on error- Note:
- Asserts isSkolem()., This method is experimental and may change in future versions.
-
getSkolemIndices
Get the skolem indices of this term.- Returns:
- The skolem indices of this term. This a list of terms that the
skolem function is indexed by. For example, the array diff skolem
SkolemId.ARRAY_DEQ_DIFF
is indexed by two arrays. - Throws:
CVC5ApiException
- on error- Note:
- Asserts isSkolem()., This method is experimental and may change in future versions.
-
iterator
-
hashCode
public int hashCode()Get the hash value of a term. -
getPointer
public long getPointer()Return the raw native pointer.- Returns:
- the pointer value
-
deletePointer
public void deletePointer()Free the native resource associated with this pointer.This method should be called to explicitly clean up the underlying native resource. It removes this instance from the
Context
, then invokes the subclass-defineddeletePointer(long)
method to perform the actual cleanup. -
toString
Return a string representation of the pointer.
-