FormalConjecturesForMathlib/NumberTheory/AdditionChain.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 project documentation, Formal Conjectures paper, arXiv v1
12 declarations, 0 contain sorry, 0 declared as axioms
Addition chains
An addition chain for $n$ is a strictly increasing sequence $1 = a_0 < a_1 < \cdots < a_r = n$ in which every entry after the first is the sum of two earlier entries. Its length is $r$, the number of additions, and $\ell(n)$ is the least length over all chains ending at $n$.
additionChainLength is an infimum over List ℕ, so an explicit chain bounds it above
(additionChainLength_le) but nothing bounds it below until the search is confined. The
confinement here is that an addition step at most doubles, so r steps cannot reach past
2 ^ r (getLast_le_two_pow), giving lt_additionChainLength_of_two_pow_lt.
Imported by 1 file
- def
IsAdditionChainAn addition chain is a strictly increasing sequence line 43 sourceSource documentation
An addition chain is a strictly increasing sequence $1 = a_0 < a_1 < \cdots < a_r$ in which every entry after the first is the sum of two (not necessarily distinct) earlier entries.
IsAdditionChain casserts that the list $c$ is such a chain: it starts at $1$, is strictly increasing, and every entry other than $1$ is a sum of two entries of $c$.no axioms what this means
Statement uses:
List,NatProof uses:
And,Eq,Option,List.head?,Option.some,OfNat.ofNat,List.Pairwise,LT.lt,Membership.mem,Ne,Exists,HAdd.hAdd5 instances, coercions and auxiliary constants left out.
Tactic trace: 2 steps
Open to load the checked before-and-after goal states.
def IsAdditionChain (c : List ℕ) : Prop := …
Mentions: c
- instance
(instance at line 50)line 50 sourceSource documentation
Every quantifier in
IsAdditionChainis bounded by the list, so membership is decidable and a concrete chain can be checked bydecide.instance (c : List ℕ) : Decidable (IsAdditionChain c) := by …
Mentions: c, IsAdditionChain
- def
additionChainLengthThe length $\ell(n)$ of $n$: the minimal number of addition steps (the number of entries minus one) over all addition chains ending at $n$ line 55 sourceSource documentation
The length $\ell(n)$ of $n$: the minimal number of addition steps (the number of entries minus one) over all addition chains ending at $n$.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
NatProof uses:
InfSet.sInf,Set.ofPred,Exists,List,And, IsAdditionChain,Eq,Option,List.getLast?,Option.some,List.length,HAdd.hAdd,OfNat.ofNat4 instances, coercions and auxiliary constants left out.
noncomputable def additionChainLength (n : ℕ) : ℕ := …
- def
additionChainStepsThe set of step counts realised by chains ending atnline 59 sourceSource documentation
The set of step counts realised by chains ending at
n.no axioms what this means
Statement uses:
Nat,SetProof uses:
Set.ofPred,Exists,List,And, IsAdditionChain,Eq,Option,List.getLast?,Option.some,List.length,HAdd.hAdd,OfNat.ofNat3 instances, coercions and auxiliary constants left out.
def additionChainSteps (n : ℕ) : Set ℕ := …
- theorem
additionChainLength_eq_sInfline 62 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq, additionChainLength,InfSet.sInf, additionChainStepsProof uses:
rfl1 instances, coercions and auxiliary constants left out.
- theorem
additionChainLength_leExhibiting a chain boundsℓabove line 66 sourceSource documentation
Exhibiting a chain bounds
ℓabove.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,List, IsAdditionChain,Eq,Option,List.getLast?,Option.some,List.length,HAdd.hAdd,OfNat.ofNat,LE.le, additionChainLengthProof uses:
Nat.sInf_le,Set.ofPred,Exists,And,Exists.intro,And.intro7 instances, coercions and auxiliary constants left out.
theorem additionChainLength_le {n r : ℕ} (c : List ℕ) (hc : IsAdditionChain c) (hlast : c.getLast? = some n) (hlen : c.length = r + 1) : additionChainLength n ≤ r := …Mentions: c, IsAdditionChain, additionChainLength
- theorem
additionChainSteps_nonemptyline 70 sourceno axioms what this means
Statement uses:
Nat,List, IsAdditionChain,Eq,Option,List.getLast?,Option.some,List.length,HAdd.hAdd,OfNat.ofNat,Set.Nonempty, additionChainStepsProof uses:
Exists.intro,Membership.mem,Set,And,And.intro7 instances, coercions and auxiliary constants left out.
- theorem
IsAdditionChain.one_le_of_memline 74 sourcestandard axioms: propext what this means
Statement uses:
List,Nat, IsAdditionChain,Membership.mem,LE.le,OfNat.ofNatProof uses:
Eq,Option,List.head?,Option.some,And,List.Pairwise,LT.lt,Ne,Exists,HAdd.hAdd,List.nil,False.elim,Eq.mp,False,Eq.symm,List.cons,Or,Iff.mp,List.mem_cons,le_rfland 5 more15 instances, coercions and auxiliary constants left out.
Tactic trace: 10 steps
Open to load the checked before-and-after goal states.
- theorem
IsAdditionChain.dropLastDropping the last entry of a chain leaves a chain line 88 sourceSource documentation
Dropping the last entry of a chain leaves a chain. The entries are positive, so a summand of the last entry is never the last entry itself and so survives the drop.
standard axioms: Quot.sound, propext what this means
Statement uses:
List,Nat, IsAdditionChain,HAppend.hAppend,List.cons,List.nil,NeProof uses:
Eq,Option,List.head?,Option.some,OfNat.ofNat,And,List.Pairwise,LT.lt,Membership.mem,Exists,HAdd.hAdd,And.intro,False.elim,Eq.mp,False,Eq.trans,Not,True,congrArg,eq_selfand 20 more17 instances, coercions and auxiliary constants left out.
Tactic trace: 31 steps
Open to load the checked before-and-after goal states.
theorem IsAdditionChain.dropLast {ys : List ℕ} {y : ℕ} (h : IsAdditionChain (ys ++ [y])) (hys : ys ≠ []) : IsAdditionChain ys := by …Mentions: IsAdditionChain
- theorem
IsAdditionChain.getLast_le_two_powEvery step at most doubles, so a chain ofrsteps cannot reach past2 ^ rline 111 sourceSource documentation
Every step at most doubles, so a chain of
rsteps cannot reach past2 ^ r.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
List,Nat, IsAdditionChain,Ne,List.nil,LE.le,List.getLast,HPow.hPow,OfNat.ofNat,HSub.hSub,List.lengthProof uses:
List.reverseRecOn,False.elim,Eq.mp,False,Eq.trans,Not,Eq,True,congrArg,eq_self,not_true_eq_false,HAppend.hAppend,List.cons,Eq.mpr,id,List.append_ne_nil_of_right_ne_nil,List.cons_ne_nil,List.getLast_append_singleton,Or,eq_or_neand 41 more49 instances, coercions and auxiliary constants left out.
Tactic trace: 50 steps
Open to load the checked before-and-after goal states.
theorem IsAdditionChain.getLast_le_two_pow {c : List ℕ} (h : IsAdditionChain c) (hne : c ≠ []) : c.getLast hne ≤ 2 ^ (c.length - 1) := by …Mentions: c, IsAdditionChain
- theorem
le_two_pow_additionChainLengthThe doubling bound, transported toℓ: reachingntakes at leastlog₂ nsteps line 154 sourceSource documentation
The doubling bound, transported to
ℓ: reachingntakes at leastlog₂ nsteps.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Set.Nonempty, additionChainSteps,LE.le,HPow.hPow,OfNat.ofNat, additionChainLengthProof uses:
List,And, IsAdditionChain,Eq,Option,List.getLast?,Option.some,List.length,HAdd.hAdd,InfSet.sInf,Membership.mem,Set,Nat.sInf_mem,Ne,List.nil,False,False.elim,Eq.mp,eq_false',Option.noneand 11 more22 instances, coercions and auxiliary constants left out.
Tactic trace: 10 steps
Open to load the checked before-and-after goal states.
theorem le_two_pow_additionChainLength {n : ℕ} (hne : (additionChainSteps n).Nonempty) : n ≤ 2 ^ additionChainLength n := by …Mentions: additionChainSteps, additionChainLength
- theorem
lt_additionChainLength_of_two_pow_ltThe lower-bound tool:rsteps cannot reach past2 ^ rline 166 sourceSource documentation
The lower-bound tool:
rsteps cannot reach past2 ^ r.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Set.Nonempty, additionChainSteps,LT.lt,HPow.hPow,OfNat.ofNat, additionChainLengthProof uses:
Decidable.byContradiction,Not,LE.le, le_two_pow_additionChainLength,Nat.pow_le_pow_right,GT.gt,Eq.mp21 instances, coercions and auxiliary constants left out.
Tactic trace: 5 steps
Open to load the checked before-and-after goal states.
theorem lt_additionChainLength_of_two_pow_lt {n r : ℕ} (hne : (additionChainSteps n).Nonempty) (h : 2 ^ r < n) : r < additionChainLength n := by …Mentions: additionChainSteps, additionChainLength