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

Stretch Goal: prove x*y=k #43

Open
d-xo opened this issue Jan 31, 2020 · 2 comments
Open

Stretch Goal: prove x*y=k #43

d-xo opened this issue Jan 31, 2020 · 2 comments

Comments

@d-xo
Copy link
Contributor

d-xo commented Jan 31, 2020

Adding this just as a note really, and the idea is stolen from this issue in k-dss.

We could introduce a new kind of block into act: invariant that would look something like this:

invariant K of UniswapV2Exchange

storage

    reserve0_reserve1_blockTimestampLast |-> #WordPackUInt112UInt112UInt32(Reserve0, Reserve1, _) => _
    totalSupply |-> TotalSupply => _
    kLast       |-> KLast => _

such that

    (Reserve0 * Reserve1) / (TotalSupply ^ 2) == KLast

This would generate a K spec with symbolic calldata that proves that the generalized invariant holds at the end of every possible call to the contract. This proof could be made fast by implicitly reusing all the other specs (i.e. implicitly including every other spec for UniswapV2Exchange in a calls block for each invariant block).

@d-xo
Copy link
Contributor Author

d-xo commented Feb 10, 2020

@d-xo
Copy link
Contributor Author

d-xo commented Feb 14, 2020

Perhaps we could even just directly append the ensures statements to the existing specs without even having to create a new spec specifically for the invariants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant