refinement-step-generator — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited refinement-step-generator (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Generate systematic refinement steps that transform high-level specifications into concrete, executable implementations while preserving correctness through formal proofs.
Refinement is the process of transforming abstract specifications into concrete implementations through a series of correctness-preserving steps. Each refinement step:
This skill provides guidance for generating refinement steps in Isabelle/HOL and Coq.
Abstract Specification
↓ [Data Refinement]
Refined Data Structures
↓ [Algorithmic Refinement]
Concrete Algorithm
↓ [Implementation Refinement]
Executable CodeEach arrow represents a refinement step with proof obligations.
Transform abstract data types into concrete data structures.
Example: Set → List
Abstract (Isabelle):
definition insert_set :: "'a ⇒ 'a set ⇒ 'a set" where
"insert_set x S = S ∪ {x}"
definition member_set :: "'a ⇒ 'a set ⇒ bool" where
"member_set x S = (x ∈ S)"Concrete (Isabelle):
definition insert_list :: "'a ⇒ 'a list ⇒ 'a list" where
"insert_list x xs = (if x ∈ set xs then xs else x # xs)"
definition member_list :: "'a ⇒ 'a list ⇒ bool" where
"member_list x xs = (x ∈ set xs)"Abstraction Relation:
definition abs_list :: "'a list ⇒ 'a set" where
"abs_list xs = set xs"Proof Obligations:
lemma insert_refines:
"abs_list (insert_list x xs) = insert_set x (abs_list xs)"
by (simp add: insert_list_def insert_set_def abs_list_def)
lemma member_refines:
"member_list x xs = member_set x (abs_list xs)"
by (simp add: member_list_def member_set_def abs_list_def)Transform specifications into algorithms.
Example: Sorting Specification → Insertion Sort
Abstract (Coq):
Definition is_sorted (l : list nat) : Prop :=
forall i j, i < j < length l → nth i l 0 ≤ nth j l 0.
Definition sort_spec (input output : list nat) : Prop :=
is_sorted output ∧ Permutation input output.Concrete (Coq):
Fixpoint insert (x : nat) (l : list nat) : list nat :=
match l with
| [] => [x]
| h :: t => if x <=? h then x :: l else h :: insert x t
end.
Fixpoint insertion_sort (l : list nat) : list nat :=
match l with
| [] => []
| h :: t => insert h (insertion_sort t)
end.Proof Obligations:
Theorem insertion_sort_correct : forall l,
sort_spec l (insertion_sort l).
Proof.
(* Prove is_sorted and Permutation properties *)
Qed.Transform algorithms into efficient implementations.
Example: Naive → Optimized
Abstract:
definition naive_reverse :: "'a list ⇒ 'a list" where
"naive_reverse xs = rev xs"Concrete (tail-recursive):
fun reverse_acc :: "'a list ⇒ 'a list ⇒ 'a list" where
"reverse_acc [] acc = acc" |
"reverse_acc (x # xs) acc = reverse_acc xs (x # acc)"
definition efficient_reverse :: "'a list ⇒ 'a list" where
"efficient_reverse xs = reverse_acc xs []"Proof Obligation:
lemma efficient_reverse_correct:
"efficient_reverse xs = naive_reverse xs"
by (simp add: efficient_reverse_def naive_reverse_def reverse_acc_correct)Analyze the specification and identify what needs refinement:
Select appropriate refinement approach:
Data Refinement:
Algorithmic Refinement:
Compositional Refinement:
Establish connection between abstract and concrete levels:
Isabelle:
definition abs_rel :: "'concrete ⇒ 'abstract ⇒ bool" where
"abs_rel c a = (abs_fun c = a)"Coq:
Definition abs_rel (c : concrete) (a : abstract) : Prop :=
abs_fun c = a.For each operation, prove refinement correctness:
Forward Simulation:
If: abs_rel c a
op_concrete c = c'
Then: ∃a'. op_abstract a = a' ∧ abs_rel c' a'Backward Simulation:
If: abs_rel c a
op_abstract a = a'
Then: ∃c'. op_concrete c = c' ∧ abs_rel c' a'Use proof tactics to discharge obligations:
Isabelle:
auto, simp, blast for automationinduction for recursive structurescase_tac for case analysisCoq:
auto, simpl, reflexivity for automationinduction for recursive proofsdestruct for case analysisFor Isabelle-specific patterns and the Autoref framework, see references/isabelle_refinement.md.
Key features:
⊑ relationFor Coq-specific patterns and refinement tactics, see references/coq_refinement.md.
Key features:
For detailed refinement patterns (data structures, algorithms, optimizations), see references/refinement_patterns.md.
Common patterns include:
Abstract Specification (Isabelle):
definition find_spec :: "'a list ⇒ ('a ⇒ bool) ⇒ 'a option" where
"find_spec xs P = (if ∃x ∈ set xs. P x
then Some (SOME x. x ∈ set xs ∧ P x)
else None)"Refinement Step 1: Deterministic Algorithm
fun find_impl :: "'a list ⇒ ('a ⇒ bool) ⇒ 'a option" where
"find_impl [] P = None" |
"find_impl (x # xs) P = (if P x then Some x else find_impl xs P)"Proof Obligation:
lemma find_impl_refines:
"find_impl xs P = find_spec xs P"
proof (induction xs)
case Nil
then show ?case by (simp add: find_spec_def)
next
case (Cons x xs)
then show ?case
by (auto simp add: find_spec_def split: if_splits)
qedRefinement Step 2: Tail-Recursive Implementation
fun find_tail :: "'a list ⇒ ('a ⇒ bool) ⇒ 'a option" where
"find_tail [] P = None" |
"find_tail (x # xs) P = (if P x then Some x else find_tail xs P)"
lemma find_tail_correct:
"find_tail xs P = find_impl xs P"
by (induction xs) autoBefore finalizing refinement:
For detailed guidance on specific aspects:
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.