Compfiles/Imo2014P5.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
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)
- Mathlib.Algebra.Order.BigOperators.Group.Finset
- Mathlib.Algebra.Order.Field.Basic
- Mathlib.Algebra.Order.Ring.Star
- Mathlib.Data.Fintype.BigOperators
- Mathlib.Data.Rat.Star
- Mathlib.Tactic.FieldSimp
- Mathlib.Tactic.FieldSimp.Lemmas
- Mathlib.Tactic.IntervalCases
- Mathlib.Tactic.Linarith
- Mathlib.Tactic.Linarith.Preprocessing
- Mathlib.Tactic.NormNum
- Mathlib.Tactic.Ring
- Mathlib.Tactic.Ring.Basic
- ProblemExtraction
Imported by 1 file
- def
Imo2014P5.valueThe total value of a collection of coins, where a coin of denominationnis worth(n : ℚ)⁻¹line 44 sourceSource documentation
The total value of a collection of coins, where a coin of denomination
nis worth(n : ℚ)⁻¹.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Multiset,Nat,RatProof uses:
Multiset.sum,Multiset.map,Inv.inv4 instances, coercions and auxiliary constants left out.
def value (c : Multiset ℕ) : ℚ := (c.map fun n : ℕ ↦ (n : ℚ)⁻¹).sum
- lemma
Imo2014P5.value_zeroline 46 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Eq,Rat, Imo2014P5.value,OfNat.ofNat,Multiset,NatProof uses:
of_eq_true,eq_self9 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Imo2014P5.value_addline 48 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Multiset,Nat,Eq,Rat, Imo2014P5.value,HAdd.hAddProof uses:
of_eq_true,Multiset.sum,Multiset.map,Inv.inv,Eq.trans,True,congrFun',congrArg,Multiset.map_add,Multiset.sum_add,eq_self14 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Imo2014P5.value_consline 51 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Multiset,Eq,Rat, Imo2014P5.value,Multiset.cons,HAdd.hAdd,Inv.invProof uses:
of_eq_true,Multiset.sum,Multiset.map,Eq.trans,True,congrFun',congrArg,Multiset.map_cons,Multiset.sum_cons,eq_self15 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Imo2014P5.value_singletonline 55 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq,Rat, Imo2014P5.value,Singleton.singleton,Multiset,Inv.invProof uses:
of_eq_true,Eq.trans,True,congrFun',congrArg,Multiset.sum_singleton,eq_self9 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Imo2014P5.value_replicateline 57 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq,Rat, Imo2014P5.value,Multiset.replicate,HMul.hMul,Inv.invProof 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.refl24 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Imo2014P5.value_nonnegline 61 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Multiset,Nat,LE.le,Rat,OfNat.ofNat, Imo2014P5.valueProof uses:
Multiset.sum_nonneg,Multiset.map,Inv.inv,Membership.mem,And,Eq,Exists,Eq.mp,Iff.mpr,inv_nonneg,Nat.cast_nonneg45 instances, coercions and auxiliary constants left out.
Tactic trace: 5 steps
Open to load the checked before-and-after goal states.
- lemma
Imo2014P5.value_sumline 68 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Finset,Multiset,Nat,Eq,Rat, Imo2014P5.value,Finset.sumProof 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.refl18 instances, coercions and auxiliary constants left out.
Tactic trace: 4 steps
Open to load the checked before-and-after goal states.
- def
Imo2014P5.capThe capacity bound: any collection of total value at mostcap kcan be split intokor fewer groups each of value at most1line 77 sourceSource documentation
The capacity bound: any collection of total value at most
cap kcan be split intokor fewer groups each of value at most1.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,RatProof uses:
HSub.hSub,HDiv.hDiv,HAdd.hAdd,HMul.hMul,OfNat.ofNat11 instances, coercions and auxiliary constants left out.
def cap (k : ℕ) : ℚ := k - k / (2 * k + 1)
- lemma
Imo2014P5.cap_eq'line 79 sourcestandard 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.hAddProof 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_congrand 29 more66 instances, coercions and auxiliary constants left out.
Tactic trace: 2 steps
Open to load the checked before-and-after goal states.
- lemma
Imo2014P5.cap_sub_one_leline 82 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,Rat,HSub.hSub, Imo2014P5.cap,OfNat.ofNatProof 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.refland 93 more120 instances, coercions and auxiliary constants left out.
Tactic trace: 17 steps
Open to load the checked before-and-after goal states.
- lemma
Imo2014P5.exists_mem_of_mem_sumline 95 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Multiset,Nat,Membership.mem,Multiset.sum,Exists,AndProof 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_mem18 instances, coercions and auxiliary constants left out.
Tactic trace: 9 steps
Open to load the checked before-and-after goal states.
- lemma
Imo2014P5.count_sum_filter_boxesline 106 sourcestandard 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,iteProof 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_filter21 instances, coercions and auxiliary constants left out.
Tactic trace: 3 steps
Open to load the checked before-and-after goal states.
- lemma
Imo2014P5.filter_boxes_add_pileline 117 sourcestandard 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.leProof 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.symmand 10 more55 instances, coercions and auxiliary constants left out.
Tactic trace: 35 steps
Open to load the checked before-and-after goal states.
- lemma
Imo2014P5.value_filter_box_leline 142 sourcestandard 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.invProof 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.introand 15 more90 instances, coercions and auxiliary constants left out.
Tactic trace: 22 steps
Open to load the checked before-and-after goal states.
- lemma
Imo2014P5.box_capacity_lt_oneline 165 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,Rat,HAdd.hAdd,HMul.hMul,OfNat.ofNat,Inv.invProof 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_pfand 108 more137 instances, coercions and auxiliary constants left out.
Tactic trace: 16 steps
Open to load the checked before-and-after goal states.
- lemma
Imo2014P5.greedyDocumented declaration: greedy line 183 sourceSource documentation
Greedy distribution of the "light" coins (of denomination at least
2k+1) into thekboxes: as long as a coin remains, some box still has room for it, for otherwise the total value would exceedcap 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,EqProof 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_zeroand 147 more179 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
- theorem
Imo2014P5.exists_partition_auxThe main claim, proved by strong induction on the number of coins: a collection of total value at mostcap kadmits a partition into at mostkgroups each of value at most1line 269 sourceSource documentation
The main claim, proved by strong induction on the number of coins: a collection of total value at most
cap kadmits a partition into at mostkgroups each of value at most1.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.sumProof 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_neand 159 more142 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
- theorem
Imo2014P5.exists_partitionline 423 sourcestandard 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.cardProof uses: Imo2014P5.exists_partition_aux,
rfl12 instances, coercions and auxiliary constants left out.
- problem
Imo2014P5.imo2014_p5line 430 sourcestandard 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.cardProof 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_suband 12 more60 instances, coercions and auxiliary constants left out.
Tactic trace: 3 steps
Open to load the checked before-and-after goal states.