invariant-generator
Skill17 starsChanged 9 months agoApache-2.0View on GitHub
Infers loop invariants automatically. Use when: (1) Proving program
In this repository98 other files it gives its agents.
- abstract-interpretation-engineSkill
- abstract-machineSkill
- acsl-annotation-assistantSkill
- actor-model-implementerSkill
- algebraic-effectsSkill
- alias-and-points-to-analysisSkill
- axiomatic-semanticsSkill
- bidirectional-type-checkingSkill
- bisimulation-checkerSkill
- capability-systemSkill
- closure-converterSkill
- common-subexpression-eliminatorSkill
- concurrency-verifierSkill
- constant-propagation-passSkill
- contextual-equivalenceSkill
- control-flow-analysisSkill
- coq-proof-assistantSkill
- cps-transformerSkill
- dafny-verifierSkill
- dataflow-analysis-frameworkSkill
- dead-code-eliminatorSkill
- defunctionalizationSkill
- denotational-semantics-builderSkill
- dependent-type-implementerSkill
- dsl-embeddingSkill
- effect-handlers-implementerSkill
- effect-systemSkill
- effect-type-systemSkill
- escape-analysisSkill
- existential-typesSkill
- ffi-designerSkill
- fuzzer-generatorSkill
- gadt-implementerSkill
- garbage-collector-implementerSkill
- graalvm-truffle-implementerSkill
- gradual-typing-implementerSkill
- higher-order-abstract-syntaxSkill
- hoare-logic-verifierSkill
- incremental-computationSkill
- information-flow-analyzerSkill
- inline-expanderSkill
- interprocedural-analysisSkill
- jit-compiler-builderSkill
- lambda-calculus-interpreterSkill
- language-server-protocolSkill
- lean-proverSkill
- lexer-generatorSkill
- linear-type-implementerSkill
- liveness-analysisSkill
- llvm-backend-generatorSkill
- lock-free-data-structureSkill
- loop-optimizerSkill
- loop-termination-proverSkill
- macro-expanderSkill
- memory-allocatorSkill
- message-passing-systemSkill
- mlir-dialect-designerSkill
- model-checkerSkill
- module-systemSkill
- monad-transformerSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 55
Start with simple bounds
- Distinctive: line 57
Use counterexamples to guide search
- Distinctive: line 104
Template selection: Must choose right templates
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Invariant Generator
Automatically infers loop invariants for program verification.
When to Use
- Proving program correctness
- Automating verification
- Loop analysis
- Counterexample generation
What This Skill Does
- Analyzes loops - Examines loop structure
- Infers candidates - Generates invariant candidates
- Verifies - Checks if invariant holds
- Refines - Improves invariants
Key Concepts
| Concept | Description |
| Loop invariant | True before and after each iteration |
| Initialization | Holds initially |
| Preservation | Maintained by body |
| Usefulness | Helps prove postcondition |
Techniques
- Template-based inference
- Abstract interpretation
- Counterexample-guided
- Iterative refinement
Tips
- Start with simple bounds
- Handle accumulators carefully
- Use counterexamples to guide search
- Combine multiple techniques
Related Skills
hoare-logic-verifier- Verify with invariantsloop-termination-prover- Prove terminationsymbolic-execution-engine- Symbolic execution
Canonical References
| Reference | Why It Matters |
| Ernst et al., "The Daikon System for Dynamic Detection of Likely Invariants" (SCP 2007) | Daikon invariant detector |
| Sankaranarayanan et al., "Non-Linear Loop Invariant Generation using Gröbner Bases" (POPL 2004) | Template-based invariant generation |
| Csallner & Xie, "DynaMine: Finding Common Error Patterns by Mining Software Repositories" (ICSE 2005) | Dynamic invariant mining |
| Gulwani et al., "Generating Numerical Invariants with Polynomials" (POPL 2009) | Counterexample-guided invariant generation |
| Sharma & Aiken, "From Invariants to Code" (POPL 2014) | Interpolants-based invariant generation |
Tradeoffs and Limitations
Invariant Inference Approach Tradeoffs
| Approach | Pros | Cons |
| Dynamic | Precise, fast | May miss bugs |
| Static | Sound | Complex |
| CEGAR | Iterative refinement | May diverge |
| Template | Guided search | Template-dependent |
When NOT to Use Automatic Invariant Inference
- For simple loops: Manual specification may be faster
- For proving liveness: Different techniques needed
- For complex data structures: Hard to infer
Complexity Considerations
- Template-based: Exponential in template variables
- Abstract interpretation: Lattice height × program size
- CEGAR: May require many iterations
Limitations
- Completeness: May miss important invariants
- Precision: May infer too weak or too strong
- Scalability: Hard for large programs
- Template selection: Must choose right templates
- Arithmetic: Nonlinear invariants hard
- Data structures: Complex invariants needed
Research Tools & Artifacts
Invariant detection tools:
| Tool | What to Learn |
| Daikon | Dynamic invariants |
| Armin | Static invariants |
Research Frontiers
1. CEGAR for Invariants
- Approach: Counterexample-guided
Implementation Pitfalls
| Pitfall | Real Consequence | Solution |
| Weak invariants | Failed proofs | Refine templates |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

