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

Lemmas on Boolean reasoning, set reasoning, map lookup #2037

Merged
merged 104 commits into from
Dec 22, 2023
Merged

Lemmas on Boolean reasoning, set reasoning, map lookup #2037

merged 104 commits into from
Dec 22, 2023

Conversation

PetarMax
Copy link
Contributor

@PetarMax PetarMax commented Aug 24, 2023

This PR upstreams further lemmas from Lukso/BlockSwap concerning

  • Boolean reasoning;
  • set reasoning; and
  • map lookup.

@PetarMax PetarMax requested review from ehildenb and lucasmt August 24, 2023 13:21
@PetarMax PetarMax self-assigned this Aug 24, 2023
@PetarMax
Copy link
Contributor Author

All of the keccak lemmas are indeed problematic (unsound, really), but needed for the engagements. I will remove them from this PR.

@PetarMax
Copy link
Contributor Author

I'm having some formatting issues here as well with the expected outputs. For example, for the I have additional spacing, different order of constraints (ACTUAL top, EXPECTED bottom):

statusCode: STATUSCODE_FINAL\n\n\n\n\n    \n    \n    rule [BASIC-BLOCK-1-TO-3]:
statusCode: STATUSCODE_FINAL\n\n\n\n\n\n\n    rule [BASIC-BLOCK-1-TO-3]:

[label(BASIC-BLOCK-1-TO-3)]\n    \n    rule [BASIC-BLOCK-3-TO-4]:
[label(BASIC-BLOCK-1-TO-3)]\n\n    rule [BASIC-BLOCK-3-TO-4]:

[label(BASIC-BLOCK-3-TO-4)]\n    \n    rule [BASIC-BLOCK-4-TO-5]:
[label(BASIC-BLOCK-3-TO-4)]\n\n    rule [BASIC-BLOCK-4-TO-5]:

[label(BASIC-BLOCK-4-TO-5)]\n    \n    rule [BASIC-BLOCK-6-TO-8]:
[label(BASIC-BLOCK-4-TO-5)]\n\n    rule [BASIC-BLOCK-6-TO-8]:

andBool ( VV0_n_114b9705:Int <=Int 51816696836262767\n       andBool ( CALLER_ID:Int <Int pow160\n       andBool ( ORIGIN_ID:Int <Int pow160\n       andBool ( NUMBER_CELL:Int <=Int maxSInt256\n       andBool ( VV0_n_114b9705:Int <Int pow256\n               ))))))))))\n
andBool ( CALLER_ID:Int <Int pow160\n       andBool ( ORIGIN_ID:Int <Int pow160\n       andBool ( NUMBER_CELL:Int <=Int maxSInt256\n       andBool ( VV0_n_114b9705:Int <Int pow256\n       andBool ( VV0_n_114b9705:Int <=Int 51816696836262767\n               ))))))))))\n

[label(BASIC-BLOCK-6-TO-8)]\n    \n    rule [BASIC-BLOCK-7-TO-9]:
[label(BASIC-BLOCK-6-TO-8)]\n\n    rule [BASIC-BLOCK-7-TO-9]:

[label(BASIC-BLOCK-7-TO-9)]\n    \n    rule [BASIC-BLOCK-8-TO-10]:
[label(BASIC-BLOCK-7-TO-9)]\n\n    rule [BASIC-BLOCK-8-TO-10]:

[label(BASIC-BLOCK-8-TO-10)]\n    \n    rule [BASIC-BLOCK-9-TO-11]:
[label(BASIC-BLOCK-8-TO-10)]\n\n    rule [BASIC-BLOCK-9-TO-11]: 

* another re-ordering of constraints, too long *

[label(BASIC-BLOCK-9-TO-11)]\n    \n    rule [BASIC-BLOCK-10-TO-12]:
[label(BASIC-BLOCK-9-TO-11)]\n\n    rule [BASIC-BLOCK-10-TO-12]:

[label(BASIC-BLOCK-10-TO-12)]\n    \n    rule [BASIC-BLOCK-11-TO-13]:
[label(BASIC-BLOCK-10-TO-12)]\n\n    rule [BASIC-BLOCK-11-TO-13]:

* another re-ordering of constraints, too long *

I'm confused, because I would think the way things are printed hasn't been affected by the PR...

@PetarMax
Copy link
Contributor Author

PetarMax commented Oct 2, 2023

On hold for the moment, waiting for #1866.

@palinatolmach
Copy link
Contributor

@PetarMax now that the blocking booster PR has been merged, shall we be able to merge it?

@PetarMax
Copy link
Contributor Author

Not yet, the PR is still failing in the booster and passing in the Haskell backend on some tests. I'm trying to figure out what's happening and liaising with @geo2a.

Comment on lines +38 to +67
rule A +Int B <Int C => A <Int C -Int B [concrete(B, C), symbolic(A), simplification(45)]
rule A +Int B <=Int C => A <=Int C -Int B [concrete(B, C), symbolic(A), simplification(45)]
rule A +Int B >Int C => A >Int C -Int B [concrete(B, C), symbolic(A), simplification(45)]
rule A +Int B >=Int C => A >=Int C -Int B [concrete(B, C), symbolic(A), simplification(45)]

rule A +Int B <Int C => B <Int C -Int A [concrete(A, C), symbolic(B), simplification(45)]
rule A +Int B <=Int C => B <=Int C -Int A [concrete(A, C), symbolic(B), simplification(45)]
rule A +Int B >Int C => B >Int C -Int A [concrete(A, C), symbolic(B), simplification(45)]
rule A +Int B >=Int C => B >=Int C -Int A [concrete(A, C), symbolic(B), simplification(45)]

rule A -Int B <Int C => A <Int C +Int B [concrete(B, C), symbolic(A), simplification(45)]
rule A -Int B <=Int C => A <=Int C +Int B [concrete(B, C), symbolic(A), simplification(45)]
rule A -Int B >Int C => A >Int C +Int B [concrete(B, C), symbolic(A), simplification(45)]
rule A -Int B >=Int C => A >=Int C +Int B [concrete(B, C), symbolic(A), simplification(45)]

rule A -Int B <Int C => A -Int C <Int B [concrete(A, C), symbolic(B), simplification(45)]
rule A -Int B <=Int C => A -Int C <=Int B [concrete(A, C), symbolic(B), simplification(45)]
rule A -Int B >Int C => A -Int C >Int B [concrete(A, C), symbolic(B), simplification(45)]
rule A -Int B >=Int C => A -Int C >=Int B [concrete(A, C), symbolic(B), simplification(45)]

rule A <Int B +Int C => A -Int B <Int C [concrete(A, B), symbolic(C), simplification(45)]
rule A <=Int B +Int C => A -Int B <=Int C [concrete(A, B), symbolic(C), simplification(45)]
rule A >Int B +Int C => A -Int B >Int C [concrete(A, B), symbolic(C), simplification(45)]
rule A >=Int B +Int C => A -Int B >=Int C [concrete(A, B), symbolic(C), simplification(45)]

rule A <Int B +Int C => A -Int C <Int B [concrete(A, C), symbolic(B), simplification(45)]
rule A <=Int B +Int C => A -Int C <=Int B [concrete(A, C), symbolic(B), simplification(45)]
rule A >Int B +Int C => A -Int C >Int B [concrete(A, C), symbolic(B), simplification(45)]
rule A >=Int B +Int C => A -Int C >=Int B [concrete(A, C), symbolic(B), simplification(45)]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice that some of these move the concrete to the left and symbolic to the rgiht, and some the other direction. I wonder if there is benefit to always picking one side of the comparison for the concrete and teh other for the symbolic?

I think there are also some rules somewhere which normalize all _>=_ and _>_ to the other operators (_<=_ and _<_), so I wonder if we actually don't need all the duplicate rules? Though I can't find those rules now, so maybe they would need to be added.

@ehildenb ehildenb changed the title Lemmas on Boolean reasoning, set reasoning, map lookup, and keccak Lemmas on Boolean reasoning, set reasoning, map lookup Dec 22, 2023
@PetarMax PetarMax merged commit cd2e87a into master Dec 22, 2023
11 checks passed
@PetarMax PetarMax deleted the lemmas branch December 22, 2023 19:20
PetarMax added a commit that referenced this pull request Dec 27, 2023
* lemmas on Boolean reasoning, set reasoning, map lookup, and keccak

* Set Version: 1.0.277

* removing keccak lemmas that should not be upstreamed

* addressing comments

* Set Version: 1.0.278

* Set Version: 1.0.278

* corrections

* removing ==Bool from expected files

* Set Version: 1.0.279

* Set Version: 1.0.279

* Set Version: 1.0.309

* Set Version: 1.0.311

* updating expected outputs

* Set Version: 1.0.312

* Set Version: 1.0.330

* Set Version: 1.0.334

* revisiting set simplifications

* --amend

* --amend

* --amend

* streamlining lookup simplifications

* streamlining set simplifications

* removing set reasoning entirely

* Set Version: 1.0.336

* concretising set simplifications:

* streamlining set simplifications

* Set Version: 1.0.337

* even more concrete set simplifications

* bringing old simplifications back

* Set Version: 1.0.340

* resolving parsing ambiguities

* --amend

* --amend

* Set Version: 1.0.341

* Set Version: 1.0.342

* Set Version: 1.0.343

* correction

* syntax

* --amend

* Set Version: 1.0.349

* Set Version: 1.0.355

