invariant-analyzer

Solid

Identify and verify loop invariants for correctness proofs

AI & Automation 1,160 stars 71 forks Updated today MIT

Install

View on GitHub

Quality Score: 94/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
74
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Invariant Analyzer Skill ## Purpose Identify and verify loop invariants to help construct correctness proofs for algorithms. ## Capabilities - Automatic loop invariant inference - Invariant verification against code - Precondition/postcondition extraction - Generate formal proof structure - Identify missing invariants ## Target Processes - correctness-proof-testing - algorithm-implementation ## Invariant Analysis Framework ### Loop Invariant Properties 1. **Initialization**: True before first iteration 2. **Maintenance**: If true before iteration, true after 3. **Termination**: Provides useful property at end ### Common Invariant Patterns - Range invariants: "for all i in [0, k), property P(i) holds" - Accumulator invariants: "sum equals sum of a[0..k-1]" - Pointer invariants: "left < right and all elements < left are processed" - State invariants: "data structure maintains property X" ## Input Schema ```json { "type": "object", "properties": { "code": { "type": "string" }, "language": { "type": "string" }, "loopIndex": { "type": "integer" }, "expectedInvariant": { "type": "string" } }, "required": ["code"] } ``` ## Output Schema ```json { "type": "object", "properties": { "success": { "type": "boolean" }, "invariants": { "type": "array" }, "preconditions": { "type": "array" }, "postconditions": { "type": "array" }, "proofOutline": { "type": "string" } }, "required": ["success"] } ```

Details

Author
a5c-ai
Repository
a5c-ai/babysitter
Created
4 months ago
Last Updated
today
Language
JavaScript
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Solid

loop-invariant-generator

Automatically generate and verify loop invariants for algorithm correctness proofs

1,160 Updated today
a5c-ai
AI & Automation Listed

invariant-guard

Use when writing or reviewing algorithms where the obvious implementation is subtly wrong — postcondition stronger than the loop's natural invariant (Boyer–Moore majority, Floyd cycle, leftmost vs any binary search, QuickSelect partition); in-place mutation with read+write pointers (dedup-in-place, partition, rotate); recursion with multiple parameters or accumulator state; off-by-one suspects with duplicates, empty inputs, boundary values; iterative refinements that must terminate (fixed-point, Newton, EM); any function where you catch yourself thinking "I know this algorithm" — the trap is usually in the contract, not the loop body. Forces writing the function contract (especially the postcondition) and loop invariant BEFORE code. Pairs with lemmaly (picks the algorithm) and mathguard (picks the math).

1 Updated 2 days ago
morsechimwai
AI & Automation Solid

proof-assistant

Assist in constructing algorithm correctness proofs

1,160 Updated today
a5c-ai
AI & Automation Solid

proof-structure-analyzer

Analyze and restructure mathematical proofs for clarity and completeness

1,160 Updated today
a5c-ai
AI & Automation Listed

invariant-test

Verify the CVE-derived invariants in .kuzushi/threat-intel.json against the code, using the tree-sitter taint MCP tools (and codeql/joern if available). Writes .kuzushi/invariant-results.json with hold / violated / needs-review verdicts. Requires /threat-intel to have run first.

0 Updated yesterday
allsmog