Download data/lean/OAI/Combinatorics/MatchingCount/Probability/Marking.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.94 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Probability/Marking.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingCount/Probability/Marking.lean
-
curl -L -o Marking.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Probability/Marking.lean
6.94 kB
| import Mathlib | |
| import OAI.Combinatorics.MatchingCount.Probability.AdaptiveLaw | |
| import OAI.Combinatorics.MatchingCount.Graphs.LabelOrder | |
| import OAI.Combinatorics.MatchingCount.Sampling.TableMarking | |
| namespace OAI | |
| namespace MatchingFPRAS.Variation | |
| lemma imageLaw_instances {A B : Type*} (Fβ Fβ : Fintype A) (f : A β B) : | |
| @imageLaw A B Fβ f=@imageLaw A B Fβ f := by | |
| cases Subsingleton.elim Fβ Fβ | |
| rfl | |
| lemma tv_instances {A : Type*} (Fβ Fβ : Fintype A) (p q : A β β) : | |
| @tv A Fβ p q=@tv A Fβ p q := by | |
| cases Subsingleton.elim Fβ Fβ | |
| rfl | |
| end MatchingFPRAS.Variation | |
| namespace MatchingFPRAS.RationalSource | |
| open Finset Transport Variation Enlargement | |
| variable {V : Type*} [Fintype V] [LinearOrder V] [Nontrivial V] | |
| attribute [local instance] NumberedHierarchy.labelOrder sym2Order bagEdgeOrder bagEdgeFintype | |
| attribute [local instance] UnitRefresh.Computable.allowedDec prodOrder sumOrder | |
| noncomputable local instance (w : V β V β β) (K : β) : DecidableEq (BagPM (bags w K)) := Classical.decEq _ | |
| noncomputable local instance (w : V β V β β) (K : β) : Fintype (BagPM (bags w K)) := Fintype.ofFinite _ | |
| def centralEdge (w : V β V β β) (K : β) (e : LogicalEdge V) : BagEdge (bags w K) := | |
| coloredReal w K (e,β¨2*(2*K+2),by omegaβ©) | |
| def probePortion (w : V β V β β) (K D : β) (e : BagEdge (bags w K)) : β := | |
| if β q,centralEdge w K q=e then 1/(D:β) else 0 | |
| def portions (w : V β V β β) (K D : β) (e : BagEdge (bags w K)) : Fin 3 β β := | |
| ![realPortion w K e,bagHeight w K e.color/D-probePortion w K D e,probePortion w K D e] | |
| lemma portions_sum (w : V β V β β) (K D : β) (e : BagEdge (bags w K)) : | |
| β i,portions w K D e i=bagWeight w K D e := by | |
| simp [portions,Fin.sum_univ_succ,bagWeight] | |
| lemma portions_nonneg (w : V β V β β) (hw : β x y,0<w x y) (K D : β) | |
| (e : BagEdge (bags w K)) (i : Fin 3) : 0β€portions w K D e i := by | |
| fin_cases i | |
| Β· exact realPortion_nonneg w hw K e | |
| Β· change 0β€bagHeight w K e.color/D-probePortion w K D e | |
| apply sub_nonneg.mpr | |
| unfold probePortion | |
| split_ifs | |
| Β· exact div_le_div_of_nonneg_right (bagHeight_one w K _) (Nat.cast_nonneg D) | |
| Β· exact div_nonneg (by dsimp [bagHeight]; positivity) (Nat.cast_nonneg D) | |
| Β· change 0β€probePortion w K D e | |
| unfold probePortion | |
| split_ifs <;> positivity | |
| lemma bagWeight_pos (w : V β V β β) (hw : β x y,0<w x y) (K D : β) (hD : 0<D) | |
| (e : BagEdge (bags w K)) : 0<bagWeight w K D e := by | |
| apply add_pos_of_nonneg_of_pos (realPortion_nonneg w hw K e) | |
| exact div_pos (by dsimp [bagHeight]; positivity) (by exact_mod_cast hD) | |
| def markingTable (w : V β V β β) (hw : β x y,0<w x y) (K D : β) (hD : 0<D) | |
| (e : BagEdge (bags w K)) : WeightedOptions (Fin 3) where | |
| size:=3 | |
| out:=id | |
| mass i:=portions w K D e i/bagWeight w K D e | |
| nonneg i:=div_nonneg (portions_nonneg w hw K D e i) (bagWeight_pos w hw K D hD e).le | |
| total:=by rw [βsum_div,portions_sum,div_self (bagWeight_pos w hw K D hD e).ne'] | |
| lemma markingTable_law (w : V β V β β) (hw : β x y,0<w x y) (K D : β) (hD : 0<D) | |
| (e : BagEdge (bags w K)) (i : Fin 3) : | |
| (markingTable w hw K D hD e).law i=portions w K D e i/bagWeight w K D e := by | |
| change (β j : Fin 3,if j=i then portions w K D e j/bagWeight w K D e else 0)=_ | |
| simp only [sum_ite_eq',mem_univ,ite_true] | |
| abbrev Marked (w : V β V β β) (K : β) := TableMarking.Marked (I:=Fin 3) (BagEdge.Incident (bags:=bags w K)) | |
| noncomputable local instance sourceMarkedFintype (w : V β V β β) (K : β) : | |
| Fintype (Marked w K) := Fintype.ofFinite _ | |
| noncomputable def markedLaw (w : V β V β β) (K D : β) : Marked w K β β := | |
| sigmaLift (gibbs (fun e=>(bagWeight w K D e:β))) | |
| (fun M=>product (fun e : M.val=>fun i=>(portions w K D e.val i/bagWeight w K D e.val:β))) | |
| def markedSampler (w : V β V β β) (hw : β x y,0<w x y) (K D m : β) | |
| (hD : 0<D) (hN : 0<Fintype.card (SourceVertex V K)) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) | |
| (hq : 0<Transport.ladderQ (Fintype.card (SourceVertex V K)) D) (M : BagPM (bags w K)) (Ξ· : β) := | |
| TableMarking.draw BagEdge.Incident (topSampler w K D m hN h hq M Ξ·) | |
| (markingTable w hw K D hD) | |
| (bitPrecision (6*Fintype.card (BagEdge (bags w K))) Ξ·) | |
| noncomputable local instance sourceMarkingBitsFintype {A : Type*} [Fintype A] | |
| (w : V β V β β) (K k : β) : | |
| Fintype (A Γ (BagEdge (bags w K) β Fin k β Bool)) := Fintype.ofFinite _ | |
| lemma marking_tv {A : Type*} [Fintype A] [Nonempty A] | |
| (w : V β V β β) (hw : β x y,0<w x y) (K D : β) (hD : 0<D) | |
| (f : A β BagPM (bags w K)) (k : β) : | |
| tv (imageLaw (TableMarking.draw BagEdge.Incident f (markingTable w hw K D hD) k)) | |
| (markedLaw w K D)β€tv (imageLaw f) (gibbs (fun e=>(bagWeight w K D e:β)))+ | |
| 6*Fintype.card (BagEdge (bags w K))/(2:β)^k := by | |
| have he : TableMarking.law BagEdge.Incident (fun e=>(bagWeight w K D e:β)) | |
| (markingTable w hw K D hD)=markedLaw w K D := by | |
| unfold TableMarking.law TableMarking.portion markedLaw | |
| simp only [markingTable_law] | |
| have hh:=TableMarking.draw_tv_size BagEdge.Incident f | |
| (fun e=>(bagWeight w K D e:β)) (markingTable w hw K D hD) k 3 (fun _=>rfl) | |
| rw [he] at hh | |
| norm_num only [Nat.cast_ofNat] at hh | |
| rw [imageLaw_instances _ (sourceMarkingBitsFintype w K k), | |
| tv_instances _ (sourceMarkedFintype w K)] at hh | |
| exact hh | |
| noncomputable def markedSamplerLaw (w : V β V β β) (hw : β x y,0<w x y) (K D m : β) | |
| (hD : 0<D) (hN : 0<Fintype.card (SourceVertex V K)) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) | |
| (hq : 0<Transport.ladderQ (Fintype.card (SourceVertex V K)) D) (M : BagPM (bags w K)) (Ξ· : β) : | |
| Marked w K β β := imageLaw (markedSampler w hw K D m hD hN h hq M Ξ·) | |
| theorem markedSampler_tv (w : V β V β β) (hw : β x y,0<w x y) (K D m : β) (hD : 1β€D) | |
| (hN : 2β€Fintype.card (SourceVertex V K)) (hm : 1 < m) | |
| (h : β x y,xβ y β BottleneckAlgorithm.edge w x yβ€(4:β)^K) | |
| (hq : 0<Transport.ladderQ (Fintype.card (SourceVertex V K)) D) (M : BagPM (bags w K)) (Ξ· : β) (hΞ· : 0<Ξ·) : | |
| tv (markedSamplerLaw w hw K D m (lt_of_lt_of_le Nat.zero_lt_one hD) (lt_of_lt_of_le Nat.zero_lt_two hN) h hq M Ξ·) | |
| (markedLaw w K D)β€2*(Ξ·:β)+(m:β)β»ΒΉ := by | |
| have hh:=marking_tv w hw K D (lt_of_lt_of_le Nat.zero_lt_one hD) | |
| (topSampler w K D m (lt_of_lt_of_le Nat.zero_lt_two hN) h hq M Ξ·) | |
| (bitPrecision (6*Fintype.card (BagEdge (bags w K))) Ξ·) | |
| have hs:=topSampler_tv w hw K D m hD hN hm h hq M Ξ· hΞ· | |
| have hb:=bitPrecision_error (6*Fintype.card (BagEdge (bags w K))) Ξ· hΞ· | |
| push_cast at hb | |
| change tv (markedSamplerLaw w hw K D m (lt_of_lt_of_le Nat.zero_lt_one hD) | |
| (lt_of_lt_of_le Nat.zero_lt_two hN) h hq M Ξ·) _β€_ at hh | |
| linarith | |
| end MatchingFPRAS.RationalSource | |
| end OAI | |