Skip to content

refactor(Order/SuccPred): simplify toZ_mono via contrapositive#38939

Closed
pbalogh wants to merge 1 commit intoleanprover-community:masterfrom
pbalogh:refactor/toZ-mono-simplify
Closed

refactor(Order/SuccPred): simplify toZ_mono via contrapositive#38939
pbalogh wants to merge 1 commit intoleanprover-community:masterfrom
pbalogh:refactor/toZ-mono-simplify

Conversation

@pbalogh
Copy link
Copy Markdown

@pbalogh pbalogh commented May 4, 2026

Summary

Simplify toZ_mono from 46 lines to 4 by using the contrapositive of the already-proved le_of_toZ_le.

Before (46 lines)

The previous proof manually handled all four quadrants (both signs of toZ i and toZ j relative to i0) with two nearly identical 20-line blocks, each constructing explicit succ/pred iterates and deriving contradictions via IsMax/IsMin.

After (4 lines)

Since le_of_toZ_le is proved independently (and before toZ_mono in the file), toZ_mono follows immediately by contrapositive:

  • Assume ¬(toZ i0 i ≤ toZ i0 j), i.e., toZ i0 j < toZ i0 i
  • By le_of_toZ_le: j ≤ i
  • Combined with hypothesis i ≤ j: i = j
  • This contradicts the strict inequality

Context

This simplification was identified by a geometric proof analysis tool that encodes Mathlib theorems as HRR (Holographic Reduced Representation) vectors and flags complexity anomalies — proofs significantly longer than their structural neighbors. toZ_mono was flagged at 46× the namespace median proof length.


  • Builds clean against current Mathlib master
  • No new dependencies
  • Net deletion: 41 lines

…of_toZ_le

The previous proof manually handled all four quadrants (both signs of
toZ i and toZ j relative to i0) with two nearly identical 20-line
blocks. Since le_of_toZ_le is already proved independently, toZ_mono
follows immediately by contrapositive: if toZ j < toZ i, then
le_of_toZ_le gives j ≤ i, combined with i ≤ j gives i = j,
contradicting the strict inequality.

46 lines → 4 lines.
@github-actions github-actions Bot added the new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! label May 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

Welcome new contributor!

Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests.

We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the awaiting-author tag, or another reason described in the Lifecycle of a PR. The review dashboard has a dedicated webpage which shows whether your PR is on the review queue, and (if not), why.

If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR.

Thank you again for joining our community.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

PR summary 415ab74ad3

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

No declarations were harmed in the making of this PR! 🐙

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.


No changes to strong technical debt.
No changes to weak technical debt.

@github-actions github-actions Bot added the t-order Order theory label May 4, 2026
@tb65536
Copy link
Copy Markdown
Contributor

tb65536 commented May 5, 2026

Could you clarify whether you used AI for the PR summary and/or for the writing of the PR?

@pbalogh
Copy link
Copy Markdown
Author

pbalogh commented May 5, 2026

Could you clarify whether you used AI for the PR summary and/or for the writing of the PR?

I did use AI for the writing of the PR and its summary. Apologies for not knowing this was required info for a PR!

@tb65536 tb65536 added the LLM-generated PRs with substantial input from LLMs - review accordingly label May 5, 2026
@vihdzp
Copy link
Copy Markdown
Collaborator

vihdzp commented May 6, 2026

I think this PR identifies a problem, but doesn't correctly fix it. What we're missing here is the theorem that toZ is strictly monotonic; I've gone ahead and added that in #39014.

@pbalogh
Copy link
Copy Markdown
Author

pbalogh commented May 6, 2026

Ach, you're right that StrictMono toZ is the proper fix here. Our tooling identified the gap (the proof was more complex than needed given the underlying monotonicity), and your #39014 fills it correctly. Happy to close this in favor of that PR.

@pbalogh pbalogh closed this May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LLM-generated PRs with substantial input from LLMs - review accordingly new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-order Order theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants