Compfiles/Usa2003P3.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
21 declarations, 0 contain sorry, 0 declared as axioms
USA Mathematical Olympiad 2003, Problem 3
Let n be a positive integer. For every sequence of integers A = (a₀, a₁, a₂, . . . , aₙ) satisfying 0 ≤ aᵢ ≤ i, for i = 0, . . . , n, we define another sequence t(A) = (t(a₀), t(a₁), t(a₂), . . . , t(aₙ)) by setting t(aᵢ) to be the number of terms in the sequence A that precede the term aᵢ and are different from aᵢ. Show that, starting from any sequence A as above, fewer than n applications of the transformation t lead to a sequence B such that t(B) = B.
Imported by 1 file
- def
Usa2003P3.tThe transformationt:t a iis the number of terms ofathat precede thei-th term and are different from it line 39 sourceSource documentation
The transformation
t:t a iis the number of terms ofathat precede thei-th term and are different from it.We model the sequence
A = (a₀, a₁, …, aₙ)as a functionℕ → ℕwhere only the values at0, 1, …, nare constrained. The problem prescribes integer values, but the constraint0 ≤ aᵢallows us to work with natural numbers throughout.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
NatProof uses:
Finset.card,Finset.filter,Ne,Eq,Finset.range2 instances, coercions and auxiliary constants left out.
def t (a : ℕ → ℕ) : ℕ → ℕ := …
- lemma
Usa2003P3.t_defline 57 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq, Usa2003P3.t,Finset.card,Finset.filter,Ne,Finset.rangeProof uses:
rfl2 instances, coercions and auxiliary constants left out.
- lemma
Usa2003P3.t_zeroline 60 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq, Usa2003P3.t,OfNat.ofNatProof uses:
Eq.mpr,Finset.card,Finset.filter,Ne,Finset.range,id,congrArg, Usa2003P3.t_def,EmptyCollection.emptyCollection,Finset,Finset.range_zero,Finset.filter_empty,Finset.card_empty,Eq.refl5 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2003P3.t_leline 63 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le, Usa2003P3.tProof uses:
Eq.mpr,Finset.card,Finset.filter,Ne,Eq,Finset.range,id,congrArg, Usa2003P3.t_def,le_trans,Finset.card_filter_le,Eq.le,Finset.card_range5 instances, coercions and auxiliary constants left out.
Tactic trace: 2 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2003P3.t_eq_zero_ofline 67 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,Eq, Usa2003P3.t,OfNat.ofNatProof uses:
Finset,Finset.filter,Ne,Finset.range,EmptyCollection.emptyCollection,Eq.mpr,Membership.mem,Not,id,congrArg,propext,Finset.filter_eq_empty_iff,of_eq_true,Eq.trans,False,True,congrFun',Eq.mp,Finset.mem_range,eq_selfand 6 more9 instances, coercions and auxiliary constants left out.
Tactic trace: 6 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2003P3.one_le_t_ofline 75 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,Ne,LE.le,OfNat.ofNat, Usa2003P3.tProof uses:
Eq.mpr,Finset.card,Finset.filter,Eq,Finset.range,id,congrArg, Usa2003P3.t_def,Iff.mpr,Finset.Nonempty,Finset.card_pos,Exists,And,Membership.mem,Finset,propext,Finset.filter_nonempty_iff,Exists.intro,And.intro,Finset.mem_range10 instances, coercions and auxiliary constants left out.
Tactic trace: 4 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2003P3.le_tIfais admissible at positioni, thena i ≤ t a iline 82 sourceSource documentation
If
ais admissible at positioni, thena i ≤ t a i.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le, Usa2003P3.tProof uses:
Eq.mpr,Finset.card,Finset.filter,Ne,Eq,Finset.range,id,congrArg, Usa2003P3.t_def,dite,OfNat.ofNat,Nat.zero_le,Not,Finset,Membership.mem,And,propext,Finset.mem_filter,LT.lt,Finset.mem_rangeand 9 more14 instances, coercions and auxiliary constants left out.
Tactic trace: 14 steps
Open to load the checked before-and-after goal states.
lemma le_t (a : ℕ → ℕ) (i : ℕ) (h : ∀ j ≤ i, a j ≤ j) : a i ≤ t a i := by …
Mentions: h, Usa2003P3.t
- lemma
Usa2003P3.iter_succline 97 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq,Nat.iterate, Usa2003P3.t,HAdd.hAdd,OfNat.ofNatProof uses:
Function.iterate_succ_apply'3 instances, coercions and auxiliary constants left out.
- lemma
Usa2003P3.iter_t_zeroline 100 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq,Nat.iterate, Usa2003P3.t,HAdd.hAdd,OfNat.ofNatProof uses:
Eq.mpr,id,congrArg, Usa2003P3.iter_succ, Usa2003P3.t_zero6 instances, coercions and auxiliary constants left out.
Tactic trace: 2 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2003P3.iter_t_leline 104 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,Nat.iterate, Usa2003P3.t,HAdd.hAdd,OfNat.ofNatProof uses:
Eq.mpr,id,Eq,congrArg, Usa2003P3.iter_succ, Usa2003P3.t_le8 instances, coercions and auxiliary constants left out.
Tactic trace: 2 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2003P3.iter_mono_succline 108 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,OfNat.ofNat,Nat.iterate, Usa2003P3.t,HAdd.hAddProof uses:
Eq,Nat.succ,Exists,Nat.exists_eq_succ_of_ne_zero,Eq.mpr,id,congrArg, Usa2003P3.iter_succ, Usa2003P3.le_t, Usa2003P3.iter_t_le,Eq.symm11 instances, coercions and auxiliary constants left out.
Tactic trace: 4 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2003P3.iter_ge_of_leline 114 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,Nat.iterate, Usa2003P3.t,OfNat.ofNatProof uses:
Nat.le_induction,le_trans,HAdd.hAdd, Usa2003P3.iter_mono_succ7 instances, coercions and auxiliary constants left out.
- lemma
Usa2003P3.iter_ge_two_of_leline 118 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,Nat.iterate, Usa2003P3.t,OfNat.ofNatProof uses:
Nat.le_induction,le_trans,HAdd.hAdd, Usa2003P3.iter_mono_succ8 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2003P3.iter_congrThe valuest^[m] a jforj ≤ ionly depend on the valuesa jforj ≤ iline 123 sourceSource documentation
The values
t^[m] a jforj ≤ ionly depend on the valuesa jforj ≤ i.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,Eq,Nat.iterate, Usa2003P3.tProof uses:
Nat.recAux,Eq.mpr,HAdd.hAdd,OfNat.ofNat,id,congrArg, Usa2003P3.iter_succ,Finset.card,Finset.filter,Ne,Finset.range, Usa2003P3.t_def,Finset,Eq.rec,Eq.refl,Finset.filter_congr,Membership.mem,le_trans,le_of_lt,Eq.mpand 5 more11 instances, coercions and auxiliary constants left out.
Tactic trace: 12 steps
Open to load the checked before-and-after goal states.
lemma iter_congr {a b : ℕ → ℕ} {i : ℕ} (h : ∀ j ≤ i, a j = b j) : ∀ m, ∀ j ≤ i, t^[m] a j = t^[m] b j := by …Mentions: h, Usa2003P3.t
- lemma
Usa2003P3.iter_stable_addOnce a whole initial segment is stable, it stays stable line 140 sourceSource documentation
Once a whole initial segment is stable, it stays stable.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,Eq,Nat.iterate, Usa2003P3.t,HAdd.hAdd,OfNat.ofNatProof uses:
Nat.recAux,Eq.mpr,id,congrArg,Eq.symm,add_assoc, Usa2003P3.iter_succ,Finset.card,Finset.filter,Ne,Finset.range, Usa2003P3.t_def,Finset,Eq.rec,Eq.refl,Finset.filter_congr,Membership.mem,le_trans,le_of_lt,Eq.mpand 5 more16 instances, coercions and auxiliary constants left out.
Tactic trace: 12 steps
Open to load the checked before-and-after goal states.
lemma iter_stable_add (a : ℕ → ℕ) {N p : ℕ} (h : ∀ i ≤ N, t^[p] a i = t^[p+1] a i) : ∀ q, ∀ i ≤ N, t^[p+q] a i = t^[p+q+1] a i := by …Mentions: h, Usa2003P3.t
- lemma
Usa2003P3.iter_eq_zeroIf the firstkterms ofaare all zero, they stay zero forever line 159 sourceSource documentation
If the first
kterms ofaare all zero, they stay zero forever.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,Eq,OfNat.ofNat,Nat.iterate, Usa2003P3.t,HAdd.hAddProof uses:
Nat.recAux,id, Usa2003P3.t_eq_zero_of,Eq.mpr,congrArg,lt_trans,Eq.refl, Usa2003P3.iter_succ9 instances, coercions and auxiliary constants left out.
Tactic trace: 12 steps
Open to load the checked before-and-after goal states.
lemma iter_eq_zero {a : ℕ → ℕ} {k : ℕ} (hz : ∀ i < k, a i = 0) : ∀ m, ∀ i < k, t^[m+1] a i = 0 := by …Mentions: Usa2003P3.t
- lemma
Usa2003P3.range_add_filter_cardCounting elementsm < j + kwithp m, whenpholds on all of[0, k)line 177 sourceSource documentation
Counting elements
m < j + kwithp m, whenpholds on all of[0, k).standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,DecidablePred,LT.lt,Eq,Finset.card,Finset.filter,Finset.range,HAdd.hAddProof uses:
Disjoint,Finset,Finset.map,Function.Embedding.mk,add_left_injective,Eq.mpr,Membership.mem,Not,id,congrArg,propext,Finset.disjoint_left,And,Function.Embedding,Exists,False,Eq.mp,Finset.mem_map,Finset.mem_range,Union.unionand 19 more50 instances, coercions and auxiliary constants left out.
Tactic trace: 38 steps
Open to load the checked before-and-after goal states.
lemma range_add_filter_card (p : ℕ → Prop) [DecidablePred p] (j k : ℕ) (hk : ∀ m < k, p m) : ((Finset.range (j+k)).filter p).card = k + ((Finset.range j).filter (fun l => p (l + k))).card := by … - lemma
Usa2003P3.comm1The key commutation relation for the casea₁ = 1: withbⱼ = t a (j+1) - 1, iteratingtonbsimulates iteratingtona, shifted by one index line 216 sourceSource documentation
The key commutation relation for the case
a₁ = 1: withbⱼ = t a (j+1) - 1, iteratingtonbsimulates iteratingtona, shifted by one index.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,OfNat.ofNat,Nat.iterate, Usa2003P3.t,HAdd.hAdd,Eq,HSub.hSubProof uses:
Nat.recAux,id,le_rfl,Eq.mpr,congrArg, Usa2003P3.iter_succ,Finset.card,Finset.filter,Ne,Finset.range, Usa2003P3.t_def,Finset,Finset.filter_congr,Membership.mem,Eq.mp,LT.lt,propext,Finset.mem_range,Iff.intro, Usa2003P3.iter_t_zero and 3 more25 instances, coercions and auxiliary constants left out.
Tactic trace: 37 steps
Open to load the checked before-and-after goal states.
lemma comm1 {a : ℕ → ℕ} {n : ℕ} (hP1 : ∀ i, 1 ≤ i → i ≤ n → ∀ m, 1 ≤ m → 1 ≤ t^[m] a i) : ∀ m, ∀ j, j + 1 ≤ n → t^[m] (fun j => t a (j+1) - 1) j + 1 = t^[m+1] a (j+1) := by …Mentions: Usa2003P3.t
- lemma
Usa2003P3.comm2The key commutation relation for the casea₀ = a₁ = ⋯ = aₖ₋₁ = 0 < aₖ: withcⱼ = t^[2] a (j+k) - k, iteratingtoncsimulates iteratingtona, shifted bykindices line 256 sourceSource documentation
The key commutation relation for the case
a₀ = a₁ = ⋯ = aₖ₋₁ = 0 < aₖ: withcⱼ = t^[2] a (j+k) - k, iteratingtoncsimulates iteratingtona, shifted bykindices.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,OfNat.ofNat,LT.lt,Eq,Nat.iterate, Usa2003P3.t,HAdd.hAdd,HSub.hSubProof uses:
Nat.recAux,id,Eq.mpr,congrArg, Usa2003P3.iter_succ,Finset.card,Finset.filter,Ne,Finset.range, Usa2003P3.t_def,Finset,Finset.filter_congr,Membership.mem,Eq.mp,propext,Finset.mem_range,Iff.intro,add_right_comm, Usa2003P3.range_add_filter_card28 instances, coercions and auxiliary constants left out.
Tactic trace: 33 steps
Open to load the checked before-and-after goal states.
lemma comm2 {a : ℕ → ℕ} {n k : ℕ} (hk1 : 1 ≤ k) (hz : ∀ m, ∀ i < k, t^[m+1] a i = 0) (hge : ∀ i, k ≤ i → i ≤ n → ∀ m, k ≤ t^[m+2] a i) : ∀ m, ∀ j, j + k ≤ n → t^[m] (fun j => t^[2] a (j+k) - k) j + k = t^[m+2] a (j+k) := by …Mentions: Usa2003P3.t
- theorem
Usa2003P3.main_auxThe main induction: aftern-1applications oft, the sequence is stable line 294 sourceSource documentation
The main induction: after
n-1applications oft, the sequence is stable.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,OfNat.ofNat,Eq,Nat.iterate, Usa2003P3.t,HSub.hSubProof uses:
Nat.strongRecOn,LT.lt,dite,Mathlib.Meta.NormNum.isNat_le_true,Mathlib.Meta.NormNum.isNat_ofNat,Eq.refl,Bool,Bool.true,Or,id,Eq.mpr,congrArg, Usa2003P3.t_zero,Eq.symm, Usa2003P3.t_eq_zero_of,Iff.mp,Nat.lt_one_iff,Not,le_rfl, Usa2003P3.le_t and 59 more80 instances, coercions and auxiliary constants left out.
Tactic trace: 236 steps (first 200 of 236)
Open to load the checked before-and-after goal states.
theorem main_aux (n : ℕ) : 1 ≤ n → ∀ a : ℕ → ℕ, (∀ i ≤ n, a i ≤ i) → ∀ i ≤ n, t^[n-1] a i = t^[n] a i := by …Mentions: Usa2003P3.t
- problem
Usa2003P3.usa2003_p3USA Mathematical Olympiad 2003, Problem 3 line 484 sourceSource documentation
USA Mathematical Olympiad 2003, Problem 3
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,OfNat.ofNat,LE.le,Exists,And,Eq,Nat.iterate, Usa2003P3.t,HAdd.hAddProof uses:
Exists.intro,HSub.hSub,And.intro,Eq.mpr,id,congrArg,Nat.sub_one_add_one_eq_of_pos, Usa2003P3.main_aux13 instances, coercions and auxiliary constants left out.
Tactic trace: 4 steps
Open to load the checked before-and-after goal states.
problem usa2003_p3 (n : ℕ) (hn : 0 < n) (a : ℕ → ℕ) (ha : ∀ i ≤ n, a i ≤ i) : ∃ k, k < n ∧ ∀ i ≤ n, t^[k] a i = t^[k+1] a i := by …Mentions: Usa2003P3.t