This journal is in preparation. Submissions are open as a pilot and the editorial board is being formed. Articles marked Demonstration show the format only.
Journal of Machine-Verified MathematicsPeer-reviewed mathematics with machine-checked proofs, for the age of AI

Solution.lean

All files · 38 lines · source at the verified commit

1module
2
3public import E424.Main
4
5public section
6
7/-!
8# Proof of `Challenge.lean`
9-/
10
11namespace Hofstadter
12
13/-- `Generated n` says that `n` lies in the smallest set of natural numbers that contains 2 and 3 and contains `a * b - 1` whenever it
14contains `a` and `b` and `a ≠ b`. (Members are at least 2, so `a * b - 1` is ordinary subtraction.) -/
15inductive Generated : ℕ → Prop
16 | two : Generated 2
17 | three : Generated 3
18 | step {a b : ℕ} : Generated a → Generated b → a ≠ b → Generated (a * b - 1)
19
20theorem generated_iff (n : ℕ) : E424.Inp.Gen n ↔ Generated n := by
21 constructor <;> intro h
22 · induction h with
23 | two => exact .two
24 | three => exact .three
25 | mul_sub_one _ _ hab iha ihb => exact .step iha ihb hab
26 · induction h with
27 | two => exact .two
28 | three => exact .three
29 | step _ _ hab iha ihb => exact .mul_sub_one iha ihb hab
30
31/-- The proportion of generated numbers among the natural numbers below `n` tends to `2 / 3` as `n` tends to infinity. -/
32theorem density_eq_two_thirds :
33 Filter.Tendsto (fun n : ℕ => (Set.ncard {m : ℕ | m < n ∧ Generated m} : ℝ) / n) Filter.atTop
34 (nhds (2 / 3)) := by
35 simpa only [generated_iff] using E424.hasDensity_two_thirds
36
37end Hofstadter
38