Compfiles/Usa1995P1.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
25 declarations, 0 contain sorry, 0 declared as axioms
USA Mathematical Olympiad 1995, Problem 1
Let p be an odd prime. The sequence (aₙ) n ≥ 0 is defined as follows:
a₀ = 0, a₁ = 1, ..., a_{p-2} = p - 2, and for all n ≥ p - 1, aₙ is the
least integer greater than a_{n-1} such that a₀, a₁, ..., aₙ does not
contain an arithmetic progression of length p.
Prove that, for all n, aₙ is the number obtained by writing n in base
p - 1 and reading the result in base p.
Imports (4)
Imported by 1 file
- def
Usa1995P1.HasApDocumented declaration: HasAp line 38 sourceSource documentation
HasAp a p n mmeans that the firstn + 1termsa 0, a 1, …, a (n-1), m(where the candidatemis then-th term) contain an arithmetic progression of lengthp: there are strictly increasing indicesv 0 < v 1 < … < v (p-1), all at mostn, whose values form an arithmetic progression. The last conjunct splits the value condition according to whether the index is the final positionn(where the candidatemsits) or not.standard axioms: propext what this means
Statement uses:
NatProof uses:
Exists,Fin,And,StrictMono,LE.le,LT.lt,Eq,HAdd.hAdd,HMul.hMul10 instances, coercions and auxiliary constants left out.
def HasAp (a : ℕ → ℕ) (p n m : ℕ) : Prop := …
- def
Usa1995P1.DigitFreeA natural number is(p)-digit-free if no digit of its base-pexpansion equalsp - 1line 47 sourceSource documentation
A natural number is
(p)-digit-free if no digit of its base-pexpansion equalsp - 1.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
NatProof uses:
Membership.mem,List,Nat.digits,Ne,HSub.hSub,OfNat.ofNat4 instances, coercions and auxiliary constants left out.
def DigitFree (p m : ℕ) : Prop := ∀ d ∈ Nat.digits p m, d ≠ p - 1
- def
Usa1995P1.bSeqbSeq p nis the number obtained by writingnin basep - 1and reading the result in basepline 51 sourceSource documentation
bSeq p nis the number obtained by writingnin basep - 1and reading the result in basep.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
NatProof uses:
Nat.ofDigits,Nat.digits,HSub.hSub,OfNat.ofNat4 instances, coercions and auxiliary constants left out.
def bSeq (p n : ℕ) : ℕ := Nat.ofDigits p (Nat.digits (p - 1) n)
- def
Usa1995P1.phiphi p mreads the base-pdigits ofmin basep - 1line 55 sourceSource documentation
phi p mreads the base-pdigits ofmin basep - 1. On digit-free numbers it is the inverse ofbSeq p.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
NatProof uses:
Nat.ofDigits,HSub.hSub,OfNat.ofNat,Nat.digits4 instances, coercions and auxiliary constants left out.
def phi (p m : ℕ) : ℕ := Nat.ofDigits (p - 1) (Nat.digits p m)
- lemma
Usa1995P1.phi_defline 57 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq, Usa1995P1.phi,Nat.ofDigits,HSub.hSub,OfNat.ofNat,Nat.digitsProof uses:
rfl4 instances, coercions and auxiliary constants left out.
- lemma
Usa1995P1.bSeq_defline 59 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq, Usa1995P1.bSeq,Nat.ofDigits,Nat.digits,HSub.hSub,OfNat.ofNatProof uses:
rfl4 instances, coercions and auxiliary constants left out.
- lemma
Usa1995P1.ofDigits_cons_natline 61 sourcestandard axioms: propext what this means
Statement uses:
Nat,List,Eq,Nat.ofDigits,List.cons,HAdd.hAdd,HMul.hMulProof uses:
of_eq_true,eq_self10 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Usa1995P1.ofDigits_eq_zero_iffline 65 sourcestandard axioms: Quot.sound, propext what this means
Statement uses:
Nat,Ne,OfNat.ofNat,List,Iff,Eq,Nat.ofDigits,Membership.memProof uses:
List.rec,of_eq_true,List.nil,Eq.trans,True,congr,congrArg,eq_self,forall_congr,False,implies_congr,Eq.refl,implies_true,iff_self,Eq.mpr,List.cons,HAdd.hAdd,HMul.hMul,id, Usa1995P1.ofDigits_cons_nat and 7 more18 instances, coercions and auxiliary constants left out.
Tactic trace: 14 steps
Open to load the checked before-and-after goal states.
- lemma
Usa1995P1.phi_posline 79 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,OfNat.ofNat,LT.lt, Usa1995P1.phiProof uses:
Eq.mpr,Ne,id,Eq,congrArg,propext,Nat.pos_iff_ne_zero,Eq.mp,Membership.mem,List,Nat.digits,Iff.mp,Nat.ofDigits,HSub.hSub, Usa1995P1.ofDigits_eq_zero_iff,Iff.mpr,Nat.ofDigits_digits12 instances, coercions and auxiliary constants left out.
Tactic trace: 8 steps
Open to load the checked before-and-after goal states.
- lemma
Usa1995P1.digits_ofDigits_neIf every entry oflis< band different fromc, then every base-bdigit ofNat.ofDigits b lis different fromcline 91 sourceSource documentation
If every entry of
lis< band different fromc, then every base-bdigit ofNat.ofDigits b lis different fromc.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,OfNat.ofNat,List,Membership.mem,Ne,Nat.digits,Nat.ofDigitsProof uses:
List.rec,List.nil,absurd,Eq.mp,congrArg,Nat.digits_zero,Nat.ofDigits_nil,of_eq_true,Not,Eq.trans,False,True,not_false_eq_true,List.cons,Eq,GT.gt,Or,Nat.eq_zero_or_pos,List.mem_cons_self,HMod.hModand 16 more19 instances, coercions and auxiliary constants left out.
Tactic trace: 28 steps
Open to load the checked before-and-after goal states.
lemma digits_ofDigits_ne {b c : ℕ} (hb : 1 < b) : ∀ {l : List ℕ}, (∀ d ∈ l, d < b) → (∀ d ∈ l, d ≠ c) → ∀ d ∈ Nat.digits b (Nat.ofDigits b l), d ≠ c := by … - lemma
Usa1995P1.digits_getDThek-th digit ofmin baseb(with0padding) line 121 sourceSource documentation
The
k-th digit ofmin baseb(with0padding).standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,OfNat.ofNat,Eq,List.getD,Nat.digits,HMod.hMod,HDiv.hDiv,HPow.hPowProof uses:
Nat.recAux,GT.gt,Or,Nat.eq_zero_or_pos,of_eq_true,Eq.trans,True,congr,congrArg,Option.getD,GetElem?.getElem?,List,List.length,List.nil,Option.none,congrFun',Nat.digits_zero,List.getD_eq_getElem?_getD,Option,getElem?_negand 19 more40 instances, coercions and auxiliary constants left out.
Tactic trace: 11 steps
Open to load the checked before-and-after goal states.
lemma digits_getD {b : ℕ} (hb : 1 < b) (m k : ℕ) : (Nat.digits b m).getD k 0 = m / b ^ k % b := by … - lemma
Usa1995P1.mem_digits_of_getD_ne_zeroline 134 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq,List.getD,Nat.digits,OfNat.ofNat,Ne,Membership.mem,ListProof uses:
LT.lt,List.length,Decidable.byContradiction,Not,LE.le,Nat.le_of_not_lt,Eq.symm,Eq.mp,congrArg,List.getD_eq_default,Eq.mpr,GetElem.getElem,id,List.getD_eq_getElem,List.getElem_mem8 instances, coercions and auxiliary constants left out.
Tactic trace: 8 steps
Open to load the checked before-and-after goal states.
- lemma
Usa1995P1.digit_add_mul_eqAdding a multiple ofd = e * p^(k+1) + c * p^konly affects thek-th base-pdigit throughc(no carries into that digit from below) line 147 sourceSource documentation
Adding a multiple of
d = e * p^(k+1) + c * p^konly affects thek-th base-pdigit throughc(no carries into that digit from below).standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,OfNat.ofNat,Eq,HAdd.hAdd,HMul.hMul,HPow.hPow,HMod.hMod,HDiv.hDivProof uses:
pow_pos,pow_succ',rfl,Eq.mpr,id,congrArg,Eq.rec,Nat.mod_lt,Eq.symm,Nat.div_add_mod,Eq.mp,pow_succ,Nat.div_div_eq_div_mul,mul_comm,Eq.refl,Mathlib.Tactic.Ring.of_eq,Nat.rawCast,Mathlib.Tactic.Ring.Common.add_congr,Mathlib.Tactic.Ring.Common.mul_congr,Mathlib.Tactic.Ring.Common.pow_congrand 30 more62 instances, coercions and auxiliary constants left out.
Tactic trace: 34 steps
Open to load the checked before-and-after goal states.
lemma digit_add_mul_eq {p : ℕ} (hp : 1 < p) {x d k c e : ℕ} (i : ℕ) (hd : d = e * p ^ (k + 1) + c * p ^ k) : (x + i * d) / p ^ k % p = (x / p ^ k % p + i * c) % p := by … - lemma
Usa1995P1.ofDigits_map_add_mulline 185 sourcestandard axioms: propext what this means
Statement uses:
Nat,List,Eq,Nat.ofDigits,List.map,HAdd.hAdd,HMul.hMulProof uses:
List.rec,of_eq_true,List.nil,Eq.trans,OfNat.ofNat,True,congr,congrArg,List.map_nil,MulZeroClass.mul_zero,add_zero,eq_self,Eq.mpr,List.cons,id,List.map_cons, Usa1995P1.ofDigits_cons_nat,Mathlib.Tactic.Ring.of_eq,HPow.hPow,Nat.rawCastand 19 more29 instances, coercions and auxiliary constants left out.
Tactic trace: 4 steps
Open to load the checked before-and-after goal states.
- lemma
Usa1995P1.phi_strictMono_on_digitFreeThe key monotonicity fact:phiis strictly increasing on digit-free numbers line 198 sourceSource documentation
The key monotonicity fact:
phiis strictly increasing on digit-free numbers. Proved by strong induction on the smaller number, comparing the least significant base-pdigits.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,OfNat.ofNat, Usa1995P1.DigitFree,LT.lt, Usa1995P1.phiProof uses:
Nat.strong_induction_on,Eq,GT.gt,Or,Nat.eq_zero_or_pos,of_eq_true,Eq.trans,True,congrFun',congrArg,List,Nat.digits,List.nil,Nat.ofDigits,HSub.hSub,Nat.digits_zero,eq_self,Eq.mpr,id, Usa1995P1.phi_pos and 28 more36 instances, coercions and auxiliary constants left out.
Tactic trace: 49 steps
Open to load the checked before-and-after goal states.
lemma phi_strictMono_on_digitFree {p : ℕ} (hp : 2 ≤ p) (x : ℕ) : ∀ y, DigitFree p x → DigitFree p y → x < y → phi p x < phi p y := by …Mentions: Usa1995P1.DigitFree, Usa1995P1.phi
- lemma
Usa1995P1.digits_bSeqThe base-pdigits ofbSeq p nare exactly the base-(p-1)digits ofnline 242 sourceSource documentation
The base-
pdigits ofbSeq p nare exactly the base-(p-1)digits ofn.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,OfNat.ofNat,Eq,List,Nat.digits, Usa1995P1.bSeq,HSub.hSubProof uses:
Eq.mpr,Nat.ofDigits,id,congrArg, Usa1995P1.bSeq_def,Nat.digits_ofDigits,Membership.mem,LT.lt.trans,Nat.digits_lt_base,Ne,List.nil,Or,List.getLast,eq_or_ne,False.elim,Eq.mp,Nat.digits_zero,rfl,Eq.symm,Nat.getLast_digit_ne_zero16 instances, coercions and auxiliary constants left out.
Tactic trace: 16 steps
Open to load the checked before-and-after goal states.
lemma digits_bSeq {p : ℕ} (hp : 3 ≤ p) (n : ℕ) : Nat.digits p (bSeq p n) = Nat.digits (p - 1) n := by …Mentions: Usa1995P1.bSeq
- lemma
Usa1995P1.phi_bSeqline 254 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,OfNat.ofNat,Eq, Usa1995P1.phi, Usa1995P1.bSeqProof uses:
Eq.mpr,Nat.ofDigits,HSub.hSub,Nat.digits,id,congrArg, Usa1995P1.phi_def,List, Usa1995P1.digits_bSeq,Nat.ofDigits_digits,Eq.refl7 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Usa1995P1.digitFree_bSeqline 257 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,OfNat.ofNat, Usa1995P1.DigitFree, Usa1995P1.bSeqProof uses:
Membership.mem,List,Nat.digits,LT.lt,HSub.hSub,Nat.digits_lt_base,Eq.mp,congrArg, Usa1995P1.digits_bSeq10 instances, coercions and auxiliary constants left out.
Tactic trace: 5 steps
Open to load the checked before-and-after goal states.
- lemma
Usa1995P1.bSeq_philine 263 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,OfNat.ofNat, Usa1995P1.DigitFree,Eq, Usa1995P1.bSeq, Usa1995P1.phiProof uses:
Eq.mpr,Nat.ofDigits,Nat.digits,HSub.hSub,id,congrArg, Usa1995P1.bSeq_def, Usa1995P1.phi_def,List,Nat.digits_ofDigits,Membership.mem,LT.lt,Nat.digits_lt_base,Ne,List.nil,Or,List.getLast,eq_or_ne,False.elim,Eq.mpand 6 more14 instances, coercions and auxiliary constants left out.
Tactic trace: 12 steps
Open to load the checked before-and-after goal states.
- lemma
Usa1995P1.bSeq_strictMonoline 277 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,OfNat.ofNat,StrictMono, Usa1995P1.bSeqProof uses:
LT.lt,Or,Eq,lt_trichotomy, Usa1995P1.phi,congrArg,absurd,Eq.mp, Usa1995P1.phi_bSeq,ne_of_lt, Usa1995P1.phi_strictMono_on_digitFree, Usa1995P1.digitFree_bSeq14 instances, coercions and auxiliary constants left out.
Tactic trace: 13 steps
Open to load the checked before-and-after goal states.
- lemma
Usa1995P1.bSeq_eq_self_of_ltline 289 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,OfNat.ofNat,LT.lt,HSub.hSub,Eq, Usa1995P1.bSeqProof uses:
Eq.mpr,Nat.ofDigits,Nat.digits,id,congrArg, Usa1995P1.bSeq_def,GT.gt,Or,Nat.eq_zero_or_pos,List.nil,List,Nat.digits_zero,Nat.ofDigits_nil,Eq.refl,Eq.symm,List.cons,Nat.digits_of_lt,HAdd.hAdd,HMul.hMul,Nat.ofDigits_consand 7 more23 instances, coercions and auxiliary constants left out.
Tactic trace: 8 steps
Open to load the checked before-and-after goal states.
- lemma
Usa1995P1.exists_mem_digits_predThe non-existence part: among the valuesbSeq p ithere is no arithmetic progression of lengthpline 301 sourceSource documentation
The non-existence part: among the values
bSeq p ithere is no arithmetic progression of lengthp. Ifx, x + d, …, x + (p-1) dare all digit-free andd > 0, then looking at the least significant nonzero base-pdigit ofd, thek-th digits of the progression terms run through all residues modp, so one of them equalsp - 1: contradiction.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Nat.Prime,LT.lt,OfNat.ofNat,Exists,And,Membership.mem,List,Nat.digits,HAdd.hAdd,HMul.hMul,HSub.hSubProof uses:
Nat.Prime.one_lt,Fact,Fact.mk,NeZero,NeZero.mk,padicValNat,Eq,rfl,Dvd.dvd,HPow.hPow,pow_padicValNat_dvd,Not,pow_succ_padicValNat_not_dvd,False,Exists.intro,Eq.mpr,id,congrArg,pow_succ',Mathlib.Tactic.Ring.of_eqand 53 more88 instances, coercions and auxiliary constants left out.
Tactic trace: 43 steps
Open to load the checked before-and-after goal states.
lemma exists_mem_digits_pred {p : ℕ} (hp : p.Prime) {x d : ℕ} (hd : 0 < d) : ∃ i < p, p - 1 ∈ Nat.digits p (x + i * d) := by … - lemma
Usa1995P1.not_hasApIf all candidate values are digit-free (here: values ofbSeq p), there is no arithmetic progression of lengthpline 345 sourceSource documentation
If all candidate values are digit-free (here: values of
bSeq p), there is no arithmetic progression of lengthp.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Nat.Prime,LE.le,OfNat.ofNat,Eq,ite,LT.lt, Usa1995P1.bSeq,Not, Usa1995P1.HasApProof uses:
Fin,And,StrictMono,Exists,HAdd.hAdd,HMul.hMul,False,dite,Eq.mpr,id,congrArg,ite_eq_left,And.left,ite_eq_right,And.right, Usa1995P1.DigitFree,Eq.symm, Usa1995P1.digitFree_bSeq,Ne,Fin.mkand 16 more32 instances, coercions and auxiliary constants left out.
Tactic trace: 39 steps
Open to load the checked before-and-after goal states.
lemma not_hasAp {p : ℕ} (hp : p.Prime) (hp3 : 3 ≤ p) {a : ℕ → ℕ} {n m : ℕ} (h : ∀ i ≤ n, (if i < n then a i else m) = bSeq p i) : ¬ HasAp a p n m := by …Mentions: h, Usa1995P1.bSeq, Usa1995P1.HasAp
- lemma
Usa1995P1.hasAp_of_mem_digits_predDocumented declaration: hasAp_of_mem_digits_pred line 382 sourceSource documentation
The construction part: if
m < bSeq p nhas a base-pdigit equal top - 1, then reducing every such digit ofmbyj(forj = p-1, …, 0) gives an arithmetic progression of lengthpwhose firstp - 1terms are digit-free, hence equal toaat indices belown.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,OfNat.ofNat,LT.lt,Eq, Usa1995P1.bSeq,Membership.mem,List,Nat.digits,HSub.hSub, Usa1995P1.HasApProof uses:
rfl,Nat.ofDigits,List.map,ite,HAdd.hAdd,HMul.hMul,funext,dite,of_eq_true,Eq.trans,True,congr,congrArg,ite_eq_left_of_eq_true,congrFun',eq_self,mul_one,zero_add,Not,ite_eq_right_of_eq_falseand 43 more53 instances, coercions and auxiliary constants left out.
Tactic trace: 139 steps
Open to load the checked before-and-after goal states.
lemma hasAp_of_mem_digits_pred {p : ℕ} (hp : 3 ≤ p) {a : ℕ → ℕ} {n m : ℕ} (IH : ∀ k < n, a k = bSeq p k) (hhi : m < bSeq p n) (hmem : p - 1 ∈ Nat.digits p m) : HasAp a p n m := by …Mentions: Usa1995P1.bSeq, Usa1995P1.HasAp
- problem
Usa1995P1.usa1995_p1USA Mathematical Olympiad 1995, Problem 1 line 501 sourceSource documentation
USA Mathematical Olympiad 1995, Problem 1.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Nat.Prime,Odd,LT.lt,HSub.hSub,OfNat.ofNat,Eq,GE.ge,IsLeast,Set.ofPred,And,Not, Usa1995P1.HasAp,Nat.ofDigits,Nat.digitsProof uses:
LE.le,Nat.Prime.two_le,HAdd.hAdd,HMul.hMul, Usa1995P1.bSeq,Nat.strong_induction_on,Or,lt_or_ge,Eq.mpr,id,congrArg, Usa1995P1.bSeq_eq_self_of_lt,Eq.refl,And.intro, Usa1995P1.bSeq_strictMono, Usa1995P1.not_hasAp,dite,ite,ite_eq_left,ite_eq_rightand 17 more49 instances, coercions and auxiliary constants left out.
Tactic trace: 53 steps
Open to load the checked before-and-after goal states.
problem usa1995_p1 (p : ℕ) (hp : p.Prime) (ho : Odd p) (a : ℕ → ℕ) (ha₀ : ∀ n < p - 1, a n = n) (ha₁ : ∀ n ≥ p - 1, IsLeast {m | a (n - 1) < m ∧ ¬ HasAp a p n m} (a n)) : ∀ n, a n = Nat.ofDigits p (Nat.digits (p - 1) n) := by …Mentions: Usa1995P1.HasAp