Compfiles/Imo2019P5.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
31 declarations, 0 contain sorry, 0 declared as axioms
International Mathematical Olympiad 2019, Problem 5
Let n be a positive integer. Harry has n coins lined up on his desk, which can show either heads or tails. He does the following operation: if there are k > 0 coins which show heads, then he flips the kth coin over; otherwise he stops the process. (For example, the process starting with THT would be THT → HHT → HTT → TTT, which takes three steps.)
Prove the process will always terminate, and determine the average number of steps this takes over all 2ⁿ configurations.
Imports (17)
- Mathlib.Algebra.BigOperators.Intervals
- Mathlib.Algebra.BigOperators.Ring.Finset
- Mathlib.Algebra.CharP.Defs
- Mathlib.Algebra.Order.BigOperators.Group.Finset
- Mathlib.Algebra.Order.Ring.Star
- Mathlib.Data.Finset.Sort
- Mathlib.Data.Int.ConditionallyCompleteOrder
- Mathlib.Data.Int.Star
- Mathlib.Data.Rat.Star
- Mathlib.Tactic.FieldSimp
- Mathlib.Tactic.Linarith
- Mathlib.Tactic.LinearCombination
- Mathlib.Tactic.NormNum.Ineq
- Mathlib.Tactic.Positivity.Basic
- Mathlib.Tactic.Ring
- Mathlib.Tactic.Zify
- ProblemExtraction
Imported by 1 file
- def
Imo2019P5.numHeadsThe number of coins showing heads in a configuration ofncoins line 53 sourceSource documentation
The number of coins showing heads in a configuration of
ncoins. A configuration is a functionFin n → Bool, wherec i = truemeans that thei-th coin from the left (starting the count at0) shows heads.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,BoolProof uses:
Finset.card,Finset.filter,Eq,Bool.true,Finset.univ2 instances, coercions and auxiliary constants left out.
def numHeads {n : ℕ} (c : Fin n → Bool) : ℕ := … - def
Imo2019P5.flipIxThe index of the coin that Harry flips in configurationc: thek-th coin from the left, wherekis the number of heads line 58 sourceSource documentation
The index of the coin that Harry flips in configuration
c: thek-th coin from the left, wherekis the number of heads.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Ne, Imo2019P5.numHeads,OfNat.ofNatProof uses:
Fin.mk,HSub.hSub5 instances, coercions and auxiliary constants left out.
Tactic trace: 3 steps
Open to load the checked before-and-after goal states.
def flipIx {n : ℕ} (c : Fin n → Bool) (h : numHeads c ≠ 0) : Fin n := …Mentions: h, Imo2019P5.numHeads
- def
Imo2019P5.stepOne step of Harry's process: if there arek > 0heads, flip thek-th coin from the left; otherwise (all coins show tails) do nothing line 65 sourceSource documentation
One step of Harry's process: if there are
k > 0heads, flip thek-th coin from the left; otherwise (all coins show tails) do nothing.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,BoolProof uses:
dite,Eq, Imo2019P5.numHeads,OfNat.ofNat,Not,Function.update, Imo2019P5.flipIx,Bool.not3 instances, coercions and auxiliary constants left out.
def step {n : ℕ} (c : Fin n → Bool) : Fin n → Bool := … - def
Imo2019P5.weightedSumThe sum of the 1-based positions of the coins showing heads line 71 sourceSource documentation
The sum of the 1-based positions of the coins showing heads.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,BoolProof uses:
Finset.sum,Finset.univ,HMul.hMul,HAdd.hAdd,OfNat.ofNat,ite,Eq,Bool.true9 instances, coercions and auxiliary constants left out.
def weightedSum {n : ℕ} (c : Fin n → Bool) : ℕ := … - def
Imo2019P5.measThe measure of a configuration: twice the sum of the 1-based positions of the heads minus the square of the number of heads line 78 sourceSource documentation
The measure of a configuration: twice the sum of the 1-based positions of the heads minus the square of the number of heads. We will show that this is a nonnegative integer (see
meas_nonneg) which drops by exactly one at each step (seestep_meas), hence it equals the number of steps the process takes.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,IntProof uses:
HSub.hSub,HMul.hMul,OfNat.ofNat, Imo2019P5.weightedSum,HPow.hPow, Imo2019P5.numHeads12 instances, coercions and auxiliary constants left out.
def meas {n : ℕ} (c : Fin n → Bool) : ℤ := … - determine
Imo2019P5.LThe number of steps that Harry's process takes starting from configurationcline 85 sourceSource documentation
The number of steps that Harry's process takes starting from configuration
c.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,BoolProof uses:
Int.toNat, Imo2019P5.measdetermine L {n : ℕ} (c : Fin n → Bool) : ℕ := (meas c).toNat …Mentions: Imo2019P5.meas
- theorem
Imo2019P5.le_orderEmbOfFinThej-th smallest element of a finsetSofFin nis at leastjline 90 sourceSource documentation
The
j-th smallest element of a finsetSofFin nis at leastj.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Finset,Fin,Finset.card,LE.le,OrderEmbedding,Finset.orderEmbOfFin,rflProof uses:
Finset.map,RelEmbedding.toEmbedding,Finset.Iio,Membership.mem,And,Eq,Function.Embedding,Exists,Eq.mp,congrArg,propext,Finset.mem_map,Eq.mpr,LT.lt,id,Finset.mem_Iio,Iff.mpr,OrderEmbedding.lt_iff_lt,Trans.trans,Eq.symmand 3 more36 instances, coercions and auxiliary constants left out.
Tactic trace: 7 steps
Open to load the checked before-and-after goal states.
theorem le_orderEmbOfFin {n : ℕ} (S : Finset (Fin n)) (j : Fin S.card) : (j : ℕ) ≤ (S.orderEmbOfFin rfl j).val := by …Mentions: S
- theorem
Imo2019P5.sum_range_card_leFor a finsetSofFin n, the sum of the values of its elements is at leastcard S * (card S - 1) / 2(twice that sum, to stay inℕ) line 106 sourceSource documentation
For a finset
SofFin n, the sum of the values of its elements is at leastcard S * (card S - 1) / 2(twice that sum, to stay inℕ).standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Finset,Fin,LE.le,HMul.hMul,Finset.card,HSub.hSub,OfNat.ofNat,Finset.sumProof uses:
OrderEmbedding,Finset.orderEmbOfFin,rfl, Imo2019P5.le_orderEmbOfFin,Eq,Finset.univ,Eq.mpr,Finset.map,RelEmbedding.toEmbedding,id,Eq.rec,Eq.refl,Eq.trans,congrArg,Eq.symm,Finset.map_orderEmbOfFin_univ,Function.Embedding,Finset.sum_map,of_eq_true,RelEmbeddingand 71 more102 instances, coercions and auxiliary constants left out.
Tactic trace: 10 steps
Open to load the checked before-and-after goal states.
theorem sum_range_card_le {n : ℕ} (S : Finset (Fin n)) : S.card * (S.card - 1) ≤ 2 * ∑ i ∈ S, (i : ℕ) := by …Mentions: S
- theorem
Imo2019P5.numHeads_mul_succ_leThe key combinatorial estimate: if a configuration haskheads, then the sum of the 1-based positions of the heads is at leastk * (k + 1) / 2line 124 sourceSource documentation
The key combinatorial estimate: if a configuration has
kheads, then the sum of the 1-based positions of the heads is at leastk * (k + 1) / 2.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,LE.le,HMul.hMul, Imo2019P5.numHeads,HAdd.hAdd,OfNat.ofNat, Imo2019P5.weightedSumProof uses:
Finset.card,Finset.filter,Eq,Bool.true,Finset.univ,HSub.hSub,Finset.sum, Imo2019P5.sum_range_card_le,Eq.mpr,ite,id,congrArg,Imo2019P5.weightedSum.eq_1,Finset.sum_filter,Finset.sum_congr,rfl,Finset,Membership.mem,dite,of_eq_trueand 85 more106 instances, coercions and auxiliary constants left out.
Tactic trace: 21 steps
Open to load the checked before-and-after goal states.
theorem numHeads_mul_succ_le {n : ℕ} (c : Fin n → Bool) : numHeads c * (numHeads c + 1) ≤ 2 * weightedSum c := by …Mentions: Imo2019P5.numHeads, Imo2019P5.weightedSum
- theorem
Imo2019P5.meas_defline 145 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Eq,Int, Imo2019P5.meas,HSub.hSub,HMul.hMul,OfNat.ofNat, Imo2019P5.weightedSum,HPow.hPow, Imo2019P5.numHeadsProof uses:
rfl12 instances, coercions and auxiliary constants left out.
- theorem
Imo2019P5.meas_nonnegline 148 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,LE.le,Int,OfNat.ofNat, Imo2019P5.measProof uses:
HMul.hMul, Imo2019P5.numHeads,HAdd.hAdd, Imo2019P5.weightedSum, Imo2019P5.numHeads_mul_succ_le,cast,Eq.symm,Eq.trans,congrFun',congrArg,Nat.cast_one,congr,Int.natCast_nonneg,id,le_of_not_gt,HSub.hSub,HPow.hPow,LT.lt,Mathlib.Tactic.Linarith.lt_irrefl,Eq.mpand 63 more82 instances, coercions and auxiliary constants left out.
Tactic trace: 6 steps
Open to load the checked before-and-after goal states.
- theorem
Imo2019P5.meas_ge_numHeadsline 156 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,LE.le,Int, Imo2019P5.numHeads, Imo2019P5.measProof uses:
HMul.hMul,HAdd.hAdd,OfNat.ofNat, Imo2019P5.weightedSum, Imo2019P5.numHeads_mul_succ_le,cast,Eq.symm,Eq.trans,congrFun',congrArg,Nat.cast_one,congr,id,le_of_not_gt,HSub.hSub,HPow.hPow,LT.lt,Mathlib.Tactic.Linarith.lt_irrefl,Eq.mp,Neg.negand 61 more83 instances, coercions and auxiliary constants left out.
Tactic trace: 5 steps
Open to load the checked before-and-after goal states.
- theorem
Imo2019P5.meas_eq_zero_iffline 163 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Iff,Eq,Int, Imo2019P5.meas,OfNat.ofNat, Imo2019P5.numHeadsProof uses:
Iff.intro,LE.le, Imo2019P5.meas_ge_numHeads,Int.natCast_nonneg,Mathlib.Tactic.Linarith.eq_of_not_lt_of_not_gt,Not.intro,LT.lt,Mathlib.Tactic.Linarith.lt_irrefl,Eq.mp,HAdd.hAdd,Neg.neg,HSub.hSub,congrArg,Mathlib.Tactic.Ring.of_eq,Mathlib.Tactic.Ring.Common.add_congr,Int.rawCast,inferInstance,Ring,Int.negOfNat,HMul.hMuland 79 more103 instances, coercions and auxiliary constants left out.
Tactic trace: 25 steps
Open to load the checked before-and-after goal states.
- theorem
Imo2019P5.numHeads_castThe number of heads as a sum of indicators, inℤline 187 sourceSource documentation
The number of heads as a sum of indicators, in
ℤ.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Eq,Int, Imo2019P5.numHeads,Finset.sum,Finset.univ,ite,Bool.true,OfNat.ofNatProof uses:
Finset.card_filter,cast,Eq.symm,Eq.trans,congrArg,Finset.sum_congr,Eq.refl,Finset,Membership.mem,ite_congr,Nat.cast_one,Not,Nat.cast_zero35 instances, coercions and auxiliary constants left out.
Tactic trace: 2 steps
Open to load the checked before-and-after goal states.
theorem numHeads_cast {n : ℕ} (c : Fin n → Bool) : (numHeads c : ℤ) = ∑ i : Fin n, (if c i then (1 : ℤ) else 0) := by …Mentions: Imo2019P5.numHeads
- theorem
Imo2019P5.weightedSum_castThe weighted sum as a sum over all positions, inℤline 194 sourceSource documentation
The weighted sum as a sum over all positions, in
ℤ.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Eq,Int, Imo2019P5.weightedSum,Finset.sum,Finset.univ,HMul.hMul,HAdd.hAdd,OfNat.ofNat,ite,Bool.trueProof uses:
Eq.mpr,id,congrArg,Imo2019P5.weightedSum.eq_1,Nat.cast_sum,Finset.sum_congr,rfl,Finset,Membership.mem,dite,of_eq_true,Eq.trans,True,congr,ite_eq_left_of_eq_true,congrFun',eq_self,mul_one,Nat.cast_add,Nat.cast_oneand 8 more54 instances, coercions and auxiliary constants left out.
Tactic trace: 5 steps
Open to load the checked before-and-after goal states.
theorem weightedSum_cast {n : ℕ} (c : Fin n → Bool) : (weightedSum c : ℤ) = ∑ i : Fin n, ((i : ℕ) + 1 : ℤ) * (if c i then (1 : ℤ) else 0) := by …Mentions: Imo2019P5.weightedSum
- theorem
Imo2019P5.headsZ_updateHow the head-count sum changes when coinpis flipped line 202 sourceSource documentation
How the head-count sum changes when coin
pis flipped.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Eq,Int,Finset.sum,Finset.univ,ite,Function.update,Bool.not,Bool.true,OfNat.ofNat,HAdd.hAdd,Neg.negProof uses:
funext,dite,of_eq_true,Eq.trans,True,congr,congrArg,ite_eq_right_of_eq_false,Bool.false,False,congrFun',Function.update_congr,Eq.refl,Bool.not_true,Function.update_self,Bool.false_eq_true,ite_eq_left_of_eq_true,eq_self,Not,idand 47 more51 instances, coercions and auxiliary constants left out.
Tactic trace: 17 steps
Open to load the checked before-and-after goal states.
theorem headsZ_update {n : ℕ} (c : Fin n → Bool) (p : Fin n) : ∑ i : Fin n, (if Function.update c p (!c p) i then (1 : ℤ) else 0) = (∑ i : Fin n, (if c i then (1 : ℤ) else 0)) + (if c p then (-1 : ℤ) else 1) := by … - theorem
Imo2019P5.weightedZ_updateHow the weighted sum changes when coinpis flipped line 220 sourceSource documentation
How the weighted sum changes when coin
pis flipped.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Eq,Int,Finset.sum,Finset.univ,HMul.hMul,HAdd.hAdd,OfNat.ofNat,ite,Function.update,Bool.not,Bool.true,Neg.negProof uses:
funext,dite,of_eq_true,Eq.trans,True,congr,congrArg,ite_eq_right_of_eq_false,Bool.false,False,congrFun',Function.update_congr,Eq.refl,Bool.not_true,Function.update_self,Bool.false_eq_true,MulZeroClass.mul_zero,mul_ite,ite_congr,mul_oneand 60 more64 instances, coercions and auxiliary constants left out.
Tactic trace: 17 steps
Open to load the checked before-and-after goal states.
theorem weightedZ_update {n : ℕ} (c : Fin n → Bool) (p : Fin n) : ∑ i : Fin n, ((i : ℕ) + 1 : ℤ) * (if Function.update c p (!c p) i then (1 : ℤ) else 0) = (∑ i : Fin n, ((i : ℕ) + 1 : ℤ) * (if c i then (1 : ℤ) else 0)) + ((p : ℕ) + 1 : ℤ) * (if c p then (-1 : ℤ) else 1) := by … - theorem
Imo2019P5.step_measThe measure drops by exactly one at each step line 240 sourceSource documentation
The measure drops by exactly one at each step.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Ne, Imo2019P5.numHeads,OfNat.ofNat,Eq,Int, Imo2019P5.meas, Imo2019P5.step,HSub.hSubProof uses:
Function.update, Imo2019P5.flipIx,Bool.not,id,Eq.mpr,dite,Not,congrArg,dite_eq_right,Eq.refl,rfl,HAdd.hAdd,LT.lt,Nat.pos_of_ne_zero,Finset.sum,Finset.univ,ite,Bool.true,Eq.symm, Imo2019P5.numHeads_cast and 89 more74 instances, coercions and auxiliary constants left out.
Tactic trace: 22 steps
Open to load the checked before-and-after goal states.
theorem step_meas {n : ℕ} (c : Fin n → Bool) (h : numHeads c ≠ 0) : meas (step c) = meas c - 1 := by …Mentions: h, Imo2019P5.numHeads, Imo2019P5.meas, Imo2019P5.step
- theorem
Imo2019P5.iter_measAftermsteps withm ≤ meas c, the measure has dropped by exactlymline 262 sourceSource documentation
After
msteps withm ≤ meas c, the measure has dropped by exactlym.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,LE.le,Int, Imo2019P5.meas,Eq,Nat.iterate, Imo2019P5.step,HSub.hSubProof uses:
Nat.recAux,OfNat.ofNat,of_eq_true,Eq.trans,True,congrArg,CharP.cast_eq_zero,sub_zero,eq_self,HAdd.hAdd,cast,Eq.symm,congrFun',Nat.cast_one,le_of_not_gt,LT.lt,Mathlib.Tactic.Linarith.lt_irrefl,Eq.mp,HMul.hMul,Neg.negand 63 more79 instances, coercions and auxiliary constants left out.
Tactic trace: 15 steps
Open to load the checked before-and-after goal states.
theorem iter_meas {n : ℕ} (c : Fin n → Bool) (m : ℕ) (hm : (m : ℤ) ≤ meas c) : meas (step^[m] c) = meas c - (m : ℤ) := by …Mentions: Imo2019P5.meas, Imo2019P5.step
- theorem
Imo2019P5.iterate_LThe process fromcstops after exactlyL csteps in the all-tails configuration line 281 sourceSource documentation
The process from
cstops after exactlyL csteps in the all-tails configuration.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Eq,Nat.iterate, Imo2019P5.step, Imo2019P5.L,Bool.falseProof uses:
Int, Imo2019P5.meas,Int.toNat_of_nonneg, Imo2019P5.meas_nonneg,HSub.hSub, Imo2019P5.iter_meas,le_of_eq,OfNat.ofNat,Eq.mpr,id,congrArg,Eq.mp,Mathlib.Tactic.Ring.of_eq,Mathlib.Tactic.Ring.Common.sub_congr,HAdd.hAdd,HMul.hMul,HPow.hPow,Nat.rawCast,Mathlib.Tactic.Ring.Common.atom_pf,rfland 46 more41 instances, coercions and auxiliary constants left out.
Tactic trace: 17 steps
Open to load the checked before-and-after goal states.
theorem iterate_L {n : ℕ} (c : Fin n → Bool) : step^[L c] c = fun _ ↦ false := by …Mentions: Imo2019P5.step, Imo2019P5.L
- theorem
Imo2019P5.not_iterate_lt_LBefore stepL c, the process has not stopped yet line 298 sourceSource documentation
Before step
L c, the process has not stopped yet.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,LT.lt, Imo2019P5.L,Ne,Nat.iterate, Imo2019P5.step,Bool.falseProof uses:
Eq,Int, Imo2019P5.meas,Int.toNat_of_nonneg, Imo2019P5.meas_nonneg,LE.le,cast,Eq.symm,le_of_not_gt,Mathlib.Tactic.Linarith.lt_irrefl,OfNat.ofNat,Eq.mp,HAdd.hAdd,HMul.hMul,Neg.neg,HSub.hSub,congrArg,Mathlib.Tactic.Ring.of_eq,Mathlib.Tactic.Ring.Common.add_congr,Int.rawCastand 75 more80 instances, coercions and auxiliary constants left out.
Tactic trace: 25 steps
Open to load the checked before-and-after goal states.
theorem not_iterate_lt_L {n : ℕ} (c : Fin n → Bool) {m : ℕ} (hm : m < L c) : step^[m] c ≠ fun _ ↦ false := by …Mentions: Imo2019P5.L, Imo2019P5.step
- theorem
Imo2019P5.card_filter_true_eq_card_filter_falseConfigurations with a head at positioniare in bijection with those with a tail at positioni, by flipping coiniline 324 sourceSource documentation
Configurations with a head at position
iare in bijection with those with a tail at positioni, by flipping coini.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Eq,Finset.card,Bool,Finset.filter,Bool.true,Finset.univ,Bool.falseProof uses:
Finset.card_bij',Membership.mem,Finset,Function.update,Bool.not,Iff.mpr,And,Finset.mem_filter,And.intro,Finset.mem_univ,And.right,Iff.mp,of_eq_true,Eq.trans,True,congrFun',congrArg,Function.update_congr,Eq.refl,Bool.not_trueand 9 more13 instances, coercions and auxiliary constants left out.
Tactic trace: 13 steps
Open to load the checked before-and-after goal states.
theorem card_filter_true_eq_card_filter_false {n : ℕ} (i : Fin n) : (univ.filter fun c : Fin n → Bool ↦ c i = true).card = (univ.filter fun c : Fin n → Bool ↦ c i = false).card := by … - theorem
Imo2019P5.card_filter_trueExactly half of all2 ^ nconfigurations have a head at positioniline 348 sourceSource documentation
Exactly half of all
2 ^ nconfigurations have a head at positioni.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,OfNat.ofNat,Fin,Eq,Finset.card,Bool,Finset.filter,Bool.true,Finset.univ,HPow.hPow,HSub.hSubProof uses:
Bool.false, Imo2019P5.card_filter_true_eq_card_filter_false,HAdd.hAdd,Not,Finset.card_filter_add_card_filter_not,Finset,Finset.ext,Eq.mpr,Iff,Membership.mem,id,congr,congrArg,Eq.trans,And,True,congrFun',true_and,of_eq_true,Falseand 23 more53 instances, coercions and auxiliary constants left out.
Tactic trace: 24 steps
Open to load the checked before-and-after goal states.
theorem card_filter_true {n : ℕ} (hn : 0 < n) (i : Fin n) : (univ.filter fun c : Fin n → Bool ↦ c i = true).card = 2 ^ (n - 1) := by … - theorem
Imo2019P5.two_mul_card_filter_pairTwice the number of configurations with heads at bothiandjequals2 ^ (n - 1)line 376 sourceSource documentation
Twice the number of configurations with heads at both
iandjequals2 ^ (n - 1).standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,OfNat.ofNat,Fin,Ne,Eq,HMul.hMul,Finset.card,Bool,Finset.filter,And,Bool.true,Finset.univ,HPow.hPow,HSub.hSubProof uses:
Bool.false,Finset.card_bij',Membership.mem,Finset,Function.update,Bool.not,Iff.mpr,Finset.mem_filter,And.intro,Finset.mem_univ,And.right,Iff.mp,Eq.mpr,id,congrArg,Function.update_of_ne,And.left,of_eq_true,Eq.trans,Trueand 31 more43 instances, coercions and auxiliary constants left out.
Tactic trace: 38 steps
Open to load the checked before-and-after goal states.
theorem two_mul_card_filter_pair {n : ℕ} (hn : 0 < n) {i j : Fin n} (hij : i ≠ j) : 2 * (univ.filter fun c : Fin n → Bool ↦ c i = true ∧ c j = true).card = 2 ^ (n - 1) := by … - theorem
Imo2019P5.card_filter_pairThe number of configurations with heads at bothiandjis2 ^ (n - 2)line 423 sourceSource documentation
The number of configurations with heads at both
iandjis2 ^ (n - 2).standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,OfNat.ofNat,Fin,Ne,Eq,Finset.card,Bool,Finset.filter,And,Bool.true,Finset.univ,HPow.hPow,HSub.hSubProof uses:
HMul.hMul, Imo2019P5.two_mul_card_filter_pair,LE.le,Iff.mp,Nontrivial,Fin.nontrivial_iff_two_le,nontrivial_of_ne,HAdd.hAdd,Eq.mpr,id,congrArg,pow_succ,mul_comm,Nat.mul_left_cancel,Mathlib.Meta.NormNum.isNat_lt_true,Mathlib.Meta.NormNum.isNat_ofNat,Eq.refl,Bool.false,Eq.mp48 instances, coercions and auxiliary constants left out.
Tactic trace: 10 steps
Open to load the checked before-and-after goal states.
theorem card_filter_pair {n : ℕ} (hn : 0 < n) {i j : Fin n} (hij : i ≠ j) : (univ.filter fun c : Fin n → Bool ↦ c i = true ∧ c j = true).card = 2 ^ (n - 2) := by … - theorem
Imo2019P5.sum_indicatorThe sum of the indicator of heads at positioniover all configurations line 435 sourceSource documentation
The sum of the indicator of heads at position
iover all configurations.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,OfNat.ofNat,Fin,Eq,Int,Finset.sum,Bool,Finset.univ,ite,Bool.true,HPow.hPow,HSub.hSubProof uses:
Finset.card,Finset.filter, Imo2019P5.card_filter_true,Finset.card_filter,cast,Eq.symm,Eq.trans,congrFun',congrArg,Finset.sum_congr,Eq.refl,Finset,Membership.mem,ite_congr,Nat.cast_one,Not,Nat.cast_zero,congr,Eq.mp56 instances, coercions and auxiliary constants left out.
Tactic trace: 4 steps
Open to load the checked before-and-after goal states.
theorem sum_indicator {n : ℕ} (hn : 0 < n) (i : Fin n) : ∑ c : Fin n → Bool, (if c i then (1 : ℤ) else 0) = 2 ^ (n - 1) := by … - theorem
Imo2019P5.sum_four_LThe total ofLover all configurations is2 ^ n * n * (n + 1) / 4; we prove four times that value to stay inℤline 444 sourceSource documentation
The total of
Lover all configurations is2 ^ n * n * (n + 1) / 4; we prove four times that value to stay inℤ.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,OfNat.ofNat,Eq,Int,HMul.hMul,Finset.sum,Fin,Bool,Finset.univ, Imo2019P5.L,HPow.hPow,HAdd.hAddProof uses:
ite,Bool.true,HSub.hSub, Imo2019P5.sum_indicator,rfl,Eq.mpr,id,congrArg,Finset.sum_add_distrib,of_eq_true,Eq.trans,True,congrFun',HSMul.hSMul,Finset.card,Finset.sum_const,Fintype.card_fin,mul_one,eq_self,Finset.rangeand 154 more170 instances, coercions and auxiliary constants left out.
Tactic trace: 103 steps
Open to load the checked before-and-after goal states.
theorem sum_four_L {n : ℕ} (hn : 0 < n) : 4 * ∑ c : Fin n → Bool, (L c : ℤ) = 2 ^ n * n * (n + 1) := by …Mentions: Imo2019P5.L
- determine
Imo2019P5.averageStepsThe average number of steps over all2 ^ ninitial configurations line 584 sourceSource documentation
The average number of steps over all
2 ^ ninitial configurations.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,RatProof uses:
HDiv.hDiv,HMul.hMul,HAdd.hAdd,OfNat.ofNat9 instances, coercions and auxiliary constants left out.
determine averageSteps (n : ℕ) : ℚ := n * (n + 1) / 4
- problem
Imo2019P5.imo2019_p5_partaPart (a): the process always terminates line 587 sourceSource documentation
Part (a): the process always terminates.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Exists,Eq,Nat.iterate, Imo2019P5.step,Bool.falseProof uses:
Exists.intro, Imo2019P5.L, Imo2019P5.iterate_Lproblem imo2019_p5_parta (n : ℕ) (c : Fin n → Bool) : ∃ m : ℕ, step^[m] c = fun _ ↦ false := …Mentions: Imo2019P5.step
- problem
Imo2019P5.imo2019_p5_partb_definitionPart (b): The number of steps that Harry's process takes starting from configurationcis L line 593 sourceSource documentation
Part (b): The number of steps that Harry's process takes starting from configuration
cis Lstandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,IsLeast,Set.ofPred,Eq,Nat.iterate, Imo2019P5.step,Bool.false, Imo2019P5.LProof uses:
id,And.intro,Membership.mem,Set,lowerBounds, Imo2019P5.iterate_L,Eq.mpr,LE.le,congrArg,propext,mem_lowerBounds,Mathlib.Tactic.Contrapose.contrapose₁,Not,LT.lt,implies_congr,Eq.refl, Imo2019P5.not_iterate_lt_L10 instances, coercions and auxiliary constants left out.
Tactic trace: 9 steps
Open to load the checked before-and-after goal states.
problem imo2019_p5_partb_definition (n : ℕ) (c : Fin n → Bool) : IsLeast {m : ℕ| step^[m] c = fun _ ↦ false} (L c) := by …Mentions: Imo2019P5.step, Imo2019P5.L
- problem
Imo2019P5.imo2019_p5_partbPart (b): the average number of steps over all2 ^ nconfigurations isn * (n + 1) / 4line 605 sourceSource documentation
Part (b): the average number of steps over all
2 ^ nconfigurations isn * (n + 1) / 4.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,OfNat.ofNat,Eq,Rat,HDiv.hDiv,Finset.sum,Fin,Bool,Finset.univ, Imo2019P5.L,HPow.hPow, Imo2019P5.averageStepsProof uses:
Int,HMul.hMul,HAdd.hAdd, Imo2019P5.sum_four_L,cast,Eq.trans,congrArg,Eq.symm,Nat.cast_one,congr,congrFun',id,Ne,ne_of_gt,pow_pos,Mathlib.Meta.Positivity.pos_of_isNat,Mathlib.Meta.NormNum.isNat_ofNat,Eq.refl,Nat.ble,Eq.mprand 84 more132 instances, coercions and auxiliary constants left out.
Tactic trace: 8 steps
Open to load the checked before-and-after goal states.
problem imo2019_p5_partb (n : ℕ) (hn : 0 < n) : (∑ c : Fin n → Bool, (L c : ℚ)) / 2 ^ n = averageSteps n := by …Mentions: Imo2019P5.L, Imo2019P5.averageSteps