Skip to content

Remove types from Constant terms #2437

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

Merged
merged 6 commits into from
Jun 23, 2025
Merged

Remove types from Constant terms #2437

merged 6 commits into from
Jun 23, 2025

Conversation

brianhuffman
Copy link
Contributor

Constant terms now use the new untyped Name type instead of ExtCns. The types of constants are now stored only in the global environment (in the ModuleMap) instead of being redundantly stored also in the term AST. Fixes #2383.

This change necessitated threading a ModuleMap throughout many operations in the saw-core-coq package (module Monadify in particular). Adding an implicit parameter seemed to be the least disruptive way to do this; eventually it would be nice to refactor that code to minimize the use of the implicit parameter.

@brianhuffman brianhuffman marked this pull request as ready for review June 21, 2025 16:21
Copy link
Contributor

@RyanGlScott RyanGlScott left a comment

Choose a reason for hiding this comment

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

Looks generally reasonable upon a quick glance of the changes involved. Having to plumb around an extra ModuleMap argument in so many places is a bit unfortunate, but it's not clear how to avoid that would more invasive changes. I've left one inline comment about a particular spot where we may be able to avoid some of this plumbing.


-- | Get the 'FunName' of a global definition
mrGlobalDef :: Ident -> MRM t FunName
mrGlobalDef :: (?mm :: ModuleMap) => Ident -> MRM t FunName
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to pass around implicit ?mm :: ModuleMap constraints for things with a return type of MRM, like in this function? My understanding is that we can retrieve a ModuleMap using liftSC0 scGetModuleMap here (as is done in extCnsToFunName, for instance) without needing to plumb extra constraints.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I guess I missed that one. Maybe this means that I'll be able to remove the implicit parameter from a few other functions that call this one too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As it turns out, mrGlobalDef is not called by anything; it's dead code, so I just removed it. I rewrote mrCallsFun as you suggested, and that let me remove the constraint on mrFunBodyRecInfo.

@brianhuffman brianhuffman merged commit 485c045 into master Jun 23, 2025
37 checks passed
@brianhuffman brianhuffman deleted the bh/constant-no-type branch June 23, 2025 12:37
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.

SAWCore Constants shouldn't include a type in the term AST
2 participants