lean-roundtrip-proofs

Formalizes Lean 4 proofs for encode/decode roundtrip theorems and padding extraction.

112|9|Updated Feb 17, 2026
One-click install
npx skills add https://github.com/kim-em/lean-zip --skill lean-roundtrip-proofs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lean-roundtrip-proofs
Source: https://github.com/kim-em/lean-zip/tree/main/.claude/skills/lean-roundtrip-proofs
Command: npx skills add https://github.com/kim-em/lean-zip --skill lean-roundtrip-proofs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a structured approach and reusable patterns for proving the correctness of encoding and decoding functions in Lean 4, specifically focusing on roundtrip theorems where encoding followed by decoding returns the original data.

Core Features & Use Cases

  • Suffix Invariance: Prove that extra bits appended to input do not affect decoding.
  • Decode-With-Remaining: Analyze what bits are left after decoding, crucial for padding and framing.
  • Padding Extraction: Demonstrate that encoded data is byte-aligned with less than 8 padding bits.
  • Composing Proofs: Combine per-level proofs into a unified, top-level roundtrip theorem.
  • Iterative Equivalence: Prove that iterative and recursive implementations are equivalent.

Quick Start

Use the lean-roundtrip-proofs skill to generate suffix invariance lemmas for a given decoder function.

Frequently Asked Questions about lean-roundtrip-proofs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prove encode/decode roundtrip theorems in Lean 4?

To prove encode/decode roundtrip theorems in Lean 4, you compose per-level proofs into a unified top-level theorem using structured patterns. This verifies that encoding followed by decoding returns the original data.

How do I prove suffix invariance for a decoder function in Lean 4?

You prove suffix invariance in Lean 4 by demonstrating that extra bits appended to the input do not affect the decoding logic. This ensures the decoder ignores trailing data during serialization.

What is the best way to extract padding bits during data serialization in Lean 4?

The best way to extract padding bits in Lean 4 is through a decode-with-remaining analysis. This demonstrates that encoded data is byte-aligned with less than 8 padding bits left after decoding.

Can I use Lean 4 to prove that iterative and recursive decoding implementations are equivalent?

Yes, you can use Lean 4 to prove iterative equivalence by formalizing iterative and recursive implementations. This verifies that both approaches produce identical decoding results.

Do I need to understand monadic structures to formalize data compression proofs in Lean 4?

Yes, formalizing data compression proofs in Lean 4 requires understanding of proof calculus and monadic structures. This knowledge is necessary for rigorous verification of complex serialization scenarios.