cantors_diagonalization

Construct diagonal elements to prove non-enumerability in Lean 4.

1|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/bneb/perqed --skill cantors-diagonalization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cantors_diagonalization
Source: https://github.com/bneb/perqed/tree/main/.agents/skills/cantors_diagonalization
Command: npx skills add https://github.com/bneb/perqed --skill cantors-diagonalization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cantor's diagonalization proves that a set has strictly greater cardinality than its power set by constructing a diagonal element that differs from every element of any proposed enumeration, thereby establishing non-enumerability. The technique also generalizes to computability arguments (e.g., no Turing machine can decide the Halting problem) and other diagonal arguments in mathematics and logic. In Lean 4 / mathlib4, Cantor.not_surjective provides the abstract result; the method typically explicitly defines a diagonal function such as d : ℕ → Bool that inverts f(n)(n) at each step.

Core Features & Use Cases

  • Formal diagonal construction to refute surjectivity in Lean 4 / mathlib4 proofs.
  • Application to uncountability results, Cantor's theorem, and computability arguments (e.g., Halting problem undecidability).
  • Lean 4 templates including a concrete diagonal function d(n) = not f(n)(n) used to exhibit a counterexample.

Quick Start

Provide a surjection f : ℕ → S and request the diagonal element that differs from every f(n) at position n.

Frequently Asked Questions about cantors_diagonalization

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

FAQPage Schema
How do I prove uncountability using diagonalization in Lean 4?

Cantor's diagonalization proves a set has strictly greater cardinality than its power set by constructing a diagonal element differing from every element in any proposed enumeration, establishing non-enumerability. It explicitly defines d(n) = not f(n)(n) to exhibit a counterexample.

How do I refute surjectivity in a mathlib4 theorem-proving proof?

Cantor's diagonalization applies to computability arguments such as Halting problem undecidability by constructing a diagonal element that differs from every f(n) in the n-th position. It generalizes from set-theoretic uncountability to refute Turing machine decidability.

Does this diagonalization method work with Lean 4 and mathlib4 templates?

To start a Cantor-style proof, provide a surjection f : ℕ → S and request the diagonal element that differs from every f(n) at position n. The method uses d(n) = not f(n)(n) to construct this counterexample directly.

What's the best way to construct a diagonal counterexample for non-enumerability proofs?

The best way to construct a diagonal counterexample is to define d(n) = not f(n)(n), ensuring the diagonal element differs from every f(n) at index n. This directly refutes enumerability by exhibiting an element outside the proposed surjection's range.