Compfiles/Usa2011P2.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
11 declarations, 0 contain sorry, 0 declared as axioms
USA Mathematical Olympiad 2011, Problem 2
An integer is assigned to each vertex of a regular pentagon so that the sum of the five integers is 2011. A turn of a solitaire game consists of subtracting an integer m (not necessarily positive) from each of the integers at two neighboring vertices and adding 2m to the opposite vertex, which is not adjacent to either of the first two vertices. (The amount m and the vertices chosen can vary from turn to turn.) The game is won at a certain vertex if, after some number of turns, that vertex has the number 2011 and the other four vertices have the number 0. Prove that for any choice of the initial integers, there is exactly one vertex at which the game can be won.
Imports (5)
Imported by 1 file
- abbrev
Usa2011P2.ConfigA configuration of the game: an integer at each vertex of the pentagon line 38 sourceSource documentation
A configuration of the game: an integer at each vertex of the pentagon. The vertices are indexed by
ZMod 5, so that the neighbors of vertexiarei - 1andi + 1.no axioms what this means
Proof uses:
ZMod,OfNat.ofNat,Nat,Int1 instances, coercions and auxiliary constants left out.
abbrev Config := ZMod 5 → ℤ
- def
Usa2011P2.ReachableReachability of configurations line 48 sourceSource documentation
Reachability of configurations. A turn at the edge
i, i + 1with amountmsubtractsmfrom the values at the verticesiandi + 1and adds2 * mto the value at the opposite vertexi + 3(the unique vertex adjacent to neither of them). The effects of successive turns add up, so a sequence of turns is described by integersx j, the sum of the amounts of the turns whose opposite vertex isj. Such a turn has edgej + 2, j + 3, hence vertexigains2 * x iin total and losesx (i + 2) + x (i + 3). Conversely any choice ofxis realized by doing one turn per edge.standard axioms: Quot.sound, propext what this means
Statement uses: Usa2011P2.Config
Proof uses:
Exists,ZMod,OfNat.ofNat,Nat,Int,Eq,HSub.hSub,HAdd.hAdd,HMul.hMul20 instances, coercions and auxiliary constants left out.
def Reachable (a b : Config) : Prop := …
Mentions: Usa2011P2.Config
- def
Usa2011P2.WinAtThe game is won at vertexvfrom the configurationaif the configuration with value 2011 atvand 0 at the other four vertices is reachable fromaline 54 sourceSource documentation
The game is won at vertex
vfrom the configurationaif the configuration with value 2011 atvand 0 at the other four vertices is reachable froma.standard axioms: Quot.sound, propext what this means
Statement uses: Usa2011P2.Config,
ZMod,OfNat.ofNat,NatProof uses: Usa2011P2.Reachable,
Pi.single,Int7 instances, coercions and auxiliary constants left out.
def WinAt (a : Config) (v : ZMod 5) : Prop := …
Mentions: Usa2011P2.Config
- def
Usa2011P2.invariantThe invariant of the game: the weighted sum of the values, where the value at vertexihas weightiline 59 sourceSource documentation
The invariant of the game: the weighted sum of the values, where the value at vertex
ihas weighti. A turn changes it by a multiple of 5.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: Usa2011P2.Config,
ZMod,OfNat.ofNat,NatProof uses:
Finset.sum,Finset.univ,HMul.hMul15 instances, coercions and auxiliary constants left out.
def invariant (a : Config) : ZMod 5 := ∑ i, i * (a i : ZMod 5) …
Mentions: Usa2011P2.Config
- lemma
Usa2011P2.zmod5_sumline 68 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
AddCommMonoid,ZMod,OfNat.ofNat,Nat,Eq,Finset.sum,Finset.univ,HAdd.hAddProof uses:
Fin.sum_univ_five22 instances, coercions and auxiliary constants left out.
- lemma
Usa2011P2.zmod5_casesline 71 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
ZMod,OfNat.ofNat,Nat,Or,EqProof uses:
of_decide_eq_true,id,Bool,Decidable.decide,Bool.true,Eq.refl36 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2011P2.key_identityThe key identity behind the invariance ofinvariant: the weight of a turn at edgei, i + 1isi + (i + 1) = 2 * (i + 3) - 5line 76 sourceSource documentation
The key identity behind the invariance of
invariant: the weight of a turn at edgei, i + 1isi + (i + 1) = 2 * (i + 3) - 5.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
ZMod,OfNat.ofNat,Nat,Eq,Finset.sum,Finset.univ,HMul.hMul,HSub.hSub,HAdd.hAddProof uses:
Fintype.sum_equiv,Equiv.addRight,id,Equiv,Eq.mpr,congrArg,add_sub_cancel_right,Eq.refl,Trans.trans,Eq.symm,Finset.sum_sub_distrib,Finset.sum_congr,rfl,Finset,Membership.mem,Mathlib.Tactic.Ring.of_eq,HPow.hPow,Nat.rawCast,Int.rawCast,inferInstanceand 47 more85 instances, coercions and auxiliary constants left out.
Tactic trace: 22 steps
Open to load the checked before-and-after goal states.
lemma key_identity (X : ZMod 5 → ZMod 5) : (∑ i, i * (2 * X i - X (i + 2) - X (i + 3))) = 0 := by … - lemma
Usa2011P2.invariant_eq_of_reachableThe invariant is preserved by any sequence of turns line 102 sourceSource documentation
The invariant is preserved by any sequence of turns.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: Usa2011P2.Config, Usa2011P2.Reachable,
Eq,ZMod,OfNat.ofNat,Nat, Usa2011P2.invariantProof uses:
Int,HSub.hSub,HAdd.hAdd,HMul.hMul,Finset.sum,Finset.univ,Eq.mpr,id,congrArg,Eq.symm,Finset.sum_add_distrib,Finset.sum_congr,rfl,Finset,Membership.mem,congrFun',Eq.trans,Int.cast_sub,Int.cast_add,Int.cast_muland 41 more68 instances, coercions and auxiliary constants left out.
Tactic trace: 10 steps
Open to load the checked before-and-after goal states.
lemma invariant_eq_of_reachable {a b : Config} (h : Reachable a b) : invariant b = invariant a := by …Mentions: Usa2011P2.Config, h, Usa2011P2.Reachable, Usa2011P2.invariant
- lemma
Usa2011P2.invariant_singleThe invariant of the configuration won at vertexv; since2011 ≡ 1 (mod 5), it equalsvline 120 sourceSource documentation
The invariant of the configuration won at vertex
v; since2011 ≡ 1 (mod 5), it equalsv.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
ZMod,OfNat.ofNat,Nat,Eq, Usa2011P2.invariant,Pi.single,IntProof uses:
id,Eq.mpr,Finset.sum,Finset.univ,HMul.hMul,congrArg,Finset.sum_eq_single,Membership.mem,Finset,Ne,Pi.single_eq_of_ne,Int.cast_zero,MulZeroClass.mul_zero,Eq.refl,Not,absurd,Finset.mem_univ,Pi.single_eq_same,of_decide_eq_true,Booland 3 more47 instances, coercions and auxiliary constants left out.
Tactic trace: 11 steps
Open to load the checked before-and-after goal states.
lemma invariant_single (v : ZMod 5) : invariant (Pi.single v 2011) = v := by …
Mentions: Usa2011P2.invariant
- lemma
Usa2011P2.win_at_zeroThe core existence lemma: a configuration with sum 2011 and vanishing invariant can be won at vertex 0 line 134 sourceSource documentation
The core existence lemma: a configuration with sum 2011 and vanishing invariant can be won at vertex 0. With
kgiven bya 1 + 2 * a 2 + 3 * a 3 + 4 * a 4 = 5 * k, the explicit solution isx 0 = 0,x 1 = -k - a 1,x 2 = -2 * k + a 3 + a 4,x 3 = -3 * k + a 2 + a 3 + 2 * a 4,x 4 = -4 * k + a 2 + 2 * a 3 + 2 * a 4.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: Usa2011P2.Config,
Eq,Int,Finset.sum,ZMod,OfNat.ofNat,Nat,Finset.univ, Usa2011P2.invariant, Usa2011P2.WinAtProof uses:
Dvd.dvd,HAdd.hAdd,HMul.hMul,Eq.mpr,id,congrFun',congrArg,Eq.trans,Int.cast_add,congr,Int.cast_mul,Int.cast_ofNat,Mathlib.Tactic.LinearCombination.eq_of_eq,Eq.mp, Usa2011P2.zmod5_sum,Mathlib.Tactic.LinearCombination.eq_rearrange,Mathlib.Tactic.Ring.of_eq,HSub.hSub,Mathlib.Tactic.Ring.Common.sub_congr,HPow.hPowand 49 more94 instances, coercions and auxiliary constants left out.
Tactic trace: 27 steps
Open to load the checked before-and-after goal states.
lemma win_at_zero (a : Config) (hsum : ∑ i, a i = 2011) (hinv : invariant a = 0) : WinAt a 0 := by …Mentions: Usa2011P2.Config, Usa2011P2.invariant, Usa2011P2.WinAt
- problem
Usa2011P2.usa2011_p2line 169 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses: Usa2011P2.Config,
Eq,Int,Finset.sum,ZMod,OfNat.ofNat,Nat,Finset.univ,ExistsUnique, Usa2011P2.WinAtProof uses:
Exists.intro,And, Usa2011P2.invariant,And.intro,HAdd.hAdd,Fintype.sum_equiv,Equiv.addRight,rfl,Eq.mp,congrArg,HMul.hMul,HSub.hSub,id,Equiv,Eq.mpr,add_sub_cancel_right,Eq.refl,Finset.mul_sum,Eq.symm,Finset.sum_sub_distriband 60 more91 instances, coercions and auxiliary constants left out.
Tactic trace: 44 steps
Open to load the checked before-and-after goal states.