* Set Version: 1.0.356

* Set Version: 1.0.357

* Correctly ordered arguments in `typed_args` (#2174)

* Correctly ordered arguments in `typed_args`

* Set Version: 1.0.357

---------

Co-authored-by: devops <[email protected]>

* Inject `ccopts` directly into `kevm_kompile` and fix some tests (#2164)

* Makefile: make sure evm-optimizations-spec is rebuilt on changes to optimizations.md

* kproj/optimizations: remove symbolic attribute on evm-optimizations-lemmas

* tests/specs/examples/sum-to-n-foundry-spec: correct imports for LLVM backend

* tests/specs/functional/infinite-gas-spec.k: allow import of main module in symbolic module for LLVM

* kevm-pyk/__main__, Makefile, VERIFICATION: rename kevm {kompile => kompile-spec} for more accurate usage

* README: update documentation

* kevm-pyk/: all builds require plugin_dir, compute it directly

* kevm-pyk/: move calculation of plugin_dir out of run_kompile, pass in ccopts directly

* kevm-pyk/__main__: adjust acceptable values for kevm kompile-spec

* VERIFICATION: update documentation

* Makefile: bring back --target argument

* Set Version: 1.0.343

* test_prove: only add ccopts if were using the booster

* Set Version: 1.0.355

* package/test-package: add previously failing test of using booster due to plugin_dir being missing

* kevm-pyk/__main__: use correct target for kompile-spec

* Set Version: 1.0.356

* Set Version: 1.0.356

* kevm-pyk/plugin: correction from code review

* kevm-pyk/kdist/plugin: hardcode plugin as dependency for other targets

* kevm-pyk/: factor out generic run_kompile from kevm_kompile

* kevm_pyk/kompile: rename lib_ccopts => _lib_ccopts

* Set Version: 1.0.357

* kevm-pyk/kdist/plugin: make sure all KEVMTarget have plugin as depenndency

* Set Version: 1.0.357

* kdist/plugin: drop self._deps

* Set Version: 1.0.358

* Set Version: 1.0.358

---------

Co-authored-by: devops <[email protected]>

* Fix circular import (#2179)

* Fix circular import

* Set Version: 1.0.359

---------

Co-authored-by: devops <[email protected]>

* Move `--port` arguments to `rpc_args` (#2178)

* Move `--port` arguments to `rpc_args`

* Set Version: 1.0.359

* Set Version: 1.0.360

---------

Co-authored-by: devops <[email protected]>
Co-authored-by: Everett Hildenbrandt <[email protected]>

* Update dependency: deps/pyk_release (#2175)

* deps/pyk_release: Set Version v0.1.501

* Set Version: 1.0.357

* kevm-pyk/: sync poetry files pyk version v0.1.501

* deps/k_release: sync release file version 6.1.14

* flake.{nix,lock}: update Nix derivations

* Set Version: 1.0.359

* kevm-pyk/: sync poetry files pyk version v0.1.501

* Set Version: 1.0.361

---------

Co-authored-by: devops <[email protected]>
Co-authored-by: Everett Hildenbrandt <[email protected]>

* Update dependency: deps/pyk_release (#2181)

* deps/pyk_release: Set Version v0.1.505

* kevm-pyk/: sync poetry files pyk version v0.1.505

* deps/k_release: sync release file version 6.1.20

* flake.{nix,lock}: update Nix derivations

* Set Version: 1.0.362

---------

Co-authored-by: devops <[email protected]>

* Set Version: 1.0.364

* Set Version: 1.0.364

* Set Version: 1.0.365

* Set Version: 1.0.372

* Set Version: 1.0.379

* adding tests

* Set Version: 1.0.381

* normalising comparisons, adding keccak

* reverting normalisation

* removing equality simplification

* Set Version: 1.0.382

* Set Version: 1.0.382

* bringing back comparison (but not equality) normalisation

* bringing back equality normalisation

* Set Version: 1.0.394

* Set Version: 1.0.396

* Set Version: 1.0.398

* removing unsound keccak simplifying assumptions

* Set Version: 1.0.399

* Set Version: 1.0.400

* Set Version: 1.0.406

* Set Version: 1.0.407

* adding tests for comparison normalisation, removing keccak

* Update kevm-pyk/src/kevm_pyk/kproj/evm-semantics/serialization.md

Co-authored-by: Everett Hildenbrandt <[email protected]>

* ----- alignment

* Update kevm-pyk/src/kevm_pyk/kproj/evm-semantics/lemmas/lemmas.k

---------

Co-authored-by: devops <[email protected]>
Co-authored-by: Palina Tolmach <[email protected]>
Co-authored-by: Everett Hildenbrandt <[email protected]>
Co-authored-by: Tamás Tóth <[email protected]>
Co-authored-by: rv-jenkins <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants