You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DIG infered the nonlinear equality m*n*t - m*(t*t) - n*(t*t) + (t*t*t) == 0 and a couple of inequalities m - t <= 0; n - t <= 0; -t <= 0
solve for t from the equality, we get a disjunction t == n or t == m or t == 0
combining these three disjuncts with the obtained inequalities t>= n and t >=m, we get t = max(n,m), which is the correct bound for this program
intpopl09_fig3_4(intn, intm){
intx=0;
inty=0;
inttCtr=0;
while((x<n||y<m)){
if(x<n){
x++;
y++;
}
elseif(y<m){
x++;
y++;
}
else{
//assert(0);break;
}
tCtr++;
}
vtrace_post(n, m, tCtr);
//DIG: m*n*t - m*(t*t) - n*(t*t) + (t*t*t) == 0, //DIG: m - t <= 0, n - t <= 0, -t <= 0return0;
}
Disjunctive Invariants through Min/Max-Plus Relations
strncpy
simulates the C strncpys function to copy the first n chars from a null-terminated source to a destination buffer.
in the following s represents length of the source buffer, d is the length of the destination buffer
DIG obtained the invs d >= min(n,s); s >= min(d,n), which represent the disjunction
(n >= s && d = s) || (n < s ∧ d >= n)
This captures the desired semantics of strncpy: if n >= |s|,
then the copy stops at the null terminator of s, which is
also copied to d, so d ends up with the same length as s.
However, if n < |s|, then the terminator is not copied to d, so |d| >= n.