Lean / Reader
Lean readerStarStatement.lean
Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports StarProcess, StarDyadic, which it does not have: you can read it there, but it will not check. Build the project itself to check it.
import StarProcessimport StarDyadicnamespace RotatingStarsprivate def Invariant (k : ℕ) : Prop :=(∀ x∈older k, size x ≤ (2:ℚ)^(k-1)) ∧(∀ j, j ≤ k → size (vertex (origin k) k j)=(2:ℚ)^k)private theorem vertices_of_origin (k : ℕ) (hk : 2 ≤ k) (h : size (origin k)=(2:ℚ)^k)(j : ℕ) : size (vertex (origin k) k j)=(2:ℚ)^k := byapply (size_add_eq ?_).trans hrw [h]simpa only [Nat.cast_add,Nat.cast_one,Nat.add_sub_cancel] usingsize_fraction_lt (k+1) j (by omega)private theorem base : Invariant 2 := byconstructor· intro x hxrw [show 2=(1:ℕ)+1 by rfl,older_step,initial_older] at hxrcases Finset.mem_union.mp hx with hx|hx· simp only [Finset.mem_singleton] at hxsubst xnorm_numobtain ⟨j,hj,rfl⟩ := Finset.mem_image.mp hxobtain h := Finset.mem_range.mp hjinterval_cases j· simpa [vertex,first_stars.1] using size_half.le· have s := size_int (1:ℤ)norm_num [vertex,first_stars.1] at *linarith· have h := size_int (1:ℤ)have s : size (1:ℚ) < size (1/4) := by rw [size_quarter]; norm_num at h; linarithhave orig : size (origin 2)=2^2 := byrw [first_stars.2,show (5:ℚ)/4=1/4+1 by norm_num,size_add_eq s,size_quarter]norm_numexact fun j _ => vertices_of_origin 2 (by decide) orig jprivate theorem invariant_all (k : ℕ) (hk : 2 ≤ k) : Invariant k := byinduction k, hk using Nat.le_induction with| base => exact base| succ k hk ih =>obtain ⟨low,high⟩ := ihhave pow : (2:ℚ)^(k-1) < 2^k := byexact pow_lt_pow_right₀ (by norm_num) (by omega)have last : size (lastAngle k)=(2:ℚ)^k := high k le_rflobtain ⟨u,hu,hp⟩ : ∃ u, 0 < u ∧ k=u+1 := ⟨k-1,by omega,by omega⟩have wit := next_from_older u hurw [←hp] at witobtain ⟨y,hy,z,hz⟩ := withave lt : size (nextAngle k) < size (lastAngle k) := byrw [hz,last]exact lt_of_le_of_lt (size_shift (low y hy) z) powhave orig : size (origin (k+1))=(2:ℚ)^(k+1) := byrw [origin_step,size_half_sum lt,last,pow_succ]; ringconstructor· intro x hxsimp only [older_step,Finset.mem_union] at hxsimp only [Nat.add_sub_cancel]rcases hx with hx|hx· exact le_trans (low x hx) pow.le· obtain ⟨j,hj,rfl⟩ := Finset.mem_image.mp hxexact (high j (by have := Finset.mem_range.mp hj; omega)).le· exact fun j _ => vertices_of_origin (k+1) (by omega) orig jprivate theorem earlier_mem (m k j : ℕ) (hm : m < k) (hj : j ≤ m) :vertex (origin m) m j ∈ older k := byinduction k, hm using Nat.le_induction with| base =>rw [older_step]exact Finset.mem_union_right _ (Finset.mem_image.mpr ⟨j,Finset.mem_range.mpr (by omega),rfl⟩)| succ k hk ih =>rw [older_step]exact Finset.mem_union_left _ ihtheorem denominator_size (n : ℕ) (hn : 3 ≤ n) (j : ℕ) (hj : j < n) :size (vertex (origin (n-1)) (n-1) j)=(2:ℚ)^(n-1) :=(invariant_all _ (by omega)).2 j (by omega)/-- The point j (zero-based) of the n-th star, in unwrapped turns. -/def angle (n j : ℕ) : ℚ := vertex (origin (n-1)) (n-1) j/-- A full turn shifts an angle by one. -/def samePoint (x y : ℚ) : Prop := ∃ z : ℤ, x=y+z/-- OEIS A385330. Two labeled vertices of different stars coincide exactly forthe sole vertex of the 1-star and the second vertex of the 2-star. -/theorem only_overwrite {m n i j : ℕ} (hm : 0 < m) (hmn : m < n) (hi : i < m) (hj : j < n) :samePoint (angle n j) (angle m i) ↔ m=1 ∧ n=2 ∧ i=0 ∧ j=1 := byconstructor· rintro ⟨z,h⟩by_cases hn : 3 ≤ n· have seen := earlier_mem (m-1) (n-1) i (by omega) (by omega)have low := size_shift ((invariant_all (n-1) (by omega)).1 _ seen) zhave high := denominator_size n hn j hjchange vertex (origin (n-1)) (n-1) j=vertex (origin (m-1)) (m-1) i+z at hrw [←h,high] at lowhave bad : (2:ℚ)^(n-1-1) < 2^(n-1) := pow_lt_pow_right₀ (by norm_num) (by omega)exact (not_lt_of_ge low bad).elim· obtain rfl : m=1 := by omegaobtain rfl : n=2 := by omegaobtain rfl : i=0 := by omegarefine ⟨rfl,rfl,rfl,?_⟩by_contra! hzobtain rfl : j=0 := by omeganorm_num [angle,vertex,origin_zero,first_stars.1] at hhave hh : ((2*z:ℤ):ℚ)=1 := by push_cast; linarithhave zz : (2*z:ℤ)=1 := by exact_mod_cast hhomega· rintro ⟨rfl,rfl,rfl,rfl⟩refine ⟨1,?_⟩norm_num [angle,vertex,origin_zero,first_stars.1]#print axioms only_overwriteend RotatingStars