arabelatso/verified-pseudocode-extractor
Extract language-agnostic pseudocode from formally verified programs (Isabelle/HOL, Coq) while preserving verified control flow, data dependencies, and algorithmic logic. Use when: (1) Users have verified code and need readable pseudocode, (2) Documenting verified algorithms for broader audiences, (3) Translating verified implementations to other languages, (4) Creating algorithm specifications from verified code, (5) Preserving verification guarantees in pseudocode form, or (6) Abstracting proof-heavy code to essential logic. Maintains semantic faithfulness to verified implementation.
npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill verified-pseudocode-extractor
Extract language-agnostic pseudocode from formally verified programs while preserving verified properties and algorithmic structure.
Scan the input code for:
fun, Fixpoint, Definitionlemma, theorem, Theorem, Lemmaassumes/shows, preconditions/postconditionsFor each verified function:
Preserve:
Remove:
by simp, auto, lia, Proof...Qed)# vs ::, @ vs ++)Identify and mark:
Preconditions:
PRECONDITION: condition [VERIFIED: lemma_name]
Postconditions:
POSTCONDITION: property [VERIFIED: theorem_name]
Invariants:
INVARIANT: property [VERIFIED]
Termination:
TERMINATION: argument [VERIFIED: termination_proof]
Unverified components:
[ASSUMED: assumption]
[UNVERIFIED: property]
Use clear, structured format:
ALGORITHM: Name
VERIFIED IN: System (theory/module name)
FUNCTION name(params: Types) -> ReturnType
DESCRIPTION: Brief description
PRECONDITION: conditions [VERIFIED: source]
POSTCONDITION: guarantees [VERIFIED: source]
[Algorithm body in structured pseudocode]
TERMINATION: argument [VERIFIED]
INVARIANT: properties [VERIFIED]
VERIFIED PROPERTIES:
1. Property 1 [VERIFIED: theorem]
2. Property 2 [VERIFIED: lemma]
Check that pseudocode:
From (Isabelle):
case xs of [] ⇒ base | (x # xs) ⇒ recursive
From (Coq):
match l with | [] => base | x :: xs => recursive end
To (Pseudocode):
MATCH list WITH
CASE []: base
CASE x :: xs: recursive
From:
fun f :: "nat ⇒ nat" where
"f 0 = 0" |
"f (Suc n) = f n + 1"
To:
FUNCTION f(n: Nat) -> Nat
IF n = 0 THEN
RETURN 0
ELSE
RETURN f(n - 1) + 1
[VERIFIED: terminates (decreasing n)]
From (Isabelle):
lemma function_correct:
assumes "precondition x"
shows "postcondition (function x)"
To:
FUNCTION function(x: Type) -> Type
PRECONDITION: precondition(x) [VERIFIED: function_correct]
POSTCONDITION: postcondition(result) [VERIFIED: function_correct]
From (Coq):
Definition safe_head (l : list A) (H : l <> []) : A
To:
FUNCTION safe_head(l: List<A>) -> A
PRECONDITION: l ≠ [] [VERIFIED: type system]
Mark with [VERIFIED] or [VERIFIED: source]:
PRECONDITION: is_sorted(list) [VERIFIED: sort_correct theorem]
POSTCONDITION: result ≤ all elements [VERIFIED: max_correct lemma]
TERMINATION: list size decreases [VERIFIED: structural recursion]
Mark clearly:
[ASSUMED: input is well-formed]
[UNVERIFIED: time complexity O(n log n)]
[UNVERIFIED: space complexity]
Be specific:
[VERIFIED: correctness]
[UNVERIFIED: termination]
Mark when preconditions make cases impossible:
CASE []:
UNREACHABLE [precondition ensures list is non-empty]
✓ Function names and signatures
✓ Control flow structure
✓ Data dependencies
✓ Algorithmic steps
✓ Verified properties
✓ Preconditions and postconditions
✓ Loop invariants
✓ Termination arguments
✗ Proof tactics and commands
✗ Proof scripts (proof...qed, Proof...Qed)
✗ Type class constraints (unless essential)
✗ Proof-only helper lemmas
✗ Language-specific syntax sugar
✗ Module system details
✗ Proof annotations
✗ Type inference hints
? Type annotations: Keep if essential for understanding
? Helper functions: Keep if used in algorithm, remove if proof-only
? Definitions: Keep if part of algorithm, remove if proof infrastructure
Use structured, readable format:
ALGORITHM: [Name]
VERIFIED IN: [System] ([Module/Theory])
═══════════════════════════════════════════════════════════
FUNCTION name(params: Types) -> ReturnType
DESCRIPTION: [Brief description]
PRECONDITION: [conditions] [VERIFIED: source]
POSTCONDITION: [guarantees] [VERIFIED: source]
[Pseudocode body with clear structure]
TERMINATION: [argument] [VERIFIED]
INVARIANT: [properties] [VERIFIED]
═══════════════════════════════════════════════════════════
VERIFIED PROPERTIES:
1. [Property] [VERIFIED: theorem]
2. [Property] [VERIFIED: lemma]
...
Before finalizing pseudocode:
For complete extraction examples including:
See examples.md
For detailed extraction patterns and rules:
See extraction_patterns.md
Take arabelatso/verified-pseudocode-extractor 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.