Agent skill

Formally Verify

by alexvanyo in alexvanyo/composelife

Guides formal verification of algorithms, data structures, and properties in the ComposeLife project using Lean 4 and Mathlib.

Apache-2.0Auto-check passedMobile

Install Formally Verify

skills CLI
$ npx skills add alexvanyo/composelife --skill formally-verify -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install alexvanyo/composelife formally-verify --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/alexvanyo/composelife.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/formally-verify .claude/skills/formally-verify && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
formally-verify
GitHub stars
267
Token cost
~2.5k tokens
SKILL.md length
955 words
Files
1
Skills in repo
3
Repo updated
First seen
Licence
Apache-2.0

At a glance

Guides formal verification of algorithms, data structures, and properties in the ComposeLife project using Lean 4 and Mathlib.

  • Works in 6 steps: Mathematical Specification vs Executable… → Master Theorem & Equivalence Reduction → Proving Completeness (Progress &… → …
  • Tasks that involve Android development
  • SKILL.md covers 🎯 Verification Criteria…, 🏛️ Architecture & Workflow, 📋 Step-by-Step Guide and 🔍 Verification Commands &…, plus 1 more section
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Formally Verify is an agent skill from alexvanyo/composelife. Guides formal verification of algorithms, data structures, and properties in the ComposeLife project using Lean 4 and Mathlib. Covers mathematical specification, equivalence reduction, metric-based completeness, invariant-based soundness, timeout avoidance, Lean modularization, C/Kotlin FFI bridge interop, and verification checks.

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Mobile, covering Android development. It works with Kotlin, Jetpack Compose and Android. The repository describes itself as: A Game of Life simulator Android app and watchface built with Jetpack Compose. The licence is Apache-2.0.

When your agent uses it

  • Tasks that involve Android development

Example prompts

  • “Use the formally-verify skill to guide formal verification of algorithms, data structures, and properties in the ComposeLife project using Lean 4…”
  • “/formally-verify”

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. Mathematical Specification vs Executable Model
  2. Master Theorem & Equivalence Reduction
  3. Proving Completeness (Progress & Reachability)
  4. Proving Soundness & Avoiding Timeouts
  5. Submodule Modularization & Clean File Organization
  6. C / Kotlin FFI & Differential Conformance Testing

What it can do on your machine

Read from SKILL.md and the folder at commit b2ddd2d. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are lean, mermaid and bash).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Formally Verify loads about 2.5k tokens when it runs. Until then it costs about 87 tokens; SKILL.md has 955 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~87
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from alexvanyo/composelife at commit b2ddd2d, republished under its Apache-2.0 licence (© alexvanyo). 955 words, ~2,455 tokens.

