{
  "id": "6092",
  "ident": "NS.06092",
  "slug": "oeis-280864",
  "title": "The cup-of-coffee sequence",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "Conjectured to be a permutation of the positive integers.",
  "subjects": [
    "math.NT",
    "msc:11"
  ],
  "tags": [],
  "collection": "oeis",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "OeisA280864.conjecture",
  "statement_lean": "theorem conjecture :\n    ∃ a : ℕ → ℕ, FollowsRule a ∧ ∀ k > 0, ∃ n, a n = k",
  "challenge_source": "/-\nCopyright 2026 The Formal Conjectures Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-/\n\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# The cup-of-coffee sequence\n\nThe sequence starts with $1, 2$. Each later term is the least unused positive integer such that,\nfor every prime, runs of consecutive multiples have length exactly two. The local rule requires\nprime factors that have just appeared to occur once more, and forbids prime factors that occurred\nin both of the preceding terms.\n\n*References:*\n- [A280864](https://oeis.org/A280864)\n-/\n\n@[expose] public section\n\nnamespace OeisA280864\n\n/-- Prime factors whose run began at `previous` and must continue at the next term. -/\ndef requiredFactors (previousPrevious previous : ℕ) : Finset ℕ :=\n  previous.primeFactors \\ previousPrevious.primeFactors\n\n/-- Prime factors whose run has length two and must end before the next term. -/\ndef forbiddenFactors (previousPrevious previous : ℕ) : Finset ℕ :=\n  previous.primeFactors ∩ previousPrevious.primeFactors\n\n/-- Whether `candidate` obeys the prime-factor run rule after the two preceding values. -/\ndef Eligible (previousPrevious previous candidate : ℕ) : Prop :=\n  0 < candidate ∧\n    (∀ p ∈ requiredFactors previousPrevious previous, p ∣ candidate) ∧\n    (∀ p ∈ forbiddenFactors previousPrevious previous, ¬p ∣ candidate)\n\n@[category test, AMS 11]\ntheorem not_eligible_zero : ¬Eligible 1 2 0 := by\n  simp [Eligible]\n\n@[category test, AMS 11]\ntheorem not_eligible_missing_required_factor : ¬Eligible 1 2 3 := by\n  norm_num [Eligible, requiredFactors, forbiddenFactors, Nat.primeFactors, Nat.primeFactorsList]\n\n@[category test, AMS 11]\ntheorem not_eligible_with_forbidden_factor : ¬Eligible 2 4 8 := by\n  norm_num [Eligible, requiredFactors, forbiddenFactors, Nat.primeFactors, Nat.primeFactorsList]\n\n@[category test, AMS 11]\ntheorem eligible_3_6_8 : Eligible 3 6 8 := by\n  norm_num [Eligible, requiredFactors, forbiddenFactors, Nat.primeFactors, Nat.primeFactorsList]\n\n/-- The value `candidate` has not appeared before index `n`. -/\ndef UnusedBefore (a : ℕ → ℕ) (n candidate : ℕ) : Prop :=\n  ∀ i < n, a i ≠ candidate\n\n/-- At index `n`, the sequence takes the least unused eligible positive value. -/\ndef GreedyAt (a : ℕ → ℕ) (n : ℕ) : Prop :=\n  Eligible (a (n - 2)) (a (n - 1)) (a n) ∧\n    UnusedBefore a n (a n) ∧\n    ∀ candidate,\n      Eligible (a (n - 2)) (a (n - 1)) candidate →\n      UnusedBefore a n candidate →\n      a n ≤ candidate\n\n/-- A total sequence obeys the initial conditions and every subsequent greedy step. -/\ndef FollowsRule (a : ℕ → ℕ) : Prop :=\n  a 0 = 1 ∧ a 1 = 2 ∧ ∀ n, 2 ≤ n → GreedyAt a n\n\n/-- A later value in a rule-following sequence differs from every earlier value. -/\n@[category API, AMS 11]\ntheorem ne_of_lt_of_followsRule {a : ℕ → ℕ} (ha : FollowsRule a) {i j : ℕ} (hij : i < j) :\n    a i ≠ a j := by\n  rcases ha with ⟨ha0, ha1, ha⟩\n  match j with\n  | 0 => omega\n  | 1 =>\n      have hi : i = 0 := by omega\n      subst i\n      simp [ha0, ha1]\n  | j + 2 =>\n      exact (ha (j + 2) (by omega)).2.1 i hij\n\n/-- Unusedness at every greedy step makes every rule-following sequence injective. -/\n@[category API, AMS 11]\ntheorem followsRule_injective {a : ℕ → ℕ} (ha : FollowsRule a) : Function.Injective a := by\n  intro i j hij\n  by_contra hne\n  rcases lt_or_gt_of_ne hne with hlt | hgt\n  · exact ne_of_lt_of_followsRule ha hlt hij\n  · exact ne_of_lt_of_followsRule ha hgt hij.symm\n\n/-- `candidate` is the least unused eligible value following the two displayed final values. -/\ndef LeastEligibleUnused (history : List ℕ) (previousPrevious previous candidate : ℕ) : Prop :=\n  Eligible previousPrevious previous candidate ∧\n    candidate ∉ history ∧\n    ∀ smaller ∈ Finset.Ico 1 candidate,\n      ¬Eligible previousPrevious previous smaller ∨ smaller ∈ history\n\n/-- A finite list generated by the same greedy rule, without assuming an infinite continuation. -/\ninductive ValidPrefix : List ℕ → Prop\n  | nil : ValidPrefix []\n  | one : ValidPrefix [1]\n  | two : ValidPrefix [1, 2]\n  | append {history : List ℕ} {previousPrevious previous candidate : ℕ}\n      (valid : ValidPrefix (history ++ [previousPrevious, previous]))\n      (least : LeastEligibleUnused (history ++ [previousPrevious, previous])\n        previousPrevious previous candidate) :\n      ValidPrefix (history ++ [previousPrevious, previous, candidate])\n\n/--\nA value occurs at the official OEIS index $n\\geq 1$ in a finite valid prefix.\nThe total sequences in `FollowsRule` use index $n-1$ for the same term.\n-/\ndef TermAt (n value : ℕ) : Prop :=\n  0 < n ∧ ∃ xs, ValidPrefix xs ∧ xs[n - 1]? = some value\n\n/-- Index zero is outside the official OEIS domain. -/\n@[category test, AMS 11]\ntheorem not_term_at_zero (value : ℕ) : ¬TermAt 0 value := by\n  simp [TermAt]\n\nprivate def initialPrefix : List ℕ := [1, 2, 4, 3, 6, 8, 5, 10, 12, 9]\n\n@[category API, AMS 11]\nprivate theorem initialPrefix_valid : ValidPrefix initialPrefix := by\n  have h2 : ValidPrefix [1, 2] := ValidPrefix.two\n  have h3 : ValidPrefix [1, 2, 4] := by\n    simpa using ValidPrefix.append (history := []) (previousPrevious := 1) (previous := 2)\n      (candidate := 4) h2 (by\n        norm_num [LeastEligibleUnused, Eligible, requiredFactors, forbiddenFactors,\n          Nat.primeFactors, Nat.primeFactorsList]\n        intro smaller hsmall hlt\n        interval_cases smaller <;> norm_num)\n  have h4 : ValidPrefix [1, 2, 4, 3] := by\n    simpa using ValidPrefix.append (history := [1]) h3 (by\n      norm_num [LeastEligibleUnused, Eligible, requiredFactors, forbiddenFactors,\n        Nat.primeFactors, Nat.primeFactorsList]\n      intro smaller hsmall hlt\n      interval_cases smaller <;> norm_num)\n  have h5 : ValidPrefix [1, 2, 4, 3, 6] := by\n    simpa using ValidPrefix.append (history := [1, 2]) h4 (by\n      norm_num [LeastEligibleUnused, Eligible, requiredFactors, forbiddenFactors,\n        Nat.primeFactors, Nat.primeFactorsList]\n      intro smaller hsmall hlt\n      interval_cases smaller <;> norm_num)\n  have h6 : ValidPrefix [1, 2, 4, 3, 6, 8] := by\n    simpa using ValidPrefix.append (history := [1, 2, 4]) h5 (by\n      norm_num [LeastEligibleUnused, Eligible, requiredFactors, forbiddenFactors,\n        Nat.primeFactors, Nat.primeFactorsList]\n      intro smaller hsmall hlt\n      interval_cases smaller <;> norm_num)\n  have h7 : ValidPrefix [1, 2, 4, 3, 6, 8, 5] := by\n    simpa using ValidPrefix.append (history := [1, 2, 4, 3]) h6 (by\n      norm_num [LeastEligibleUnused, Eligible, requiredFactors, forbiddenFactors,\n        Nat.primeFactors, Nat.primeFactorsList]\n      intro smaller hsmall hlt\n      interval_cases smaller <;> norm_num)\n  have h8 : ValidPrefix [1, 2, 4, 3, 6, 8, 5, 10] := by\n    simpa using ValidPrefix.append (history := [1, 2, 4, 3, 6]) h7 (by\n      norm_num [LeastEligibleUnused, Eligible, requiredFactors, forbiddenFactors,\n        Nat.primeFactors, Nat.primeFactorsList]\n      intro smaller hsmall hlt\n      interval_cases smaller <;> norm_num)\n  have h9 : ValidPrefix [1, 2, 4, 3, 6, 8, 5, 10, 12] := by\n    simpa using ValidPrefix.append (history := [1, 2, 4, 3, 6, 8]) h8 (by\n      norm_num [LeastEligibleUnused, Eligible, requiredFactors, forbiddenFactors,\n        Nat.primeFactors, Nat.primeFactorsList]\n      intro smaller hsmall hlt\n      interval_cases smaller <;> norm_num)\n  have h10 : ValidPrefix initialPrefix := by\n    simpa [initialPrefix] using\n      ValidPrefix.append (history := [1, 2, 4, 3, 6, 8, 5]) h9 (by\n        norm_num [LeastEligibleUnused, Eligible, requiredFactors, forbiddenFactors,\n          Nat.primeFactors, Nat.primeFactorsList]\n        intro smaller hsmall hlt\n        interval_cases smaller <;> norm_num)\n  exact h10\n\n@[category test, AMS 11]\ntheorem a_1 : TermAt 1 1 := by\n  exact ⟨by decide, initialPrefix, initialPrefix_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_2 : TermAt 2 2 := by\n  exact ⟨by decide, initialPrefix, initialPrefix_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_3 : TermAt 3 4 := by\n  exact ⟨by decide, initialPrefix, initialPrefix_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_4 : TermAt 4 3 := by\n  exact ⟨by decide, initialPrefix, initialPrefix_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_5 : TermAt 5 6 := by\n  exact ⟨by decide, initialPrefix, initialPrefix_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_6 : TermAt 6 8 := by\n  exact ⟨by decide, initialPrefix, initialPrefix_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_7 : TermAt 7 5 := by\n  exact ⟨by decide, initialPrefix, initialPrefix_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_8 : TermAt 8 10 := by\n  exact ⟨by decide, initialPrefix, initialPrefix_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_9 : TermAt 9 12 := by\n  exact ⟨by decide, initialPrefix, initialPrefix_valid, by decide⟩\n\n@[category test, AMS 11]\ntheorem a_10 : TermAt 10 9 := by\n  exact ⟨by decide, initialPrefix, initialPrefix_valid, by decide⟩\n\n/--\nConjectured to be a permutation of the positive integers.\n-/\n@[category research open, AMS 11]\ntheorem conjecture :\n    ∃ a : ℕ → ℕ, FollowsRule a ∧ ∀ k > 0, ∃ n, a n = k := by\n  sorry\n\nend OeisA280864\n",
  "statement_hash": "864da1c5b1a49b2c1f9bc7218a43af468c13bedc16e96a7559ecdc492c980fec",
  "toolchain": "leanprover/lean4:v4.33.1",
  "upstream_commit": "f9b3868d5ca994a7bf95039bcec05338c0c21e2f",
  "workspace": "formal-conjectures",
  "field": "math",
  "formalization": "formal",
  "verification": "lean-kernel",
  "license": "Apache-2.0",
  "attribution": "google-deepmind/formal-conjectures contributors",
  "metric_name": null,
  "metric_direction": null,
  "critiques": [],
  "public_partial_proofs": [],
  "research_threads": [],
  "instructions": "Read research_threads first: other people's public repositories and what they already tried. Write Solution.lean starting from challenge_source. Keep every definition identical, prove decl_name with exactly the same type, no sorry in its dependency closure, no new axioms, no native_decide, no metaprogramming. Submit with POST /api/v1/submissions."
}