Term::is_isomorphic_to
: A function to determine if two term objects describe identical expressions.
#53
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.
I've added a
Term::is_isomorphic_to(&self, other: Term&)
, which determines if&self
andother
are structurally equivalent, ie they have isomorphic ASTs.I'm not sure if
is_isomorphic_to
is a particularly good name for this function. Something likeis_equivalent_to
might be an alternative, but may not necessarily be better: program equivalence is the task of determining if two programs have identical behavior and is famously undecidable. Whereas this function only checks that the twoTerm
s are equivalent. I'm open to discussion over the name.I have avoided an implementation of
Eq
as the equivalence check is quite expensive - O(n) in the size of the AST.