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

Use numbers instead of primes to distinguish shadowed names in prettyprinted saw-core #1619

Closed
brianhuffman opened this issue Mar 17, 2022 · 0 comments · Fixed by #1636
Closed
Labels
subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem

Comments

@brianhuffman
Copy link
Contributor

Currently, the saw-core prettyprinter adds primes (') to bound variable names during printing to avoid name shadowing when it encounters a bound name that was already bound in an outer scope. In some terms this can get really out of hand: For example, I'm looking at some saw-core terms coming from heapster, and when printed they contain names like z''''''''''''''''''''''''''''' and z''''''''''''''''''''''''''''''. Are those the same name, or not? I don't know!

Instead of adding primes, we should switch to appending numbers. So instead of x, x', x'', x''' we would do x, x1, x2, x3. There's already code for doing this kind of unique name variant generation in the saw-core-coq package, which we could copy.

nextVariant :: Coq.Ident -> Coq.Ident
nextVariant = reverse . go . reverse
where
go :: String -> String
go (c : cs)
| c == '9' = '0' : go cs
| isDigit c = succ c : cs
go cs = '1' : cs

@brianhuffman brianhuffman added the subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem label Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant