import Mathlib import OAI.GroupTheory.SimpleAmenable.Arithmetic.ConcurrentDenominators import OAI.GroupTheory.SimpleAmenable.PolygonGeometry.FlagSites import OAI.GroupTheory.SimpleAmenable.Arithmetic.QuadraticRectangleCounts import OAI.GroupTheory.SimpleAmenable.Amenability.BarrierCells namespace OAI section section open scoped symmDiff namespace SimpleAmenable open scoped commutatorElement open scoped commutatorElement section BarrierLineGeometry open Classical Set noncomputable def barrierLinePoint (a : ℕ) (j : Fin 4) (c : CutRing) (t : ℝ) : ℝ×ℝ := ![(ordinary c,t),(t,ordinary c),(t,ordinary c+Real.goldenRatio^a*t), (ordinary c+Real.goldenRatio^a*t,t)] j noncomputable def barrierLineParameter (j : Fin 4) (p : ℝ×ℝ) : ℝ := ![p.2,p.1,p.1,p.2] j noncomputable def barrierLineLower (a : ℕ) (j : Fin 4) (c : CutRing) : ℝ := ![0,0,max 0 (-ordinary c/Real.goldenRatio^a),max 0 (-ordinary c/Real.goldenRatio^a)] j noncomputable def barrierLineUpper (a : ℕ) (j : Fin 4) (c : CutRing) : ℝ := ![1,1,min 1 ((1-ordinary c)/Real.goldenRatio^a),min 1 ((1-ordinary c)/Real.goldenRatio^a)] j theorem cutForm_barrierLinePoint (a : ℕ) (j : Fin 4) (c : CutRing) (t : ℝ) : cutForm a j (barrierLinePoint a j c t)=ordinary c := by fin_cases j <;> simp [cutForm,barrierLinePoint] theorem barrierLineParameter_point (a : ℕ) (j : Fin 4) (c : CutRing) (t : ℝ) : barrierLineParameter j (barrierLinePoint a j c t)=t := by fin_cases j <;> simp [barrierLineParameter,barrierLinePoint] theorem barrierLinePoint_parameter {a : ℕ} {j : Fin 4} {c : CutRing} {p : ℝ×ℝ} (hp : cutForm a j p=ordinary c) : barrierLinePoint a j c (barrierLineParameter j p)=p := by fin_cases j <;> simp [cutForm] at hp <;> apply Prod.ext <;> simp [barrierLinePoint,barrierLineParameter] <;> linarith noncomputable def barrierCandidate (a : ℕ) (j : Fin 4) (N : ℝ) : Set CutRing := {c | |conjugate c|≤4*N ∧ ∃p∈squareInterior,cutForm a j p=ordinary c} theorem squareInterior_cutForm_bound {a : ℕ} {p : ℝ×ℝ} (hp : p∈squareInterior) (j : Fin 4) : |cutForm a j p|≤1+Real.goldenRatio^a := by have ht : 0 simp [cutForm] <;> constructor <;> nlinarith theorem barrierCandidate_finite (a : ℕ) (j : Fin 4) {N : ℝ} (hN : 0 simp [barrierLinePoint,barrierLineLower,barrierLineUpper, squareInterior,Set.mem_prod,Set.mem_Ioo] · have hz := barrierCandidate_coordinate hc (Or.inl rfl) exact fun _ _ => hz · have hz := barrierCandidate_coordinate hc (Or.inr rfl) exact fun _ _ => hz · rw [div_lt_iff₀ ht,lt_div_iff₀ ht] constructor <;> intro h <;> constructor <;> constructor <;> linarith [h.1.1,h.1.2,h.2.1,h.2.2] · rw [div_lt_iff₀ ht,lt_div_iff₀ ht] constructor <;> intro h <;> constructor <;> constructor <;> linarith [h.1.1,h.1.2,h.2.1,h.2.2] end BarrierLineGeometry section BarrierFlags open Classical noncomputable def barrierTangent (a : ℕ) (j : Fin 4) : ℝ×ℝ := ![(0,1),(1,0),(1,Real.goldenRatio^a),(Real.goldenRatio^a,1)] j theorem barrierLinePoint_sub (a : ℕ) (j : Fin 4) (c : CutRing) (s t : ℝ) : barrierLinePoint a j c s-barrierLinePoint a j c t=(s-t) • barrierTangent a j := by fin_cases j <;> apply Prod.ext <;> simp [barrierLinePoint,barrierTangent] <;> ring theorem barrierTangent_cut (a : ℕ) (j : Fin 4) : cutForm a j (barrierTangent a j)=0 := by fin_cases j <;> simp [barrierTangent,cutForm] theorem positiveDiagonal_transverse {a : ℕ} (ha : 0 simp [cutForm] <;> linarith theorem exists_barrierFlagDirection {a : ℕ} (ha : 0 Or.inr (positiveDiagonal_transverse ha k)) have ht : 0 norm_num [cutForm,barrierTangent,ne_of_gt ht,not_lt_of_gt ht] at hh ⊢ <;> exact hh exact lt_of_le_of_ne (le_of_not_gt hnot) hn.symm have hpos₂ : 0 norm_num [cutForm,barrierTangent,ne_of_gt ht,not_lt_of_gt ht] at hh ⊢ <;> exact hh exact lt_of_le_of_ne (le_of_not_gt hnot) hn.symm exact ⟨d,hd,hpos₁,hpos₂,he⟩ noncomputable def barrierFlagDirection {a : ℕ} (ha : 0 hd.2.1, fun h => False.elim ((ne_of_lt hx.2) h),fun _ => hd.2.2.1, fun h => False.elim ((ne_of_lt hy.2) h)⟩ theorem barrierIncoming_edge {a : ℕ} {j : Fin 4} {N : ℝ} {c : CutRing} (hc : c∈barrierCandidate a j N) : ∃k : Fin 4,k≠j ∧ cutForm a k (barrierIncoming a j c)=ordinary (0:CutRing) := by obtain ⟨hx,hy,hzero⟩ := barrierIncoming_bounds hc have hj := cutForm_barrierLinePoint a j c (barrierLineLower a j c) change cutForm a j (barrierIncoming a j c)=ordinary c at hj by_cases hj₀ : j=0 · subst j refine ⟨1,by decide,?_⟩ have hcpos := (barrierCandidate_coordinate hc (Or.inl rfl)).1 have hxne : (barrierIncoming a 0 c).1≠0 := by simp [cutForm] at hj rw [hj]; exact ne_of_gt hcpos simpa [cutForm] using hzero.resolve_left hxne · rcases hzero with hzero | hzero · exact ⟨0,Ne.symm hj₀,by simpa [cutForm] using hzero⟩ · refine ⟨1,?_,by simpa [cutForm] using hzero⟩ intro he subst j have hcpos := (barrierCandidate_coordinate hc (Or.inr rfl)).1 simp [cutForm] at hj linarith theorem barrierIncoming_lattice {a : ℕ} (ha : 0 simp only [scaledOrdinary] · rw [hu,mul_div_cancel_left₀ _ (by exact_mod_cast Nat.ne_of_gt (commonVertexDenominator_pos ha))] · rw [hv,mul_div_cancel_left₀ _ (by exact_mod_cast Nat.ne_of_gt (commonVertexDenominator_pos ha))] noncomputable def barrierIncomingSite {a m : ℕ} (ha : 0