-
Notifications
You must be signed in to change notification settings - Fork 2
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
Converting SV-COMP (complexity competition) programs. #3
Comments
@ishimwed , turn this into smaller tasks. Let's start with say 20 programs first. |
I selected 20 programs to start with. Selection criteria: randomly picked programs for which I couldn't compute complexity in less than 20 seconds. I also selected programs for which AProVE and CoFloCo did not compute the same upper bound. I tried to have all complexity classes (n, n^2, n^3, n^4, \inf) represented.
|
@ishimwed thanks, can you also select about 10 "easy" programs so that the undergraduate students can try them first? |
Let's start with the programs from the list above. The two programs converted could lead to non-terminating executions. We will avoid such programs since their worst case complexity is infinite and dynaplex cannot handle such programs. |
Did you want us to create our own branches to try some examples? |
You can create your own branches. We will merge the results once we are done. I checked PastaA10.c and it looks good. I would change one thing in rec_foo() for better readability: move the two recursive calls at the end since they are similar in both branches.
|
Great, Thanks for the feedback! will fix with the suggestions. |
Converting 2019 Complexity competition programs to recursive structure.
There are around 500 imperative programs with nontrivial loops in the complexity competition. We want to convert these iterative programs to recursive programs.
Most of these functions with loops have the following structure:
the header: statements before the loop. This may declare some new variables
the loop condition: which indicates when to stop the loop
the loop body: which changes some header variables and/or function parameters. This is the main part we want to eliminate or convert into recursion.
the tail; statements after the loop.
We transform the above foo_iterative function to recursion as follows:
Example: Bangalore_v4_true-termination.c
Converting foo() into a recursive function:
if (y > x)
(x >= 0)
x = x - y;
return 0;
Resulting recursive foo program:
Remarks:
Although these steps help to transform a lot of iterative functions into recursion it is not comprehensive. There are examples where it would be difficult to follow the above steps. Fortunately, termination competition have a lot of programs and many of them can be converted by just using the above technique. We want to start with those easier programs. We are not trying to remove all loops, just the main loops. For example, in case of nested loops we want to transform the outer loop and consider the inner loop as loop body (step 3). More examples are given in
recursive_programs/c
(dev branch); the file names matches the file names given in the complexity termination to avoid confusion.Note: I haven't figured out how to handle sequential loops. Do not commit any changes to the master branch.
The text was updated successfully, but these errors were encountered: