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

proof of assignment in Verify #975

Closed
kanigsson opened this issue Apr 6, 2022 · 2 comments · Fixed by #978
Closed

proof of assignment in Verify #975

kanigsson opened this issue Apr 6, 2022 · 2 comments · Fixed by #978
Labels
bug generator Related to generator package (SPARK code generation)

Comments

@kanigsson
Copy link
Collaborator

The Verify function as generated by Recordflux contains this code:

                     Ctx.Cursors (Successor (Ctx, Fld)) := (State => S_Invalid, Predecessor => Fld);

The predicate seems to be difficult to prove for SPARK currently. Previously, the code was duplicated for each field using a case statement, which helped proof but increased code size. This was recently replaced by a for loop:

               for F in Field loop
                  if Fld = F then
                     Ctx.Cursors (Successor (Ctx, Fld)) := (State => S_Invalid, Predecessor => Fld);
                  end if;
               end loop;

For SPARK, this is somewhat similar to the case statement, as the loop is unrolled and we get each case separately. However the loop unrolling has a threshold of 20. For any message with more than 20 fields, the loop is not unrolled and proof breaks down (it would require a loop invariant). This happens in SPDM code (message Alg_Struct).

@kanigsson kanigsson added bug generator Related to generator package (SPARK code generation) labels Apr 6, 2022
@kanigsson kanigsson added this to To do in RecordFlux 0.6 via automation Apr 6, 2022
@treiher
Copy link
Collaborator

treiher commented Apr 6, 2022

The naive solution would be using the loop only in cases where there are at most 20 fields, and the previous approach otherwise. Is there a better solution?

@kanigsson
Copy link
Collaborator Author

It seems we can now remove the loop, please check out my pull request.

RecordFlux 0.6 automation moved this from To do to Done Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug generator Related to generator package (SPARK code generation)
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants