Establish explicit traceability between formal specifications (preconditions, postconditions, invariants) and verified code components with their correctness proofs. Produce structured Markdown mapping reports showing verification coverage and proof evidence. Use when auditing formal verification, documenting verified systems, establishing traceability for certification, or when the user asks to map specifications to code, generate verification reports, or analyze verification coverage in Coq, Dafny, Isabelle, or other proof assistants.
npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill verified-spec-code-mapper
Establish explicit, evidence-based traceability between formal specifications and verified code components. Generate structured reports that map each specification to its implementation and correctness proofs, supporting verification auditing, documentation, and reproducibility.
Locate all formal specifications in the codebase:
forall ... -> P -> ... (hypothesis before conclusion)requires clausesassumes clauses... -> Q (conclusion of theorem)ensures clausesshows clausesinvariant clauses in loopspredicate Valid() methodsFor each specification, identify corresponding code:
Lemma factorial_positive : forall n, factorial n >= 1→ Maps to factorial function
sort_correct → sort)For each specification-code mapping, find proof evidence:
Qeddone or qedAdmittedsorryAxiom declarationsaxiomatizationDetermine verification completeness:
Coverage = (Verified Specs / Total Specs) × 100%
Coverage = (Verified Functions / Total Functions) × 100%
Completeness = (Complete Proofs / Total Proofs) × 100%
Produce structured Markdown report:
For detailed patterns and templates, see mapping_patterns.md.
| Specification Type | Typical Location | Verification Evidence |
|-------------------|------------------|----------------------|
| Precondition | requires, hypothesis | Checked by verifier or proved |
| Postcondition | ensures, conclusion | Theorem proving property |
| Loop Invariant | invariant, lemma | Induction proof |
| Class Invariant | predicate Valid() | Maintained by all methods |
| Functional Correctness | Theorem statement | Complete proof |
Input Code:
Definition divide (n m : nat) : option nat :=
if m =? 0 then None else Some (n / m).
Lemma divide_safe : forall n m : nat,
m <> 0 -> exists q, divide n m = Some q.
Proof.
intros n m Hm.
unfold divide.
destruct (m =? 0) eqn:E.
- apply Nat.eqb_eq in E. contradiction.
- exists (n / m). reflexivity.
Qed.
Generated Report:
# Verification Report: divide
## Function Signature
Definition divide (n m : nat) : option nat
## Specifications
### Precondition: Non-zero Divisor
- **Specification:** `m <> 0`
- **Location:** divide.v:4 (lemma hypothesis)
- **Status:** ✓ Fully Verified
### Postcondition: Returns Quotient
- **Specification:** `exists q, divide n m = Some q`
- **Location:** divide.v:4 (lemma conclusion)
- **Status:** ✓ Fully Verified
## Verification Evidence
### Theorem: divide_safe
- **Statement:** `forall n m, m <> 0 -> exists q, divide n m = Some q`
- **Location:** divide.v:4-10
- **Proof Status:** ✓ Complete (ends with Qed)
- **Proof Method:** Case analysis on `m =? 0`
- **Dependencies:** None
## Coverage Summary
- Specifications: 2 total, 2 verified (100%)
- Status: ✓ Fully Verified
Input Code:
class BankAccount {
var balance: int
predicate Valid()
reads this
{
balance >= 0
}
constructor(initial: int)
requires initial >= 0
ensures Valid()
ensures balance == initial
{
balance := initial;
}
method Deposit(amount: int)
requires Valid()
requires amount >= 0
modifies this
ensures Valid()
ensures balance == old(balance) + amount
{
balance := balance + amount;
}
}
Generated Report:
# Verification Report: BankAccount
## Class Invariant
### Invariant: Non-negative Balance
- **Specification:** `balance >= 0`
- **Location:** BankAccount.dfy:5 (Valid predicate)
- **Status:** ✓ Fully Verified
## Method: constructor
### Specifications
1. **Precondition: Non-negative Initial**
- Specification: `requires initial >= 0`
- Location: BankAccount.dfy:10
- Status: ✓ Verified by Dafny
2. **Postcondition: Establishes Invariant**
- Specification: `ensures Valid()`
- Location: BankAccount.dfy:11
- Status: ✓ Verified by Dafny
3. **Postcondition: Correct Balance**
- Specification: `ensures balance == initial`
- Location: BankAccount.dfy:12
- Status: ✓ Verified by Dafny
## Method: Deposit
### Specifications
1. **Precondition: Valid State**
- Specification: `requires Valid()`
- Location: BankAccount.dfy:18
- Status: ✓ Verified by Dafny
2. **Precondition: Non-negative Amount**
- Specification: `requires amount >= 0`
- Location: BankAccount.dfy:19
- Status: ✓ Verified by Dafny
3. **Postcondition: Maintains Invariant**
- Specification: `ensures Valid()`
- Location: BankAccount.dfy:21
- Status: ✓ Verified by Dafny
4. **Postcondition: Correct Balance Update**
- Specification: `ensures balance == old(balance) + amount`
- Location: BankAccount.dfy:22
- Status: ✓ Verified by Dafny
## Coverage Summary
- Total Specifications: 7
- Fully Verified: 7 (100%)
- Status: ✓ Fully Verified
- Verification Method: Dafny automatic verifier
Input Code:
Require Import FunctionalExtensionality.
Definition compose {A B C : Type} (g : B -> C) (f : A -> B) : A -> C :=
fun x => g (f x).
Lemma compose_assoc : forall (A B C D : Type)
(f : A -> B) (g : B -> C) (h : C -> D),
compose h (compose g f) = compose (compose h g) f.
Proof.
intros.
apply functional_extensionality.
intro x. reflexivity.
Qed.
Generated Report:
# Verification Report: compose
## Function Signature
Definition compose {A B C : Type} (g : B -> C) (f : A -> B) : A -> C
## Specifications
### Functional Correctness: Associativity
- **Specification:** `compose h (compose g f) = compose (compose h g) f`
- **Location:** compose.v:6-8
- **Status:** ⚠ Verified with Assumptions
## Verification Evidence
### Theorem: compose_assoc
- **Statement:** Composition is associative
- **Location:** compose.v:6-13
- **Proof Status:** ✓ Complete (ends with Qed)
- **Proof Method:** Functional extensionality + reflexivity
- **Dependencies:**
- ⚠ **Axiom:** `functional_extensionality` (assumed)
## Assumptions
### Axiom: functional_extensionality
- **Statement:** `forall (A B : Type) (f g : A -> B), (forall x, f x = g x) -> f = g`
- **Source:** Coq standard library
- **Justification:** Standard axiom for function equality
- **Used in:** compose_assoc
- **Impact:** Widely accepted axiom, consistent with Coq's logic
## Coverage Summary
- Specifications: 1 total, 1 verified (100%)
- Status: ⚠ Partially Verified (relies on standard axiom)
- Confidence: High (standard axiom)
Generated Report:
# Verification Traceability Matrix: Sorting Module
| Spec ID | Specification | Code Component | Proof/Theorem | Status |
|---------|---------------|----------------|---------------|--------|
| SORT-001 | Permutation preservation | `sort` (sort.v:15) | `sort_permutes` (sort.v:45) | ✓ |
| SORT-002 | Output is sorted | `sort` (sort.v:15) | `sort_sorted` (sort.v:62) | ✓ |
| SORT-003 | Combined correctness | `sort` (sort.v:15) | `sort_correct` (sort.v:78) | ✓ |
| SORT-004 | Stability (equal elements) | `sort` (sort.v:15) | - | ✗ |
| SORT-005 | Time complexity O(n log n) | `sort` (sort.v:15) | - | ✗ |
## Summary
- Total Specifications: 5
- Fully Verified: 3 (60%)
- Unverified: 2 (40%)
## Verification Gaps
### SORT-004: Stability
- **Status:** ✗ Unverified
- **Reason:** Stability not formally specified or proved
- **Impact:** Cannot guarantee order of equal elements
- **Priority:** Medium
### SORT-005: Time Complexity
- **Status:** ✗ Unverified
- **Reason:** Complexity analysis not formalized
- **Impact:** Performance guarantees not verified
- **Priority:** Low (functional correctness verified)
filename.extfilename.ext:linefilename.ext:start-endGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
Automatically creates user-facing changelogs from git commits by analyzing commit history, categorizing changes, and transforming technical commits into clear, customer-friendly release notes. Turns hours of manual changelog writing into minutes of automated generation.
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
Take arabelatso/verified-spec-code-mapper from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.