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

Factor out vat arithmetic in proof-reuse for MCD #2467

Merged
merged 25 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dc99444
tests/specs/mcd/vat-arithmetic-spec: single spec file with all vat ar…
ehildenb Sep 25, 2023
9669082
tests/specs/mcd/vat-spec.k: add single file incorporating all VAT proofs
ehildenb Sep 25, 2023
d723cc7
tests/specs/mcd/vat-*: update vat specs with more dependencies
ehildenb Sep 25, 2023
14f4c9b
tests/specs/mcd/flopper-cage-pass: formatting
ehildenb Sep 25, 2023
31d8752
tests/specs/mcd/vat-*: update with more dependency proofs
ehildenb Sep 25, 2023
52a64ad
tests/specs/mcd/vat-spec: add missing spec
ehildenb Sep 25, 2023
a9d1742
tests/specs/mcd/vat-arithmetic-spec: update <useGas> cell, remove unu…
ehildenb May 28, 2024
1a41014
tests/specs/mcd: remove now-redundant vat arithmetic pass proofs
ehildenb May 28, 2024
1984a08
tests/failing: update failing lists
ehildenb May 28, 2024
28b6ef2
tests/specs/mcd/vat-flux-diff-pass-spec.k: add useGas cell
ehildenb May 28, 2024
2d4c9b4
tests/specs/mcd: add useGas cell in several places
ehildenb May 28, 2024
166a977
tests/specs/mcd/vat*: reuse specs from vat-arithmetic-spec file
ehildenb May 28, 2024
b457693
tests/specs/mcd/vat-spec: update to list all Vat proofs
ehildenb May 28, 2024
ba8cb56
tests/specs/mcd: remove exit-code cell from specs
ehildenb May 29, 2024
ee959b3
tests/specs/mcd/vat-frob-diff-zero-dart-pass-rough-spec.k: add other …
ehildenb Jun 4, 2024
41a0499
kevm-pyk/kevm: add dummy merge-nodes heuristic
ehildenb Jun 4, 2024
778df2b
Makefile, kevm-pyk/: add test of DSS spec reuse
ehildenb Jun 5, 2024
8384f29
.github/test-pr: add job for spec-reuse proofs
ehildenb Jun 5, 2024
3df8000
tests/test_prove: tests/failing: remove tests/specs/mcd/vat-* from te…
ehildenb Jun 11, 2024
10a6802
kevm-pyk/{utils,cli,__main__,test_prove}: use new field direct_subpro…
ehildenb Jun 11, 2024
2d5dcac
Set Version: 1.0.599
Jun 11, 2024
bdae6e0
Merge branch 'master' into vat-arithmetic
ehildenb Jun 12, 2024
96c4333
Set Version: 1.0.602
Jun 12, 2024
193aaec
Revert "kevm-pyk/kevm: add dummy merge-nodes heuristic"
ehildenb Jun 12, 2024
7c98e77
kevm-pyk/{conftest,test_prove}: hardcode the number of workers for ds…
ehildenb Jun 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ jobs:
- test-suite: 'test-prove-optimizations'
test-args:
timeout: 45
- test-suite: 'test-prove-dss'
test-args:
timeout: 45
timeout-minutes: ${{ matrix.timeout }}
steps:
- name: 'Check out code'
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ kevm-pyk: poetry-env
# Tests
# -----

test: test-integration test-conformance test-prove test-prove-pyk test-prove-kprove test-interactive
test: test-integration test-conformance test-prove test-prove-pyk test-prove-kprove test-prove-dss test-interactive


# Conformance Tests
Expand All @@ -50,7 +50,7 @@ test-rest-bchain: poetry

# Proof Tests

test-prove: test-prove-pyk test-prove-kprove test-prove-optimizations
test-prove: test-prove-pyk test-prove-kprove test-prove-optimizations test-prove-dss

test-prove-pyk: poetry
$(MAKE) -C kevm-pyk/ test-integration PYTEST_ARGS+="-k test_pyk_prove"
Expand All @@ -61,6 +61,9 @@ test-prove-kprove: poetry
test-prove-optimizations: poetry
$(MAKE) -C kevm-pyk/ test-integration PYTEST_ARGS+="-k test_prove_optimizations"

test-prove-dss: poetry
$(MAKE) -C kevm-pyk/ test-integration PYTEST_ARGS+="-k test_prove_dss"


# Integration Tests

Expand Down
2 changes: 1 addition & 1 deletion kevm-pyk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "kevm-pyk"
version = "1.0.601"
version = "1.0.602"
description = ""
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion kevm-pyk/src/kevm_pyk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
if TYPE_CHECKING:
from typing import Final

VERSION: Final = '1.0.601'
VERSION: Final = '1.0.602'
1 change: 1 addition & 0 deletions kevm-pyk/src/kevm_pyk/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ def create_kcfg_explore() -> KCFGExplore:
fail_fast=options.fail_fast,
always_check_subsumption=options.always_check_subsumption,
fast_check_subsumption=options.fast_check_subsumption,
direct_subproof_rules=options.direct_subproof_rules,
max_frontier_parallel=options.max_frontier_parallel,
)
end_time = time.time()
Expand Down
9 changes: 9 additions & 0 deletions kevm-pyk/src/kevm_pyk/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,15 @@ class KProveOptions(Options):
debug_equations: list[str]
always_check_subsumption: bool
fast_check_subsumption: bool
direct_subproof_rules: bool

@staticmethod
def default() -> dict[str, Any]:
return {
'debug_equations': [],
'always_check_subsumption': True,
'fast_check_subsumption': False,
'direct_subproof_rules': False,
}


Expand Down Expand Up @@ -907,6 +909,13 @@ def kprove_args(self) -> ArgumentParser:
action='store_true',
help='Use fast-check on k-cell to determine subsumption (experimental).',
)
args.add_argument(
'--direct-subproof-rules',
dest='direct_subproof_rules',
default=None,
action='store_true',
help='For passing subproofs, construct lemmas directly from initial to target state.',
)
return args

@cached_property
Expand Down
5 changes: 5 additions & 0 deletions kevm-pyk/src/kevm_pyk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class RunProverParams:
counterexample_info: bool
always_check_subsumption: bool
fast_check_subsumption: bool
direct_subproof_rules: bool


class APRProofStrategy(ABC):
Expand Down Expand Up @@ -141,6 +142,7 @@ def create_prover() -> APRProver:
counterexample_info=self.params.counterexample_info,
always_check_subsumption=self.params.always_check_subsumption,
fast_check_subsumption=self.params.fast_check_subsumption,
direct_subproof_rules=self.params.direct_subproof_rules,
)

parallel_advance_proof(
Expand Down Expand Up @@ -168,6 +170,7 @@ def prove(self, proof: APRProof, max_iterations: int | None = None, fail_fast: b
counterexample_info=self.params.counterexample_info,
always_check_subsumption=self.params.always_check_subsumption,
fast_check_subsumption=self.params.fast_check_subsumption,
direct_subproof_rules=self.params.direct_subproof_rules,
)
prover.advance_proof(fail_fast=fail_fast, max_iterations=max_iterations, proof=proof)

Expand Down Expand Up @@ -215,6 +218,7 @@ def run_prover(
counterexample_info: bool = False,
always_check_subsumption: bool = False,
fast_check_subsumption: bool = False,
direct_subproof_rules: bool = False,
max_frontier_parallel: int = 1,
) -> bool:
prover: APRProver | ImpliesProver
Expand All @@ -231,6 +235,7 @@ def run_prover(
execute_depth=max_depth,
fast_check_subsumption=fast_check_subsumption,
terminal_rules=terminal_rules,
direct_subproof_rules=direct_subproof_rules,
),
)
strategy.prove(fail_fast=fail_fast, max_iterations=max_iterations, proof=proof)
Expand Down
48 changes: 46 additions & 2 deletions kevm-pyk/src/tests/integration/test_prove.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging
import sys
from pathlib import Path
from typing import TYPE_CHECKING, NamedTuple

