santosomar/general-secure-coding-agent-skills/abstract-invariant-generator
- community
Checking that the SKILL.md file is still in the repository.
Generates abstract invariants using domain abstraction — intervals, octagons, polyhedra, sign domains — to find invariants that concrete reasoning misses. Use when standard invariant inference fails, when the invariant involves relationships between multiple variables, or when verifying numerical code.
Install
npx vskill@latest install santosomar/general-secure-coding-agent-skills/abstract-invariant-generatorSKILL.md
Abstract Invariant Generator
When → invariant-inference (which works from concrete traces) can't find the invariant, abstract interpretation can. It over-approximates: instead of tracking exact values, track which region of a chosen domain the values are in.
Abstract domains — pick by invariant shape
| Domain | Can express | Example invariant | Cost | |
|---|---|---|---|---|
| Sign | x > 0, x = 0, x < 0 | n > 0 | Trivial | |
| Interval | lo ≤ x ≤ hi | 0 ≤ i ≤ n | Cheap | |
| Octagon | ±x ± y ≤ c (two-var bounds) | i ≤ j, j - i ≤ n | Moderate | |
| Polyhedra | Arbitrary linear inequalities | 2i + 3j ≤ n + 5 | Expensive | |
| Congruence | x ≡ k (mod m) | i is even | Cheap |
Start cheap. Intervals catch 80% of array-bounds invariants. Octagons catch most two-pointer patterns. Polyhedra are for when you actually need a weird linear relationship.
The algorithm (fixpoint iteration)
- Abstract the initial state.
i = 0→ in intervals:i ∈ [0, 0]. - Abstract the transition.
i := i + 1on[a, b]→[a+1, b+1]. - Join at loop head. Union the incoming abstract states:
[0,0] ⊔ [1,1] = [0,1]. - Iterate until fixpoint. The loop stabilizes → that's your invariant.
- Widen if it doesn't stabilize.
[0,1] ⊔ [0,2] ⊔ [0,3] ⊔ ...→ widen to[0, +∞). Then narrow: apply the loop guardi < nto get[0, n-1].
Worked example — interval domain
Code:
Interval abstraction:
| Iteration | i | j | |
|---|---|---|---|
| Init | [0, 0] | [n, n] | |
| After 1 | [1, 1] | [n-1, n-1] | |
| Join | [0, 1] | [n-1, n] | |
| After 2 | [1, 2] | [n-2, n-1] | |
| Join | [0, 2] | [n-2, n] | |
| …widen | [0, +∞) | (-∞, n] | |
Narrow (guard i < j) | [0, n] | [0, n] |
Interval invariant: 0 ≤ i ≤ n ∧ 0 ≤ j ≤ n. True but weak — doesn't capture i + j = n.
Octagon domain (tracks ±x ± y ≤ c):
Initial: i + j = n (since i=0, j=n). Transition: i' = i+1, j' = j-1 → i' + j' = i + j = n. Preserved. Octagon finds i + j = n (as i+j ≤ n ∧ -(i+j) ≤ -n).
Lesson: Intervals are per-variable; they can't see i + j = n. For relational invariants, you need a relational domain.
Choosing the domain
- Look at the postcondition you're trying to prove. What shape is it?
- Single-var bound → intervals suffice.
- Two-var comparison (
i ≤ j) → octagons. - Three+ var linear → polyhedra.
- Divisibility → congruence.
- Run with the cheapest domain that could express it.
- If the result is too weak (e.g.,
[-∞, +∞]), the domain can't express the invariant — upgrade.
Do not
- Do not start with polyhedra. They're exponentially expensive. Intervals → octagons → polyhedra.
- Do not forget to narrow after widening. Widening alone gives
[0, +∞)— useless. The guard narrows it back. - Do not expect abstract interpretation to find nonlinear invariants.
i*i ≤ n— none of these domains can express it. You need a polynomial domain or template-based search. - Do not trust an invariant without checking it's inductive. Abstract interpretation is sound (no false invariants) — but double-check by plugging it back into the verifier.
Output format
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/verification/abstract-invariant-generator/SKILL.md
Popularity
- 7-day trend score
- 0
Refreshed 18 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/santosomar/general-secure-coding-agent-skills/abstract-invariant-generator)