import Mathlib import OAI.Geometry.Cannon.CirclePacking.OpenEuclideanFan import OAI.Geometry.Cannon.CirclePacking.PetalAngle namespace OAI section section section noncomputable section namespace CannonPackingGeometry open Set def SectorRingData (n : ℕ) (t α : ℕ → ℝ) : Prop := (∀ i,t i∈Icc (0:ℝ) 1) ∧ (∀ i,α i∈Icc (0:ℝ) Real.pi) ∧ t 0=1/2 ∧ t n=1/2 ∧ α 0=0 ∧ α n=Real.pi/3 ∧ (∀ i,i00by by_cases hkm : k=m · have H:=hstep k (by omega) have hz : t (k+1)=0 := hnull (k+1) (by omega) (by omega) simpa only [hz,petalAngle_zero_right,add_zero] using H · simpa only [hnull k (by omega) hkM,petalAngle_zero_left,add_zero] using hstep k (by omega)) have H := hdisj m (by omega) M hMn (by omega) rw [ham,sub_self,Real.cos_zero] at H nlinarith [mul_pos hmp hMp] lemma sectorRingData_closed (n : ℕ) : IsClosed {p : (ℕ → ℝ) × (ℕ → ℝ) | SectorRingData n p.1 p.2} := by unfold SectorRingData simp only [ofPred_and] refine IsClosed.inter ?_ (IsClosed.inter ?_ (IsClosed.inter ?_ (IsClosed.inter ?_ (IsClosed.inter ?_ (IsClosed.inter ?_ (IsClosed.inter ?_ ?_)))))) · simpa only [ofPred_forall,Set.preimage] using isClosed_iInter (fun i : ℕ => isClosed_Icc.preimage (show Continuous (fun p : (ℕ → ℝ) × (ℕ → ℝ) => p.1 i) by fun_prop)) · simpa only [ofPred_forall,Set.preimage] using isClosed_iInter (fun i : ℕ => isClosed_Icc.preimage (show Continuous (fun p : (ℕ → ℝ) × (ℕ → ℝ) => p.2 i) by fun_prop)) · exact isClosed_eq (by fun_prop) continuous_const · exact isClosed_eq (by fun_prop) continuous_const · exact isClosed_eq (by fun_prop) continuous_const · exact isClosed_eq (by fun_prop) continuous_const · simp only [ofPred_forall] exact isClosed_iInter (fun i => isClosed_iInter (fun _hi => isClosed_eq (by fun_prop) (by unfold petalAngle; fun_prop))) · simp only [ofPred_forall] exact isClosed_iInter (fun i => isClosed_iInter (fun _hi => isClosed_iInter (fun j => isClosed_iInter (fun _hj => isClosed_iInter (fun _hij => isClosed_le (by fun_prop) (by fun_prop)))))) lemma sectorRingData_compact (n : ℕ) : IsCompact {p : (ℕ → ℝ) × (ℕ → ℝ) | SectorRingData n p.1 p.2} := by have ht : IsCompact (pi univ (fun _ : ℕ => Icc (0:ℝ) 1)) := isCompact_univ_pi (fun _ => isCompact_Icc) have hα : IsCompact (pi univ (fun _ : ℕ => Icc (0:ℝ) Real.pi)) := isCompact_univ_pi (fun _ => isCompact_Icc) apply (ht.prod hα).of_isClosed_subset (sectorRingData_closed n) intro p hp exact ⟨by simpa only [mem_pi,mem_univ,true_implies] using hp.1, by simpa only [mem_pi,mem_univ,true_implies] using hp.2.1⟩ theorem exists_bounded_sector_constant (N : ℕ) : ∃ c : ℝ,0 p.1 i.val) K from (by fun_prop : Continuous (fun p : (ℕ → ℝ) × (ℕ → ℝ) => p.1 i.val)).continuousOn) exact ⟨p.1 i.val,SectorRingData.pos hp (by omega),fun t α h=>hmin (show (t,α)∈K from h)⟩ · exact ⟨1,zero_lt_one,fun t α h=>(hK ⟨(t,α),h⟩).elim⟩ choose c hc using hex let S := Finset.univ.image (fun p : (n : Fin (N+1)) × Fin (n.val+1)=>c p.1 p.2) let T := insert 1 S have hT : T.Nonempty := ⟨1,Finset.mem_insert_self _ _⟩ refine ⟨T.min' hT,?_,Finset.min'_le T 1 (Finset.mem_insert_self _ _),?_⟩ · have hmem:=Finset.min'_mem T hT rcases Finset.mem_insert.mp hmem with h|h · rw [h]; exact zero_lt_one · obtain ⟨p,-,hp⟩:=Finset.mem_image.mp h rw [←hp]; exact (hc p.1 p.2).1 · intro n hn t α h i hi let nn : Fin (N+1) := ⟨n,by omega⟩ let ii : Fin (nn.val+1) := ⟨i,by change ir+s k let d : ℕ → ℝ := fun k=>s k+s (k+1) obtain ⟨e,_heA,heB⟩ := open_fan_global_frame n hn L α d (fun k _hk=>add_pos hr (hs _)) (fun k _hk=>add_pos (hs _) (hs _)) hα hcos A B hAB hBC hop let t : ℕ → ℝ := fun k=>s (min k n)/(r+s (min k n)) let β : ℕ → ℝ := fun k=>∑ j∈Finset.range (min k n),α j have hb (k : ℕ) : β k∈Icc (0:ℝ) Real.pi := by have hsmall : min k n≤n := min_le_right _ _ have hle : β k≤Real.pi/3 := by rw [←hsum] exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.range_mono hsmall) (fun j hj _=>(hα j (Finset.mem_range.mp hj)).1.le) refine ⟨Finset.sum_nonneg (fun j hj=>(hα j (lt_of_lt_of_le (Finset.mem_range.mp hj) hsmall)).1.le),?_⟩ linarith [Real.pi_pos] refine ⟨t,β,⟨fun k=>⟨(radius_fraction_mem hr (hs _)).1.le,(radius_fraction_mem hr (hs _)).2.le⟩, hb,?_,?_,by simp [β],by simpa [β] using hsum,?_,?_⟩,fun i hi=>by simp only [t,min_eq_left hi]⟩ · simp only [t,zero_min,hs0] field_simp ring · simp only [t,min_self,hsn] field_simp ring · intro k hk dsimp [β] rw [min_eq_left (show k+1≤n by omega),min_eq_left hk.le,Finset.sum_range_succ] congr 1 simpa only [t,min_eq_left hk.le,min_eq_left (show k+1≤n by omega)] using tangent_petal_angle hr (hs k) (hs (k+1)) (hα k hk) (hcos k hk) · intro i hi j hj hij have hsq := fanRay_dist_sq_pair L α i j rw [←heB i hi,←heB j hj,e.dist_eq] at hsq have H := tangent_nonoverlap_cosine hr (hs i) (hs j) (hdis i hi j hj hij) hsq simpa only [β,t,min_eq_left hi,min_eq_left hj] using H end CannonPackingGeometry end end end end end OAI