import pytest
Expand All @@ -24,7 +25,6 @@

if TYPE_CHECKING:
from collections.abc import Callable
from pathlib import Path
from typing import Any, Final

from pyk.utils import BugReport
Expand Down Expand Up @@ -57,6 +57,8 @@ def spec_files(dir_name: str, glob: str) -> tuple[Path, ...]:
ERC20_TESTS: Final = spec_files('erc20', '*/*-spec.k')
EXAMPLES_TESTS: Final = spec_files('examples', '*-spec.k') + spec_files('examples', '*-spec.md')
MCD_TESTS: Final = spec_files('mcd', '*-spec.k')
VAT_TESTS: Final = spec_files('mcd', 'vat*-spec.k')
NON_VAT_MCD_TESTS: Final = tuple(test for test in MCD_TESTS if test not in VAT_TESTS)
KONTROL_TESTS: Final = spec_files('kontrol', '*-spec.k')

ALL_TESTS: Final = sum(
Expand All @@ -65,7 +67,7 @@ def spec_files(dir_name: str, glob: str) -> tuple[Path, ...]:
FUNCTIONAL_TESTS,
ERC20_TESTS,
EXAMPLES_TESTS,
MCD_TESTS,
NON_VAT_MCD_TESTS,
KONTROL_TESTS,
],
(),
Expand Down Expand Up @@ -357,6 +359,48 @@ def _get_optimization_proofs() -> list[APRProof]:
assert proof.passed


def test_prove_dss(
kompiled_target_for: Callable[[Path], Path],
tmp_path: Path,
caplog: LogCaptureFixture,
bug_report: BugReport | None,
spec_name: str | None,
) -> None:
spec_file = Path('../tests/specs/mcd/vat-spec.k')
caplog.set_level(logging.INFO)

if spec_name is not None and str(spec_file).find(spec_name) < 0:
pytest.skip()

# Given
log_file = tmp_path / 'log.txt'
use_directory = tmp_path / 'kprove'
use_directory.mkdir()

# When
try:
definition_dir = kompiled_target_for(spec_file)
options = ProveOptions(
{
'spec_file': spec_file,
'definition_dir': definition_dir,
'includes': [str(include_dir) for include_dir in config.INCLUDE_DIRS],
'save_directory': use_directory,
'md_selector': 'foo', # TODO Ignored flag, this is to avoid KeyError
'use_booster': True,
'bug_report': bug_report,
'break_on_calls': False,
'workers': 8,
'direct_subproof_rules': True,
}
)
exec_prove(options=options)
except BaseException:
raise
finally:
log_file.write_text(caplog.text)


# ------------
# Legacy tests
# ------------
Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.601
1.0.602
14 changes: 0 additions & 14 deletions tests/failing-symbolic.haskell
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,5 @@ tests/specs/mcd/flopper-kick-pass-rough-spec.k
tests/specs/mcd/flopper-tick-pass-rough-spec.k
tests/specs/mcd/functional-spec.k
tests/specs/mcd/pot-join-pass-rough-spec.k
tests/specs/mcd/vat-addui-fail-rough-spec.k
tests/specs/mcd/vat-addui-pass-spec.k
tests/specs/mcd/vat-deny-diff-fail-rough-spec.k
tests/specs/mcd/vat-flux-diff-pass-rough-spec.k
tests/specs/mcd/vat-fold-pass-rough-spec.k
tests/specs/mcd/vat-fork-diff-pass-rough-spec.k
tests/specs/mcd/vat-frob-diff-zero-dart-pass-rough-spec.k
tests/specs/mcd/vat-move-diff-rough-spec.k
tests/specs/mcd/vat-mului-pass-spec.k
tests/specs/mcd/vat-muluu-pass-spec.k
tests/specs/mcd/vat-slip-pass-rough-spec.k
tests/specs/mcd/vat-subui-fail-rough-spec.k
tests/specs/mcd/vat-subui-pass-rough-spec.k
tests/specs/mcd/vat-subui-pass-spec.k
tests/specs/mcd/vow-fess-fail-rough-spec.k
tests/specs/mcd/vow-flog-fail-rough-spec.k
3 changes: 0 additions & 3 deletions tests/failing-symbolic.haskell-booster
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ tests/specs/examples/sum-to-n-foundry-spec.k
tests/specs/examples/sum-to-n-spec.k
tests/specs/functional/merkle-spec.k
tests/specs/functional/storageRoot-spec.k
tests/specs/mcd/vat-fold-pass-rough-spec.k
tests/specs/mcd/vat-fork-diff-pass-rough-spec.k
tests/specs/mcd/vat-frob-diff-zero-dart-pass-rough-spec.k
14 changes: 0 additions & 14 deletions tests/failing-symbolic.haskell-booster-dev
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,5 @@ tests/specs/mcd/flopper-kick-pass-rough-spec.k
tests/specs/mcd/flopper-tick-pass-rough-spec.k
tests/specs/mcd/functional-spec.k
tests/specs/mcd/pot-join-pass-rough-spec.k
tests/specs/mcd/vat-addui-fail-rough-spec.k
tests/specs/mcd/vat-addui-pass-spec.k
tests/specs/mcd/vat-deny-diff-fail-rough-spec.k
tests/specs/mcd/vat-flux-diff-pass-rough-spec.k
tests/specs/mcd/vat-fold-pass-rough-spec.k
tests/specs/mcd/vat-fork-diff-pass-rough-spec.k
tests/specs/mcd/vat-frob-diff-zero-dart-pass-rough-spec.k
tests/specs/mcd/vat-move-diff-rough-spec.k
tests/specs/mcd/vat-mului-pass-spec.k
tests/specs/mcd/vat-muluu-pass-spec.k
tests/specs/mcd/vat-slip-pass-rough-spec.k
tests/specs/mcd/vat-subui-fail-rough-spec.k
tests/specs/mcd/vat-subui-pass-rough-spec.k
tests/specs/mcd/vat-subui-pass-spec.k
tests/specs/mcd/vow-fess-fail-rough-spec.k
tests/specs/mcd/vow-flog-fail-rough-spec.k
6 changes: 0 additions & 6 deletions tests/failing-symbolic.pyk
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,5 @@ tests/specs/mcd/flopper-kick-pass-rough-spec.k
tests/specs/mcd/flopper-tick-pass-rough-spec.k
tests/specs/mcd/functional-spec.k
tests/specs/mcd/pot-join-pass-rough-spec.k
tests/specs/mcd/vat-flux-diff-pass-rough-spec.k
tests/specs/mcd/vat-fold-pass-rough-spec.k
tests/specs/mcd/vat-fork-diff-pass-rough-spec.k
tests/specs/mcd/vat-frob-diff-zero-dart-pass-rough-spec.k
tests/specs/mcd/vat-move-diff-rough-spec.k
tests/specs/mcd/vat-slip-pass-rough-spec.k
tests/specs/mcd/vow-fess-fail-rough-spec.k
tests/specs/mcd/vow-flog-fail-rough-spec.k
1 change: 0 additions & 1 deletion tests/specs/mcd/flopper-cage-pass-spec.k
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ requires "verification.k"
module FLOPPER-CAGE-PASS-SPEC
imports VERIFICATION

// Flopper_cage
claim [Flopper.cage.pass]:
<k> #execute ~> CONTINUATION => #halt ~> CONTINUATION </k>
<mode> NORMAL </mode>
Expand Down
107 changes: 0 additions & 107 deletions tests/specs/mcd/vat-addui-pass-spec.k

This file was deleted.

Loading