Download data/lean/OAI/Combinatorics/MatchingCount/Sampling/Through.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 19.4 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Sampling/Through.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingCount/Sampling/Through.lean
-
curl -L -o Through.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Sampling/Through.lean
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 | |