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

Short names are not always used for pretty-printing terms #1277

Open
brianhuffman opened this issue Apr 29, 2021 · 5 comments
Open

Short names are not always used for pretty-printing terms #1277

brianhuffman opened this issue Apr 29, 2021 · 5 comments
Labels
subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem type: enhancement Issues describing an improvement to an existing feature or capability usability An issue that impedes efficient understanding and use
Milestone

Comments

@brianhuffman
Copy link
Contributor

PR GaloisInc/saw-core#126 implemented a namespace-aware prettyprinter for saw-core, which uses the shortest unambiguous form of names, so we don't have to see fully-qualified names everywhere.

The print_goal proof command uses the namespace-aware prettyprinter, as does the print_term command.

sawscript> prove do { print_goal; assume_unsat; } {{ \(x:Bit) -> ~ x }}
[23:56:52.297] Goal prove (goal number 0):
[23:56:52.298] (x : Bool)
-> EqTrue (ecCompl Bool PLogicBit x)
[23:56:52.298] WARNING: assuming goal prove is unsat
[23:56:52.298] Valid
sawscript> print_term {{ \(x:Bit) -> ~ x }}
[23:57:02.808] \(x : Bool) -> ecCompl Bool PLogicBit x

However, if a term is just written directly on the REPL, it is printed with all qualified names:

sawscript> {{ \(x:Bit) -> ~ x }}
[23:57:09.145] \(x : Prelude.Bool) ->
  Cryptol.ecCompl Prelude.Bool Cryptol.PLogicBit x

We should always be using the namespace-aware prettyprinter.

@brianhuffman brianhuffman added subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem and removed subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem labels Apr 29, 2021
@brianhuffman
Copy link
Contributor Author

The print_term function is implemented using scShowTerm, which runs in the IO monad and uses a SharedContext to obtain naming information.

show_term :: Term -> TopLevel String
show_term t =
do opts <- getTopLevelPPOpts
sc <- getSharedContext
liftIO $ scShowTerm sc opts t
print_term :: Term -> TopLevel ()
print_term t = printOutLnTop Info =<< show_term t

However, when a value is written by itself on the REPL, it is printed by function processStmtBind, which calls showsPrecValue on the computed value.

-- Print non-unit result if it was not bound to a variable
case pat of
SS.PWild _ | printBinds && not (isVUnit result) ->
printOutLnTop Info (showsPrecValue opts 0 result "")
_ -> return ()

To fix the problem, we'll have to replace or modify showsPrecValue so that it takes a SharedContext argument and can run in the IO monad.

@robdockins robdockins added the usability An issue that impedes efficient understanding and use label May 21, 2021
@brianhuffman brianhuffman self-assigned this May 21, 2021
@brianhuffman
Copy link
Contributor Author

We might just try removing the Show instance for the saw-script Value type and see what breaks.

@brianhuffman
Copy link
Contributor Author

See also #1608.

@robdockins
Copy link
Contributor

Some progress has been made on this in #1689

@robdockins robdockins removed their assignment Aug 26, 2022
@sauclovian-g
Copy link
Contributor

And see #747. Arguably, this is a duplicate...

@sauclovian-g sauclovian-g added type: enhancement Issues describing an improvement to an existing feature or capability subsystem: saw-core Issues related to the saw-core representation or the saw-core subsystem labels Nov 1, 2024
@sauclovian-g sauclovian-g added this to the 2025T1 milestone Nov 1, 2024
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 type: enhancement Issues describing an improvement to an existing feature or capability usability An issue that impedes efficient understanding and use
Projects
None yet
Development

No branches or pull requests

3 participants