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

20 declarations, 0 contain sorry, 0 declared as axioms

International Mathematical Olympiad 2014, Problem 5

For every positive integer n, the Bank of Cape Town issues coins of denomination 1/n. Given a finite collection of such coins (of not necessarily different denominations) with total value at most 99 + 1/2, prove that it is possible to split this collection into 100 or fewer groups, such that each group has total value at most 1.

Imports (14)
Imported by 1 file
  1. def Imo2014P5.value The total value of a collection of coins, where a coin of denomination n is worth (n : ℚ)⁻¹ line 44 source

    Source documentation

    The total value of a collection of coins, where a coin of denomination n is worth (n : ℚ)⁻¹.

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

    Statement uses: Multiset, Nat, Rat

    Proof uses: Multiset.sum, Multiset.map, Inv.inv

    4 instances, coercions and auxiliary constants left out.

    def value (c : Multiset ℕ) : ℚ := (c.map fun n : ℕ ↦ (n : ℚ)⁻¹).sum
  2. lemma Imo2014P5.value_zero line 46 source

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

    Statement uses: Eq, Rat, Imo2014P5.value, OfNat.ofNat, Multiset, Nat

    Proof uses: of_eq_true, eq_self

    9 instances, coercions and auxiliary constants left out.

    Tactic trace: 1 steps

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

  3. lemma Imo2014P5.value_add line 48 source

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

    Statement uses: Multiset, Nat, Eq, Rat, Imo2014P5.value, HAdd.hAdd

    Proof uses: of_eq_true, Multiset.sum, Multiset.map, Inv.inv, Eq.trans, True, congrFun', congrArg, Multiset.map_add, Multiset.sum_add, eq_self

    14 instances, coercions and auxiliary constants left out.

    Tactic trace: 1 steps

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

  4. lemma Imo2014P5.value_cons line 51 source

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

    Statement uses: Nat, Multiset, Eq, Rat, Imo2014P5.value, Multiset.cons, HAdd.hAdd, Inv.inv

    Proof uses: of_eq_true, Multiset.sum, Multiset.map, Eq.trans, True, congrFun', congrArg, Multiset.map_cons, Multiset.sum_cons, eq_self

    15 instances, coercions and auxiliary constants left out.

    Tactic trace: 1 steps

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

  5. lemma Imo2014P5.value_singleton line 55 source

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

    Statement uses: Nat, Eq, Rat, Imo2014P5.value, Singleton.singleton, Multiset, Inv.inv

    Proof uses: of_eq_true, Eq.trans, True, congrFun', congrArg, Multiset.sum_singleton, eq_self

    9 instances, coercions and auxiliary constants left out.

    Tactic trace: 1 steps

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

  6. lemma Imo2014P5.value_replicate line 57 source

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

    Statement uses: Nat, Eq, Rat, Imo2014P5.value, Multiset.replicate, HMul.hMul, Inv.inv

    Proof uses: Eq.mpr, Multiset.sum, Multiset.map, id, congrArg, Imo2014P5.value.eq_1, Multiset, Multiset.map_replicate, HSMul.hSMul, Multiset.sum_replicate, nsmul_eq_mul, Eq.refl

    24 instances, coercions and auxiliary constants left out.

    Tactic trace: 1 steps

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

  7. lemma Imo2014P5.value_nonneg line 61 source

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

    Statement uses: Multiset, Nat, LE.le, Rat, OfNat.ofNat, Imo2014P5.value

    Proof uses: Multiset.sum_nonneg, Multiset.map, Inv.inv, Membership.mem, And, Eq, Exists, Eq.mp, Iff.mpr, inv_nonneg, Nat.cast_nonneg

    45 instances, coercions and auxiliary constants left out.

    Tactic trace: 5 steps

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

  8. lemma Imo2014P5.value_sum line 68 source

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

    Statement uses: Finset, Multiset, Nat, Eq, Rat, Imo2014P5.value, Finset.sum

    Proof uses: Finset.induction, Classical.propDecidable, of_eq_true, OfNat.ofNat, eq_self, Not, Membership.mem, Eq.mpr, Insert.insert, HAdd.hAdd, id, congrArg, Finset.sum_insert, Imo2014P5.value_add, Eq.refl

    18 instances, coercions and auxiliary constants left out.

    Tactic trace: 4 steps

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

  9. def Imo2014P5.cap The capacity bound: any collection of total value at most cap k can be split into k or fewer groups each of value at most 1 line 77 source

    Source documentation

    The capacity bound: any collection of total value at most cap k can be split into k or fewer groups each of value at most 1.

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

    Statement uses: Nat, Rat

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

    11 instances, coercions and auxiliary constants left out.

    def cap (k : ℕ) : ℚ := k - k / (2 * k + 1)
  10. lemma Imo2014P5.cap_eq' line 79 source

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

    Statement uses: Nat, Eq, Rat, Imo2014P5.cap, HMul.hMul, HSub.hSub, OfNat.ofNat, Inv.inv, HAdd.hAdd

    Proof uses: Eq.mpr, HDiv.hDiv, id, congrArg, Imo2014P5.cap.eq_1, div_eq_mul_inv, Mathlib.Tactic.Ring.of_eq, HPow.hPow, Nat.rawCast, Int.rawCast, inferInstance, Ring, Int.negOfNat, Mathlib.Tactic.Ring.Common.sub_congr, Mathlib.Tactic.Ring.Common.atom_pf, rfl, Eq.symm, Eq.refl, Mathlib.Tactic.Ring.Common.mul_congr, Mathlib.Tactic.Ring.Common.inv_congr and 29 more

    66 instances, coercions and auxiliary constants left out.

    Tactic trace: 2 steps

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

  11. lemma Imo2014P5.cap_sub_one_le line 82 source

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

    Statement uses: Nat, LE.le, Rat, HSub.hSub, Imo2014P5.cap, OfNat.ofNat

    Proof uses: Eq, GT.gt, Or, Nat.eq_zero_or_pos, of_eq_true, Eq.trans, True, Neg.neg, congr, congrArg, congrFun', Mathlib.Meta.NormNum.IsNat.to_eq, Mathlib.Meta.NormNum.instAddMonoidWithOne, HDiv.hDiv, HAdd.hAdd, HMul.hMul, Mathlib.Meta.NormNum.IsInt.to_isNat, Mathlib.Meta.NormNum.isInt_sub, Int.ofNat, Eq.refl and 93 more

    120 instances, coercions and auxiliary constants left out.

    Tactic trace: 17 steps

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

  12. lemma Imo2014P5.exists_mem_of_mem_sum line 95 source

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

    Statement uses: Multiset, Nat, Membership.mem, Multiset.sum, Exists, And

    Proof uses: Multiset.induction_on, OfNat.ofNat, False.elim, Eq.mp, False, Multiset.cons, Or, HAdd.hAdd, congrArg, propext, Multiset.mem_add, Multiset.sum_cons, Exists.intro, And.intro, Multiset.mem_cons_self, Multiset.mem_cons_of_mem

    18 instances, coercions and auxiliary constants left out.

    Tactic trace: 9 steps

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

  13. lemma Imo2014P5.count_sum_filter_boxes line 106 source

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

    Statement uses: Nat, Multiset, Eq, Multiset.count, Finset.sum, Finset.range, Multiset.filter, Or, HAdd.hAdd, HMul.hMul, OfNat.ofNat, ite

    Proof uses: Eq.mpr, Multiset.sum, Multiset.map, Finset.val, id, congrArg, rfl, Multiset.count_sum, congrFun', Multiset.map_congr, Eq.refl, Membership.mem, Multiset.count_filter

    21 instances, coercions and auxiliary constants left out.

    Tactic trace: 3 steps

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

  14. lemma Imo2014P5.filter_boxes_add_pile line 117 source

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

    Statement uses: Nat, Multiset, Membership.mem, LT.lt, OfNat.ofNat, Eq, HAdd.hAdd, Finset.sum, Finset.range, Multiset.filter, Or, HMul.hMul, LE.le

    Proof uses: Multiset.ext', Eq.mpr, Multiset.count, id, congrArg, Multiset.count_add, ite, Imo2014P5.count_sum_filter_boxes, Multiset.count_filter, dite, Iff.mpr, Not, Multiset.count_eq_zero, absurd, False, Finset.sum_eq_zero, Finset, ite_eq_right, Eq.refl, Eq.symm and 10 more

    55 instances, coercions and auxiliary constants left out.

    Tactic trace: 35 steps

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

  15. lemma Imo2014P5.value_filter_box_le line 142 source

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

    Statement uses: Multiset, Nat, LE.le, OfNat.ofNat, Multiset.count, HMul.hMul, HAdd.hAdd, Rat, Imo2014P5.value, Multiset.filter, Or, Eq, Inv.inv

    Proof uses: Multiset.ext', Eq.mpr, id, congrArg, Multiset.count_add, ite, Multiset.count_filter, dite, ite_eq_left, Or.inl, ite_eq_right, add_zero, Eq.refl, Not, Or.inr, zero_add, Iff.mpr, And, not_or, And.intro and 15 more

    90 instances, coercions and auxiliary constants left out.

    Tactic trace: 22 steps

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

  16. lemma Imo2014P5.box_capacity_lt_one line 165 source

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

    Statement uses: Nat, LT.lt, Rat, HAdd.hAdd, HMul.hMul, OfNat.ofNat, Inv.inv

    Proof uses: Eq, HSub.hSub, Eq.mpr, id, congrFun', congrArg, Eq.trans, Nat.cast_add, congr, Nat.cast_mul, Nat.cast_one, Mathlib.Tactic.Ring.of_eq, Nat.rawCast, HPow.hPow, Mathlib.Tactic.Ring.Common.add_congr, Mathlib.Tactic.Ring.Common.mul_congr, Mathlib.Tactic.Ring.cast_pos, Mathlib.Meta.NormNum.isNat_ofNat, Eq.refl, Mathlib.Tactic.Ring.Common.atom_pf and 108 more

    137 instances, coercions and auxiliary constants left out.

    Tactic trace: 16 steps

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

  17. lemma Imo2014P5.greedy Documented declaration: greedy line 183 source

    Source documentation

    Greedy distribution of the "light" coins (of denomination at least 2k+1) into the k boxes: as long as a coin remains, some box still has room for it, for otherwise the total value would exceed cap k.

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

    Statement uses: Nat, Multiset, Membership.mem, LE.le, HAdd.hAdd, HMul.hMul, OfNat.ofNat, Fin, Rat, Imo2014P5.value, Finset.sum, Finset.univ, Imo2014P5.cap, Exists, And, Eq

    Proof uses: Multiset.induction_on, Exists.intro, And.intro, Finset.sum_const_zero, Eq.mpr, id, congrFun', congrArg, add_zero, Multiset.cons, Multiset.mem_cons_self, Multiset.mem_cons_of_mem, LT.lt, Inv.inv, Iff.mpr, inv_pos, cast, Eq.symm, Eq.trans, Nat.cast_zero and 147 more

    179 instances, coercions and auxiliary constants left out.

    Tactic trace: 84 steps

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

    lemma greedy (k : ℕ) (pile : Multiset ℕ) :
        (∀ n ∈ pile, 2 * k + 1 ≤ n) → ∀ w : Fin k → ℚ, (∀ m, w m ≤ 1) →
        value pile + ∑ m, w m ≤ cap k →
        ∃ parts : Fin k → Multiset ℕ,
          (∑ m, parts m) = pile ∧ ∀ m, w m + value (parts m) ≤ 1 := by
    …

    Mentions: Imo2014P5.value, Imo2014P5.cap

  18. theorem Imo2014P5.exists_partition_aux The main claim, proved by strong induction on the number of coins: a collection of total value at most cap k admits a partition into at most k groups each of value at most 1 line 269 source

    Source documentation

    The main claim, proved by strong induction on the number of coins: a collection of total value at most cap k admits a partition into at most k groups each of value at most 1.

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

    Statement uses: Nat, Multiset, Eq, Multiset.card, Membership.mem, LT.lt, OfNat.ofNat, LE.le, Rat, Imo2014P5.value, Imo2014P5.cap, Exists, And, Multiset.sum

    Proof uses: Nat.strong_induction_on, dite, Multiset.count, HMul.hMul, Classical.propDecidable, Insert.insert, Singleton.singleton, Eq.mpr, id, congrArg, propext, Multiset.le_iff_count, Multiset.cons, rfl, HAdd.hAdd, Multiset.count_cons_self, Multiset.count_singleton_self, Eq.symm, Not, Multiset.count_cons_of_ne and 159 more

    142 instances, coercions and auxiliary constants left out.

    Tactic trace: 144 steps

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

    theorem exists_partition_aux : ∀ (N k : ℕ) (c : Multiset ℕ), c.card = N →
        (∀ n ∈ c, 0 < n) → value c ≤ cap k →
        ∃ gs : Multiset (Multiset ℕ), gs.sum = c ∧ gs.card ≤ k ∧ ∀ g ∈ gs, value g ≤ 1 := by
    …

    Mentions: Imo2014P5.value, Imo2014P5.cap

  19. theorem Imo2014P5.exists_partition line 423 source

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

    Statement uses: Nat, Multiset, Membership.mem, LT.lt, OfNat.ofNat, LE.le, Rat, Imo2014P5.value, Imo2014P5.cap, Exists, And, Eq, Multiset.sum, Multiset.card

    Proof uses: Imo2014P5.exists_partition_aux, rfl

    12 instances, coercions and auxiliary constants left out.

  20. problem Imo2014P5.imo2014_p5 line 430 source

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

    Statement uses: Multiset, Nat, Membership.mem, LT.lt, OfNat.ofNat, LE.le, Rat, Imo2014P5.value, HAdd.hAdd, HDiv.hDiv, Exists, And, Eq, Multiset.sum, Multiset.card

    Proof uses: Imo2014P5.cap, of_eq_true, Eq.trans, True, congr, congrArg, Mathlib.Meta.NormNum.IsNNRat.to_eq, Mathlib.Meta.NormNum.isNNRat_add, Eq.refl, Mathlib.Meta.NormNum.IsNat.to_isNNRat, Mathlib.Meta.NormNum.isNat_ofNat, Mathlib.Meta.NormNum.isNNRat_div, Mathlib.Meta.NormNum.isNNRat_mul, HMul.hMul, Inv.inv, Mathlib.Meta.NormNum.isNNRat_inv_pos, Nat.mul, HSub.hSub, Mathlib.Meta.NormNum.IsRat.to_isNNRat, Mathlib.Meta.NormNum.isRat_sub and 12 more

    60 instances, coercions and auxiliary constants left out.

    Tactic trace: 3 steps

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