-
Notifications
You must be signed in to change notification settings - Fork 143
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
Updates to infinite gas abstraction #945
Conversation
claim <k> runLemma(#gas(G) <Int #gas(G' +Int 700)) => doneLemma(false) ... </k> | ||
claim <k> runLemma(#gas(G' +Int 700) <=Int #gas(G)) => doneLemma(true) ... </k> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How these 2 can be true? We don't know the value difference between G and G'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #945 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The values under the #gas
do not matter, they are only used for tracking the gas usage as metadata. #gas(_)
with any argument is the same positive infinity as any other #gas(_)
claim <k> runLemma(#if _:Int ==Int 0 #then #gas(VGas -Int Csstore(_, _, _,_)) #else #gas(VGas +Int -344) #fi <Int 8) => doneLemma(false) ... </k> | ||
claim <k> runLemma(8 <=Int #if _:Int ==Int 0 #then #gas(VGas -Int Csstore(_, _, _,_)) #else #gas(VGas +Int -344) #fi) => doneLemma(true) ... </k> | ||
|
||
claim <k> runLemma(#if _:Int ==Int 0 #then #gas(VGas -Int Csstore(_, _, _,_)) #else #gas(VGas +Int -344) #fi <Int minInt(#if _ #then #gas(_) #else #gas(_) #fi, #gas(_))) => doneLemma(false) ... </k> | ||
claim <k> runLemma(minInt(#if _ #then #gas(_) #else #gas(_) #fi, #gas(_)) <=Int #if _:Int ==Int 0 #then #gas(VGas -Int Csstore(_, _, _,_)) #else #gas(VGas +Int -344) #fi) => doneLemma(true) ... </k> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I don't understand how these lemmas can be proved. The if _ == 0
must be undecided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If both branches of the #if
are +Inf gas, then the entire expression will always be infinite gas. Same with minInt
.
We have to make sure that #gas
always "bubbles up" to the top of the expression in the <gas>
cell, so that when we compare any particular value to it during execution we never run out of gas.
rule #gas(_) <Int #gas(_) => false [simplification] | ||
rule #gas(_) <=Int #gas(_) => true [simplification] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rationale behind these lemmas is unclear to me. Can you add a comment explaining them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, in what kind of scenarios are they useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#gas represents positive infinite: +Inf
. We have that +Inf <Int +Inf => false
and +Inf <=Int +Inf => true
They are used when you make a CALL
, because you end up with a comparison between the current gas (which is some #gas(_)
expression), and the gas allocated for the call (which is another #gas(_)
) expression..
These are setup so that we never fail due to OOG.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! All makes sense now. I think it's useful to add your explanation as comment in k file, as this is non-obvious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment with this explanation to the documentation at the top of the file.
f624eda
to
028f8b9
Compare
concrete
attribute.