Download SKILL.mdSave it as .claude/skills/formally-verify/SKILL.md (or your agent's skills folder).
name
formally-verify
description
Guides formal verification of algorithms, data structures, and properties in the ComposeLife project using Lean 4 and Mathlib. Covers mathematical specification, equivalence reduction, metric-based completeness, invariant-based soundness, timeout avoidance, Lean modularization, C/Kotlin FFI bridge interop, and verification checks.

Formally Verify Skill

Use this skill when formally verifying an algorithm, data structure, or mathematical property in the ComposeLife codebase using Lean 4 and Mathlib.

The repository pairs Kotlin Multiplatform implementations with formal Lean 4 models, connected via C FFI bridges (and Kotlin/Native cinterop) for runtime validation and differential conformance testing.


🎯 Verification Criteria (Definition of Done)

A verification task is only complete when:

  1. The Target Theorem is Proven in its Unmodified Form: The master theorem statement matches the specification without introducing artificial preconditions or weakening the theorem's guarantees.
  2. Zero sorrys: No sorrys anywhere in tracked project files.
  3. Zero Custom Axioms: The theorem must depend strictly on the standard Lean 4 core axioms:
    lean
    [propext, Classical.choice, Quot.sound]
    No custom axiom declarations or unverified assumptions.
  4. Clean Compilation: lake build <Target>:static succeeds with 0 warnings and 0 errors.
  5. Differential & Conformance Tests Pass: All Kotlin/Native bridge tests and randomized fuzz tests pass cleanly via Gradle (./gradlew :<module>:check).

🏛️ Architecture & Workflow

Formal verification follows a 6-phase lifecycle:

mermaid
graph TD
    A["Phase 1: Mathematical Specification vs Executable Model"] --> B["Phase 2: Master Theorem & Equivalence Reduction"]
    B --> C1["Phase 3: Completeness / Reachability (Metric Progress)"]
    B --> C2["Phase 4: Soundness / Invariant Preservation (Structural Candidates)"]
    C1 --> D["Phase 5: Submodule Modularization & DAG Architecture"]
    C2 --> D
    D --> E["Phase 6: C / Kotlin FFI & Differential Testing"]
    E --> F["Phase 7: Final Audit (Axioms, Sorries, Checks)"]

📋 Step-by-Step Guide

Phase 1: Mathematical Specification vs Executable Model
  1. Define the Ground Truth Specification:
    • Model the mathematical truth declaratively (e.g. relations, set comprehension, inductive predicates, or closed-form expressions).
    • Use exact, uncompromised mathematical types (such as Nat, Int, Rat, or inductive structures) rather than lossy representations to avoid rounding errors and floating-point ambiguity.
  2. Define the Executable Algorithmic Model:
    • Model the algorithm as it executes in practice (e.g. step functions, recursors, loop iterations, or state machines).
    • Ensure the algorithmic model matches the design intended for production code in Kotlin.

Phase 2: Master Theorem & Equivalence Reduction
  1. State the Master Theorem:
    lean
    theorem algorithm_correctness (inputs : InputType) :
        algorithmExecutable inputs ↔ SpecificationPredicate inputs
  2. Prove a Reduction Lemma Early:
    • Factor out trivial edge cases (e.g. empty collections, identity inputs, degenerate bounds) into base lemmas.
    • Separate the equivalence into two independent directions:
      • Completeness (No False Negatives): Every element or state satisfying the specification is produced or reached by the algorithm.
      • Soundness (No False Positives): Every element or state produced by the algorithm satisfies the specification.

Phase 3: Proving Completeness (Progress & Reachability)
  1. Construct a Strictly Monotonic Progress Metric:
    • When an algorithm iterates or steps toward a goal state, avoid inducting directly on complex multidimensional structures.
    • Construct a non-negative progress metric $D : \text{State} \to \mathbb{N}$ that measures distance to completion or target state.
  2. Prove Abstract Reachability:
    • Prove that for every non-terminal state $s$ with $D(s) > 0$:
      • The step does not prematurely terminate.
      • The next state either achieves the goal or strictly decreases the metric: $D(\text{step}(s)) < D(s)$.
  3. Bound the Fuel / Iteration Budget:
    • Prove by well-founded induction on $D(s)$ (or natural number induction on fuel) that any initial budget $\text{fuel} \ge D(s_0)$ guarantees reaching the target state without skipping.

Phase 4: Proving Soundness & Avoiding Timeouts
  1. Formulate Inductive Invariants:
    • Define an invariant predicate $I(s)$ that holds on the initial state $s_0$ and implies the desired postcondition at termination.
    • Prove step preservation: $I(s) \implies I(\text{step}(s))$.
  2. Prevent Combinatorial State Explosion (Deterministic Timeouts):

    [!CAUTION] Never unfold recursive functions with complex nested conditionals directly inside arithmetic goals or heavy automation (simp, split_ifs, whnf). This causes exponential branch blowup and deterministic timeouts.

  3. The Structural Candidate Lemma Pattern:
    • Encapsulate the finite transition possibilities of the step function into a simple membership lemma:
      lean
      theorem step_candidates (s : State) :
          step s ∈ [candidate₁ s, candidate₂ s, ..., candidateₖ s]
    • Case split on the finite list of candidates rather than destructing internal condition trees.
  4. Domain Partitioning:
    • When conditions involve directional signs or inequalities, partition the input domain into disjoint regions where sign variables are fixed.
    • In fixed-sign subdomains, denominators do not change sign, and linear arithmetic (linarith), normalization (ring), and positivity (positivity) tactics can resolve goals in constant time without branching.

Show full SKILL.md (355 more words)Show less
Phase 5: Submodule Modularization & Clean File Organization

When a verification file exceeds 1,500–2,000 lines, split it into a clean Directed Acyclic Graph (DAG) of submodules:

  • Specification.lean / Types.lean: Domain types, predicates, and declarative specifications.
  • Step.lean / Model.lean: Executable transitions, structural candidate lemmas, and directional properties.
  • Completeness.lean: Progress metric definition, distance descent lemmas, and reachability theorems.
  • Soundness.lean: Invariant preservation across partitioned domains and soundness induction.
  • Properties.lean: High-level module importing submodules and stating the master correctness theorems.

[!IMPORTANT]

  • Ensure every .lean file begins with the Apache 2.0 license header from config/license.template.
  • Modularization enables Lake to compile submodules in parallel, cutting build times and preventing editor lockups.
  • Remove all leftover exploratory duplicate theorems (e.g. *_dup).

Phase 6: C / Kotlin FFI & Differential Conformance Testing
  1. Lossless Type Marshaling:
    • Connect the Lean model to Kotlin via C ABI bindings.
    • When converting between Kotlin primitives (e.g. IEEE-754 floats) and exact mathematical models (e.g. dyadic rationals Rat):
      • Unpack binary representations faithfully (e.g. evaluating sign, exponent, and fraction bitfields) to preserve exact numerical values.
      • Never cast raw bit patterns directly into integer values.
  2. Memory & Runtime Safety:
    • Ensure Lean runtime initialization (lean_initialize_runtime_module) is called once.
    • Correctly manage Lean reference counting (lean_dec_ref, lean_alloc_array, lean_box_*, lean_unbox_*).
  3. Differential Fuzz Testing:
    • In Kotlin tests, write randomized property-based tests running hundreds of iterations comparing Kotlin implementations against the Lean oracle:
      kotlin
      assertEquals(oracle.compute(inputs), kotlinImplementation(inputs))
  4. Gradle Native Cache Invalidation:
    • When modifying C or Lean native static libraries, rerun native test binaries with --no-build-cache --rerun-tasks to ensure the linker doesn't reuse stale executables.

🔍 Verification Commands & Audit Checklist

Execute these exact verification checks before concluding any formal verification task:

bash
# 1. Clean Lake build (must compile with 0 warnings, 0 errors)
cd <path-to-lean-module>
lake clean && lake build <Target>:static

# 2. Axioms verification (must only report [propext, Classical.choice, Quot.sound])
lake env lean --run - << 'EOF'
import <Module>.Properties
#print axioms <Module>.<MasterTheorem>
EOF

# 3. Check for any sorrys in the codebase (must return 0 results)
grep -rn "sorry" <path-to-lean-module>/

# 4. Check for any custom axioms (must return 0 results)
grep -rn "axiom" <path-to-lean-module>/

# 5. Run full Gradle checks, conformance tests, and Detekt inspections
cd <project-root>
./gradlew :<module>:check --no-build-cache

💡 Practical Proof Tactics Reference

TacticBest Used For
omegaNatural number and integer linear arithmetic, modulo arithmetic, Presburger constraints, fuel bounds.
linarithLinear real, rational, or ordered field inequalities with hypotheses.
ringRing equalities on algebraic structures (expanding polynomials, verifying common denominators).
positivityAutomatically discharging strict positivity ($> 0$), non-negativity ($\ge 0$), or non-zero ($\ne 0$) goals.
rcases / obtainDestructing existential hypotheses (∃ x, ...) and conjunctions without deeply nested indentation.
split_ifs with hSplitting conditional expressions while retaining the condition hypothesis $h$.
aesopAutomated proof search for propositional logic, set memberships, and basic structural goals.

© alexvanyo, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/formally-verify of alexvanyo/composelife.

Open the folder on GitHubat commit b2ddd2d

Compare with similar skills

Formally Verify next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Formally Verify compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Formally Verify this skillalexvanyo/composelife267—~2.5kAutomated safety check: PassApache-2.0
Compose Multiplatform Patternsmonta-app/ocpp-emulator1805 repos~2kAutomated safety check: PassApache-2.0
Android Developmentdpconde/claude-android-skill336—~1.7kAutomated safety check: PassMIT
Claude Android NinjaDrjacky/claude-android-ninja124—~5.2kAutomated safety check: PassApache-2.0
Jetpack Composedarriousliu/PiPixiv263—~1.5kAutomated safety check: PassApache-2.0
Coding Stylesk2andy/candy-browser532—~548Automated safety check: PassMPL-2.0

Similar skills

  • Compose Multiplatform Patterns

    monta-app/ocpp-emulator

    Compose Multiplatform and Jetpack Compose patterns for KMP projects — state management, navigation, theming, performance, and platform-specific UI.

    180 GitHub starsUsed in 5 repos~2k tokens
    MobileAuto-check passed
  • Android Development

    dpconde/claude-android-skill

    Create production-quality Android applications following Google's official architecture guidance and NowInAndroid best practices.

    336 GitHub stars~1.7k tokensUpdated 10 mo ago
    MobileAuto-check passed
  • Claude Android Ninja

    Drjacky/claude-android-ninja

    Build and migrate Android apps with Kotlin, Jetpack Compose, MVVM, Hilt, Room 3 (KSP, SQLiteDriver, Flow/suspend DAOs), Navigation3, and multi-module Gradle.

    124 GitHub stars~5.2k tokensUpdated 11 days ago
    MobileAuto-check passed
  • Jetpack Compose

    darriousliu/PiPixiv

    Jetpack Compose expert skill for Android UI development. An agent skill from darriousliu/PiPixiv.

    263 GitHub stars~1.5k tokensUpdated yesterday
    MobileAuto-check passed
  • Coding Style

    sk2andy/candy-browser

    Apply Candy Browser's project-specific Kotlin, Jetpack Compose, Android/WebView, testing, and generator conventions.

    532 GitHub stars~548 tokensUpdated yesterday
    MobileAuto-check passed
  • Compose Agent

    hamen/compose_skill

    Helps AI coding assistants write modern Jetpack Compose: correct state, side effects, performance-aware modifiers, Navigation 3, Paging 3 in Compose, coroutines on lifecycle, animations, UI tests…

    373 GitHub stars~4k tokensUpdated 2 mo ago
    MobileAuto-check: notes

More from alexvanyo/composelife

  • Guided PR Fixup

    alexvanyo/composelife

    Performs a guided fixup of a given GitHub PR. An agent skill from alexvanyo/composelife.

    267 GitHub stars~1k tokensUpdated today
    Auto-check passed
  • Improve Code Coverage

    alexvanyo/composelife

    Helps increment code coverage in this Kotlin Multiplatform project.

    267 GitHub stars~1.1k tokensUpdated today
    Auto-check passed

Categories

Questions about Formally Verify

What does Formally Verify do?

Guides formal verification of algorithms, data structures, and properties in the ComposeLife project using Lean 4 and Mathlib. Formally Verify is an agent skill from alexvanyo/composelife. Guides formal verification of algorithms, data structures, and properties in the ComposeLife project using Lean 4 and Mathlib.

When should I use Formally Verify?

Formally Verify fits situations like: tasks that involve Android development.

How do I install Formally Verify in Claude Code?

Run `npx skills add alexvanyo/composelife --skill formally-verify -a claude-code`. Or copy the skill folder (.agents/skills/formally-verify in alexvanyo/composelife) into .claude/skills/formally-verify in your project. Claude Code loads it when a task matches its description.

How do I install Formally Verify in Codex?

Run `npx skills add alexvanyo/composelife --skill formally-verify -a codex`. Or copy the skill folder (.agents/skills/formally-verify in alexvanyo/composelife) into .agents/skills/formally-verify in your project. Codex loads it when a task matches its description.

Can I use Formally Verify in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add alexvanyo/composelife --skill formally-verify -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/formally-verify, .gemini/skills/formally-verify, .github/skills/formally-verify and .opencode/skills/formally-verify in your project.

What does Formally Verify need to run?

SKILL.md names no scripts, command-line tools or credentials: Formally Verify is instructions for the agent only.

Does Formally Verify access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Formally Verify safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Formally Verify use?

Formally Verify is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Formally Verify use?

About 2.5k tokens (SKILL.md is roughly 9.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Formally Verify?

Skills that share tags, products or a category with Formally Verify: Compose Multiplatform Patterns (monta-app/ocpp-emulator, 180 stars), Android Development (dpconde/claude-android-skill, 336 stars), Claude Android Ninja (Drjacky/claude-android-ninja, 124 stars) and Jetpack Compose (darriousliu/PiPixiv, 263 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Formally Verify?

alexvanyo (a GitHub user) maintains it in alexvanyo/composelife, which has 267 GitHub stars. The repository holds 3 skills in this directory. The repository was last updated on October 10, 2026.

Source: alexvanyo/composelife on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.