Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Term::is_isomorphic_to: A function to determine if two term objects describe identical expressions. #53

Merged
merged 2 commits into from
May 29, 2024

Conversation

AgentElement
Copy link
Contributor

@AgentElement AgentElement commented May 29, 2024

I've added a Term::is_isomorphic_to(&self, other: Term&), which determines if &self and other 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 like is_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 two Terms 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.

src/term.rs Outdated Show resolved Hide resolved
Copy link
Owner

@ljedrz ljedrz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, very cool; two requests:

  • rebase
  • a small refactoring, as proposed in the suggestion

Co-authored-by: ljedrz <ljedrz@users.noreply.github.com>
@AgentElement
Copy link
Contributor Author

Both should now be done, thanks.

Copy link
Owner

@ljedrz ljedrz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ljedrz ljedrz merged commit 221c85c into ljedrz:master May 29, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants