Compfiles/Usa2018P4.lean

GitHub source file

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
  1. lemma Usa2018P4.card_filter_ne_product The number of ordered pairs of distinct elements of a finset, in additive form line 55 source

    Source 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.hMul

    Proof 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_product and 8 more

    25 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
    …
  2. def Usa2018P4.f The values aᵢ + ik (computed in ZMod p) produced by the shift k line 77 source

    Source documentation

    The values aᵢ + ik (computed in ZMod p) produced by the shift k.

    standard axioms: Quot.sound, propext what this means

    Statement uses: Nat, Fin, ZMod

    Proof uses: HAdd.hAdd, HMul.hMul

    14 instances, coercions and auxiliary constants left out.

    def f (k : ZMod p) (i : Fin p) : ZMod p := a i + ((i : ℕ) : ZMod p) * k
  3. def Usa2018P4.phi The unique residue k mod p for which the pair (i, j) collides (this is well-defined when i ≠ j and p is prime) line 81 source

    Source documentation

    The unique residue k mod p for which the pair (i, j) collides (this is well-defined when i ≠ j and p is prime).

    standard axioms: Quot.sound, propext what this means

    Statement uses: Nat, Fin, ZMod, Prod

    Proof uses: HMul.hMul, HSub.hSub, Prod.fst, Prod.snd, Inv.inv

    17 instances, coercions and auxiliary constants left out.

    def phi (ij : Fin p × Fin p) : ZMod p :=
    …
  4. def Usa2018P4.F Ordered pairs of distinct indices whose values collide for the shift k line 85 source

    Source 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, Prod

    Proof uses: Finset.filter, And, Ne, Prod.fst, Prod.snd, Eq, Usa2018P4.f, Finset.univ

    6 instances, coercions and auxiliary constants left out.

    def F (k : ZMod p) : Finset (Fin p × Fin p) :=
    …
  5. def Usa2018P4.S All ordered pairs of distinct indices line 89 source

    Source documentation

    All ordered pairs of distinct indices.

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: Nat, Finset, Prod, Fin

    Proof uses: Finset.filter, Ne, Prod.fst, Prod.snd, Eq, Finset.univ

    4 instances, coercions and auxiliary constants left out.

    def S : Finset (Fin p × Fin p) := Finset.univ.filter (fun ij ↦ ij.1 ≠ ij.2)
  6. def Usa2018P4.im The set of values attained by the shift k line 92 source

    Source 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, Finset

    Proof uses: Finset.image, Usa2018P4.f, Finset.univ

    2 instances, coercions and auxiliary constants left out.

    def im (k : ZMod p) : Finset (ZMod p) := Finset.univ.image (f a k)

    Mentions: Usa2018P4.f

  7. def Usa2018P4.fib The fiber over v of the value map of the shift k line 95 source

    Source documentation

    The fiber over v of the value map of the shift k.

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: Nat, Fin, ZMod, Finset

    Proof uses: Finset.filter, Eq, Usa2018P4.f, Finset.univ

    2 instances, coercions and auxiliary constants left out.

    def fib (k : ZMod p) (v : ZMod p) : Finset (Fin p) :=
    …
  8. lemma Usa2018P4.cast_ne_of_ne line 98 source

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: Nat, Fin, Ne, ZMod

    Proof uses: Eq, Fin.ext, Nat.ModEq.eq_of_lt_of_lt, Eq.mp, Nat.ModEq, congrArg, propext, ZMod.natCast_eq_natCast_iff, Fin.is_lt

    14 instances, coercions and auxiliary constants left out.

    Tactic trace: 3 steps

    Open to load the checked before-and-after goal states.

  9. lemma Usa2018P4.f_eq_iff_phi_eq The pair (i, j) collides for the shift k iff k = phi a (i, j) line 105 source

    Source documentation

    The pair (i, j) collides for the shift k iff k = 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.mk

    Proof 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_congr and 46 more

    49 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

  10. lemma Usa2018P4.card_S_add There are p * (p - 1) ordered pairs of distinct indices (additive form) line 126 source

    Source 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.hMul

    Proof 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_univ

    13 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

  11. lemma Usa2018P4.sum_card_F_add Every ordered pair collides for exactly one shift k, hence the collision counts over all shifts sum to the number of ordered pairs line 133 source

    Source 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.hMul

    Proof 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 more

    31 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

  12. lemma Usa2018P4.exists_F_card_lt Pigeonhole: some shift k has fewer than p colliding ordered pairs line 157 source

    Source documentation

    Pigeonhole: some shift k has fewer than p colliding 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.F

    Proof 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, congrArg and 8 more

    32 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

  13. lemma Usa2018P4.two_mul_le_card_F_add Documented declaration: two_mul_le_card_F_add line 173 source

    Source documentation

    If N distinct values are attained and C ordered pairs collide, then 2 * p ≤ C + 2 * N: writing nᵥ ≥ 1 for the fiber sizes we have p = Σ nᵥ, N = Σ 1 and C = Σ nᵥ (nᵥ - 1), and n * (n - 1) + 2 ≥ 2 * n for n ≥ 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.im

    Proof 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.snd and 64 more

    67 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

  14. problem Usa2018P4.usa2018_p4 Documented declaration: usa2018_p4 line 229 source

    Source documentation

    We index by Fin p instead of {1, ..., p} (the map i ↦ i mod p is a bijection {1, ..., p} ≃ Fin p sending p ↦ 0, and p * k ≡ 0 (mod p), so the families of remainders coincide), we work directly with remainders in ZMod p, and the conclusion p ≤ 2 * N is the integral form of "N ≥ p / 2 distinct 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.univ

    Proof 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_cast

    47 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
    …