roseking's picture
Add lean source and binary files (part 18)
67aee1d verified
Raw History Blame Contribute Delete
11.3 kB
19
def physicalEdges (anchor : J → Torus L) :=
body · 1 line
  Bool×{p : J×J // p.1≠p.2 ∧ torusDistance L (anchor p.1) (anchor p.2)≤21}
22
instance physicalEdges_fintype (anchor : J → Torus L) : Fintype (physicalEdges anchor) :=
body · 1 line
  inferInstanceAs (Fintype (Bool×{p : J×J // p.1≠p.2 ∧ torusDistance L (anchor p.1) (anchor p.2)≤21}))
25
def physicalSparseChecks (r : ℝ) (anchor : J → Torus L) (allowed : J → Set C(Time,Point))
    (owner : Bool → J → I) (path : ∀b j,V (owner b j) → allowed j)
    (hpath : ∀b j,Measurable (path b j)) : physicalEdges anchor → LocalCheck V :=
body · 1 line
  factorPathCheck (L:=L) allowed owner Prod.fst (fun e ↦ e.2.val.1) (fun e ↦ e.2.val.2) path hpath r
31
lemma physicalSparseChecks_complete (r : ℝ) (hr : r≤1)
    (anchor : J → Torus L) (allowed : J → Set C(Time,Point))
    (hconf : ∀j,∀f : allowed j,Confined (anchor j) (projectCurve L f.val))
    (owner : Bool → J → I) (path : ∀b j,V (owner b j) → allowed j)
    (hpath : ∀b j,Measurable (path b j)) (x : ∀i,V i)
    (hx : x∈retainedEvent (physicalSparseChecks r anchor allowed owner path hpath) Finset.univ) :
    ∀b j k,j≠k → ¬TrialCollision r (projectCurve L (path b k (x (owner b k))).val)
      (path b j (x (owner b j))).val := by
proof · 8 lines
  intro b j k hjk
  by_cases hn : torusDistance L (anchor j) (anchor k)≤21
  · exact hx (b,⟨(j,k),hjk,hn⟩) (Finset.subset_univ _)
  · rintro ⟨s,hs⟩
    exact (not_le_of_gt (confined_far_avoid (anchor j) (anchor k)
      (projectCurve L (path b j (x (owner b j))).val)
      (projectCurve L (path b k (x (owner b k))).val)
      (hconf _ _) (hconf _ _) (lt_of_not_ge hn) hr s)) hs
48
lemma physicalSparseChecks_degree {K : ℕ} [NeZero K] (hL : L.val=(K:ℝ))
    (anchor : J → Torus L) (center : I → Fin 3 → Fin K)
    (M : ℕ) (hm : ∀v,(Finset.univ.filter (fun i : I ↦ center i=v)).card≤M)
    (owner : Bool → J → I) (howner : ∀b,Function.Injective (owner b))
    (hcenter : ∀b j,torusDistance L (anchor j) (gridCenter L (center (owner b j)))≤1)
    (i : I) :
    (Finset.univ.filter (fun e : physicalEdges anchor ↦ owner e.1 e.2.val.1=i ∨ owner e.1 e.2.val.2=i)).card≤4*(49^3*M) := by
proof · 19 lines
  have hinj : Function.Injective (fun e : physicalEdges anchor ↦
      (e.1,(owner e.1 e.2.val.1,owner e.1 e.2.val.2))) := by
    rintro ⟨b,⟨⟨j,k⟩,h⟩⟩ ⟨b',⟨⟨j',k'⟩,h'⟩⟩ he
    have hb : b=b' := congrArg Prod.fst he
    subst b'
    have hj : j=j' := howner b (congrArg (fun p ↦ p.2.1) he)
    have hk : k=k' := howner b (congrArg (fun p ↦ p.2.2) he)
    subst j';subst k';rfl
  have hn : ∀e : physicalEdges anchor,
      torusDistance L (gridCenter L (center (owner e.1 e.2.val.1)))
        (gridCenter L (center (owner e.1 e.2.val.2)))≤23 := by
    intro e
    exact incident_centers_close anchor (fun j ↦ gridCenter L (center (owner e.1 j))) id
      (hcenter e.1) e.2.val.1 e.2.val.2 e.2.property.2
  have hd := physical_incident_degree L hL center M hm
    (fun e : physicalEdges anchor ↦ owner e.1 e.2.val.1)
    (fun e : physicalEdges anchor ↦ owner e.1 e.2.val.2) Prod.fst hinj hn i
  simp only [Fintype.card_bool] at hd
  omega
75
lemma physicalSparseChecks_insertion {K : ℕ} [NeZero K] (hL : L.val=(K:ℝ))
    (r : ℝ) (anchor : J → Torus L) (center : I → Fin 3 → Fin K)
    (M : ℕ) (hm : ∀v,(Finset.univ.filter (fun i : I ↦ center i=v)).card≤M)
    (allowed : J → Set C(Time,Point))
    (owner : Bool → J → I) (howner : ∀b,Function.Injective (owner b))
    (hcenter : ∀b j,torusDistance L (anchor j) (gridCenter L (center (owner b j)))≤1)
    (path : ∀b j,V (owner b j) → allowed j) (hpath : ∀b j,Measurable (path b j))
    (μ : ∀i,Measure (V i)) [∀i,IsProbabilityMeasure (μ i)]
    (P : ∀j,Measure (allowed j)) (G q a : ℝ≥0∞) (U : Finset I)
    (hdom : ∀b j,owner b j∈U → (μ (owner b j)).map (path b j)≤G • P j)
    (hq : ∀j k,j≠k → ∀g : allowed k,P j {f | TrialCollision r (projectCurve L g.val) f.val}≤q)
    (hsmall : a+(4*(49^3*M):ℕ)*(G*q)≤1) :
    UniformInsertionOn (physicalSparseChecks r anchor allowed owner path hpath) μ a U := by
proof · 10 lines
  have hd : ∀i∈U,(Finset.univ.filter (fun e : physicalEdges anchor ↦
      owner e.1 e.2.val.1=i ∨ owner e.1 e.2.val.2=i)).card≤4*(49^3*M) := by
    intro i _
    exact physicalSparseChecks_degree hL anchor center M hm owner howner hcenter i
  exact factorPath_insertion (L:=L) allowed owner howner
    (fun e : physicalEdges anchor ↦ e.1)
    (fun e : physicalEdges anchor ↦ e.2.val.1)
    (fun e : physicalEdges anchor ↦ e.2.val.2)
    (fun e : physicalEdges anchor ↦ e.2.property.1) path hpath r μ P G q a
    (4*(49^3*M)) U hdom hq hd hsmall
114
def fiberEquiv {i j : I} (h : i=j) : X i ≃ᵐ X j := by
body · 2 lines
  subst j
  exact MeasurableEquiv.refl _
118
lemma fiberEquiv_pi {i j : I} (h : i=j) (x : ∀i,X i) : fiberEquiv h (x i)=x j := by
proof · 2 lines
  subst j
  rfl
122
@[simp] lemma fiberEquiv_self {i : I} (h : i=i) (x : X i) : fiberEquiv h x=x := rfl
127
lemma move_mem_iff (i : I) : σ i∈S ↔ i∈S := by
proof · 9 lines
  constructor
  · intro hi
    by_contra hn
    exact hn (by simpa only [hfix i hn] using hi)
  · intro hi
    by_contra hn
    have hf := hfix (σ i) hn
    have he := σ.injective hf
    exact hn (he.symm ▸ hi)
138
def routeOwner (label : J → I) (b : Bool) (j : J) : I := if b then σ (label j) else label j
140
lemma routeOwner_injective (label : J → I) (hlabel : Function.Injective label) (b : Bool) :
    Function.Injective (routeOwner σ label b) := by
proof · 3 lines
  cases b
  · exact hlabel
  · exact σ.injective.comp hlabel
146
def routePath (allowed : J → Set C(Time,Point)) (label : J → I)
    (get : ∀j,X (label j) → allowed j) (b : Bool) (j : J) :
    (X (routeOwner σ label b j)×X (σ.symm (routeOwner σ label b j))) → allowed j := by
body · 5 lines
  cases b
  · exact fun p ↦ get j p.1
  · exact fun p ↦ if h : label j∈S then
      get j (fiberEquiv (σ.symm_apply_apply (label j)) p.2)
    else get j (fiberEquiv (hfix (label j) h) p.1)
156
lemma routePath_measurable (allowed : J → Set C(Time,Point)) (label : J → I)
    (get : ∀j,X (label j) → allowed j) (hg : ∀j,Measurable (get j)) (b : Bool) (j : J) :
    Measurable (routePath σ S hfix allowed label get b j) := by
proof · 7 lines
  cases b
  · exact (hg j).comp measurable_fst
  · by_cases h : label j∈S
    · simp only [routePath,dite_eq_left h]
      exact (hg j).comp ((fiberEquiv (σ.symm_apply_apply (label j))).measurable.comp measurable_snd)
    · simp only [routePath,dite_eq_right h]
      exact (hg j).comp ((fiberEquiv (hfix (label j) h)).measurable.comp measurable_fst)
167
def routeChecks (r : ℝ) (anchor : J → Torus L) (allowed : J → Set C(Time,Point))
    (label : J → I) (get : ∀j,X (label j) → allowed j) (hg : ∀j,Measurable (get j)) :=
body · 2 lines
  physicalSparseChecks (V:=fun i ↦ X i×X (σ.symm i)) r anchor allowed (routeOwner σ label)
    (routePath σ S hfix allowed label get) (routePath_measurable σ S hfix allowed label get hg)
172
def primaryChecks (r : ℝ) (anchor : J → Torus L) (allowed : J → Set C(Time,Point))
    (label : J → I) (get : ∀j,X (label j) → allowed j) (hg : ∀j,Measurable (get j)) :=
body · 1 line
  physicalSparseChecks r anchor allowed (fun _ ↦ label) (fun _ ↦ get) (fun _ ↦ hg)
177
lemma routeChecks_primary (r : ℝ) (anchor : J → Torus L) (allowed : J → Set C(Time,Point))
    (label : J → I) (get : ∀j,X (label j) → allowed j) (hg : ∀j,Measurable (get j))
    (u : Finset I) (p : ∀i,X i×X (σ.symm i))
    (hp : p∈retainedEvent (routeChecks σ S hfix r anchor allowed label get hg) u) :
    (fun i ↦ (p i).1)∈retainedEvent (primaryChecks r anchor allowed label get hg) u := by
proof · 2 lines
  intro e he
  exact hp (false,e.2) he
186
lemma routePath_unselected (allowed : J → Set C(Time,Point)) (label : J → I)
    (get : ∀j,X (label j) → allowed j) (j : J) (hj : label j∉S)
    (p : ∀i,X i×X (σ.symm i)) :
    routePath σ S hfix allowed label get true j (p (routeOwner σ label true j))=
      get j (p (label j)).1 := by
proof · 2 lines
  simp only [routePath,dite_eq_right hj]
  exact congrArg (get j) (fiberEquiv_pi (hfix (label j) hj) (fun i ↦ (p i).1))
195
lemma routeChecks_outside (r : ℝ) (anchor : J → Torus L) (allowed : J → Set C(Time,Point))
    (label : J → I) (get : ∀j,X (label j) → allowed j) (hg : ∀j,Measurable (get j))
    (o : Finset I) (hso : Disjoint S o) (p : ∀i,X i×X (σ.symm i))
    (hp : (fun i ↦ (p i).1)∈retainedEvent (primaryChecks r anchor allowed label get hg) o) :
    p∈retainedEvent (routeChecks σ S hfix r anchor allowed label get hg) o := by
proof · 22 lines
  intro e he
  rcases e with ⟨b,⟨⟨j,k⟩,hjk,hnear⟩⟩
  cases b
  · exact hp (false,⟨(j,k),hjk,hnear⟩) he
  · have hj : label j∉S := by
      intro hs
      exact Finset.disjoint_left.mp hso ((move_mem_iff σ S hfix (label j)).mpr hs)
        (he (by simp [routeChecks,physicalSparseChecks,factorPathCheck,dependentCheck,routeOwner]))
    have hk : label k∉S := by
      intro hs
      exact Finset.disjoint_left.mp hso ((move_mem_iff σ S hfix (label k)).mpr hs)
        (he (by simp [routeChecks,physicalSparseChecks,factorPathCheck,dependentCheck,routeOwner]))
    have he' : (primaryChecks r anchor allowed label get hg (false,⟨(j,k),hjk,hnear⟩)).support⊆o := by
      simpa [routeChecks,primaryChecks,physicalSparseChecks,factorPathCheck,dependentCheck,routeOwner,
        hfix (label j) hj,hfix (label k) hk] using he
    have hh := hp (false,⟨(j,k),hjk,hnear⟩) he'
    change ¬TrialCollision r (projectCurve L (routePath σ S hfix allowed label get true k
      (p (routeOwner σ label true k))).val) (routePath σ S hfix allowed label get true j
      (p (routeOwner σ label true j))).val
    rw [routePath_unselected σ S hfix allowed label get j hj,
      routePath_unselected σ S hfix allowed label get k hk]
    exact hh