|
44 | 44 | from pyk.proof.proof import Proof
|
45 | 45 | from pyk.proof.reachability import APRFailureInfo, APRProof
|
46 | 46 | from pyk.proof.show import APRProofNodePrinter, APRProofShow
|
| 47 | +from pyk.proof.tui import APRProofViewer |
47 | 48 | from pyk.utils import ensure_dir_path, hash_str, run_process_2, single, unique
|
48 | 49 |
|
49 | 50 | from . import VERSION
|
|
86 | 87 | SimplifyNodeOptions,
|
87 | 88 | SplitNodeOptions,
|
88 | 89 | StepNodeOptions,
|
89 |
| - ToDotOptions, |
90 | 90 | UnrefuteNodeOptions,
|
| 91 | + ViewKcfgOptions, |
91 | 92 | )
|
92 | 93 |
|
93 | 94 | _LOGGER: Final = logging.getLogger(__name__)
|
@@ -670,6 +671,14 @@ def success(s: KInner, dst: KInner, r: KInner, c: KInner, e1: KInner, e2: KInner
|
670 | 671 | def fail(s: KInner, dst: KInner, r: KInner, c: KInner, e1: KInner, e2: KInner) -> KApply:
|
671 | 672 | return notBool(Foundry.success(s, dst, r, c, e1, e2))
|
672 | 673 |
|
| 674 | + @staticmethod |
| 675 | + def hevm_success(s: KInner, dst: KInner, out: KInner) -> KApply: |
| 676 | + return KApply('hevm_success', [s, dst, out]) |
| 677 | + |
| 678 | + @staticmethod |
| 679 | + def hevm_fail(s: KInner, dst: KInner) -> KApply: |
| 680 | + return KApply('hevm_fail', [s, dst]) |
| 681 | + |
673 | 682 | # address(uint160(uint256(keccak256("foundry default caller"))))
|
674 | 683 |
|
675 | 684 | @staticmethod
|
@@ -735,13 +744,28 @@ def symbolic_account(prefix: str, program: KInner, storage: KInner | None = None
|
735 | 744 | )
|
736 | 745 |
|
737 | 746 | @staticmethod
|
738 |
| - def help_info() -> list[str]: |
| 747 | + def help_info(proof_id: str, hevm: bool) -> list[str]: |
739 | 748 | res_lines: list[str] = []
|
740 |
| - res_lines.append('') |
741 |
| - res_lines.append('See `foundry_success` predicate for more information:') |
742 |
| - res_lines.append( |
743 |
| - 'https://github.com/runtimeverification/kontrol/blob/master/src/kontrol/kdist/foundry.md#foundry-success-predicate' |
744 |
| - ) |
| 749 | + if hevm: |
| 750 | + _, test = proof_id.split('.') |
| 751 | + if not any(test.startswith(prefix) for prefix in ['testFail', 'checkFail', 'proveFail']): |
| 752 | + res_lines.append('') |
| 753 | + res_lines.append('See `hevm_success` predicate for more information:') |
| 754 | + res_lines.append( |
| 755 | + 'https://github.com/runtimeverification/kontrol/blob/master/src/kontrol/kdist/hevm.md#hevm-success-predicate' |
| 756 | + ) |
| 757 | + else: |
| 758 | + res_lines.append('') |
| 759 | + res_lines.append('See `hevm_fail` predicate for more information:') |
| 760 | + res_lines.append( |
| 761 | + 'https://github.com/runtimeverification/kontrol/blob/master/src/kontrol/kdist/hevm.md#hevm-fail-predicate' |
| 762 | + ) |
| 763 | + else: |
| 764 | + res_lines.append('') |
| 765 | + res_lines.append('See `foundry_success` predicate for more information:') |
| 766 | + res_lines.append( |
| 767 | + 'https://github.com/runtimeverification/kontrol/blob/master/src/kontrol/kdist/foundry.md#foundry-success-predicate' |
| 768 | + ) |
745 | 769 | res_lines.append('')
|
746 | 770 | res_lines.append('Access documentation for Kontrol at https://docs.runtimeverification.com/kontrol')
|
747 | 771 | return res_lines
|
@@ -990,7 +1014,7 @@ def foundry_show(
|
990 | 1014 | extra_module=foundry.load_lemmas(options.lemmas),
|
991 | 1015 | ) as kcfg_explore:
|
992 | 1016 | res_lines += print_failure_info(proof, kcfg_explore, options.counterexample_info)
|
993 |
| - res_lines += Foundry.help_info() |
| 1017 | + res_lines += Foundry.help_info(proof.id, False) |
994 | 1018 |
|
995 | 1019 | if options.to_kevm_claims or options.to_kevm_rules:
|
996 | 1020 | _foundry_labels = [
|
@@ -1070,16 +1094,19 @@ def _collect_klabel(_k: KInner) -> None:
|
1070 | 1094 | return '\n'.join([line.rstrip() for line in res_lines])
|
1071 | 1095 |
|
1072 | 1096 |
|
1073 |
| -def foundry_to_dot(foundry: Foundry, options: ToDotOptions) -> None: |
1074 |
| - dump_dir = foundry.proofs_dir / 'dump' |
| 1097 | +def foundry_view(foundry: Foundry, options: ViewKcfgOptions) -> None: |
1075 | 1098 | test_id = foundry.get_test_id(options.test, options.version)
|
1076 |
| - contract_name, _ = single(foundry.matching_tests([options.test])).split('.') |
| 1099 | + contract_name, _ = test_id.split('.') |
1077 | 1100 | proof = foundry.get_apr_proof(test_id)
|
1078 | 1101 |
|
1079 |
| - node_printer = foundry_node_printer(foundry, contract_name, proof) |
1080 |
| - proof_show = APRProofShow(foundry.kevm, node_printer=node_printer) |
| 1102 | + compilation_unit = CompilationUnit.load_build_info(foundry.build_info) |
| 1103 | + |
| 1104 | + def _custom_view(elem: KCFGElem) -> Iterable[str]: |
| 1105 | + return foundry.custom_view(contract_name, elem, compilation_unit) |
1081 | 1106 |
|
1082 |
| - proof_show.dump(proof, dump_dir, dot=True) |
| 1107 | + node_printer = foundry_node_printer(foundry, contract_name, proof) |
| 1108 | + viewer = APRProofViewer(proof, foundry.kevm, node_printer=node_printer, custom_view=_custom_view) |
| 1109 | + viewer.run() |
1083 | 1110 |
|
1084 | 1111 |
|
1085 | 1112 | def foundry_list(foundry: Foundry) -> list[str]:
|
@@ -1212,8 +1239,7 @@ def foundry_split_node(
|
1212 | 1239 | proof = foundry.get_apr_proof(test_id)
|
1213 | 1240 |
|
1214 | 1241 | token = KToken(options.branch_condition, 'Bool')
|
1215 |
| - node_printer = foundry_node_printer(foundry, contract_name, proof) |
1216 |
| - parsed_condition = node_printer.kprint.parse_token(token, as_rule=True) |
| 1242 | + parsed_condition = foundry.kevm.parse_token(token, as_rule=True) |
1217 | 1243 |
|
1218 | 1244 | split_nodes = proof.kcfg.split_on_constraints(
|
1219 | 1245 | options.node, [mlEqualsTrue(parsed_condition), mlEqualsFalse(parsed_condition)]
|
|
0 commit comments