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

Provide counterexamples in hexadecimal #1767

Closed
bboston7 opened this issue Nov 24, 2022 · 3 comments
Closed

Provide counterexamples in hexadecimal #1767

bboston7 opened this issue Nov 24, 2022 · 3 comments
Labels
type: feature request Issues requesting a new feature or capability usability An issue that impedes efficient understanding and use

Comments

@bboston7
Copy link
Contributor

A few SAW learners have mentioned to me that they would find SAW counterexamples to be more useful if they were in hexadecimal, or if there were an option like :set base in Cryptol to change the default for counterexamples from decimal to hexadecimal.

One example:

[00:12:49.938] SolverStats {solverStatsSolvers = fromList ["SBV->Z3"], solverStatsGoalSize = 550}
[00:12:49.938] ----------Counterexample----------
[00:12:49.938]   x: 205214799977500604566419154610474108846
[00:12:49.938] ----------------------------------
[00:12:49.938] Stack trace:
"llvm_verify" (/workspaces/exercises/functional-correctness/u128/exercise.saw:27:1-27:12):
Proof failed.
@bboston7 bboston7 added usability An issue that impedes efficient understanding and use type: feature request Issues requesting a new feature or capability labels Nov 24, 2022
@weaversa
Copy link
Contributor

This is an easy one!

sawscript> :h set_base
Description
-----------

    set_base : Int -> TopLevel ()

Set the number base for pretty-printing numeric literals.
Permissible values include 2, 8, 10, and 16.
sawscript> set_base 16
sawscript> sat z3 {{ \(x : [32]) -> x + 100 > x }}
[01:41:57.468] Sat: [x = 0x3f8c]
sawscript> sat z3 {{ \(x : [32]) -> x + 100 < x }}
[01:42:00.324] Sat: [x = 0xffffffbc]

@bboston7
Copy link
Contributor Author

Huh, I'm surprised I didn't know about that one! I'll close this issue then. Thanks @weaversa!

@weaversa
Copy link
Contributor

Well, it could be improved...you'll notice in the counterexamples gotten in my example, the first one 0x3f8c won't type check in Cryptol because the output is supposed to be of type [32]. It would be nicer if the counterexample was printed as `0x00003f8c'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request Issues requesting a new feature or capability usability An issue that impedes efficient understanding and use
Projects
None yet
Development

No branches or pull requests

2 participants