proof_by_contraposition

Convert implications to their contrapositive in Lean 4 proofs.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Contraposition-based proofs in Lean 4: convert implications to their contrapositive to obtain a more concrete hypothesis and complete the proof.

Core Features & Use Cases

  • Convert P → Q into ¬Q → ¬P and apply standard Lean 4 tactics (contrapose/contrapose!, push_neg) to discharge goals.
  • Works well when the negation of the conclusion yields a stronger or more usable assumption, such as in inequalities, divisibility, or connectivity arguments.
  • Provides a Lean 4 template and worked example showing a typical contrapositive proof flow.

Quick Start

Apply contraposition in Lean 4 to convert P → Q into ¬Q → ¬P and complete the proof from the negated premise.

Frequently Asked Questions about proof_by_contraposition

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

FAQPage Schema
How do I prove an implication in Lean 4 by contraposition?

Use the contrapose or contrapose! tactic in Lean 4 to convert an implication P → Q into its contrapositive ¬Q → ¬P, allowing you to prove the goal from the negated conclusion instead of the original premise.

When should I use contraposition in a Lean 4 mathlib proof?

Use contraposition in Lean 4 when the negated conclusion provides a stronger, more concrete hypothesis. It is particularly effective for simplifying proofs involving inequalities, divisibility, and graph connectivity arguments.

What is the difference between contrapose and push_neg in Lean 4?

The contrapose tactic converts an implication P → Q into its contrapositive ¬Q → ¬P, while push_neg pushes negations inward to simplify logical expressions. They are often used together to transform and normalize goals before applying standard tactics.

Does the contrapose tactic work for inequalities and divisibility proofs in Lean 4?

Yes, the contrapose tactic works for inequalities and divisibility proofs in Lean 4. Contraposition is specifically useful in these domains because negating the conclusion often produces a more concrete and directly applicable mathematical assumption.

Why is my Lean 4 contraposition tactic not working on a graph connectivity goal?

Contraposition tactics may fail if the logical structure resists automatic negation or requires manual normalization. Apply push_neg after contrapose to push negations inward and resolve nested definitions that prevent the tactic from completing the proof.