program-correctness-prover — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited program-correctness-prover (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Generate formal proofs establishing correctness of imperative programs.
This skill takes imperative program code with formal specifications (preconditions and postconditions) and generates complete correctness proofs in Isabelle or Coq using Hoare logic. It handles loop invariant generation, verification condition generation, and proof construction for both partial and total correctness.
Provide:
The skill will generate:
Identify program components:
x := EC1; C2if B then C1 else C2while B do CFor each loop, construct an invariant that:
{I ∧ B} C {I}I ∧ ¬B ⟹ QStrategies:
Apply Hoare logic rules to generate VCs:
Assignment: {P[E/x]} x := E {P}
Sequence: Chain intermediate conditions
Conditional: Prove both branches
Loop: Prove initialization, preservation, and termination
Build formal proof in target system:
Provide variant function V that:
Program:
sum := 0;
i := 0;
while i < n do
sum := sum + a[i];
i := i + 1
doneSpecification:
n ≥ 0sum = Σ(a[0..n-1])Analysis:
Loop Invariant:
I: sum = Σ(a[0..i-1]) ∧ 0 ≤ i ≤ nVerification Conditions:
n ≥ 0 ⟹ 0 = Σ(a[0..-1]) ∧ 0 ≤ 0 ≤ nn ≥ 0 ⟹ 0 = 0 ∧ 0 ≤ n ✓{I ∧ i < n} sum := sum + a[i]; i := i + 1 {I}sum + a[i] = Σ(a[0..i]) ∧ 0 ≤ i + 1 ≤ nI ∧ ¬(i < n) ⟹ sum = Σ(a[0..n-1])V = n - iIsabelle Proof (abbreviated):
lemma sum_array_partial:
"⦃λs. s ''n'' ≥ 0⦄
sum := 0;; i := 0;;
While (λs. s ''i'' < s ''n'')
Do (sum := (λs. s ''sum'' + s ''a'' (s ''i''));;
i := (λs. s ''i'' + 1))
⦃λs. s ''sum'' = (∑j<s ''n''. s ''a'' j)⦄"
proof -
define I where "I = (λs. s ''sum'' = (∑j<s ''i''. s ''a'' j) ∧
0 ≤ s ''i'' ∧ s ''i'' ≤ s ''n'')"
(* Initialization *)
have "⦃λs. s ''n'' ≥ 0⦄ sum := 0;; i := 0 ⦃I⦄"
unfolding I_def by (auto intro: hoare_seq hoare_asgn)
(* Loop body preserves invariant *)
moreover have "⦃λs. I s ∧ s ''i'' < s ''n''⦄
sum := (λs. s ''sum'' + s ''a'' (s ''i''));;
i := (λs. s ''i'' + 1)
⦃I⦄"
unfolding I_def by (auto intro: hoare_seq hoare_asgn)
(* Apply while rule *)
ultimately have "⦃λs. s ''n'' ≥ 0⦄
sum := 0;; i := 0;;
While (λs. s ''i'' < s ''n'')
Do (sum := (λs. s ''sum'' + s ''a'' (s ''i''));;
i := (λs. s ''i'' + 1))
⦃λs. I s ∧ ¬(s ''i'' < s ''n'')⦄"
by (auto intro: hoare_seq hoare_while)
(* Postcondition follows from invariant *)
then show ?thesis
unfolding I_def by (rule hoare_conseq) auto
qedCoq Proof (abbreviated):
Theorem sum_array_partial : forall n a,
n >= 0 ->
{{ fun st => st N = n /\ n >= 0 }}
sum ::= 0;;
i ::= 0;;
while i < N do
sum ::= sum + a[i];;
i ::= i + 1
done
{{ fun st => st sum = sum_array a n }}.
Proof.
intros n a Hn.
remember (fun st => st sum = sum_array a (st i) /\
0 <= st i /\ st i <= st N) as I.
(* Initialization *)
eapply hoare_seq. apply hoare_asgn.
eapply hoare_seq. apply hoare_asgn.
(* Loop *)
eapply hoare_consequence_post.
- apply hoare_while.
(* Loop body *)
eapply hoare_seq. apply hoare_asgn.
eapply hoare_consequence_pre.
+ apply hoare_asgn.
+ intros st [HI Hcond]. subst I. simpl.
destruct HI as [Hsum [Hi1 Hi2]].
split; [|split]; try lia.
rewrite Hsum. unfold sum_array. lia.
- (* Postcondition *)
intros st [HI Hcond]. subst I.
destruct HI as [Hsum [Hi1 Hi2]].
assert (st i = n) by lia.
rewrite H. exact Hsum.
Qed.Program:
if x >= y then
max := x
else
max := ySpecification:
truemax = max(x, y)Analysis:
Verification Conditions:
{x ≥ y} max := x {max = max(x, y)}x = max(x, y){x < y} max := y {max = max(x, y)}y = max(x, y)Isabelle Proof:
lemma max_correct:
"⦃λs. True⦄
If (λs. s ''x'' ≥ s ''y'')
Then max := (λs. s ''x'')
Else max := (λs. s ''y'')
⦃λs. s ''max'' = max (s ''x'') (s ''y'')⦄"
proof (rule hoare_if)
show "⦃λs. s ''x'' ≥ s ''y''⦄
max := (λs. s ''x'')
⦃λs. s ''max'' = max (s ''x'') (s ''y'')⦄"
by (rule hoare_conseq[OF hoare_asgn]) simp
next
show "⦃λs. ¬(s ''x'' ≥ s ''y'')⦄
max := (λs. s ''y'')
⦃λs. s ''max'' = max (s ''x'') (s ''y'')⦄"
by (rule hoare_conseq[OF hoare_asgn]) simp
qedCoq Proof:
Example max_correct :
{{ fun st => True }}
if x >= y then
max ::= x
else
max ::= y
{{ fun st => st max = max (st x) (st y) }}.
Proof.
apply hoare_if.
- eapply hoare_consequence_pre.
+ apply hoare_asgn.
+ intros st H. simpl. lia.
- eapply hoare_consequence_pre.
+ apply hoare_asgn.
+ intros st H. simpl. lia.
Qed.Program: x := E1; y := E2; z := E3
Strategy: Work backwards with weakest precondition
Program: result := init; while i < n do result := f(result, a[i]); i := i + 1
Invariant: result = fold(f, init, a[0..i-1]) ∧ 0 ≤ i ≤ n
Program: found := false; while i < n && !found do if a[i] == target then found := true else i := i + 1
Invariant: (∀j. 0 ≤ j < i ⟹ a[j] ≠ target) ∧ 0 ≤ i ≤ n
Program: Outer loop with inner loop
Invariants: Outer invariant + inner invariant (may depend on outer variables)
Definition: If precondition holds and program terminates, postcondition holds
Hoare triple: {P} C {Q}
What to prove:
Definition: If precondition holds, program terminates AND postcondition holds
Hoare triple: [P] C [Q] (square brackets)
What to prove:
Variant requirements:
Detailed guides for program verification:
Load these references when:
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.