-
Notifications
You must be signed in to change notification settings - Fork 148
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
Output counterexamples for failed Foundry proofs #1946
Changes from all commits
c9e37f3
b51288c
89c0085
28bedb6
f95834e
7bfa8df
988e9e9
c7b11d8
cd569a7
b9130b9
c283305
c9d786f
6d0257a
53142aa
dfb0c1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "kevm-pyk" | ||
version = "1.0.231" | ||
version = "1.0.232" | ||
description = "" | ||
authors = [ | ||
"Runtime Verification, Inc. <[email protected]>", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
from typing import TYPE_CHECKING | ||
|
||
from pyk.cterm import CTerm | ||
from pyk.kast.inner import KApply, KRewrite, KVariable, Subst | ||
from pyk.kast.inner import KApply, KInner, KRewrite, KVariable, Subst | ||
from pyk.kast.manip import ( | ||
abstract_term_safely, | ||
bottom_up, | ||
|
@@ -25,9 +25,8 @@ | |
from collections.abc import Callable, Collection, Iterable | ||
from typing import Final, TypeVar | ||
|
||
from pyk.kast import KInner | ||
from pyk.kast.outer import KDefinition | ||
from pyk.kcfg import KCFGExplore | ||
from pyk.kcfg import KCFG, KCFGExplore | ||
from pyk.ktool.kprove import KProve | ||
from pyk.proof.proof import Proof | ||
from pyk.utils import BugReport | ||
|
@@ -177,7 +176,7 @@ def kevm_prove( | |
return False | ||
|
||
|
||
def print_failure_info(proof: Proof, kcfg_explore: KCFGExplore) -> list[str]: | ||
def print_failure_info(proof: Proof, kcfg_explore: KCFGExplore, counterexample_info: bool = False) -> list[str]: | ||
if type(proof) is APRProof or type(proof) is APRBMCProof: | ||
target = proof.kcfg.node(proof.target) | ||
|
||
|
@@ -213,11 +212,13 @@ def print_failure_info(proof: Proof, kcfg_explore: KCFGExplore) -> list[str]: | |
|
||
res_lines.append(' Path condition:') | ||
res_lines += [f' {kcfg_explore.kprint.pretty_print(proof.path_constraints(node.id))}'] | ||
if counterexample_info: | ||
res_lines.extend(print_model(node, kcfg_explore)) | ||
|
||
res_lines.append('') | ||
res_lines.append( | ||
'Join the Runtime Verification Discord server for support: https://discord.gg/GHvFbRDD' | ||
) | ||
res_lines.append('') | ||
res_lines.append( | ||
'Join the Runtime Verification Discord server for support: https://discord.com/invite/CurfmXNtbN' | ||
) | ||
|
||
return res_lines | ||
elif type(proof) is EqualityProof: | ||
|
@@ -226,6 +227,20 @@ def print_failure_info(proof: Proof, kcfg_explore: KCFGExplore) -> list[str]: | |
raise ValueError('Unknown proof type.') | ||
|
||
|
||
def print_model(node: KCFG.Node, kcfg_explore: KCFGExplore) -> list[str]: | ||
res_lines: list[str] = [] | ||
result_subst = kcfg_explore.cterm_get_model(node.cterm) | ||
if type(result_subst) is Subst: | ||
res_lines.append(' Model:') | ||
for var, term in result_subst.to_dict().items(): | ||
term_kast = KInner.from_dict(term) | ||
res_lines.append(f' {var} = {kcfg_explore.kprint.pretty_print(term_kast)}') | ||
else: | ||
res_lines.append(' Failed to generate a model.') | ||
|
||
return res_lines | ||
Comment on lines
+230
to
+241
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We rewrote the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks Noah! I can probably try integrating the new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, didn't have a chance to do this, and I'll unfortunately be travelling starting tomorrow. Could you please advise if we should merge it in as it is and refactor |
||
|
||
|
||
def arg_pair_of( | ||
fst_type: Callable[[str], T1], snd_type: Callable[[str], T2], delim: str = ',' | ||
) -> Callable[[str], tuple[T1, T2]]: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should produce a data structure (maybe
FoundryModel | None
). Functionprint_model
can be a method on this class (without the"Failed to ..."
branch). Functionprint_failure_info
then can be redefined asThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I agree! Will add the
FoundryModel
class and modify the printing functions accordingly (there's some more refactoring to be done, as suggested by @nwatson22), but I need a bit more time to work on it. Would you recommend to merge the current PR and refactor it later, or should I include this change in this PR? Thank you!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine either way. If you decide to merge now, please open an issue to document the requested changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue created: #1955