Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Parity alignment after at most one interchange of the right-hand entries

Proved
EqualTwoSquares.parity_alignment

by Yuxuan Xu · Sep 26, 2026 · Mathlib 0df444a (Lean v4.33.1)

number-theoryparity

Let a, b, c and d be integers with a^2 + b^2 = c^2 + d^2. Then either a - c and b - d are both even, or a - d and b - c are both even. Equivalently, either a agrees with c modulo 2 and b agrees with d modulo 2, or the same holds after c and d are interchanged.

Preamble
import Mathlib
Formal statement
namespace EqualTwoSquares

/-- Objective 4, parity: after possibly swapping c and d, matching entries have equal parity. -/
theorem parity_alignment {a b c d : ℤ} (h : a^2 + b^2 = c^2 + d^2) :
    (Even (a - c) ∧ Even (b - d)) ∨ (Even (a - d) ∧ Even (b - c)) := by sorry

end EqualTwoSquares
Source
Mission target; no machine-checked proof yet.
Read-back

What the Lean code literally says, in plain math · independent-agent

Read-back: parity_alignment

Declared in namespace EqualTwoSquares (file items/parity_alignment.lean); the name agrees with the file name. Its own doc line reads "Objective 4, parity: after possibly swapping c and d, matching entries have equal parity."

What the declaration literally says

Let a,b,c,d∈Za, b, c, d \in \mathbb{Z}a,b,c,d∈Z satisfy the single hypothesis

a2+b2  =  c2+d2.a^2 + b^2 \;=\; c^2 + d^2 .a2+b2=c2+d2.

Then at least one of the following two alternatives holds:

  1. a−ca - ca−c is even and b−db - db−d is even; or
  2. a−da - da−d is even and b−cb - cb−c is even.

Here "even" means divisible by 222 inside Z\mathbb{Z}Z, i.e. the difference is 2k2k2k for some integer kkk; this is symmetric in sign, so it is the same as saying that the two entries have the same parity. The disjunction is inclusive. Note carefully which pairings occur: the first branch pairs aaa with ccc and bbb with ddd (the pairing given by the order of the two sides of the equation (a,b)∣(c,d)(a,b) \mid (c,d)(a,b)∣(c,d)), and the second branch pairs aaa with ddd and bbb with ccc (the pairing obtained after swapping the roles of ccc and ddd), matching the doc line. Nothing is assumed about the entries: they may be zero, negative, or coincide, and no coprimality or non-degeneracy is required.

Cases covered silently: a=b=c=d=0a=b=c=d=0a=b=c=d=0; all entries odd; all entries even; and mixed cases where exactly one entry on each side is odd — including the genuinely mixed sub-case a,b,c,d≡1,0,0,1(mod2)a, b, c, d \equiv 1, 0, 0, 1 \pmod 2a,b,c,d≡1,0,0,1(mod2) (e.g. a=1,b=8,c=4,d=7a=1, b=8, c=4, d=7a=1,b=8,c=4,d=7: 12+82=65=42+721^2+8^2 = 65 = 4^2+7^212+82=65=42+72), where the first alternative fails (a−c=−3a-c = -3a−c=−3 and b−d=1b-d = 1b−d=1 are odd) and the conclusion survives only through the second alternative (a−d=−6a-d = -6a−d=−6 and b−c=4b-c = 4b−c=4 are even). So neither disjunct alone is implied by the hypothesis, and the disjunction is genuinely needed.

Audit notes

  • Truth. TRUE. Proof of the (mod 444) content: a square is ≡0(mod4)\equiv 0 \pmod 4≡0(mod4) when its base is even and ≡1(mod4)\equiv 1 \pmod 4≡1(mod4) when odd; hence, writing AAA for the number of odd entries among {a,b}\{a,b\}{a,b} and CCC for the number of odd entries among {c,d}\{c,d\}{c,d}, the hypothesis gives A≡C(mod4)A \equiv C \pmod 4A≡C(mod4). Since A,C∈{0,1,2}A, C \in \{0,1,2\}A,C∈{0,1,2}, this forces A=CA = CA=C. If A=C∈{0,2}A = C \in \{0,2\}A=C∈{0,2} then a,b,c,da,b,c,da,b,c,d are all even or all odd, so a−ca - ca−c and b−db - db−d are even (branch 1). If A=C=1A = C = 1A=C=1: when the odd entry on the left and the odd entry on the right occupy corresponding positions (aaa odd and ccc odd, or bbb odd and ddd odd) branch 1 again gives even differences; when they occupy crossed positions (aaa odd, ddd odd, b,cb,cb,c even, or bbb odd, ccc odd, a,da,da,d even) then a−da-da−d and b−cb-cb−c are even, i.e. branch 2. Note that the naive mod-222 argument would be insufficient (it only gives that a−ca-ca−c and b−db-db−d have equal parity); the count of odd entries, obtained from the stronger mod-444 information, is what makes the statement true — and, indeed, the case analysis above shows no counterexample can hide in the "both differences odd" corner, because then the cross differences are automatically even. Exhaustive verification: all quadruples with a,b,c,d∈[−24,24]a,b,c,d \in [-24,24]a,b,c,d∈[−24,24] satisfying the hypothesis (checked side by side with the conclusion) produce zero failures. An additional random/high-value search for entries beyond that box likewise produced none. No counterexample.
  • Faithfulness. Name matches file name. The doc line "after possibly swapping ccc and ddd, matching entries have equal parity" corresponds exactly to the two-branch structure with the two pairings (a,c),(b,d)(a,c),(b,d)(a,c),(b,d) and (a,d),(b,c)(a,d),(b,c)(a,d),(b,c). All four variables are implicit arguments bound by the statement, all appear in the hypothesis, and all appear in the conclusion; nothing is free.
  • Trivializing premise. None: a2+b2=c2+d2a^2+b^2 = c^2+d^2a2+b2=c2+d2 is the object of study, not a restatement of the parity conclusion, and it is neither contradictory nor strong enough to make the conclusion vacuous. Interesting instances are plentiful (see (1,8,4,7)(1,8,4,7)(1,8,4,7) above, where only one branch survives).
  • Satisfiability. Satisfiable, non-vacuously and with rich instances: (0,0,0,0)(0,0,0,0)(0,0,0,0), (3,4,5,0)(3,4,5,0)(3,4,5,0), (1,8,4,7)(1,8,4,7)(1,8,4,7), and every member of the explicit family (1,n2−n+1,2n−1,n2−n−1)(1, n^2-n+1, 2n-1, n^2-n-1)(1,n2−n+1,2n−1,n2−n−1). Infinitely many witnesses.
  • Elaboration. Included in statements/All.lean; elaborates with only the expected declaration uses 'sorry' warning.

FAITHFUL

Human review
  • Endorsed by Shuze Chen · Sep 26, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Yuxuan Xu · Sep 26, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me