Closed AllanBlanchard closed 2 years ago
FYI @pbaudin @vprevosto @zilbuz
What if a function has a loop that might not terminate and another (before the first one, obviously) that ought to always terminate, as in
/*@ terminates \false; */
void f(void) {
/*@ terminates \true; */
{
/*@ loop invariant 0 <= i <= 3;
loop assigns i;
loop variant 3 - i;
*/
for (int i = 0; i < 3; i++) ;
}
while(1) ;
}
In other words, I'd suggest that the variant is conditioned by the terminates
clause of the innermost contract enclosing it. In addition, it might also be worth it to state explicitly that , if a statement contract with terminates
clause T1
is enclosed into another contract with terminates
clause T2
, we must have T2 ==> T1
Oh yes, I forgot this case.
I have nothing more to say.
Hum. What about the behavior of:
// decreases p for some_relation ;
void f(int *p){
if(condition) f(p);
}
The fact that some_relation
must be well-founded is clear. If I correctly understand:
some_relation
cannot have labels,@here
.This is somewhat what is explained in the section but I think that we could emphasize on this behavior.
In fact, giving the details mentioned in the previous comment is probably more suitable for a course :thinking: , so let's forget about that.
@AllanBlanchard, in the branch clarifies-measures-termination
of the Github project acsl-language/acsl
I added a commit (the last one) that you could cherry-pick
part of it to this pull request. By the way, these modifications can still be discussed here.
I have included the commit made by @pbaudin and added a few details + fixed some typos. I think it is ready.
It is fine for me.
@vprevosto, are you ready to merge this pull request ?
Use these commits directly to review the diff:
There is a commit that trims spaces.
There was a misunderstanding in https://github.com/acsl-language/acsl/issues/79, this is also fixed.