视觉画布设计
canvas-design
基于设计原则创作静态视觉作品,用于海报与品牌图形。
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 lan…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
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