Generate formal specifications (definitions, predicates, invariants, pre/post-conditions) in Isabelle/HOL or Coq from informal requirements, source code, pseudocode, or mathematical descriptions. Use when users need to: (1) Formalize algorithms or data structures, (2) Create function specifications with contracts, (3) Generate predicates and properties for verification, (4) Translate informal requirements into formal logic, (5) Specify invariants for loops or data structures, or (6) Create formal definitions for mathematical concepts. Supports both Isabelle/HOL and Coq equally.
5k tokens
context cost
the whole folder, loaded on every use
4
files
instructions only
0
copies elsewhere
how many repositories repackaged it
141
stars on the repo
on the repository, not the skill itself
Install
one command, takes just this skill from the repository
Generate formal specifications in Isabelle/HOL or Coq from informal descriptions, source code, or mathematical statements.
Workflow
1. Understand the Input
Identify what type of input is provided:
Informal requirements: Natural language descriptions (e.g., "a function that sorts a list")
Source code: Existing implementations in Python, C, Java, or other languages
Pseudocode: Algorithmic descriptions with semi-formal structure
Mathematical definitions: Properties or theorems to formalize
2. Choose Target System
Ask the user which formal proof assistant to target:
Isabelle/HOL: Preferred for higher-order logic, functional programming style
Coq: Preferred for constructive logic, dependent types, proof automation
Both: Generate specifications in both systems when requested
If not specified, default to generating both versions.
3. Identify Specification Components
Determine what needs to be formalized:
Function definitions: Type signatures and implementations
Data types: Algebraic data types, records, or inductive types
Predicates: Properties and logical relationships
Pre/post-conditions: Function contracts and correctness specifications
Invariants: Loop invariants or data structure invariants
4. Generate Formal Specifications
Use the reference files for syntax and patterns:
Isabelle patterns: See isabelle_patterns.md
Coq patterns: See coq_patterns.md
Complete examples: See examples.md
Generate specifications that include:
Type definitions for data structures
Function definitions with proper types
Predicates describing properties
Correctness specifications relating inputs to outputs
Theorem statements (proofs can be left as sorry in Isabelle or Admitted in Coq)
5. Structure the Output
Organize the generated specifications clearly:
For Isabelle/HOL:
theory TheoryName
imports Main
begin
(* Data type definitions *)
datatype ...
(* Function definitions *)
fun function_name :: "types" where
...
(* Predicates and properties *)
definition property_name :: "type" where
...
(* Correctness specifications *)
theorem theorem_name:
"specification"
sorry
end
For Coq:
Require Import List Arith.
Import ListNotations.
(* Data type definitions *)
Inductive ...
(* Function definitions *)
Fixpoint function_name ... :=
...
(* Predicates and properties *)
Definition property_name ... : Prop :=
...
(* Correctness theorems *)
Theorem theorem_name :
specification.
Proof.
Admitted.
Key Principles
Completeness
Include all necessary type definitions
Specify both preconditions and postconditions
Define helper predicates when needed
State correctness theorems even if proofs are omitted
Clarity
Use descriptive names for functions and predicates