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

src/lemmas.k.md: rewrite TIME lemma #63

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
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
7 changes: 3 additions & 4 deletions src/lemmas.k.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ rule A -Word B <=Int A => #rangeUInt(256, A -Int B)

### Bitwise Modulo

The solidity optimizer compiles `block.time % 2**32` into `TIME AND maxUInt32` instead of `TIME
MOD pow32`. `K` is then unable to reason about the size of the result and so cannot apply further
simplifications. We therefore rewrite it back to `modInt pow32`.
The solidity optimizer compiles `block.time % 2**32` to `block.time AND maxUInt32`.
This lemma ensures the packed storage rules will apply.

```k
rule (maxUInt32 &Int X) => (X modInt pow32)
rule (maxUInt32 &Int X) <=Int maxUInt32 => true
d-xo marked this conversation as resolved.
Show resolved Hide resolved
```

Repeated application of `modInt pow32` can be simplified as follows. This lets us clean the storage
Expand Down