Compfiles/Imo1995P6.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

28 declarations, 0 contain sorry, 0 declared as axioms

International Mathematical Olympiad 1995, Problem 6

Let p be an odd prime number. How many p-element subsets A of {1, 2, ..., 2p} are there, the sum of whose elements is divisible by p?

Imports (6)
Imported by 1 file
  1. def Imo1995P6.shift The cyclic shift x ↦ x + 1 on {1, ..., p} (sending p back to 1), extended by the identity on all other natural numbers line 34 source

    Source documentation

    The cyclic shift x ↦ x + 1 on {1, ..., p} (sending p back to 1), extended by the identity on all other natural numbers.

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

    Statement uses: Nat

    Proof uses: ite, Membership.mem, Finset, Finset.Icc, OfNat.ofNat, HAdd.hAdd, HMod.hMod

    11 instances, coercions and auxiliary constants left out.

    def shift (p x : ℕ) : ℕ := if x ∈ Finset.Icc 1 p then x % p + 1 else x
  2. def Imo1995P6.shiftSet The action of shift p on sets of naturals: the elements of A lying in {1, ..., p} are cyclically shifted and all other elements stay fixed line 38 source

    Source documentation

    The action of shift p on sets of naturals: the elements of A lying in {1, ..., p} are cyclically shifted and all other elements stay fixed.

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

    Statement uses: Nat, Finset

    Proof uses: Finset.image, Imo1995P6.shift

    1 instances, coercions and auxiliary constants left out.

    def shiftSet (p : ℕ) (A : Finset ℕ) : Finset ℕ := A.image (shift p)

    Mentions: Imo1995P6.shift

  3. theorem Imo1995P6.shiftSet_eq line 40 source

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

    Statement uses: Nat, Finset, Eq, Imo1995P6.shiftSet, Finset.image, Imo1995P6.shift

    Proof uses: rfl

    1 instances, coercions and auxiliary constants left out.

  4. theorem Imo1995P6.shift_of_mem line 42 source

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

    Statement uses: Nat, Membership.mem, Finset, Finset.Icc, OfNat.ofNat, Eq, Imo1995P6.shift, HAdd.hAdd, HMod.hMod

    Proof uses: ite_eq_left

    20 instances, coercions and auxiliary constants left out.

  5. theorem Imo1995P6.shift_of_not_mem line 44 source

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

    Statement uses: Nat, Not, Membership.mem, Finset, Finset.Icc, OfNat.ofNat, Eq, Imo1995P6.shift

    Proof uses: ite_eq_right, HAdd.hAdd, HMod.hMod

    16 instances, coercions and auxiliary constants left out.

  6. theorem Imo1995P6.shift_mem_Icc line 46 source

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Membership.mem, Finset, Finset.Icc, Imo1995P6.shift

    Proof uses: Eq, HAdd.hAdd, HMod.hMod, ite_eq_left, Eq.mpr, And, LE.le, id, congrArg, propext, Finset.mem_Icc, Nat.mod_lt

    20 instances, coercions and auxiliary constants left out.

    Tactic trace: 5 steps

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

  7. theorem Imo1995P6.shift_mem_iff line 54 source

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Iff, Membership.mem, Finset, Finset.Icc, Imo1995P6.shift

    Proof uses: Iff.intro, dite, Not, Eq.mpr, id, Eq, congrArg, Imo1995P6.shift_of_not_mem, absurd, Imo1995P6.shift_mem_Icc

    14 instances, coercions and auxiliary constants left out.

    Tactic trace: 10 steps

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

  8. theorem Imo1995P6.shift_injective line 63 source

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Function.Injective, Imo1995P6.shift

    Proof uses: Eq, dite, Membership.mem, Finset, Finset.Icc, HAdd.hAdd, HMod.hMod, ite_eq_left, Eq.mp, congrArg, Eq.mpr, id, Eq.symm, Nat.mod_self, Eq.refl, Dvd.dvd, Nat.dvd_of_mod_eq_zero, LE.le, Nat.le_of_dvd, And and 7 more

    24 instances, coercions and auxiliary constants left out.

    Tactic trace: 58 steps

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

  9. theorem Imo1995P6.shift_iterate_mem_Icc line 107 source

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Membership.mem, Finset, Finset.Icc, Eq, Nat.iterate, Imo1995P6.shift, HAdd.hAdd, HMod.hMod, HSub.hSub

    Proof uses: Nat.recAux, id, Eq.mpr, congrArg, Nat.mod_eq_of_lt, Eq.mp, And, LE.le, propext, Finset.mem_Icc, Nat.sub_add_cancel, And.left, Eq.refl, Nat.mod_lt, Nat.succ, Function.iterate_succ_apply', ite_eq_left, Nat.mod_add_mod, Iff.mp, HAdd and 1 more

    30 instances, coercions and auxiliary constants left out.

    Tactic trace: 15 steps

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

  10. theorem Imo1995P6.shift_iterate_not_mem line 127 source

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

    Statement uses: Nat, Not, Membership.mem, Finset, Finset.Icc, OfNat.ofNat, Eq, Nat.iterate, Imo1995P6.shift

    Proof uses: Nat.recAux, Eq.refl, Eq.mpr, HAdd.hAdd, id, congrArg, Nat.succ, Function.iterate_succ_apply', ite_eq_right, HMod.hMod

    16 instances, coercions and auxiliary constants left out.

    Tactic trace: 4 steps

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

  11. theorem Imo1995P6.shift_iterate_mem_Icc' line 133 source

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Membership.mem, Finset, Finset.Icc, Nat.iterate, Imo1995P6.shift

    Proof uses: Eq.mpr, HAdd.hAdd, HMod.hMod, HSub.hSub, id, Eq, congrArg, Imo1995P6.shift_iterate_mem_Icc, And, LE.le, propext, Finset.mem_Icc, Nat.mod_lt

    20 instances, coercions and auxiliary constants left out.

    Tactic trace: 4 steps

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

  12. theorem Imo1995P6.shift_iterate_p line 140 source

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Eq, Nat.iterate, Imo1995P6.shift

    Proof uses: dite, Membership.mem, Finset, Finset.Icc, Eq.mpr, HAdd.hAdd, HMod.hMod, HSub.hSub, id, congrArg, Imo1995P6.shift_iterate_mem_Icc, Nat.add_mod_right, Nat.mod_eq_of_lt, Eq.mp, And, LE.le, propext, Finset.mem_Icc, Nat.sub_add_cancel, And.left and 3 more

    18 instances, coercions and auxiliary constants left out.

    Tactic trace: 8 steps

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

  13. theorem Imo1995P6.shiftSet_iterate line 147 source

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

    Statement uses: Nat, Finset, Eq, Nat.iterate, Imo1995P6.shiftSet, Finset.image, Imo1995P6.shift

    Proof uses: Nat.recAux, Eq.mpr, OfNat.ofNat, id, congrArg, Function.iterate_zero, Finset.image_id, id_eq, Eq.refl, HAdd.hAdd, Nat.succ, Function.iterate_succ_apply', Function.comp, Function.iterate_succ', Finset.image_image

    5 instances, coercions and auxiliary constants left out.

    Tactic trace: 5 steps

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

  14. theorem Imo1995P6.shiftSet_iterate_p line 156 source

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Finset, Eq, Nat.iterate, Imo1995P6.shiftSet

    Proof uses: Eq.mpr, Finset.image, Imo1995P6.shift, id, congrArg, Imo1995P6.shiftSet_iterate, funext, Imo1995P6.shift_iterate_p, Finset.image_id, Eq.refl

    5 instances, coercions and auxiliary constants left out.

    Tactic trace: 1 steps

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

  15. theorem Imo1995P6.shiftSet_injective line 159 source

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Function.Injective, Finset, Imo1995P6.shiftSet

    Proof uses: Finset.image_injective, Imo1995P6.shift, Imo1995P6.shift_injective

    5 instances, coercions and auxiliary constants left out.

  16. theorem Imo1995P6.sum_shiftSet The key congruence: shifting a set once increases its sum by the number of its elements lying in {1, ..., p}, modulo p line 164 source

    Source documentation

    The key congruence: shifting a set once increases its sum by the number of its elements lying in {1, ..., p}, modulo p.

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Finset, Nat.ModEq, Finset.sum, Imo1995P6.shiftSet, HAdd.hAdd, Finset.card, Finset.filter, Membership.mem, Finset.Icc

    Proof uses: Eq.mpr, Finset.image, Imo1995P6.shift, id, Eq, congrArg, Imo1995P6.shiftSet_eq, Finset.sum_image, Set, Imo1995P6.shift_injective, Not, Eq.symm, Finset.sum_filter_add_sum_filter_not, HMod.hMod, ite_eq_left, And.right, Iff.mp, And, Finset.mem_filter, ite_eq_right and 16 more

    47 instances, coercions and auxiliary constants left out.

    Tactic trace: 14 steps

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

    theorem sum_shiftSet {p : ℕ} (hp : 0 < p) (A : Finset ℕ) :
        ∑ x ∈ shiftSet p A, x ≡ ∑ x ∈ A, x + (A.filter (· ∈ Finset.Icc 1 p)).card [MOD p] := by
    …

    Mentions: Imo1995P6.shiftSet

  17. theorem Imo1995P6.low_card_shiftSet line 189 source

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Finset, Eq, Finset.card, Finset.filter, Membership.mem, Finset.Icc, Imo1995P6.shiftSet

    Proof uses: Finset.image, Imo1995P6.shift, Finset.ext, Eq.mpr, Iff, And, Exists, id, congr, congrArg, Eq.trans, congrFun', funext, Iff.intro, Exists.intro, And.intro, Iff.mp, Imo1995P6.shift_mem_iff, rfl, Iff.mpr and 3 more

    21 instances, coercions and auxiliary constants left out.

    Tactic trace: 11 steps

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

  18. theorem Imo1995P6.low_card_shiftSet_iterate line 202 source

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Finset, Eq, Finset.card, Finset.filter, Membership.mem, Finset.Icc, Nat.iterate, Imo1995P6.shiftSet

    Proof uses: Nat.recAux, Eq.mpr, id, congrArg, Function.iterate_zero, id_eq, Eq.refl, HAdd.hAdd, Nat.succ, Function.iterate_succ_apply', Imo1995P6.low_card_shiftSet

    18 instances, coercions and auxiliary constants left out.

    Tactic trace: 3 steps

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

  19. theorem Imo1995P6.sum_shiftSet_iterate line 208 source

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Finset, Nat.ModEq, Finset.sum, Nat.iterate, Imo1995P6.shiftSet, HAdd.hAdd, HMul.hMul, Finset.card, Finset.filter, Membership.mem, Finset.Icc

    Proof uses: Nat.recAux, Eq.mpr, id, Eq, congrArg, Nat.zero_mul, Nat.ModEq.refl, Imo1995P6.sum_shiftSet, Nat.succ, Function.iterate_succ_apply', Nat.ModEq.trans, Eq.mp, Imo1995P6.low_card_shiftSet_iterate, Nat.ModEq.add, Mathlib.Tactic.Ring.of_eq, HPow.hPow, Nat.rawCast, Mathlib.Tactic.Ring.Common.add_congr, Mathlib.Tactic.Ring.Common.atom_pf, rfl and 18 more

    42 instances, coercions and auxiliary constants left out.

    Tactic trace: 12 steps

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

  20. theorem Imo1995P6.shiftSet_iterate_mem line 229 source

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Finset, Membership.mem, Finset.powersetCard, Finset.Icc, HMul.hMul, Nat.iterate, Imo1995P6.shiftSet

    Proof uses: Eq.mpr, And, LE.le, Eq, Finset.card, id, congrArg, propext, Finset.mem_powersetCard, Eq.mp, Finset.image, Imo1995P6.shift, Imo1995P6.shiftSet_iterate, And.intro, Exists, Iff.mp, Finset.mem_image, dite, Imo1995P6.shift_iterate_mem_Icc', Finset.mem_Icc and 6 more

    25 instances, coercions and auxiliary constants left out.

    Tactic trace: 17 steps

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

  21. theorem Imo1995P6.shiftSet_iterate_Icc_left line 246 source

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Eq, Finset, Nat.iterate, Imo1995P6.shiftSet, Finset.Icc

    Proof uses: Eq.mpr, Finset.image, Imo1995P6.shift, id, congrArg, Imo1995P6.shiftSet_iterate, Finset.card, Finset.card_image_of_injective, Function.Injective.iterate, Imo1995P6.shift_injective, LE.le, Membership.mem, And, Exists, Iff.mp, Finset.mem_image, Imo1995P6.shift_iterate_mem_Icc', Finset.eq_of_subset_of_card_le, le_of_eq, Eq.symm

    17 instances, coercions and auxiliary constants left out.

    Tactic trace: 7 steps

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

  22. theorem Imo1995P6.shiftSet_iterate_Icc_right line 257 source

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

    Statement uses: Nat, Eq, Finset, Nat.iterate, Imo1995P6.shiftSet, Finset.Icc, HAdd.hAdd, OfNat.ofNat, HMul.hMul

    Proof uses: Eq.mpr, Finset.image, Imo1995P6.shift, id, congrArg, Imo1995P6.shiftSet_iterate, Finset.ext, Iff, Membership.mem, Exists, And, congrFun', Iff.intro, Imo1995P6.shift_iterate_not_mem, Not, LE.le, propext, Finset.mem_Icc, Eq.mp, Iff.mpr and 2 more

    23 instances, coercions and auxiliary constants left out.

    Tactic trace: 18 steps

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

  23. theorem Imo1995P6.shiftSet_iterate_mem_U line 272 source

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Finset, Membership.mem, SDiff.sdiff, Finset.powersetCard, Finset.Icc, HMul.hMul, Insert.insert, Singleton.singleton, HAdd.hAdd, Nat.iterate, Imo1995P6.shiftSet

    Proof uses: Eq.mpr, And, Not, id, Eq, congrArg, propext, Finset.mem_sdiff, Eq.mp, Or, Finset.mem_insert, Finset.mem_singleton, Ne, And.intro, Imo1995P6.shiftSet_iterate_mem, And.left, Function.Injective.iterate, Imo1995P6.shiftSet_injective, Imo1995P6.shiftSet_iterate_Icc_left, Eq.refl and 2 more

    32 instances, coercions and auxiliary constants left out.

    Tactic trace: 13 steps

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

  24. theorem Imo1995P6.low_card_bounds If A is a p-element subset of {1, ..., 2p} different from the two "interval" subsets, then A ∩ {1, ..., p} has between 1 and p - 1 elements line 291 source

    Source documentation

    If A is a p-element subset of {1, ..., 2p} different from the two "interval" subsets, then A ∩ {1, ..., p} has between 1 and p - 1 elements.

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

    Statement uses: Nat, LT.lt, OfNat.ofNat, Finset, Membership.mem, SDiff.sdiff, Finset.powersetCard, Finset.Icc, HMul.hMul, Insert.insert, Singleton.singleton, HAdd.hAdd, And, LE.le, Finset.card, Finset.filter, HSub.hSub

    Proof uses: Eq, Ne, Eq.mp, Not, Or, congrArg, propext, Finset.mem_powersetCard, Finset.mem_singleton, Finset.mem_insert, Finset.mem_sdiff, And.right, Iff.mp, Finset.mem_filter, Trans.trans, Finset.card_le_card, Eq.mpr, id, Nat.card_Icc, Nat.add_sub_cancel and 11 more

    52 instances, coercions and auxiliary constants left out.

    Tactic trace: 38 steps

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

    theorem low_card_bounds {p : ℕ} (hp : 0 < p) {A : Finset ℕ}
        (hA : A ∈ (Finset.Icc 1 (2 * p)).powersetCard p \
          {Finset.Icc 1 p, Finset.Icc (p + 1) (2 * p)}) :
        1 ≤ (A.filter (· ∈ Finset.Icc 1 p)).card ∧
        (A.filter (· ∈ Finset.Icc 1 p)).card ≤ p - 1 := by
    …
  25. theorem Imo1995P6.card_range_filter_eq_one For A as above, among the p sets A, σ A, ..., σ^{p-1} A exactly one has sum divisible by p (here σ is shiftSet p) line 331 source

    Source documentation

    For A as above, among the p sets A, σ A, ..., σ^{p-1} A exactly one has sum divisible by p (here σ is shiftSet p).

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

    Statement uses: Nat, Nat.Prime, Finset, Membership.mem, SDiff.sdiff, Finset.powersetCard, Finset.Icc, OfNat.ofNat, HMul.hMul, Insert.insert, Singleton.singleton, HAdd.hAdd, Eq, Finset.card, Finset.filter, Dvd.dvd, Finset.sum, Nat.iterate, Imo1995P6.shiftSet, Finset.range

    Proof uses: LT.lt, Nat.Prime.pos, NeZero, NeZero.mk, LT.lt.ne', Fact, Fact.mk, LE.le, HSub.hSub, And, Imo1995P6.low_card_bounds, Iff, ZMod, Nat.ModEq, Imo1995P6.sum_shiftSet_iterate, Eq.mpr, id, congrArg, Eq.symm, Nat.cast_sum and 30 more

    86 instances, coercions and auxiliary constants left out.

    Tactic trace: 47 steps

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

    theorem card_range_filter_eq_one {p : ℕ} (hp : p.Prime) {A : Finset ℕ}
        (hA : A ∈ (Finset.Icc 1 (2 * p)).powersetCard p \
          {Finset.Icc 1 p, Finset.Icc (p + 1) (2 * p)}) :
        ((Finset.range p).filter (fun i ↦ p ∣ ∑ x ∈ (shiftSet p)^[i] A, x)).card = 1 := by
    …

    Mentions: Imo1995P6.shiftSet

  26. theorem Imo1995P6.card_U_filter_eq Shifting i times is a bijection on the good subsets, so for each fixed i the number of good A with p ∣ ∑ σⁱ A equals the number of good B with p ∣ ∑ B line 392 source

    Source documentation

    Shifting i times is a bijection on the good subsets, so for each fixed i the number of good A with p ∣ ∑ σⁱ A equals the number of good B with p ∣ ∑ B.

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

    Statement uses: Nat, Nat.Prime, Membership.mem, Finset, Finset.range, Eq, Finset.card, Finset.filter, Dvd.dvd, Finset.sum, Nat.iterate, Imo1995P6.shiftSet, SDiff.sdiff, Finset.powersetCard, Finset.Icc, OfNat.ofNat, HMul.hMul, Insert.insert, Singleton.singleton, HAdd.hAdd

    Proof uses: LT.lt, Nat.Prime.pos, Finset.card_bij, Eq.mpr, And, id, congrArg, propext, Finset.mem_filter, And.intro, Imo1995P6.shiftSet_iterate_mem_U, And.left, Eq.mp, And.right, Function.Injective.iterate, Imo1995P6.shiftSet_injective, LE.le, Nat.le_of_lt, Iff.mp, Finset.mem_range and 8 more

    38 instances, coercions and auxiliary constants left out.

    Tactic trace: 22 steps

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

    theorem card_U_filter_eq {p : ℕ} (hp : p.Prime) (i : ℕ) (hi : i ∈ Finset.range p) :
        (((Finset.Icc 1 (2 * p)).powersetCard p \
            {Finset.Icc 1 p, Finset.Icc (p + 1) (2 * p)}).filter
          (fun A ↦ p ∣ ∑ x ∈ (shiftSet p)^[i] A, x)).card =
        (((Finset.Icc 1 (2 * p)).powersetCard p \
            {Finset.Icc 1 p, Finset.Icc (p + 1) (2 * p)}).filter
          (fun A ↦ p ∣ ∑ x ∈ A, x)).card := by
    …

    Mentions: Imo1995P6.shiftSet

  27. determine Imo1995P6.solution line 419 source

    no axioms what this means

    Statement uses: Nat

    Proof uses: HAdd.hAdd, OfNat.ofNat, HDiv.hDiv, HSub.hSub, Nat.choose, HMul.hMul

    9 instances, coercions and auxiliary constants left out.

  28. problem Imo1995P6.imo1995_p6 line 421 source

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

    Statement uses: Nat, Nat.Prime, Odd, Eq, Finset.card, Finset, Finset.filter, Dvd.dvd, Finset.sum, Finset.powersetCard, Finset.Icc, OfNat.ofNat, HMul.hMul, Imo1995P6.solution

    Proof uses: LT.lt, Nat.Prime.pos, Membership.mem, Eq.mpr, And, LE.le, id, congrArg, propext, Finset.mem_powersetCard, And.intro, Finset.Icc_subset_Icc, le_refl, HSub.hSub, HAdd.hAdd, Nat.card_Icc, Nat.add_sub_cancel, Eq.refl, Ne, Eq.rec and 95 more

    104 instances, coercions and auxiliary constants left out.

    Tactic trace: 105 steps

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