invariant-inference

Installation
SKILL.md

Invariant Inference

A loop invariant is what stays true every time you hit the loop head. Verifiers need it stated; programmers rarely state it. This skill guesses it from evidence.

Two routes to an invariant

Route How it works Good at Bad at
Dynamic (Daikon-style) Run the code, record state at loop head, generalize patterns Concrete relationships in traces Generalization — might be coincidence
Static (template-based) Guess invariants of form ax + by ≤ c, solve for a,b,c Sound by construction Limited to the template shapes

Do both: dynamic finds candidates fast; static checks them.

Dynamic — the observe-and-generalize loop

  1. Instrument. At every loop head, dump all local variable values.
  2. Run on a bunch of inputs. The more diverse, the better.
  3. Mine patterns across the dumps. What's true at every observation?
  4. Filter for inductiveness. A pattern true by coincidence won't survive the inductive check.
Installs
1
GitHub Stars
1
First Seen
Mar 29, 2026
invariant-inference — santosomar/general-secure-coding-agent-skills