refactor(Order/SuccPred): simplify toZ_mono via contrapositive#38939
refactor(Order/SuccPred): simplify toZ_mono via contrapositive#38939pbalogh wants to merge 1 commit intoleanprover-community:masterfrom
Conversation
…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.
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 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. |
PR summary 415ab74ad3Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
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! |
|
I think this PR identifies a problem, but doesn't correctly fix it. What we're missing here is the theorem that |
|
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. |
Summary
Simplify
toZ_monofrom 46 lines to 4 by using the contrapositive of the already-provedle_of_toZ_le.Before (46 lines)
The previous proof manually handled all four quadrants (both signs of
toZ iandtoZ jrelative toi0) with two nearly identical 20-line blocks, each constructing explicitsucc/prediterates and deriving contradictions viaIsMax/IsMin.After (4 lines)
Since
le_of_toZ_leis proved independently (and beforetoZ_monoin the file),toZ_monofollows immediately by contrapositive:¬(toZ i0 i ≤ toZ i0 j), i.e.,toZ i0 j < toZ i0 ile_of_toZ_le:j ≤ ii ≤ j:i = jContext
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_monowas flagged at 46× the namespace median proof length.