invariant-inference

Infer loop invariants and function contracts from execution traces.

1|2|Updated Mar 10, 2026
One-click install
npx skills add https://github.com/santosomar/general-secure-coding-agent-skills --skill invariant-inference-santosomar
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: invariant-inference
Source: https://github.com/santosomar/general-secure-coding-agent-skills/tree/main/skills/verification/invariant-inference
Command: npx skills add https://github.com/santosomar/general-secure-coding-agent-skills --skill invariant-inference-santosomar

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill automatically infers loop invariants and function contracts, which are crucial for formal verification but often tedious for developers to write manually.

Core Features & Use Cases

  • Dynamic Invariant Inference: Observes execution traces to identify patterns and generalize potential invariants (Daikon-style).
  • Static Invariant Inference: Uses template-based guessing (e.g., linear relations) to synthesize invariants.
  • Inductive Checking: Verifies candidate invariants for correctness and sufficiency using SMT solvers or verifiers.
  • Use Case: When a verification tool rejects a loop due to a missing or weak invariant, this skill can automatically generate and validate suitable candidates.

Quick Start

Use the invariant-inference skill to find invariants for the loop in the provided Python code.

Frequently Asked Questions about invariant-inference

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automatically infer loop invariants when formal verification fails due to missing or weak candidates?

Loop invariant inference is automated by observing execution traces and synthesizing candidates using dynamic Daikon-style methods or static template-based guessing, followed by inductive checking to validate sufficiency.

What is the difference between dynamic and static invariant inference for generating function contracts?

Dynamic invariant inference observes execution traces to generalize patterns, while static inference uses template-based guessing like linear relations to synthesize invariants, both requiring inductive checking for correctness validation.

Can I use template-based invariant inference to find linear relations for program analysis without writing contracts manually?

Template-based invariant inference uses linear relation templates to synthesize candidates automatically, eliminating manual contract writing by generating and validating potential invariants through inductive checking.

How do I verify if a synthesized loop invariant is correct and sufficient for formal methods?

Synthesized loop invariants are verified for correctness and sufficiency using SMT solvers or verifiers during inductive checking, ensuring candidates satisfy formal verification requirements before deployment.

When do I need to use automated invariant inference instead of manually specifying program contracts?

Automated invariant inference is needed when verification tools reject loops due to missing or weak invariants, making manual contract specification tedious and error-prone for complex program analysis tasks.

Does invariant inference work with Python code for formal verification processes?

Invariant inference works with Python code by analyzing provided loops to automatically generate and validate suitable invariant candidates, supporting both dynamic trace observation and static template synthesis.