Conversation
kwasm-lemmas.md
Outdated
|
|
||
| ```k | ||
| rule #signed(_, 0) => 0 [simplification] | ||
| rule #signed(_, X -Int Y) => X -Int Y [simplification] |
There was a problem hiding this comment.
This isn't true. Consider the definition of #signed (in data.md)
rule #signed(ITYPE, N) => N requires 0 <=Int N andBool N <Int #pow1(ITYPE)
rule #signed(ITYPE, N) => N -Int #pow(ITYPE) requires #pow1(ITYPE) <=Int N andBool N <Int #pow (ITYPE)
So if we have that notBool (0 <=Int X -Int Y andBool X - Int Y <Int #pow1(ITYPE)), and we also have that #pow1(ITYPE) <=Int X -Int Y andBool X -Int Y <Int #pow(ITYPE), we should be returning (X -Int Y) -Int #pow(ITYPE), but your simplification rule returns X -Int Y.
There was a problem hiding this comment.
You can add a requires clause to your second rule which says 0 <=Int X -Int Y andBool X -Int Y <Int #pow1(ITYPE), but that would be saying the same thing as the original rule in the semantics.
So instead, we should make it so the prover can know that 0 <=Int X -Int Y andBool X -Int Y <Int #pow1(ITYPE) is true. Which proof is this lemma needed for?
|
|
||
| module SIMPLE-SPEC | ||
| imports KWASM-LEMMAS | ||
|
|
There was a problem hiding this comment.
Write a functional spec:
claim <instrs> run(#signed(ITYPE, X -Int Y)) => done(X -Int Y) ... </k> requires #inUnsignedRange(ITYPE, X -Int Y)
tests/proofs/simple-spec.k
Outdated
| requires | ||
| #inUnsignedRange(ITYPE, X) andBool | ||
| #inUnsignedRange(ITYPE, Y) |
There was a problem hiding this comment.
| requires | |
| #inUnsignedRange(ITYPE, X) andBool | |
| #inUnsignedRange(ITYPE, Y) | |
| requires #inUnsignedRange(ITYPE, X) | |
| andBool #inUnsignedRange(ITYPE, Y) |
| @@ -0,0 +1,56 @@ | |||
| requires "kwasm-lemmas.md" | |||
There was a problem hiding this comment.
For #signed(ITYPE, 0), it probably can't tell that 0 <Int #pow1(ITYPE), even though ITYPE can only be i32 or i64.
rule 0 <Int #pow1(_) => true [simplification]
and see if this works on Ana's branch.
Make sure to check the defniition of #pow1 and make sure this is true.
Added some claims I came up with as an exercise