Download data/lean/OAI/Combinatorics/MatchingCount/Sampling/Sym2Order.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 19.8 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Sampling/Sym2Order.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingCount/Sampling/Sym2Order.lean
-
curl -L -o Sym2Order.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Sampling/Sym2Order.lean
19.8 kB
| import Mathlib | |
| import OAI.Combinatorics.MatchingCount.Graphs.RemainingBags | |
| namespace OAI | |
| namespace MatchingFPRAS.Transport | |
| open Finset Replica Replica.Ladder Variation | |
| variable {V L : Type*} [Fintype V] [LinearOrder V] [Fintype L] [LinearOrder L] | |
| @[instance_reducible] def sym2Order : LinearOrder (Sym2 V) := | |
| LinearOrder.lift' (fun e=>toLex (Sym2.sortEquiv e).val) | |
| (fun _ _ h=>Sym2.sortEquiv.injective (Subtype.ext (toLex.injective h))) | |
| attribute [local instance] sym2Order | |
| @[instance_reducible] def bagEdgeOrder {bags : V β Finset L} : LinearOrder (BagEdge bags) := | |
| LinearOrder.lift' (fun e : BagEdge bags=>toLex e.val.val) | |
| (fun _ _ h=>Subtype.ext (Subtype.ext (toLex.injective h))) | |
| attribute [local instance] bagEdgeOrder | |
| def rationalTierBase (V : Type*) [Fintype V] : β := 1+((Fintype.card V:β)^2)β»ΒΉ | |
| omit [LinearOrder V] in | |
| lemma rationalTierBase_cast : (rationalTierBase V:β)=tierBase V := by | |
| simp [rationalTierBase,tierBase] | |
| def rationalSlotWeight {bags : V β Finset L} {T q : β} (w : BagEdge bags β β) | |
| (x : Slot T q) (e : BagEdge bags) : β := | |
| max ((rationalTierBase V)^tier x)β»ΒΉ (min ((rationalTierBase V)^tier x) (w e)) | |
| omit [LinearOrder V] [Fintype L] [LinearOrder L] in | |
| lemma rationalSlotWeight_cast [LinearOrder V] [Fintype L] [LinearOrder L] | |
| {bags : V β Finset L} {T q : β} (w : BagEdge bags β β) | |
| (x : Slot T q) (e : BagEdge bags) : | |
| (rationalSlotWeight w x e:β)=slotWeight (fun e=>(w e:β)) x e := by | |
| simp [rationalSlotWeight,slotWeight,tierClamp,rationalTierBase_cast] | |
| lemma rationalSlotWeight_pos {bags : V β Finset L} {T q : β} (w : BagEdge bags β β) | |
| (x : Slot T q) (e : BagEdge bags) : 0<rationalSlotWeight w x e := by | |
| have h:=slotWeight_pos (fun e=>(w e:β)) x e | |
| rw [βrationalSlotWeight_cast] at h | |
| exact_mod_cast h | |
| variable {bags : V β Finset L} {G : SimpleGraph L} | |
| variable (hbags : β v,β aβbags v,β bβbags v,a=b β¨ G.Adj a b) (hG : G.IsAcyclic) | |
| attribute [local instance] UnitRefresh.Computable.allowedDec | |
| @[instance_reducible] def bagEdgeFintype : Fintype (BagEdge bags) := Subtype.fintype (Allowed bags) | |
| attribute [local instance] bagEdgeFintype | |
| abbrev BagPM (bags : V β Finset L) := PM (BagEdge.Incident (bags:=bags)) | |
| noncomputable local instance : DecidableEq (BagPM bags) := Classical.decEq _ | |
| include hbags hG in | |
| lemma parallels_bound (e : BagEdge bags) : | |
| (univ.filter (fun f : BagEdge bags=>f.val.val.1=e.val.val.1)).cardβ€2 := by | |
| have h:=BagEdge.parallels_card_le (label_memberships_le_two hbags hG) e | |
| unfold BagEdge.parallels at h | |
| have instances_eq : tierClampBagEdgeFintype (bags:=bags) = | |
| (inferInstance : Fintype (BagEdge bags)) := Subsingleton.elim _ _ | |
| rw [instances_eq] at h | |
| exact h | |
| def sampleLadderPair {T q : β} (w : BagEdge bags β β) (x y : Slot T q) | |
| (a : BagPM bags Γ BagPM bags) (k : β) : (Fin k β Bool) β BagPM bags Γ BagPM bags := | |
| (Sparse.pairStepTable (fun e : BagEdge bags=>e.val.val.1) (fun e=>e.val.property) | |
| (parallels_bound hbags hG) | |
| (rationalSlotWeight w x) (rationalSlotWeight w y) | |
| (rationalSlotWeight_pos w x) (rationalSlotWeight_pos w y) a).draw k | |
| lemma pairProposal_instances {E : Type*} (Fβ Fβ : Fintype E) (Dβ Dβ : DecidableEq E) | |
| (ends : E β Sym2 V) (hloop : β e,Β¬(ends e).IsDiag) | |
| (hpβ : β e,(@univ E Fβ |>.filter (fun f=>ends f=ends e)).cardβ€2) | |
| (hpβ : β e,(@univ E Fβ |>.filter (fun f=>ends f=ends e)).cardβ€2) : | |
| @pairProposal V E _ _ Fβ Dβ ends hloop hpβ = | |
| @pairProposal V E _ _ Fβ Dβ ends hloop hpβ := by | |
| cases Subsingleton.elim Fβ Fβ | |
| cases Subsingleton.elim Dβ Dβ | |
| rfl | |
| omit [LinearOrder V] in | |
| lemma pairLaw_instances [LinearOrder V] {E : Type*} (Fβ Fβ : Fintype E) (ends : E β Sym2 V) | |
| (w z : E β β) : @pairLaw V E _ Fβ ends w z = @pairLaw V E _ Fβ ends w z := by | |
| cases Subsingleton.elim Fβ Fβ | |
| rfl | |
| lemma pairProposal_eq (F : Fintype (BagEdge bags)) (D : DecidableEq (BagEdge bags)) | |
| (hpar : β e : BagEdge bags,(@univ (BagEdge bags) F |>.filter | |
| (fun f=>f.val.val.1=e.val.val.1)).cardβ€2) : | |
| @pairProposal V (BagEdge bags) _ _ F D (fun e=>e.val.val.1) (fun e=>e.val.property) | |
| hpar = treePairProposal hbags hG := by | |
| unfold treePairProposal | |
| exact pairProposal_instances _ _ _ _ _ _ _ _ | |
| omit [LinearOrder L] in | |
| lemma pairLaw_eq [LinearOrder L] (F : Fintype (BagEdge bags)) {T q : β} (w : BagEdge bags β β) | |
| (x y : Slot T q) : | |
| @pairLaw V (BagEdge bags) _ F (fun e=>e.val.val.1) (slotWeight (fun e=>(w e:β)) x) | |
| (slotWeight (fun e=>(w e:β)) y) = | |
| (fun a : BagPM bags Γ BagPM bags=>slotLaw (fun e=>(w e:β)) x a.1* | |
| slotLaw (fun e=>(w e:β)) y a.2) := by | |
| exact pairLaw_instances F (instFintypeBagEdge_5 (bags:=bags)) | |
| (fun e : BagEdge bags=>e.val.val.1) (slotWeight (fun e=>(w e:β)) x) | |
| (slotWeight (fun e=>(w e:β)) y) | |
| lemma metropolis_eq_capacity (D : DecidableEq (BagPM bags Γ BagPM bags)) | |
| {T q : β} (w : BagEdge bags β β) (x y : Slot T q) (a : BagPM bags Γ BagPM bags) : | |
| (@metropolis _ _ D (treePairProposal hbags hG) | |
| (fun a=>slotLaw (fun e=>(w e:β)) x a.1*slotLaw (fun e=>(w e:β)) y a.2) a)= | |
| (fun b=>(treeLadderCapacity hbags hG (fun e=>(w e:β)) x y).q a b / | |
| (slotLaw (fun e=>(w e:β)) x a.1*slotLaw (fun e=>(w e:β)) y a.2)) := by | |
| rw [Subsingleton.elim D (inferInstance : DecidableEq (BagPM bags Γ BagPM bags))] | |
| unfold metropolis treeLadderCapacity | |
| funext b | |
| congr 2 | |
| lemma sampleLadderPair_tv {T q : β} (w : BagEdge bags β β) (x y : Slot T q) | |
| (a : BagPM bags Γ BagPM bags) (k : β) : | |
| tv (imageLaw (sampleLadderPair hbags hG w x y a k)) | |
| (fun b=>(treeLadderCapacity hbags hG (fun e=>(w e:β)) x y).q a b / | |
| (slotLaw (fun e=>(w e:β)) x a.1*slotLaw (fun e=>(w e:β)) y a.2)) β€ | |
| 4*(8*(Fintype.card (BagEdge bags):β)^2+4*Fintype.card (BagEdge bags)+3)/(2:β)^k := by | |
| classical | |
| have ht := Sparse.pairStepTable_tv (fun e : BagEdge bags=>e.val.val.1) | |
| (fun e=>e.val.property) | |
| (parallels_bound hbags hG) | |
| (rationalSlotWeight w x) (rationalSlotWeight w y) | |
| (rationalSlotWeight_pos w x) (rationalSlotWeight_pos w y) a k | |
| simp_rw [rationalSlotWeight_cast] at ht | |
| change tv (imageLaw (sampleLadderPair hbags hG w x y a k)) _ β€ _ at ht | |
| erw [pairProposal_eq hbags hG,pairLaw_eq,metropolis_eq_capacity] at ht | |
| apply ht.trans | |
| apply div_le_div_of_nonneg_right _ (by positivity) | |
| have ha : (a.1.val.card:β)β€Fintype.card (BagEdge bags) := by exact_mod_cast card_le_univ a.1.val | |
| have hb : (a.2.val.card:β)β€Fintype.card (BagEdge bags) := by exact_mod_cast card_le_univ a.2.val | |
| have hc : (a.1.val.card.choose 2:β)β€(a.1.val.card:β)^2 := by exact_mod_cast Nat.choose_le_pow a.1.val.card 2 | |
| have hd : (a.1.val.card:β)^2β€(Fintype.card (BagEdge bags):β)^2 := | |
| pow_le_pow_leftβ (Nat.cast_nonneg _) ha 2 | |
| nlinarith | |
| end MatchingFPRAS.Transport | |
| namespace MatchingFPRAS.Variation | |
| open Finset | |
| variable {A B C : Type*} [Fintype A] [Fintype B] [Fintype C] | |
| omit [Fintype C] in | |
| lemma imageLaw_ignoreRight [Fintype C] [Nonempty B] (f : A β C) : | |
| imageLaw (fun x : AΓB=>f x.1)=imageLaw f := by | |
| change imageLaw ((fun x : BΓA=>f x.2) β Equiv.prodComm A B)=_ | |
| rw [imageLaw_comp_equiv,imageLaw_ignore] | |
| end MatchingFPRAS.Variation | |
| namespace MatchingFPRAS.Transport | |
| open Finset Replica Replica.Ladder Variation | |
| variable {V L : Type*} [Fintype V] [LinearOrder V] [Fintype L] [LinearOrder L] | |
| variable {bags : V β Finset L} | |
| attribute [local instance] sym2Order bagEdgeOrder bagEdgeFintype UnitRefresh.Computable.allowedDec | |
| noncomputable local instance : DecidableEq (BagPM bags) := Classical.decEq _ | |
| lemma gibbs_one_uniform (A : BagPM bags) : gibbs (fun _ : BagEdge bags=>(1:β)) A= | |
| uniform (BagPM bags) A := by | |
| classical | |
| simp only [gibbs,partition,matchingWeight,prod_const_one,sum_const,nsmul_eq_mul, | |
| card_univ,mul_one,uniform,Fintype.card_eq_nat_card] | |
| lemma base_slotLaw {T q : β} (w : BagEdge bags β β) (x : Slot T q) (hx : xβbase T q) : | |
| slotLaw (fun e=>(w e:β)) x=uniform (BagPM bags) := by | |
| classical | |
| have he : slotWeight (fun e=>(w e:β)) x=fun _ : BagEdge bags=>(1:β) := by | |
| funext e | |
| have ht : tier x=0 := by simp only [tier,(mem_base x).mp hx,Nat.sub_self] | |
| simp only [slotWeight,tierClamp,ht,pow_zero,inv_one] | |
| exact max_eq_left (min_le_left _ _) | |
| unfold slotLaw | |
| rw [he] | |
| funext A | |
| simp only [gibbs,partition,matchingWeight,prod_const_one,sum_const,nsmul_eq_mul, | |
| card_univ,mul_one,uniform,Fintype.card_eq_nat_card] | |
| open Finset Replica Replica.Ladder Variation | |
| variable {V L : Type*} [Fintype V] [LinearOrder V] [Fintype L] [LinearOrder L] | |
| variable {bags : V β Finset L} {G : SimpleGraph L} | |
| attribute [local instance] sym2Order bagEdgeOrder bagEdgeFintype UnitRefresh.Computable.allowedDec | |
| noncomputable local instance : DecidableEq (BagPM bags) := Classical.decEq _ | |
| @[instance_reducible] def prodOrder {A B : Type*} [LinearOrder A] [LinearOrder B] : | |
| LinearOrder (AΓB) := LinearOrder.lift' toLex toLex.injective | |
| @[instance_reducible] def sumOrder {A B : Type*} [LinearOrder A] [LinearOrder B] : | |
| LinearOrder (AβB) := LinearOrder.lift' toLex toLex.injective | |
| attribute [local instance] prodOrder sumOrder | |
| variable (hbags : β v,β aβbags v,β bβbags v,a=b β¨ G.Adj a b) (hG : G.IsAcyclic) | |
| variable (rank : L β β) (parent : L β Option L) | |
| variable (hb : UnitRefresh.RankedBags bags rank parent) (hne : β v,(bags v).Nonempty) | |
| variable (hp : β l p,parent l=some p β rank p<rank l) | |
| abbrev LocalBits (V : Type*) [Fintype V] (k : β) := | |
| (Fin k β Bool) Γ (Fin (Fintype.card V) β Fin k β Bool) | |
| abbrev ScanBits (V : Type*) [Fintype V] (k : β) := (Fin k β Bool) Γ LocalBits V k | |
| def pairDraw {T q : β} (w : BagEdge bags β β) (k : β) (x y : Slot T q) | |
| (a : BagPM bags Γ BagPM bags) (bits : LocalBits V k) : BagPM bags Γ BagPM bags := | |
| sampleLadderPair hbags hG w x y a k bits.1 | |
| def baseDraw (M : BagPM bags) (k : β) (bits : LocalBits V k) : BagPM bags := | |
| UnitRefresh.sampleMatching k bags rank parent hb hne hp M bits.2 | |
| def ladderScan {T q : β} (hq : 0<q) (w : BagEdge bags β β) (M : BagPM bags) (k : β) | |
| (s : Slot T q β BagPM bags) (bits : ScanBits V k) : Slot T q β BagPM bags := | |
| sampleScan guides (base T q) (base_nonempty T q hq) (pairDraw hbags hG w k) | |
| (fun _=>baseDraw rank parent hb hne hp M k) k s bits | |
| def scanErrorNumerator (V L : Type*) [Fintype V] [LinearOrder V] [Fintype L] [LinearOrder L] (bags : V β Finset L) | |
| (T q : β) : β := | |
| 2*(1+(T*q^2+q))+ | |
| 4*(8*(Fintype.card (BagEdge bags))^2+4*Fintype.card (BagEdge bags)+3)+ | |
| 2*(Fintype.card V)^2*Fintype.card L | |
| lemma ladderScan_tv {T q : β} (hq : 0<q) (w : BagEdge bags β β) (M : BagPM bags) (k : β) | |
| (s : Slot T q β BagPM bags) : | |
| tv (imageLaw (ladderScan hbags hG rank parent hb hne hp hq w M k s)) | |
| (FiniteChain.kernel (ladderLaw (fun e=>(w e:β)) T q) | |
| (ladderFlow hbags hG (fun e=>(w e:β)) T q) s) β€ | |
| (scanErrorNumerator V L bags T q:β)/(2:β)^k := by | |
| classical | |
| let eP : β := 4*(8*(Fintype.card (BagEdge bags):β)^2+4*Fintype.card (BagEdge bags)+3)/(2:β)^k | |
| let eU : β := 2*(Fintype.card V:β)^2*Fintype.card L/(2:β)^k | |
| have hep : 0β€eP := by dsimp [eP]; positivity | |
| have heu : 0β€eU := by dsimp [eU]; positivity | |
| have hpr : β x y : Slot T q,yβguides x β β a : BagPM bags Γ BagPM bags, | |
| tv (imageLaw (pairDraw hbags hG w k x y a)) | |
| (fun b=>(treeLadderCapacity hbags hG (fun e=>(w e:β)) x y).q a b / | |
| (slotLaw (fun e=>(w e:β)) x a.1*slotLaw (fun e=>(w e:β)) y a.2))β€eP+eU := by | |
| intro x y _ a | |
| unfold pairDraw | |
| rw [imageLaw_ignoreRight] | |
| exact (sampleLadderPair_tv hbags hG w x y a k).trans (le_add_of_nonneg_right heu) | |
| have hr : β i : Slot T q,iβbase T q β | |
| tv (imageLaw (baseDraw rank parent hb hne hp M k)) (slotLaw (fun e=>(w e:β)) i)β€eP+eU := by | |
| intro i hi | |
| rw [base_slotLaw w i hi] | |
| unfold baseDraw | |
| rw [imageLaw_ignore] | |
| exact (UnitRefresh.sampleMatching_tv k bags rank parent hb hne hp M).trans | |
| (le_add_of_nonneg_left hep) | |
| have ht:= sampleScan_tv_on (slotLaw (fun e=>(w e:β))) (slotLaw_pos _) | |
| (fun x=>slotLaw_sum _ x M) guides (fun x y hy=>(guides_order x y hy).ne) | |
| (base T q) (base_nonempty T q hq) (treeLadderCapacity hbags hG (fun e=>(w e:β))) | |
| (pairDraw hbags hG w k) (fun _=>baseDraw rank parent hb hne hp M k) (eP+eU) | |
| (add_nonneg hep heu) hpr hr k s | |
| change tv (imageLaw (ladderScan hbags hG rank parent hb hne hp hq w M k s)) | |
| (FiniteChain.kernel (ladderLaw (fun e=>(w e:β)) T q) | |
| (ladderFlow hbags hG (fun e=>(w e:β)) T q) s) β€ _ at ht | |
| convert ht using 1 | |
| have hcount : updateCount (@guides T q) (base T q)=T*q^2+q := updates_count T q | |
| rw [hcount] | |
| simp only [scanErrorNumerator,Nat.cast_add,Nat.cast_mul,Nat.cast_pow,Nat.cast_ofNat, | |
| Nat.cast_one,eP,eU,add_div] | |
| ring | |
| def ladderRun {T q : β} (hq : 0<q) (w : BagEdge bags β β) (M : BagPM bags) (k n : β) | |
| (s : Slot T q β BagPM bags) (bits : Fin n β ScanBits V k) : Slot T q β BagPM bags := | |
| runSample (ladderScan hbags hG rank parent hb hne hp hq w M k) s n bits | |
| lemma ladderKernel_nonneg {T q : β} (w : BagEdge bags β β) (s t : Slot T q β BagPM bags) : | |
| 0β€FiniteChain.kernel (ladderLaw (fun e=>(w e:β)) T q) | |
| (ladderFlow hbags hG (fun e=>(w e:β)) T q) s t := by | |
| apply div_nonneg | |
| Β· exact scanFlow_nonneg (slotLaw _) (fun i a=>(slotLaw_pos _ i a).le) _ _ _ s t | |
| Β· exact (Finset.prod_pos (fun i _=>slotLaw_pos _ i (s i))).le | |
| lemma ladderKernel_sum {T q : β} (hq : 0<q) (w : BagEdge bags β β) (M : BagPM bags) | |
| (s : Slot T q β BagPM bags) : | |
| (β t,FiniteChain.kernel (ladderLaw (fun e=>(w e:β)) T q) | |
| (ladderFlow hbags hG (fun e=>(w e:β)) T q) s t)=1 := by | |
| unfold FiniteChain.kernel | |
| rw [βsum_div] | |
| have hr:=scanFlow_row (slotLaw (fun e=>(w e:β))) (fun i=>slotLaw_sum _ i M) | |
| guides (base T q) (base_nonempty T q hq) (treeLadderCapacity hbags hG (fun e=>(w e:β))) s | |
| change (β t,ladderFlow hbags hG (fun e=>(w e:β)) T q s t)=_ at hr | |
| rw [hr] | |
| exact div_self (Finset.prod_pos (fun i _=>slotLaw_pos _ i (s i))).ne' | |
| lemma ladderRun_walk_tv {T q : β} (hq : 0<q) (w : BagEdge bags β β) (M : BagPM bags) (k n : β) | |
| (s : Slot T q β BagPM bags) : | |
| tv (imageLaw (ladderRun hbags hG rank parent hb hne hp hq w M k n s)) | |
| (FiniteChain.walk (ladderLaw (fun e=>(w e:β)) T q) | |
| (ladderFlow hbags hG (fun e=>(w e:β)) T q) s n) β€ | |
| n * (scanErrorNumerator V L bags T q:β)/(2:β)^k := by | |
| have ht:=runSample_walk_tv _ _ (ladderKernel_nonneg hbags hG w) | |
| (ladderKernel_sum hbags hG hq w M) | |
| (ladderScan hbags hG rank parent hb hne hp hq w M k) _ | |
| (ladderScan_tv hbags hG rank parent hb hne hp hq w M k) s n | |
| change tv (imageLaw (ladderRun hbags hG rank parent hb hne hp hq w M k n s)) _ β€ _ at ht | |
| simpa only [mul_div_assoc] using ht | |
| lemma ladderRun_gibbs_tv (height : L β β) (hheight : β l,0<height l) | |
| (hstep : β a b,G.Adj a b β height aβ€2*height b) | |
| (D K : β) (hD : 1β€D) (hN : 2β€Fintype.card V) (w : BagEdge bags β β) | |
| (hw : β e,height e.color / D β€ (w e:β) β§ (w e:β)β€3*height e.color) | |
| (hglobal : β e,(D:β)β»ΒΉβ€(w e:β) β§ (w e:β)β€3*4^K) | |
| (M : BagPM bags) (T k : β) (ΞΎ : β) (hΞΎ : 0<ΞΎ) (hΞΎ1 : ΞΎ<1) | |
| (hq : 0<ladderQ (Fintype.card V) D) | |
| (s : Slot T (ladderQ (Fintype.card V) D) β BagPM bags) : | |
| tv (imageLaw (ladderRun hbags hG rank parent hb hne hp hq w M k | |
| (ladderSteps (Fintype.card V) D K T ΞΎ) s)) | |
| (ladderLaw (fun e=>(w e:β)) T (ladderQ (Fintype.card V) D)) β€ | |
| (ladderSteps (Fintype.card V) D K T ΞΎ : β) * | |
| scanErrorNumerator V L bags T (ladderQ (Fintype.card V) D)/(2:β)^k+ΞΎ := by | |
| have hi:=ideal_ladder_sampling hbags hG height hheight hstep D K hD hN | |
| (fun e=>(w e:β)) hw hglobal M T s ΞΎ hΞΎ hΞΎ1 | |
| have hb:=ladderRun_walk_tv hbags hG rank parent hb hne hp hq w M k | |
| (ladderSteps (Fintype.card V) D K T ΞΎ) s | |
| exact (tv_triangle _ _ _).trans (add_le_add hb hi) | |
| open Finset Replica Replica.Ladder Variation | |
| def bitPrecision (R : β) (Ξ· : β) : β := Nat.clog 2 (R*βΞ·β»ΒΉββ) | |
| lemma bitPrecision_error (R : β) (Ξ· : β) (hΞ· : 0<Ξ·) : | |
| (R:β)/(2:β)^bitPrecision R Ξ· β€ (Ξ·:β) := by | |
| have hp : (R:β)*(βΞ·β»ΒΉββ:β)β€(2:β)^bitPrecision R Ξ· := by | |
| exact_mod_cast Nat.le_pow_clog (by decide : 1<2) (R*βΞ·β»ΒΉββ) | |
| have hh : (Ξ·:β)β»ΒΉβ€(βΞ·β»ΒΉββ:β) := by | |
| exact_mod_cast Nat.le_ceil (Ξ·β»ΒΉ) | |
| have he : (0:β)<(Ξ·:β) := by exact_mod_cast hΞ· | |
| apply (div_le_iffβ (by positivity : (0:β)<2^bitPrecision R Ξ·)).mpr | |
| calc | |
| (R:β) = (Ξ·:β)*((R:β)*(Ξ·:β)β»ΒΉ) := by field_simp | |
| _ β€ (Ξ·:β)*((R:β)*(βΞ·β»ΒΉββ:β)) := by gcongr | |
| _ β€ _ := mul_le_mul_of_nonneg_left hp he.le | |
| def pairBitsEquiv (m n : β) : (Fin (m+n) β Bool) β ((Fin m β Bool) Γ (Fin n β Bool)) := | |
| (Equiv.arrowCongr finSumFinEquiv.symm (Equiv.refl Bool)).trans | |
| (Equiv.sumArrowEquivProdArrow _ _ _) | |
| def matrixBitsEquiv (m n : β) : (Fin (m*n) β Bool) β (Fin m β Fin n β Bool) := | |
| (Equiv.arrowCongr finProdFinEquiv.symm (Equiv.refl Bool)).trans (Equiv.curry _ _ _) | |
| def scanBitCount (N k : β) : β := k+(k+N*k) | |
| def scanBitsEquiv (V : Type*) [Fintype V] (k : β) : | |
| (Fin (scanBitCount (Fintype.card V) k) β Bool) β ScanBits V k := | |
| (pairBitsEquiv k (k+Fintype.card V*k)).trans | |
| (Equiv.prodCongr (Equiv.refl _) ((pairBitsEquiv k (Fintype.card V*k)).trans | |
| (Equiv.prodCongr (Equiv.refl _) (matrixBitsEquiv (Fintype.card V) k)))) | |
| def runBitsEquiv (V : Type*) [Fintype V] (k n : β) : | |
| (Fin (n*scanBitCount (Fintype.card V) k) β Bool) β (Fin n β ScanBits V k) := | |
| (matrixBitsEquiv n _).trans (Equiv.piCongrRight fun _=>scanBitsEquiv V k) | |
| variable {V L : Type*} [Fintype V] [LinearOrder V] [Fintype L] [LinearOrder L] | |
| variable {bags : V β Finset L} {G : SimpleGraph L} | |
| attribute [local instance] sym2Order bagEdgeOrder bagEdgeFintype UnitRefresh.Computable.allowedDec | |
| noncomputable local instance : DecidableEq (BagPM bags) := Classical.decEq _ | |
| attribute [local instance] prodOrder sumOrder | |
| variable (hbags : β v,β aβbags v,β bβbags v,a=b β¨ G.Adj a b) (hG : G.IsAcyclic) | |
| variable (rank : L β β) (parent : L β Option L) | |
| variable (hb : UnitRefresh.RankedBags bags rank parent) (hne : β v,(bags v).Nonempty) | |
| variable (hp : β l p,parent l=some p β rank p<rank l) | |
| def ladderBitRun {T q : β} (hq : 0<q) (w : BagEdge bags β β) (M : BagPM bags) (k n : β) | |
| (s : Slot T q β BagPM bags) (bits : Fin (n*scanBitCount (Fintype.card V) k) β Bool) : | |
| Slot T q β BagPM bags := | |
| ladderRun hbags hG rank parent hb hne hp hq w M k n s (runBitsEquiv V k n bits) | |
| lemma ladderBitRun_walk_tv {T q : β} (hq : 0<q) (w : BagEdge bags β β) (M : BagPM bags) | |
| (n : β) (Ξ· : β) (hΞ· : 0<Ξ·) (s : Slot T q β BagPM bags) : | |
| let k:=bitPrecision (n*scanErrorNumerator V L bags T q) Ξ· | |
| tv (imageLaw (ladderBitRun hbags hG rank parent hb hne hp hq w M k n s)) | |
| (FiniteChain.walk (ladderLaw (fun e=>(w e:β)) T q) | |
| (ladderFlow hbags hG (fun e=>(w e:β)) T q) s n) β€ (Ξ·:β) := by | |
| dsimp only | |
| unfold ladderBitRun | |
| change tv (imageLaw (_ β runBitsEquiv V _ n)) _ β€ _ | |
| rw [imageLaw_comp_equiv] | |
| exact (ladderRun_walk_tv hbags hG rank parent hb hne hp hq w M _ n s).trans | |
| (by simpa only [Nat.cast_mul] using bitPrecision_error (n*scanErrorNumerator V L bags T q) Ξ· hΞ·) | |
| end MatchingFPRAS.Transport | |
| end OAI | |