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

Issuing prove_print command in interpreter results in extra output #25

Closed
jpziegler opened this issue Jun 12, 2015 · 2 comments
Closed
Labels
better-in-python Will be fixed by switching to python frontend

Comments

@jpziegler
Copy link

Running saw on the following file (test.saw):

let thm = {{ \x -> x+x == x*(2:[32]) }};
prove_print abc thm;

Results in the following output:

$ saw test.saw
Loading module Cryptol
Loading file "test.saw"
Loading module Main
Valid

However, running the same commands directly in the interpreter results in extra output:

sawscript> let thm = {{ \x -> x+x == x*(2:[32]) }};
sawscript> prove_print abc thm;
Valid
Theorem (let { x0 = Cryptol.TCNum 2;
      x1 = Cryptol.TCNum 32;
      x2 = Cryptol.ePArith x3;
      x3 = Cryptol.seq x1
             Prelude.Bool;
    }
 in \(x::x3) ->
      Cryptol.ecEq x3
        (Cryptol.ePCmp x3)
        (Cryptol.ecPlus x3 x2 x x)
        (Cryptol.ecMul x3 x2 x
           (Cryptol.ecDemote x0 x1
              (Cryptol.ePFin x0)
              (Cryptol.ePFin x1)
              (Cryptol.ePGeq x1
                 (Cryptol.tcWidth x0)))))
@brianhuffman
Copy link
Contributor

This is by design; it's made to match the behavior of ghci. In the interpreter, if you evaluate a command that has saw-script type TopLevel a and don't bind the result to a variable, then the return value of the command is printed (unless the return value is (), which never gets printed). Otherwise the result value would be lost.

I guess what's weird about prove_print is that it prints output to the screen and has a return value. In Haskell, most library IO functions just do one or the other. The name prove_print suggests that it prints something, so maybe we should make it return (). We'll consider this when we do our overhaul of the saw-script proof commands (see #9).

@jpziegler
Copy link
Author

I originally ran into this with one of the examples from the tutorial. In that case, the amount of output was so large that most of it scrolled completely off the buffer of my terminal. Only after I increased the buffer size was I able to scroll up and see that "Valid" was printed at all.

I suggest adding variable bindings to the tutorial examples that use prove_print so that the code generates the same output in the interpreter as it does in a script. This would result in less confusion for new learners (like myself) who go off-book from time to time. Like so:

result <- prove_print abc thm;

@brianhuffman brianhuffman added the better-in-python Will be fixed by switching to python frontend label Jan 29, 2021
@atomb atomb closed this as completed Jan 29, 2021
brianhuffman pushed a commit that referenced this issue Apr 26, 2021
brianhuffman pushed a commit that referenced this issue Apr 26, 2021
This is another step toward addressing #25.
brianhuffman pushed a commit that referenced this issue Apr 26, 2021
…vLit (as the two had the same definition anyway); also changed bitvector literals to use signed integers, and switched to using the bv-sized library to do this translation instead of rolling our own; all of this in support of #25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
better-in-python Will be fixed by switching to python frontend
Projects
None yet
Development

No branches or pull requests

3 participants