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

Pretty-printing uniques explicitly #4808

Closed
effectfully opened this issue Aug 11, 2022 · 2 comments · Fixed by #5972
Closed

Pretty-printing uniques explicitly #4808

effectfully opened this issue Aug 11, 2022 · 2 comments · Fixed by #5972
Assignees
Labels
bug Low priority Doesn't require immediate attention status: triaged

Comments

@effectfully
Copy link
Contributor

effectfully commented Aug 11, 2022

Summary

Currently the unique of a variable is not pretty-printed with the default strategy, which I believe is in fact a bug, because parsing a pretty-printed program may get you back a different program. Not up to alpha, an actually different program. A program with a free variable is almost guaranteed to trigger this, however it doesn't need to be free for that, consider pretty-printing and parsing back \x_0 x_1 -> x_0 -- you'll get \x_0 x_1 -> x_1 back.

Now we could just pretty-print the uniques by default, but this has its own problems: it practically changes the names, because syntactically a pretty-printed unique is indistinguishable from a normal part of a name (i.e. x_0 was either the x name with the pretty-printed 0 unique or the x_0 name without a pretty-printed unique). Randomly changing names confuse people, invalidate in-memory environments and cause other kinds of disruption.

Thanks to Runtime Verification Inc. for reaching out to us regarding these issues.

Steps to reproduce the behavior

  1. pretty-print the AST of \x_0 x_1 -> x_0 using the default strategy
  2. parse it back

Actual Result

got a different term back

Expected Result

the resulting term is alpha-equal to the original one

Describe the approach you would take to fix this

We can solve all these problems by always pretty-printing the uniques and not making them a syntactically legal part of the textual name of the variable. For example by pretty-printing the x variable having the 0 unique as x!0 or x#0 or whatever (suggestions are welcome).

System info

Plutus: 1203fa3

@michaelpj
Copy link
Contributor

We can solve all these problems by always pretty-printing the uniques and not making them a syntactically legal part of the textual name of the variable.

And by parsing this format as well, obviously.

@bezirg
Copy link
Contributor

bezirg commented May 16, 2024

mpj wrote on SCP-817:

At the moment it doesn't, so we can't necessarily tell in our tests that we don't mix up same-named arguments.

But in order to not make the tests awful we'd want to do what we do for PLC and de-Bruijnify the terms, which would require writing a similar pass for PIR. So it's a bit of work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Low priority Doesn't require immediate attention status: triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants