From f6278d30c7c9ab8357bb94b528a174ca216cf2d2 Mon Sep 17 00:00:00 2001 From: Maria Kotsifakou Date: Mon, 16 Sep 2024 16:43:28 -0500 Subject: [PATCH 1/2] Summaries for SortTokens function (for non reverting cases). --- src/solidity.md | 2 +- src/uniswap-summaries.md | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/solidity.md b/src/solidity.md index 3b55f6b..82ad844 100644 --- a/src/solidity.md +++ b/src/solidity.md @@ -181,7 +181,7 @@ module SOLIDITY imports SOLIDITY-TRANSACTION imports SOLIDITY-EXPRESSION imports SOLIDITY-STATEMENT - imports SOLIDITY-UNISWAP-INIT-SUMMARY + imports SOLIDITY-UNISWAP-SUMMARIES rule _:PragmaDefinition Ss:SourceUnits => Ss ... false diff --git a/src/uniswap-summaries.md b/src/uniswap-summaries.md index e6e11eb..26e1122 100644 --- a/src/uniswap-summaries.md +++ b/src/uniswap-summaries.md @@ -2397,3 +2397,37 @@ module SOLIDITY-UNISWAP-INIT-SUMMARY endmodule ``` + +```k +module SOLIDITY-UNISWAP-SORTTOKENS-SUMMARY + imports SOLIDITY-CONFIGURATION + imports SOLIDITY-EXPRESSION + imports SOLIDITY-UNISWAP-TOKENS + + rule uniswapV2LibrarySortTokens:Id ( v(V1:MInt{160}, address #as T), v(V2:MInt{160}, T), .TypedVals ) => v(ListItem(V1) ListItem(V2), T[]) ... + true + + ... .Map => ((!_:Int |-> V1) (!_:Int |-> V2) (!_:Int |-> default(T[])) + (!_:Int |-> (ListItem(V1) ListItem(V2))) + ) + + requires V1 uniswapV2LibrarySortTokens:Id ( v(V1:MInt{160}, address #as T), v(V2:MInt{160}, T), .TypedVals ) => v(ListItem(V2) ListItem(V1), T[]) ... + true + + ... .Map => ((!_:Int |-> V1) (!_:Int |-> V2) (!_:Int |-> default(T[])) + (!_:Int |-> (ListItem(V2) ListItem(V1))) + ) + + requires V2 Date: Wed, 18 Sep 2024 17:16:53 -0500 Subject: [PATCH 2/2] Updated summary with store cell being a list --- src/uniswap-summaries.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/uniswap-summaries.md b/src/uniswap-summaries.md index 26e1122..5c3854c 100644 --- a/src/uniswap-summaries.md +++ b/src/uniswap-summaries.md @@ -2407,18 +2407,20 @@ module SOLIDITY-UNISWAP-SORTTOKENS-SUMMARY rule uniswapV2LibrarySortTokens:Id ( v(V1:MInt{160}, address #as T), v(V2:MInt{160}, T), .TypedVals ) => v(ListItem(V1) ListItem(V2), T[]) ... true - ... .Map => ((!_:Int |-> V1) (!_:Int |-> V2) (!_:Int |-> default(T[])) - (!_:Int |-> (ListItem(V1) ListItem(V2))) - ) + S => S ListItem(V1) + ListItem(V2) + ListItem(default(T[])) + ListItem(ListItem(V1) ListItem(V2)) requires V1 uniswapV2LibrarySortTokens:Id ( v(V1:MInt{160}, address #as T), v(V2:MInt{160}, T), .TypedVals ) => v(ListItem(V2) ListItem(V1), T[]) ... true - ... .Map => ((!_:Int |-> V1) (!_:Int |-> V2) (!_:Int |-> default(T[])) - (!_:Int |-> (ListItem(V2) ListItem(V1))) - ) + S => S ListItem(V1) + ListItem(V2) + ListItem(default(T[])) + ListItem(ListItem(V2) ListItem(V1)) requires V2