Compfiles/Imo2021P5.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
16 declarations, 0 contain sorry, 0 declared as axioms
International Mathematical Olympiad 2021, Problem 5
Two squirrels, Bushy and Jumpy, have collected 2001 walnuts for winter. Jumpy numbers the walnuts from 1 to 2021, and digs 2021 little holes in a circular pattern around their favorite tree. The next morning, Jumpy notices that Bushy had placed one walnut into each hole, but had paid no attention to the numbering. Unhappy, Jumpy decides to reorder the walnuts by performing a sequence of 2021 moves. In the kth move, Jump swaps the positions of the two walnuts adjacent to walnut k.
Prove that there exists a value of k such that, on the kth move, Jumpy swaps some walnuts a and b such that a < k < b.
Imports (4)
Imported by 1 file
- abbrev
Imo2021P5.PositionThe arrangement of walnuts, as an equiv from holes to walnuts (0-based) line 39 sourceSource documentation
The arrangement of walnuts, as an equiv from holes to walnuts (0-based).
no axioms what this means
Proof uses:
Equiv,Fin,OfNat.ofNat,Nat1 instances, coercions and auxiliary constants left out.
abbrev Position : Type := Fin 2021 ≃ Fin 2021
- def
Imo2021P5.Position.swappedThe numbers of the walnuts swapped in movek(0-based), given the position line 42 sourceSource documentation
The numbers of the walnuts swapped in move
k(0-based), given the position.standard axioms: Quot.sound, propext what this means
Statement uses: Imo2021P5.Position,
Fin,OfNat.ofNat,Nat,ProdProof uses:
Prod.mk,HSub.hSub,Equiv,Equiv.symm,HAdd.hAdd11 instances, coercions and auxiliary constants left out.
def Position.swapped (p : Position) (k : Fin 2021) : Fin 2021 × Fin 2021 := …
Mentions: Imo2021P5.Position
- def
Imo2021P5.moveA single move, on a pair of position and move number line 46 sourceSource documentation
A single move, on a pair of position and move number.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Prod, Imo2021P5.Position,Fin,OfNat.ofNat,NatProof uses:
Prod.mk,Equiv.trans,Prod.fst,Equiv.swap, Imo2021P5.Position.swapped,Prod.snd,HAdd.hAdd7 instances, coercions and auxiliary constants left out.
def move (p : Position × Fin 2021) : Position × Fin 2021 := …
Mentions: Imo2021P5.Position
- def
Imo2021P5.Position.nthThe position afternmoves line 50 sourceSource documentation
The position after
nmoves.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: Imo2021P5.Position,
Fin,OfNat.ofNat,NatProof uses:
Prod.fst,Nat.iterate,Prod, Imo2021P5.move,Prod.mk5 instances, coercions and auxiliary constants left out.
def Position.nth (p : Position) (n : Fin 2021) : Position := (move^[n] (p, 0)).1 …
Mentions: Imo2021P5.Position, Imo2021P5.move
- def
Imo2021P5.coloringAfterjmoves, color holexred iff the walnut in it has number< j; otherwise the hole is black line 56 sourceSource documentation
After
jmoves, color holexred iff the walnut in it has number< j; otherwise the hole is black.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: Imo2021P5.Position,
Nat,Fin,OfNat.ofNat,BoolProof uses:
Decidable.decide,LT.lt,Prod.fst,Nat.iterate,Prod, Imo2021P5.move,Prod.mk10 instances, coercions and auxiliary constants left out.
def coloring (p : Position) (j : ℕ) (x : Fin 2021) : Bool := …
Mentions: Imo2021P5.Position
- def
Imo2021P5.blackPairsThe number (mod 2) of adjacent pairs of holes that are both black line 60 sourceSource documentation
The number (mod 2) of adjacent pairs of holes that are both black.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Fin,OfNat.ofNat,Nat,Bool,ZModProof uses:
Finset.sum,Finset.univ,HMul.hMul,cond,HAdd.hAdd25 instances, coercions and auxiliary constants left out.
def blackPairs (c : Fin 2021 → Bool) : ZMod 2 := …
- theorem
Imo2021P5.fin_val_oneline 63 sourcestandard axioms: propext what this means
Statement uses:
Eq,Nat,OfNat.ofNat,FinProof uses:
rfl8 instances, coercions and auxiliary constants left out.
- theorem
Imo2021P5.fin_sub_one_add_oneline 65 sourcestandard axioms: Quot.sound, propext what this means
Statement uses:
Fin,OfNat.ofNat,Nat,Eq,HAdd.hAdd,HSub.hSubProof uses:
sub_add_cancel12 instances, coercions and auxiliary constants left out.
- theorem
Imo2021P5.fin_sub_one_ne_selfline 67 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Fin,OfNat.ofNat,Nat,Ne,HSub.hSubProof uses:
Eq,congrArg12 instances, coercions and auxiliary constants left out.
Tactic trace: 4 steps
Open to load the checked before-and-after goal states.
- theorem
Imo2021P5.fin_add_one_ne_selfline 73 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Fin,OfNat.ofNat,Nat,Ne,HAdd.hAddProof uses:
Eq,congrArg12 instances, coercions and auxiliary constants left out.
Tactic trace: 4 steps
Open to load the checked before-and-after goal states.
- theorem
Imo2021P5.fin_sub_one_ne_add_oneline 79 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Fin,OfNat.ofNat,Nat,Ne,HSub.hSub,HAdd.hAddProof uses:
Eq,congrArg16 instances, coercions and auxiliary constants left out.
Tactic trace: 4 steps
Open to load the checked before-and-after goal states.
- theorem
Imo2021P5.iterate_sndThe second component of the iterated move state is the move number line 86 sourceSource documentation
The second component of the iterated move state is the move number.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: Imo2021P5.Position,
Nat,Eq,OfNat.ofNat,Prod.snd,Fin,Nat.iterate,Prod, Imo2021P5.move,Prod.mk,HMod.hModProof uses:
Nat.recAux,Eq.refl,Eq.mpr,HAdd.hAdd,id,congrArg,Nat.succ,Function.iterate_succ_apply',Fin.val_add, Imo2021P5.fin_val_one16 instances, coercions and auxiliary constants left out.
Tactic trace: 8 steps
Open to load the checked before-and-after goal states.
theorem iterate_snd (p : Position) (j : ℕ) : ((move^[j] (p, 0)).2).val = j % 2021 := by …
Mentions: Imo2021P5.Position, Imo2021P5.move
- theorem
Imo2021P5.iterate_fst_succOne step of the move process on the position component line 95 sourceSource documentation
One step of the move process on the position component.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: Imo2021P5.Position,
Nat,LT.lt,OfNat.ofNat,Eq,Prod.fst,Fin,Nat.iterate,Prod, Imo2021P5.move,HAdd.hAdd,Prod.mk,Equiv.trans,Equiv.swap,HSub.hSub,Equiv,Equiv.symm,Fin.mkProof uses:
Prod.snd,Fin.ext,Eq.mpr,HMod.hMod,id,congrArg, Imo2021P5.iterate_snd,Nat.mod_eq_of_lt,Nat.succ,Function.iterate_succ_apply',Eq.rec,Eq.refl,Eq.trans,Prod.ext,rfl29 instances, coercions and auxiliary constants left out.
Tactic trace: 6 steps
Open to load the checked before-and-after goal states.
theorem iterate_fst_succ (p : Position) (j : ℕ) (hj : j < 2021) : (move^[j + 1] (p, 0)).1 = (move^[j] (p, 0)).1.trans (Equiv.swap ((move^[j] (p, 0)).1 ((move^[j] (p, 0)).1.symm ⟨j, hj⟩ - 1)) ((move^[j] (p, 0)).1 ((move^[j] (p, 0)).1.symm ⟨j, hj⟩ + 1))) := by …Mentions: Imo2021P5.Position, Imo2021P5.move
- theorem
Imo2021P5.blackPairs_updateFlipping one black hole to red, where the two neighbors have the same color, does not change the number of black-black adjacent pairs, mod 2 line 108 sourceSource documentation
Flipping one black hole to red, where the two neighbors have the same color, does not change the number of black-black adjacent pairs, mod 2.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Fin,OfNat.ofNat,Nat,Bool,Eq,Bool.false,HSub.hSub,HAdd.hAdd,Ne,ZMod, Imo2021P5.blackPairs,Function.update,Bool.trueProof uses:
id,Eq.mpr,Finset.sum,Finset.univ,HMul.hMul,cond,congrArg,Eq.symm,propext,sub_eq_zero,Finset.sum_sub_distrib,Insert.insert,Finset,Singleton.singleton,Finset.sum_subset,Finset.subset_univ,Membership.mem,Not,And.left,Eq.mpand 33 more68 instances, coercions and auxiliary constants left out.
Tactic trace: 24 steps
Open to load the checked before-and-after goal states.
theorem blackPairs_update (c : Fin 2021 → Bool) (h : Fin 2021) (hh : c h = false) (hn : c (h - 1) = c (h + 1)) (h1 : h - 1 ≠ h) (h2 : h + 1 ≠ h) : blackPairs (Function.update c h true) = blackPairs c := by …Mentions: h, Imo2021P5.blackPairs
- theorem
Imo2021P5.coloring_succDocumented declaration: coloring_succ line 143 sourceSource documentation
If there is no good move, then after move
jthe coloring is the previous coloring with the hole of walnutjflipped from black to red, and the two neighbors of that hole have the same color.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: Imo2021P5.Position,
Nat,LT.lt,OfNat.ofNat,Fin,Not,Or,And,Prod.fst, Imo2021P5.Position.swapped, Imo2021P5.Position.nth,Prod.snd,Eq,Bool, Imo2021P5.coloring,HAdd.hAdd,Function.update,Equiv,Equiv.symm,Nat.iterateand 7 moreProof uses:
Eq.mpr,id,congrArg,rfl,Equiv.trans,Equiv.swap, Imo2021P5.iterate_fst_succ,Eq.mp,Eq.symm,Eq.refl,Equiv.apply_symm_apply,Ne, Imo2021P5.fin_sub_one_ne_self, Imo2021P5.fin_add_one_ne_self, Imo2021P5.fin_sub_one_ne_add_one,Equiv.injective,Iff,Fin.ext,Eq.trans,congrand 17 more39 instances, coercions and auxiliary constants left out.
Tactic trace: 84 steps
Open to load the checked before-and-after goal states.
theorem coloring_succ (p : Position) (j : ℕ) (hj : j < 2021) (H : ∀ k : Fin 2021, ¬((((p.nth k).swapped k).1 < k ∧ k < ((p.nth k).swapped k).2) ∨ (((p.nth k).swapped k).2 < k ∧ k < ((p.nth k).swapped k).1))) : (∀ x, coloring p (j + 1) x = Function.update (coloring p j) ((move^[j] (p, 0)).1.symm ⟨j, hj⟩) true x) ∧ coloring p j ((move^[j] (p, 0)).1.symm ⟨j, hj⟩) = false ∧ coloring p j ((move^[j] (p, 0)).1.symm ⟨j, hj⟩ - 1) = coloring p j ((move^[j] (p, 0)).1.symm ⟨j, hj⟩ + 1) := by …Mentions: Imo2021P5.Position, Imo2021P5.coloring, Imo2021P5.move
- problem
Imo2021P5.imo2021_p5line 225 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: Imo2021P5.Position,
Exists,Fin,OfNat.ofNat,Nat,Or,And,LT.lt,Prod.fst, Imo2021P5.Position.swapped, Imo2021P5.Position.nth,Prod.sndProof uses:
Decidable.byContradiction,Not,Exists.intro,Eq,ZMod, Imo2021P5.blackPairs, Imo2021P5.coloring,HAdd.hAdd,Bool,Function.update,Equiv,Equiv.symm,Nat.iterate,Prod, Imo2021P5.move,Prod.mk,Fin.mk,Bool.true,Bool.false,HSub.hSuband 47 more75 instances, coercions and auxiliary constants left out.
Tactic trace: 30 steps
Open to load the checked before-and-after goal states.