introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
19.4 kB
import Mathlib
import OAI.Combinatorics.MatchingCount.Graphs.Cycle
namespace OAI
namespace MatchingFPRAS.Transport
variable {V E : Type*} [Fintype V] [DecidableEq V] [DecidableEq E]
variable {inc : E β†’ V β†’ Prop}
namespace PatternCode
variable (x : PatternCode inc)
def through : Finset E := x.val.1
def closed : Finset E := x.val.2
def total : Finset E := x.through βˆͺ x.closed
noncomputable def ofPath (p : OddPath inc) (chord : E) (hlong : 3 ≀ p.length)
(hc : βˆ€ v, inc chord v ↔ v = p.vertex 0 ∨ v = p.vertex p.length) : PatternCode inc :=
⟨(p.through,p.closed chord),p.closedCycle chord hlong hc,
p.closedCycle_parity_zero chord hlong hc,p.closedCycle_parity_one chord hlong hc⟩
omit [DecidableEq V] in
lemma activated {A B : Finset E}
(hA : MatchingOn inc A Finset.univ) (hB : MatchingOn inc B Finset.univ)
(hT : x.through βŠ† A) (hC : x.closed βŠ† B) :
x.total ∈ components (inc := inc) (A βˆͺ B) ∧
A ∩ x.total = x.through ∧ B ∩ x.total = x.closed := by
obtain ⟨c,ht,hc⟩ := x.property
have heq : c.edgeSet = x.total := by
rw [c.edgeSet_eq_parity_union,ht,hc]
rfl
have hU : βˆ€ i, c.edgeAt i ∈ A βˆͺ B := by
intro i
have he := c.edgeAt_mem_edgeSet i
rw [heq] at he
rcases Finset.mem_union.mp he with he | he
Β· exact Finset.mem_union_left _ (hT he)
Β· exact Finset.mem_union_right _ (hC he)
have hz : c.edgeAt 0 ∈ A := hT (by change c.edgeAt 0 ∈ x.val.1; rw [← ht]; exact c.zero_mem_parity)
have hzn : c.edgeAt 0 βˆ‰ B := fun hb => ((c.cycle_edge_mem_complement hA hB hU 0).mp hb) hz
have hUr : βˆ€ i, c.edgeAt i ∈ B βˆͺ A := by simpa only [Finset.union_comm] using hU
refine ⟨heq β–Έ c.edgeSet_mem_components hA hB hU,?_,?_⟩
Β· have h := c.inter_edgeSet_parity hA hB hU
simpa only [ite_eq_left hz,heq,ht,through] using h
Β· have h := c.inter_edgeSet_parity hB hA hUr
simpa only [ite_eq_right hzn,heq,hc,closed] using h
omit [DecidableEq V] in
lemma activated_injective {A B : Finset E}
(hA : MatchingOn inc A Finset.univ) (hB : MatchingOn inc B Finset.univ) :
Set.InjOn (fun x : PatternCode inc => x.total)
{x | x.through βŠ† A ∧ x.closed βŠ† B} := by
intro x hx y hy he
change x.total = y.total at he
have hxx := x.activated hA hB hx.1 hx.2
have hyy := y.activated hA hB hy.1 hy.2
apply Subtype.ext
apply Prod.ext
Β· change x.through = y.through
rw [← hxx.2.1,← hyy.2.1,he]
Β· change x.closed = y.closed
rw [← hxx.2.2,← hyy.2.2,he]
omit [DecidableEq V] in
lemma activated_derivative {A B : Finset E}
(hA : MatchingOn inc A Finset.univ) (hB : MatchingOn inc B Finset.univ)
(hT : x.through βŠ† A) (hC : x.closed βŠ† B)
(f g : Finset E β†’ ℝ) :
(f ((A \ x.through) βˆͺ x.through) - f ((A \ x.through) βˆͺ x.closed)) -
(g ((B \ x.closed) βˆͺ x.through) - g ((B \ x.closed) βˆͺ x.closed)) =
(f A + g B) - (f (exchange A B x.total) + g (exchange B A x.total)) := by
have hx := x.activated hA hB hT hC
have hAT : A \ x.through = A \ x.total := by rw [← hx.2.1]; ext e; simp
have hBC : B \ x.closed = B \ x.total := by rw [← hx.2.2]; ext e; simp
rw [Finset.sdiff_union_of_subset hT,Finset.sdiff_union_of_subset hC,hAT,hBC]
simp only [exchange,hx.2.1,hx.2.2]
ring
variable [Fintype E]
noncomputable instance : Fintype (PatternCode inc) := Fintype.ofFinite _
omit [DecidableEq V] in
theorem activated_sum_le {A B : Finset E}
(hA : MatchingOn inc A Finset.univ) (hB : MatchingOn inc B Finset.univ)
(f g : Finset E β†’ ℝ) :
(βˆ‘ x : PatternCode inc, if x.through βŠ† A ∧ x.closed βŠ† B then
((f ((A \ x.through) βˆͺ x.through) - f ((A \ x.through) βˆͺ x.closed)) -
(g ((B \ x.closed) βˆͺ x.through) - g ((B \ x.closed) βˆͺ x.closed)))^2 else 0)
≀ βˆ‘ S ∈ components (inc := inc) (A βˆͺ B),
((f A + g B) - (f (exchange A B S) + g (exchange B A S)))^2 := by
classical
rw [← Finset.sum_filter]
let active : Finset (PatternCode inc) := Finset.univ.filter (fun x => x.through βŠ† A ∧ x.closed βŠ† B)
let cost : Finset E β†’ ℝ := fun S =>
((f A + g B) - (f (exchange A B S) + g (exchange B A S)))^2
change (βˆ‘ x ∈ active, _) ≀ βˆ‘ S ∈ components (inc := inc) (A βˆͺ B), cost S
have hinj : Set.InjOn (fun x : PatternCode inc => x.total) (active : Set (PatternCode inc)) := by
intro x hx y hy h
exact activated_injective hA hB (Finset.mem_filter.mp hx).2 (Finset.mem_filter.mp hy).2 h
calc
_ = βˆ‘ x ∈ active, cost x.total := by
apply Finset.sum_congr rfl
intro x hx
have hh := (Finset.mem_filter.mp hx).2
rw [x.activated_derivative hA hB hh.1 hh.2 f g]
_ = βˆ‘ S ∈ active.image (fun x => x.total), cost S := (Finset.sum_image hinj).symm
_ ≀ _ := Finset.sum_le_sum_of_subset_of_nonneg (by
intro S hS
obtain ⟨x,hx,rfl⟩ := Finset.mem_image.mp hS
have hh := (Finset.mem_filter.mp hx).2
exact (x.activated hA hB hh.1 hh.2).1) (fun S _ _ => sq_nonneg _)
end PatternCode
end MatchingFPRAS.Transport
namespace MatchingFPRAS.PairEnergy
open scoped BigOperators
structure Law (Ξ© : Type*) [Fintype Ξ©] where
weight : Ξ© β†’ ℝ
nonneg : βˆ€ x, 0 ≀ weight x
total : βˆ‘ x, weight x = 1
variable {ΞΉ Ξ© Ξ” : Type*} [Fintype ΞΉ] [Fintype Ξ©] [Fintype Ξ”]
noncomputable def guideMass (Ο€ : Law Ξ©) (closed : ΞΉ β†’ Finset Ξ©) (X : ΞΉ) : ℝ :=
βˆ‘ B ∈ closed X, Ο€.weight B
noncomputable def guideMean (Ο€ : Law Ξ©) (closed : ΞΉ β†’ Finset Ξ©)
(derivative : ΞΉ β†’ Ξ© β†’ ℝ) (X : ΞΉ) : ℝ :=
(βˆ‘ B ∈ closed X, Ο€.weight B * derivative X B) / guideMass Ο€ closed X
noncomputable def contextMass (ρ : Ξ” β†’ ℝ) (arc : Ξ” β†’ ΞΉ) (context : Ξ” β†’ Ξ©)
(X : ΞΉ) (A : Ξ©) : ℝ := by
classical
exact βˆ‘ d with arc d = X ∧ context d = A, ρ d
noncomputable def swapSum (Ο€ : Law Ξ©) (through closed : ΞΉ β†’ Finset Ξ©)
(d₁ dβ‚‚ : ΞΉ β†’ Ξ© β†’ ℝ) : ℝ :=
βˆ‘ X, βˆ‘ A ∈ through X, βˆ‘ B ∈ closed X,
Ο€.weight A * Ο€.weight B * (d₁ X A - dβ‚‚ X B) ^ 2
omit [Fintype Ξ©] in
lemma weighted_jensen (s : Finset Ξ©) (w b : Ξ© β†’ ℝ) (a : ℝ)
(hw : βˆ€ i ∈ s, 0 ≀ w i) :
(βˆ‘ i ∈ s, w i) * (a - (βˆ‘ i ∈ s, w i * b i) / (βˆ‘ i ∈ s, w i)) ^ 2 ≀
βˆ‘ i ∈ s, w i * (a - b i) ^ 2 := by
have hm : 0 ≀ βˆ‘ i ∈ s, w i := Finset.sum_nonneg hw
obtain hm0 | hmpos := hm.eq_or_lt
Β· rw [← hm0, zero_mul]
exact Finset.sum_nonneg fun i hi => mul_nonneg (hw i hi) (sq_nonneg _)
Β· have hc := Finset.sum_sq_le_sum_mul_sum_of_sq_le_mul s
(r := fun i => w i * (a - b i))
(f := w) (g := fun i => w i * (a - b i) ^ 2)
hw (fun i hi => mul_nonneg (hw i hi) (sq_nonneg _))
(fun i hi => by nlinarith [sq_nonneg (w i * (a - b i))])
have heq : (βˆ‘ i ∈ s, w i * (a - b i)) =
(βˆ‘ i ∈ s, w i) *
(a - (βˆ‘ i ∈ s, w i * b i) / (βˆ‘ i ∈ s, w i)) := by
simp_rw [mul_sub, Finset.sum_sub_distrib, ← Finset.sum_mul]
rw [mul_div_cancelβ‚€ _ (ne_of_gt hmpos)]
rw [heq, mul_pow] at hc
apply (mul_le_mul_iff_rightβ‚€ hmpos).mp
nlinarith [hc]
omit [Fintype Ξ©] in
lemma sum_contextMass (ρ : Ξ” β†’ ℝ) (arc : Ξ” β†’ ΞΉ) (context : Ξ” β†’ Ξ©)
(through : ΞΉ β†’ Finset Ξ©) (hcontext : βˆ€ d, context d ∈ through (arc d))
(h : ΞΉ β†’ Ξ© β†’ ℝ) :
(βˆ‘ d, ρ d * h (arc d) (context d)) =
βˆ‘ X, βˆ‘ A ∈ through X, contextMass ρ arc context X A * h X A := by
classical
symm
simp only [contextMass, Finset.sum_mul]
calc
_ = βˆ‘ X, βˆ‘ A ∈ through X,
βˆ‘ d with arc d = X ∧ context d = A, ρ d * h (arc d) (context d) := by
apply Finset.sum_congr rfl
intro X _
apply Finset.sum_congr rfl
intro A _
apply Finset.sum_congr rfl
intro d hd
obtain ⟨hX, hA⟩ := (Finset.mem_filter.mp hd).2
rw [hX, hA]
_ = βˆ‘ X, βˆ‘ d with arc d = X, ρ d * h (arc d) (context d) := by
apply Finset.sum_congr rfl
intro X _
have ht : βˆ€ d ∈ Finset.univ.filter (fun d => arc d = X), context d ∈ through X := by
intro d hd
simpa only [(Finset.mem_filter.mp hd).2] using hcontext d
simpa only [Finset.filter_filter] using
Finset.sum_fiberwise_of_maps_to ht (fun d => ρ d * h (arc d) (context d))
_ = βˆ‘ d, ρ d * h (arc d) (context d) := Finset.sum_fiberwise _ arc _
omit [Fintype ΞΉ] in
lemma tagged_context_bound {Tag : Type*} [Fintype Tag]
(Ο€ : Law Ξ©) (closed : ΞΉ β†’ Finset Ξ©) (ρ : Ξ” β†’ ℝ)
(arc : Ξ” β†’ ΞΉ) (context guide : Ξ” β†’ Ξ©) (tag : Ξ” β†’ Tag) (C : ℝ)
(hC : 0 ≀ C)
(hguide : βˆ€ d, guide d ∈ closed (arc d))
(hinj : Function.Injective fun d => (context d, guide d, tag d))
(hweight : βˆ€ d, ρ d ≀ C * Ο€.weight (context d) * Ο€.weight (guide d))
(X : ΞΉ) (A : Ξ©) :
contextMass ρ arc context X A ≀
(C * Fintype.card Tag) * Ο€.weight A * guideMass Ο€ closed X := by
classical
let s : Finset Ξ” := Finset.univ.filter (fun d => arc d = X ∧ context d = A)
have hmaps : βˆ€ d ∈ s, guide d ∈ closed X := by
intro d hd
have hX := (Finset.mem_filter.mp hd).2.1
simpa only [hX] using hguide d
have hfiber (B : Ξ©) : (s.filter (fun d => guide d = B)).card ≀ Fintype.card Tag := by
apply Finset.card_le_card_of_injOn tag (t := Finset.univ)
Β· intro d hd
exact Finset.mem_univ _
Β· intro d hd e he heq
apply hinj
have hd' := (Finset.mem_filter.mp (Finset.mem_filter.mp hd).1).2
have he' := (Finset.mem_filter.mp (Finset.mem_filter.mp he).1).2
have hdB := (Finset.mem_filter.mp hd).2
have heB := (Finset.mem_filter.mp he).2
exact Prod.ext (hd'.2.trans he'.2.symm) (Prod.ext (hdB.trans heB.symm) heq)
change (βˆ‘ d ∈ s, ρ d) ≀ _
rw [← Finset.sum_fiberwise_of_maps_to hmaps ρ]
calc
_ ≀ βˆ‘ B ∈ closed X, (Fintype.card Tag : ℝ) * (C * Ο€.weight A * Ο€.weight B) := by
apply Finset.sum_le_sum
intro B hB
calc
_ ≀ βˆ‘ d ∈ s with guide d = B, C * Ο€.weight A * Ο€.weight B := by
apply Finset.sum_le_sum
intro d hd
have hdA := (Finset.mem_filter.mp (Finset.mem_filter.mp hd).1).2.2
have hdB := (Finset.mem_filter.mp hd).2
simpa only [hdA, hdB] using hweight d
_ = ((s.filter (fun d => guide d = B)).card : ℝ) *
(C * Ο€.weight A * Ο€.weight B) := by simp
_ ≀ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast hfiber B)
(mul_nonneg (mul_nonneg hC (Ο€.nonneg A)) (Ο€.nonneg B))
_ = _ := by
simp only [guideMass, Finset.mul_sum]
apply Finset.sum_congr rfl
intro B hB
ring
theorem error_demand_load
(Ο€ : Law Ξ©) (through closed : ΞΉ β†’ Finset Ξ©) (d₁ dβ‚‚ : ΞΉ β†’ Ξ© β†’ ℝ)
(ρ : Ξ” β†’ ℝ) (arc : Ξ” β†’ ΞΉ) (cβ‚€ c₁ : Ξ” β†’ Ξ©) (C : ℝ)
(hρ : βˆ€ d, 0 ≀ ρ d) (hC : 0 ≀ C)
(hcβ‚€ : βˆ€ d, cβ‚€ d ∈ through (arc d))
(hc₁ : βˆ€ d, c₁ d ∈ through (arc d))
(hmβ‚€ : βˆ€ X A, contextMass ρ arc cβ‚€ X A ≀ C * Ο€.weight A * guideMass Ο€ closed X)
(hm₁ : βˆ€ X A, contextMass ρ arc c₁ X A ≀ C * Ο€.weight A * guideMass Ο€ closed X) :
(βˆ‘ d, ρ d * (d₁ (arc d) (c₁ d) - d₁ (arc d) (cβ‚€ d)) ^ 2) ≀
4 * C * swapSum Ο€ through closed d₁ dβ‚‚ := by
classical
let ΞΌ := guideMean Ο€ closed dβ‚‚
have hcontext (c : Ξ” β†’ Ξ©) (hc : βˆ€ d, c d ∈ through (arc d))
(hm : βˆ€ X A, contextMass ρ arc c X A ≀ C * Ο€.weight A * guideMass Ο€ closed X) :
(βˆ‘ d, ρ d * (d₁ (arc d) (c d) - ΞΌ (arc d)) ^ 2) ≀
C * swapSum Ο€ through closed d₁ dβ‚‚ := by
rw [sum_contextMass ρ arc c through hc (fun X A => (d₁ X A - ΞΌ X) ^ 2)]
calc
_ ≀ βˆ‘ X, βˆ‘ A ∈ through X,
C * Ο€.weight A * guideMass Ο€ closed X * (d₁ X A - ΞΌ X) ^ 2 := by
apply Finset.sum_le_sum
intro X _
exact Finset.sum_le_sum fun A _ =>
mul_le_mul_of_nonneg_right (hm X A) (sq_nonneg _)
_ ≀ βˆ‘ X, βˆ‘ A ∈ through X, C * Ο€.weight A *
(βˆ‘ B ∈ closed X, Ο€.weight B * (d₁ X A - dβ‚‚ X B) ^ 2) := by
apply Finset.sum_le_sum
intro X _
apply Finset.sum_le_sum
intro A _
have hj := weighted_jensen (closed X) Ο€.weight (dβ‚‚ X) (d₁ X A)
(fun B _ => Ο€.nonneg B)
change guideMass Ο€ closed X * (d₁ X A - ΞΌ X) ^ 2 ≀ _ at hj
convert mul_le_mul_of_nonneg_left hj (mul_nonneg hC (Ο€.nonneg A)) using 1
ring
_ = C * swapSum Ο€ through closed d₁ dβ‚‚ := by
simp only [swapSum, Finset.mul_sum]
apply Finset.sum_congr rfl
intro X _
apply Finset.sum_congr rfl
intro A _
apply Finset.sum_congr rfl
intro B _
ring
have hβ‚€ := hcontext cβ‚€ hcβ‚€ hmβ‚€
have h₁ := hcontext c₁ hc₁ hm₁
calc
_ ≀ βˆ‘ d, (2 * (ρ d * (d₁ (arc d) (c₁ d) - ΞΌ (arc d)) ^ 2) +
2 * (ρ d * (d₁ (arc d) (cβ‚€ d) - ΞΌ (arc d)) ^ 2)) := by
apply Finset.sum_le_sum
intro d _
nlinarith [mul_nonneg (hρ d)
(sq_nonneg (d₁ (arc d) (c₁ d) + d₁ (arc d) (cβ‚€ d) - 2 * ΞΌ (arc d)))]
_ = 2 * (βˆ‘ d, ρ d * (d₁ (arc d) (c₁ d) - ΞΌ (arc d)) ^ 2) +
2 * (βˆ‘ d, ρ d * (d₁ (arc d) (cβ‚€ d) - ΞΌ (arc d)) ^ 2) := by
rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum]
_ ≀ 4 * C * swapSum Ο€ through closed d₁ dβ‚‚ := by linarith
end MatchingFPRAS.PairEnergy
namespace MatchingFPRAS.Transport
variable {V E : Type*} [Fintype V] [DecidableEq V] [Fintype E] [DecidableEq E]
variable {inc : E β†’ V β†’ Prop}
noncomputable instance instFintypePM : Fintype (PM inc) := Fintype.ofFinite _
noncomputable def gibbsLaw (w : E β†’ ℝ) (hw : βˆ€ e, 0 < w e) (M : PM inc) :
MatchingFPRAS.PairEnergy.Law (PM inc) where
weight := gibbs w
nonneg := fun A => le_of_lt (gibbs_pos w hw A)
total := gibbs_sum w hw M
namespace PatternCode
noncomputable def throughStates (x : PatternCode inc) : Finset (PM inc) := by
classical
exact Finset.univ.filter (fun A => x.through βŠ† A.val)
noncomputable def closedStates (x : PatternCode inc) : Finset (PM inc) := by
classical
exact Finset.univ.filter (fun A => x.closed βŠ† A.val)
omit [DecidableEq V] in
lemma mem_throughStates (x : PatternCode inc) (A : PM inc) :
A ∈ x.throughStates ↔ x.through βŠ† A.val := by
classical
simp [throughStates]
omit [DecidableEq V] in
lemma mem_closedStates (x : PatternCode inc) (A : PM inc) :
A ∈ x.closedStates ↔ x.closed βŠ† A.val := by
classical
simp [closedStates]
def firstDerivative (f : Finset E β†’ ℝ) (x : PatternCode inc) (A : PM inc) : ℝ :=
f A.val - f ((A.val \ x.through) βˆͺ x.closed)
def secondDerivative (g : Finset E β†’ ℝ) (x : PatternCode inc) (B : PM inc) : ℝ :=
g ((B.val \ x.closed) βˆͺ x.through) - g B.val
end PatternCode
end MatchingFPRAS.Transport
namespace MatchingFPRAS.Transport.CellDemands
variable {V L : Type*} [Fintype V] [DecidableEq V] [Fintype L] [DecidableEq L]
variable {bags : V β†’ Finset L} {G : SimpleGraph L}
noncomputable local instance : Fintype (BagEdge bags) := Fintype.ofFinite _
variable {hbags : βˆ€ v, βˆ€ a ∈ bags v, βˆ€ b ∈ bags v, a = b ∨ G.Adj a b}
variable {hG : G.IsAcyclic}
namespace ErrorDemand
variable (e : ErrorDemand hbags hG)
omit [Fintype L] in
lemma X_long : 3 ≀ (e.demand.paths.side e.X).length := by
have hp := (e.demand.paths.side e.X).positive
have ho := (e.demand.paths.side e.X).odd
have hn := e.property e.X e.X_bit
change (e.demand.paths.side e.X).length β‰  1 at hn
omega
noncomputable def pattern : PatternCode (BagEdge.Incident (bags := bags)) :=
PatternCode.ofPath (e.demand.paths.side e.X) (e.demand.paths.chord e.X) e.X_long
(e.demand.paths.chord_incidence e.X)
variable (height : L β†’ ℝ) (hheight : βˆ€ l, 0 < height l)
variable (hstep : βˆ€ a b, G.Adj a b β†’ height a ≀ 2 * height b)
variable (D : ℝ) (hD : 1 ≀ D) (w : BagEdge bags β†’ ℝ)
variable (hw : βˆ€ e, height e.color / D ≀ w e ∧ w e ≀ 3 * height e.color)
variable (lo hi : ℝ) (hlo : 0 < lo) (hlohi : lo ≀ hi)
noncomputable def choice (j : Bool) : DemandEncoding BagEdge.Incident e.raw :=
if j then e.errorOne height hheight hstep D hD w hw lo hi hlo hlohi
else e.errorZero height hheight hstep D hD w hw lo hi hlo hlohi
lemma choice_spec (j : Bool) :
let enc := e.choice height hheight hstep D hD w hw lo hi hlo hlohi j
enc.first.val = e.demand.outside βˆͺ
(if j then e.demand.paths.contextOne e.bit e.Y else e.demand.paths.orientation e.bit) ∧
e.pattern.closed βŠ† enc.second.val ∧
gibbs (fun e => max lo (min hi (w e))) e.demand.1.1 *
gibbs (fun e => max lo (min hi (w e))) e.demand.1.2 ≀
(1000*D)^4 * gibbs (fun e => max lo (min hi (w e))) enc.first *
gibbs (fun e => max lo (min hi (w e))) enc.second := by
have h := (e.exists_errors height hheight hstep D hD w hw lo hi hlo hlohi).choose_spec.choose_spec
change _ ∧ _ ∧ _ ∧ _ ∧ _ ∧ _ at h
cases j
· exact ⟨h.1,h.2.2.1,h.2.2.2.2.1⟩
· exact ⟨h.2.1,h.2.2.2.1,h.2.2.2.2.2⟩
lemma choice_injective (j : Bool) : Function.Injective (fun e : ErrorDemand hbags hG =>
(e.choice height hheight hstep D hD w hw lo hi hlo hlohi j).finiteCode) := by
intro e f h
exact raw_injective (DemandEncoding.finiteCode_recovers _ _ h)
lemma choice_through (j : Bool) :
(e.choice height hheight hstep D hD w hw lo hi hlo hlohi j).first ∈ e.pattern.throughStates := by
apply (e.pattern.mem_throughStates _).mpr
rw [(e.choice_spec height hheight hstep D hD w hw lo hi hlo hlohi j).1]
change (e.demand.paths.side e.X).through βŠ† _
apply Finset.Subset.trans _ (Finset.subset_union_right)
cases j
Β· exact e.demand.paths.through_subset_orientation e.bit e.X e.X_bit
Β· exact e.demand.paths.through_subset_contextOne e.bit e.X e.Y e.X_bit e.Y_bit e.X_ne_Y
BagEdge.exists_incident
theorem context_load (M : PM (BagEdge.Incident (bags := bags))) (j : Bool)
(X : PatternCode (BagEdge.Incident (bags := bags))) (A : PM BagEdge.Incident) :
let wt := fun e => max lo (min hi (w e))
let Ο€ := gibbsLaw wt (fun _ => lt_of_lt_of_le hlo (le_max_left _ _)) M
let ρ := fun e : ErrorDemand hbags hG => gibbs wt e.demand.1.1 * gibbs wt e.demand.1.2
let enc := fun e : ErrorDemand hbags hG => e.choice height hheight hstep D hD w hw lo hi hlo hlohi j
MatchingFPRAS.PairEnergy.contextMass ρ pattern (fun e => (enc e).first) X A ≀
((1000*D)^4 * Fintype.card (DemandTag (V := V) (E := BagEdge bags))) *
Ο€.weight A * MatchingFPRAS.PairEnergy.guideMass Ο€ PatternCode.closedStates X := by
dsimp only
apply MatchingFPRAS.PairEnergy.tagged_context_bound
(guide := fun e => (e.choice height hheight hstep D hD w hw lo hi hlo hlohi j).second)
(tag := fun e => (e.choice height hheight hstep D hD w hw lo hi hlo hlohi j).tag)
Β· positivity
Β· intro e
exact (e.pattern.mem_closedStates _).mpr
(e.choice_spec height hheight hstep D hD w hw lo hi hlo hlohi j).2.1
Β· exact choice_injective height hheight hstep D hD w hw lo hi hlo hlohi j
Β· intro e
exact (e.choice_spec height hheight hstep D hD w hw lo hi hlo hlohi j).2.2
end ErrorDemand
end MatchingFPRAS.Transport.CellDemands
end OAI