Compfiles/Usa2018P4.lean
Explanation legend Lean4 Domain Explanation Language (L4DEL)
L4DEL explanations are a separate layer. They do not change the Lean source. Intuition is explanatory prose; numbered items are a reading path; sources link the wording back to evidence.
- L4DEL
- Lean4 Domain Explanation Language
Credit: The upstream authors and contributors retain credit for the project and mathematics. lean4-explainer only renders their pinned source and adds the separately disclosed explanation layer.
Project sources: Pinned compfiles documentation, Pinned compfiles corpus index
14 declarations, 0 contain sorry, 0 declared as axioms
USA Mathematical Olympiad 2018, Problem 4
Let p be a prime, and let a₁, ..., aₚ be integers. Show that there exists an integer k such that the numbers
a₁ + k, a₂ + 2k, ..., aₚ + pk
produce at least ½p distinct remainders upon division by p.
Imports (7)
Imported by 1 file
- lemma
Usa2018P4.card_filter_ne_productThe number of ordered pairs of distinct elements of a finset, in additive form line 55 sourceSource documentation
The number of ordered pairs of distinct elements of a finset, in additive form.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
DecidableEq,Finset,Eq,Nat,HAdd.hAdd,Finset.card,Prod,Finset.filter,Ne,Prod.fst,Prod.snd,SProd.sprod,HMul.hMulProof uses:
SDiff.sdiff,Finset.diag,Finset.ext,Iff,Membership.mem,Eq.mpr,Prod.mk,And,Not,id,congr,congrArg,Eq.trans,congrFun',Iff.intro,And.intro,And.right,LE.le,Iff.mpr,Finset.mem_productand 8 more25 instances, coercions and auxiliary constants left out.
Tactic trace: 18 steps
Open to load the checked before-and-after goal states.
lemma card_filter_ne_product {α : Type*} [DecidableEq α] (s : Finset α) : ((s ×ˢ s).filter (fun ij : α × α ↦ ij.1 ≠ ij.2)).card + s.card = s.card * s.card := by … - def
Usa2018P4.fThe valuesaᵢ + ik(computed inZMod p) produced by the shiftkline 77 sourceSource documentation
The values
aᵢ + ik(computed inZMod p) produced by the shiftk.standard axioms: Quot.sound, propext what this means
Statement uses:
Nat,Fin,ZModProof uses:
HAdd.hAdd,HMul.hMul14 instances, coercions and auxiliary constants left out.
def f (k : ZMod p) (i : Fin p) : ZMod p := a i + ((i : ℕ) : ZMod p) * k
- def
Usa2018P4.phiThe unique residuekmodpfor which the pair(i, j)collides (this is well-defined wheni ≠ jandpis prime) line 81 sourceSource documentation
The unique residue
kmodpfor which the pair(i, j)collides (this is well-defined wheni ≠ jandpis prime).standard axioms: Quot.sound, propext what this means
Statement uses:
Nat,Fin,ZMod,ProdProof uses:
HMul.hMul,HSub.hSub,Prod.fst,Prod.snd,Inv.inv17 instances, coercions and auxiliary constants left out.
def phi (ij : Fin p × Fin p) : ZMod p := …
- def
Usa2018P4.FOrdered pairs of distinct indices whose values collide for the shiftkline 85 sourceSource documentation
Ordered pairs of distinct indices whose values collide for the shift
k.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,ZMod,Finset,ProdProof uses:
Finset.filter,And,Ne,Prod.fst,Prod.snd,Eq, Usa2018P4.f,Finset.univ6 instances, coercions and auxiliary constants left out.
def F (k : ZMod p) : Finset (Fin p × Fin p) := …
- def
Usa2018P4.SAll ordered pairs of distinct indices line 89 sourceSource documentation
All ordered pairs of distinct indices.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Finset,Prod,FinProof uses:
Finset.filter,Ne,Prod.fst,Prod.snd,Eq,Finset.univ4 instances, coercions and auxiliary constants left out.
def S : Finset (Fin p × Fin p) := Finset.univ.filter (fun ij ↦ ij.1 ≠ ij.2)
- def
Usa2018P4.imThe set of values attained by the shiftkline 92 sourceSource documentation
The set of values attained by the shift
k.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,ZMod,FinsetProof uses:
Finset.image, Usa2018P4.f,Finset.univ2 instances, coercions and auxiliary constants left out.
def im (k : ZMod p) : Finset (ZMod p) := Finset.univ.image (f a k)
Mentions: Usa2018P4.f
- def
Usa2018P4.fibThe fiber overvof the value map of the shiftkline 95 sourceSource documentation
The fiber over
vof the value map of the shiftk.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,ZMod,FinsetProof uses:
Finset.filter,Eq, Usa2018P4.f,Finset.univ2 instances, coercions and auxiliary constants left out.
def fib (k : ZMod p) (v : ZMod p) : Finset (Fin p) := …
- lemma
Usa2018P4.cast_ne_of_neline 98 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Ne,ZModProof uses:
Eq,Fin.ext,Nat.ModEq.eq_of_lt_of_lt,Eq.mp,Nat.ModEq,congrArg,propext,ZMod.natCast_eq_natCast_iff,Fin.is_lt14 instances, coercions and auxiliary constants left out.
Tactic trace: 3 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2018P4.f_eq_iff_phi_eqThe pair(i, j)collides for the shiftkiffk = phi a (i, j)line 105 sourceSource documentation
The pair
(i, j)collides for the shiftkiffk = phi a (i, j).standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,ZMod,Nat.Prime,Ne,Iff,Eq, Usa2018P4.f, Usa2018P4.phi,Prod.mkProof uses:
Fact,Fact.mk,HSub.hSub,OfNat.ofNat,Iff.mpr,sub_ne_zero, Usa2018P4.cast_ne_of_ne,Ne.symm,id,Iff.intro,HAdd.hAdd,HMul.hMul,Inv.inv,Mathlib.Tactic.LinearCombination.eq_of_eq,Mathlib.Tactic.LinearCombination.eq_rearrange,Mathlib.Tactic.Ring.of_eq,Mathlib.Tactic.Ring.Common.sub_congr,HPow.hPow,Nat.rawCast,Mathlib.Tactic.Ring.Common.add_congrand 46 more49 instances, coercions and auxiliary constants left out.
Tactic trace: 15 steps
Open to load the checked before-and-after goal states.
lemma f_eq_iff_phi_eq (hp : p.Prime) (k : ZMod p) {i j : Fin p} (hij : i ≠ j) : f a k i = f a k j ↔ phi a (i, j) = k := by …Mentions: Usa2018P4.f, Usa2018P4.phi
- lemma
Usa2018P4.card_S_addThere arep * (p - 1)ordered pairs of distinct indices (additive form) line 126 sourceSource documentation
There are
p * (p - 1)ordered pairs of distinct indices (additive form).standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq,HAdd.hAdd,Finset.card,Prod,Fin, Usa2018P4.S,HMul.hMulProof uses:
Finset.filter,Ne,Prod.fst,Prod.snd,SProd.sprod,Finset,Finset.univ, Usa2018P4.card_filter_ne_product,Eq.mp,Fintype.card,congrArg,Fintype.card_fin,Finset.card_univ,Finset.univ_product_univ13 instances, coercions and auxiliary constants left out.
Tactic trace: 3 steps
Open to load the checked before-and-after goal states.
lemma card_S_add : (S : Finset (Fin p × Fin p)).card + p = p * p := by …
Mentions: Usa2018P4.S
- lemma
Usa2018P4.sum_card_F_addEvery ordered pair collides for exactly one shiftk, hence the collision counts over all shifts sum to the number of ordered pairs line 133 sourceSource documentation
Every ordered pair collides for exactly one shift
k, hence the collision counts over all shifts sum to the number of ordered pairs.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,ZMod,NeZero,Nat.Prime,Eq,HAdd.hAdd,Finset.sum,Finset.univ,Finset.card,Prod, Usa2018P4.F,HMul.hMulProof uses:
Finset,Finset.filter, Usa2018P4.phi, Usa2018P4.S,Finset.ext,Iff,Membership.mem,Eq.mpr,Prod.mk,And,Ne, Usa2018P4.f,id,congr,congrArg,Eq.trans,Prod.fst,Prod.snd,True,congrFun'and 14 more31 instances, coercions and auxiliary constants left out.
Tactic trace: 14 steps
Open to load the checked before-and-after goal states.
lemma sum_card_F_add [NeZero p] (hp : p.Prime) : (∑ k : ZMod p, (F a k).card) + p = p * p := by …Mentions: Usa2018P4.F
- lemma
Usa2018P4.exists_F_card_ltPigeonhole: some shiftkhas fewer thanpcolliding ordered pairs line 157 sourceSource documentation
Pigeonhole: some shift
khas fewer thanpcolliding ordered pairs.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,ZMod,Nat.Prime,Exists,LT.lt,Finset.card,Prod, Usa2018P4.FProof uses:
NeZero,NeZero.mk,LT.lt.ne',OfNat.ofNat,Nat.Prime.pos,Decidable.byContradiction,Not,LE.le,HMul.hMul,Finset.sum,Finset.univ,Finset.sum_le_sum,Membership.mem,Finset,Eq.mp,Eq.trans,binderNameHint,forall_congr,HSMul.hSMul,congrArgand 8 more32 instances, coercions and auxiliary constants left out.
Tactic trace: 10 steps
Open to load the checked before-and-after goal states.
lemma exists_F_card_lt (hp : p.Prime) : ∃ k : ZMod p, (F a k).card < p := by …
Mentions: Usa2018P4.F
- lemma
Usa2018P4.two_mul_le_card_F_addDocumented declaration: two_mul_le_card_F_add line 173 sourceSource documentation
If
Ndistinct values are attained andCordered pairs collide, then2 * p ≤ C + 2 * N: writingnᵥ ≥ 1for the fiber sizes we havep = Σ nᵥ,N = Σ 1andC = Σ nᵥ (nᵥ - 1), andn * (n - 1) + 2 ≥ 2 * nforn ≥ 1.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,ZMod,LE.le,HMul.hMul,OfNat.ofNat,HAdd.hAdd,Finset.card,Prod, Usa2018P4.F, Usa2018P4.imProof uses:
Eq,Finset.sum, Usa2018P4.fib,Finset.univ,Finset.filter, Usa2018P4.f,Finset.card_eq_sum_card_fiberwise,Membership.mem,Set,Finset,Finset.mem_image_of_mem,Finset.mem_univ,Eq.mp,Fintype.card,congrArg,Fintype.card_fin,Finset.card_univ,Prod.fst,Ne,Prod.sndand 64 more67 instances, coercions and auxiliary constants left out.
Tactic trace: 44 steps
Open to load the checked before-and-after goal states.
lemma two_mul_le_card_F_add (k : ZMod p) : 2 * p ≤ (F a k).card + 2 * (im a k).card := by …Mentions: Usa2018P4.F, Usa2018P4.im
- problem
Usa2018P4.usa2018_p4Documented declaration: usa2018_p4 line 229 sourceSource documentation
We index by
Fin pinstead of{1, ..., p}(the mapi ↦ i mod pis a bijection{1, ..., p} ≃ Fin psendingp ↦ 0, andp * k ≡ 0 (mod p), so the families of remainders coincide), we work directly with remainders inZMod p, and the conclusionp ≤ 2 * Nis the integral form of "N ≥ p / 2distinct remainders".standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Nat.Prime,Fin,Int,Exists,LE.le,HMul.hMul,OfNat.ofNat,Finset.card,ZMod,Finset.image,HAdd.hAdd,Finset.univProof uses:
LT.lt,Prod, Usa2018P4.F, Usa2018P4.exists_F_card_lt, Usa2018P4.im, Usa2018P4.two_mul_le_card_F_add,Exists.intro,ZMod.cast,Eq.mpr,id,Eq,congrArg,ZMod.intCast_zmod_cast47 instances, coercions and auxiliary constants left out.
Tactic trace: 7 steps
Open to load the checked before-and-after goal states.
problem usa2018_p4 (p : ℕ) (hp : p.Prime) (a : Fin p → ℤ) : ∃ k : ℤ, p ≤ 2 * (Finset.univ.image fun i : Fin p ↦ (a i : ZMod p) + ((i : ℕ) : ZMod p) * (k : ZMod p)).card := by …