Add hash
field to all BasicSymbolic
subtypes
#590
+29
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR does the following things:
Previously only
Term
,Mul
,Add
have the fieldhash
. It is now added to allBasicSymbolic
subtypes. Nowhash
is only computed and stored the first time when it is needed.Fix Why don't
Pow
andDiv
havehash
field? #465Previously the default initial value of the field
hash
isconst EMPTY_HASH = RefValue(UInt(0))
. That is, the pointer of thehash
field of any newly constructedBasicSymbolic
directs to exactly the identicalRefValue(UInt(0))
object. This has not caused issues because the constructors ofTerm
,Mul
,Add
manually created a freshRefValue(UInt(0))
. This PR modifies the struct definition ofBasicSymbolic
such that it automatically creates a newRefVaule
object forhash
whenever a newBasicSymbolic
object is created and we don't need to add it as a keyword argument anymore in the constructors.A test is fixed, because that as a field of type
RefValue{UInt}
is added toSym
, the following should now returnfalse
.