Sum-loop obligations for n ≤ 5Complete bounded program family · 6 inputs
The problem
Verify a loop that increments i and then adds i to total, starting from zero.
The checked result
Postcondition holds: yes; Variant decreases: yes.
The invariant explains the partial sum at each boundary. The remaining iteration count strictly decreases, and the exit condition turns the invariant into the postcondition.
Why the checker accepts it
- Enumerate every admitted bound n.
- Start with i=0 and total=0.
- Check 2·total=i(i+1) and the decreasing variant n−i.
- Replay the sample trace and require total=n(n+1)/2 at exit.
Formal specification
{
"program": "sum-first-n",
"max_n": 5,
"sample_n": 3,
"precondition": "n ≥ 0; i=0; total=0",
"invariant": "2*total = i*(i+1) and 0 ≤ i ≤ n",
"variant": "n-i"
}Claim and evidence
{
"claim": {
"postcondition_holds": true,
"variant_decreases": true
},
"witness": {
"trace": [
[
0,
0
],
[
1,
1
],
[
2,
3
],
[
3,
6
]
]
}
}Dataset construction
Deterministic finite fixture; full enumeration or witness replay as stated. Structured JSON; field meanings are stated in the specification. Acceptance covers 6 checker units for this record; the unit type is stated in its verification scope.
Complexity and limits
The family runs Σ n loop iterations for n=0…N, so total replay is O(N²).
This replay checks n through the stated bound; it does not constitute an unrestricted deductive proof.
A boundary to investigate
A postcondition on one execution is weaker than an invariant and a declared input domain. Add inductive proof obligations and externally checked Hoare derivations.