hoare-logic-verifier
Skill17 starsChanged 9 months agoApache-2.0View on GitHub
Verifies programs using Hoare logic. Use when: (1) Proving program correctness,
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
- incremental-computationSkill
- information-flow-analyzerSkill
- inline-expanderSkill
- interprocedural-analysisSkill
- invariant-generatorSkill
- 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
10 rules. About 0 are common, 10 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
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 61
Start with simple programs, add complexity
- Distinctive: line 62
Always verify loop invariants manually first
- Distinctive: line 63
Use consequences to strengthen/weaken
- Distinctive: line 64
Consider using SMT solvers for complex conditions
- Distinctive: line 118
For concurrent programs: Use concurrent separation logic
- Distinctive: line 119
For pointer-heavy code: Use separation logic instead
- Distinctive: line 120
For automated verification: Consider model checking
- Distinctive: line 121
For large codebases: Consider symbolic execution + testing
- Distinctive: line 131
Loop invariants: Must be provided manually (undecidable to find)
- Distinctive: line 178
Goal: Verify concurrent programs
≈ “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
Hoare Logic Verifier
Verifies program correctness using Floyd-Hoare logic.
When to Use
- Proving program correctness
- Developing verified software
- Verifying loop invariants
- Static verification
What This Skill Does
- Specifies contracts - Pre/postconditions and loop invariants
- Generates verification conditions - Formulas to prove
- Checks soundness - Proves VCs are valid
- Handles loops - Invariant inference
Key Concepts
| Concept | Description |
| Precondition | State before execution |
| Postcondition | State after execution |
| Invariant | True before/after each loop iteration |
| Weakest precondition | Minimal condition ensuring postcondition |
| Verification condition | Formula to prove for correctness |
Verification Condition Generation
{P} while b do c {Q}
VCs:
1. P ⇒ I (initiation)
2. I ∧ b ⇒ wp(c, I) (preservation)
3. I ∧ ¬b ⇒ Q (usefulness)Tips
- Start with simple programs, add complexity
- Always verify loop invariants manually first
- Use consequences to strengthen/weaken
- Consider using SMT solvers for complex conditions
- Handle division carefully (non-zero)
Common Patterns
Swap
{ x = a ∧ y = b }
t := x;
x := y;
y := t;
{ x = b ∧ y = a }Linear Search
{ ∃i. A[i] = k ∧ 0 ≤ i < n }
i := 0;
while i < n do
if A[i] = k then break;
i := i + 1
{ (i < n ⇒ A[i] = k) ∧ (i = n ⇒ ∀j. 0≤j<n ⇒ A[j] ≠ k) }Related Skills
separation-logician- Heap verificationinvariant-generator- Automatic invariant inferenceloop-termination-prover- Prove termination
Canonical References
| Reference | Why It Matters |
| Hoare, "An Axiomatic Basis for Computer Programming" (CACM 1969) | Original Hoare logic paper (Turing Award) |
| Apt & Olderog, "Verification of Programs" (1981) | Comprehensive survey |
| Floyd, "Assigning Meanings to Programs" (1967) | Predecessor to Hoare logic |
| Nielson & Nielson, "Hoare Logic" (1999) | Formal treatment |
| Gupta et al., "A Practical Guide to Design of C Programs" (1991) | Verifiable C coding |
Tradeoffs and Limitations
Approach Tradeoffs
| Approach | Pros | Cons |
| Standard Hoare | Simple, intuitive | Can't handle heap/pointers |
| Separation Logic | Handles pointers, heap | More complex |
| Dynamic Logic | Loops as formulas | Harder to use |
When NOT to Use Hoare Logic
- For concurrent programs: Use concurrent separation logic
- For pointer-heavy code: Use separation logic instead
- For automated verification: Consider model checking
- For large codebases: Consider symbolic execution + testing
Complexity Considerations
- VC generation: O(n) in program size
- SMT solving: Expensive for complex formulas; undecidable in general
- Invariant inference: NP-hard in general
Limitations
- Loop invariants: Must be provided manually (undecidable to find)
- Frame problem: Hard to specify what doesn't change; use separation logic
- Partial correctness: Standard Hoare logic proves partial correctness (no termination)
- Scalability: Manual proof effort grows with program size
- Concurrency: Requires extensions (concurrent separation logic)
Research Tools & Artifacts
Verification tools based on Hoare logic:
| Tool | Language | What to Learn |
| Dafny | C#/Boogie | Verified programs |
| Verifiable C (VST) | Coq | C verification |
| Frama-C | C | Static analysis |
| Why3 | Why3 | Verification platform |
| ESC/Java | Java | Extended Static Checking |
| Spec# | C# | Contract-based verification |
Interactive Theorem Provers
- Coq - Proof assistant, VST for C
- Isabelle/HOL - General purpose
- Lean - Functional verification
- Agda - Dependent types
Research Frontiers
1. Verification Condition Generation
- Goal: Automate proof effort
- Approach: Generate VCs, discharge with SMT
- Papers: "VCGen for Dummies" (various)
- Tools: Boogie, Why3
2. Loop Invariant Inference
- Goal: Automatically find invariants
- Approach: Abstract interpretation, learning
- Papers: "Invariant Generation" (Sankaranarayanan)
- Tools: Abstract interpretation tools
3. Separation Logic
- Goal: Handle heap and pointers
- Approach: Local reasoning, frame rule
- Papers: "Separation Logic" (O'Hearn, Reynolds)
- Tools: Verifiable C, Smallfoot
4. Concurrent Verification
- Goal: Verify concurrent programs
- Approach: Concurrent separation logic
- Papers: "Concurrent Separation Logic" (O'Hearn)
- Tools: Verifast, Grain
Implementation Pitfalls
| Pitfall | Real Consequence | Solution |
| Wrong invariant | Unsound proof | Verify each VC |
| Missing frames | Incomplete specs | Use separation logic |
| Division by zero | Runtime errors | Add precondition |
| Overflow | Unsoundness | Use bounded integers |
The "Loop Invariant" Challenge
Finding invariants is undecidable:
# What invariant proves this?
i = 0
sum = 0
while i < n:
sum = sum + i
i = i + 1
# Answer: sum = i*(i-1)/2
# Another valid invariant: 0 <= i <= n AND sum >= 0
# But this is too weak to prove final result!This is why verification requires human insight!
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.

