Download data/lean/OAI/Combinatorics/MatchingCount/Algorithm/RationalObservables.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 9.89 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Algorithm/RationalObservables.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingCount/Algorithm/RationalObservables.lean
-
curl -L -o RationalObservables.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingCount/Algorithm/RationalObservables.lean
9.89 kB
| import Mathlib | |
| import OAI.Combinatorics.MatchingCount.Sampling.MarkBridge | |
| namespace OAI | |
| 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 (SourceLabel (fun x y=>(w x y:β)) K) := Classical.decEq _ | |
| noncomputable local instance (w : V β V β β) (K : β) : | |
| Fintype (BagEdge (sourceBags (fun x y=>(w x y:β)) K)) := Fintype.ofFinite _ | |
| def rawReweight (w wβ : V β V β β) (K : β) (e : SourceRealEdge V K) : β := | |
| if e.2.val=2*(2*K+2) then BottleneckAlgorithm.edge wβ (source e.1) (target e.1)/ | |
| BottleneckAlgorithm.edge w (source e.1) (target e.1) else 1 | |
| def bagReweight (w wβ : V β V β β) (K : β) (e : BagEdge (bags w K)) : β := | |
| 1+β q : SourceRealEdge V K,if coloredReal w K q=e then rawReweight w wβ K q-1 else 0 | |
| lemma bagReweight_on (w wβ : V β V β β) (K : β) (q : SourceRealEdge V K) : | |
| bagReweight w wβ K (coloredReal w K q)=rawReweight w wβ K q := by | |
| simp only [bagReweight,(coloredReal_injective w K).eq_iff,sum_ite_eq',mem_univ,ite_true] | |
| ring | |
| lemma bagReweight_off (w wβ : V β V β β) (K : β) (e : BagEdge (bags w K)) | |
| (he : Β¬β q,coloredReal w K q=e) : bagReweight w wβ K e=1 := by | |
| have hz : (β q : SourceRealEdge V K,if coloredReal w K q=e then rawReweight w wβ K q-1 else 0)=0 := by | |
| apply sum_eq_zero | |
| intro q _ | |
| exact ite_eq_right (fun h=>he β¨q,hβ©) | |
| rw [bagReweight,hz,add_zero] | |
| omit [Fintype V] [Nontrivial V] in | |
| lemma rawReweight_cast (w wβ : V β V β β) (K : β) (q : SourceRealEdge V K) : | |
| (rawReweight w wβ K q:β)=Enlargement.rawReweight (fun x y=>(w x y:β)) | |
| (fun x y=>(wβ x y:β)) K q := by | |
| simp only [rawReweight,Enlargement.rawReweight] | |
| split_ifs | |
| Β· simp only [Rat.cast_div,BottleneckAlgorithm.edge,logicalActivity,Switching.edgeActivity] | |
| split_ifs <;> rfl | |
| Β· norm_cast | |
| lemma bagReweight_cast (w wβ : V β V β β) (K : β) | |
| (e : BagEdge (sourceBags (fun x y=>(w x y:β)) K)) : | |
| (bagReweight w wβ K (sourceEdgeEquiv w K e):β)= | |
| Enlargement.bagReweight (fun x y=>(w x y:β)) (fun x y=>(wβ x y:β)) K e := by | |
| classical | |
| by_cases he : β q,sourceColoredReal (fun x y=>(w x y:β)) K q=e | |
| Β· obtain β¨q,rflβ©:=he | |
| rw [sourceEdgeEquiv_real,bagReweight_on] | |
| exact (rawReweight_cast w wβ K q).trans (Enlargement.bagReweight_on _ _ K q).symm | |
| Β· rw [bagReweight_off w wβ K _ ?_] | |
| Β· unfold Enlargement.bagReweight | |
| change Β¬β q,sourceRealEmbedding (fun x y=>(w x y:β)) K q=e at he | |
| rw [dite_eq_right he] | |
| norm_cast | |
| Β· rintro β¨q,hqβ© | |
| apply he | |
| refine β¨q,(sourceEdgeEquiv w K).injective ?_β© | |
| rwa [sourceEdgeEquiv_real] | |
| def observableA (w : V β V β β) (K : β) (a : Marked w K) : β := | |
| if a.2=(fun _=>0) then 1 else 0 | |
| def observableD (w wβ : V β V β β) (K : β) (a : Marked w K) : β := | |
| if a.2=(fun _=>0) then β e β a.1.val,bagReweight w wβ K e else 0 | |
| def observableProbe (w wβ : V β V β β) (K : β) (eβ : LogicalEdge V) (a : Marked w K) : β := | |
| if {centralEdge w K eβ}βa.1.val β§ | |
| a.2=(fun e=>if e.valβ({centralEdge w K eβ}:Finset _) then 2 else 0) | |
| then β e β a.1.val \ {centralEdge w K eβ},bagReweight w wβ K e else 0 | |
| end MatchingFPRAS.RationalSource | |
| namespace MatchingFPRAS.Transport | |
| open Finset | |
| variable {V E F I : Type*} [Fintype V] [DecidableEq V] | |
| variable [Fintype E] [DecidableEq E] [Fintype F] [DecidableEq F] [Fintype I] | |
| variable {inc : E β V β Prop} {j : F β V β Prop} | |
| omit [DecidableEq V] [Fintype E] [Fintype F] [Fintype I] in | |
| lemma markedEquiv_marks_eq (e : E β F) (he : β a v,j (e a) v β inc a v) | |
| (a : Marking.Marked (I:=I) inc) (r : F β I) : | |
| (markedEquiv e he a).2=(fun x=>r x.val) β a.2=(fun x=>r (e x.val)) := by | |
| constructor | |
| Β· intro h | |
| funext x | |
| have hh:=congrFun h (selectedEquiv e he a.1 x) | |
| rw [markedEquiv_mark] at hh | |
| exact hh | |
| Β· intro h | |
| funext x | |
| obtain β¨y,rflβ©:=(selectedEquiv e he a.1).surjective x | |
| rw [markedEquiv_mark,congrFun h] | |
| rfl | |
| omit [DecidableEq V] [Fintype E] [Fintype F] in | |
| lemma markedEquiv_zero (e : E β F) (he : β a v,j (e a) v β inc a v) | |
| (a : Marking.Marked (I:=Fin 3) inc) : | |
| (markedEquiv e he a).2=(fun _=>0) β a.2=(fun _=>0) := | |
| markedEquiv_marks_eq e he a (fun _=>0) | |
| omit [DecidableEq V] [Fintype E] [Fintype F] in | |
| lemma markedEquiv_probe (e : E β F) (he : β a v,j (e a) v β inc a v) | |
| (a : Marking.Marked (I:=Fin 3) inc) (u : E) : | |
| ({e u}β(markedEquiv e he a).1.val β§ | |
| (markedEquiv e he a).2=(fun x=>if x.valβ({e u}:Finset _) then 2 else 0)) β | |
| ({u}βa.1.val β§ a.2=(fun x=>if x.valβ({u}:Finset _) then 2 else 0)) := by | |
| rw [markedEquiv_marks_eq e he a (fun x=>if xβ({e u}:Finset F) then 2 else 0)] | |
| rw [singleton_subset_iff,singleton_subset_iff] | |
| change (e uβa.1.val.image e β§ _) β (uβa.1.val β§ _) | |
| simp only [mem_singleton,e.injective.eq_iff, | |
| mem_image,exists_eq_right] | |
| omit [DecidableEq V] [Fintype E] [Fintype F] in | |
| lemma pmEquiv_product_erase {R : Type*} [CommMonoid R] | |
| (e : E β F) (he : β a v,j (e a) v β inc a v) (M : PM inc) (u : E) (f : F β R) : | |
| (β x β (pmEquiv e he M).val \ {e u},f x)=β x β M.val \ {u},f (e x) := by | |
| have hh : (pmEquiv e he M).val \ {e u}=(M.val \ {u}).image e := by | |
| change M.val.image e \ {e u}=(M.val \ {u}).image e | |
| ext x | |
| simp only [mem_sdiff,mem_image,mem_singleton] | |
| constructor | |
| Β· rintro β¨β¨y,hy,rflβ©,huβ© | |
| exact β¨y,β¨hy,fun h=>hu (congrArg e h)β©,rflβ© | |
| Β· rintro β¨y,β¨hy,huβ©,rflβ© | |
| exact β¨β¨y,hy,rflβ©,fun h=>hu (e.injective h)β© | |
| rw [hh] | |
| exact prod_image (fun _ _ _ _ h=>e.injective h) | |
| end MatchingFPRAS.Transport | |
| 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 (SourceLabel (fun x y=>(w x y:β)) K) := Classical.decEq _ | |
| noncomputable local instance (w : V β V β β) (K : β) : | |
| Fintype (BagEdge (sourceBags (fun x y=>(w x y:β)) K)) := Fintype.ofFinite _ | |
| lemma sourceEdgeEquiv_incidence (w : V β V β β) (K : β) | |
| (e : BagEdge (sourceBags (fun x y=>(w x y:β)) K)) (x : SourceVertex V K) : | |
| (sourceEdgeEquiv w K e).Incident x β e.Incident x := Iff.rfl | |
| lemma sourceMarkedEquiv_zero (w : V β V β β) (K : β) | |
| (a : SourceMarked (fun x y=>(w x y:β)) K) : | |
| (sourceMarkedEquiv w K a).2=(fun _=>0) β a.2=(fun _=>0) := | |
| markedEquiv_zero (inc:=BagEdge.Incident (bags:=sourceBags (fun x y=>(w x y:β)) K)) | |
| (j:=BagEdge.Incident (bags:=bags w K)) (sourceEdgeEquiv w K) (sourceEdgeEquiv_incidence w K) a | |
| lemma observableA_cast (w : V β V β β) (K : β) | |
| (a : SourceMarked (fun x y=>(w x y:β)) K) : | |
| (observableA w K (sourceMarkedEquiv w K a):β)=Enlargement.observableA (fun x y=>(w x y:β)) K a := by | |
| simp only [observableA,Enlargement.observableA,sourceMarkedEquiv_zero] | |
| split_ifs <;> norm_cast | |
| lemma observableD_cast (w wβ : V β V β β) (K : β) | |
| (a : SourceMarked (fun x y=>(w x y:β)) K) : | |
| (observableD w wβ K (sourceMarkedEquiv w K a):β)= | |
| Enlargement.observableD (fun x y=>(w x y:β)) (fun x y=>(wβ x y:β)) K a := by | |
| simp only [observableD,Enlargement.observableD,sourceMarkedEquiv_zero] | |
| split_ifs | |
| Β· push_cast | |
| change matchingWeight (fun e=>(bagReweight w wβ K e:β)) | |
| (pmEquiv (inc:=BagEdge.Incident (bags:=sourceBags (fun x y=>(w x y:β)) K)) | |
| (j:=BagEdge.Incident (bags:=bags w K)) (sourceEdgeEquiv w K) (sourceEdgeEquiv_incidence w K) a.1)=_ | |
| rw [matchingWeight_pmEquiv (sourceEdgeEquiv w K) (sourceEdgeEquiv_incidence w K)] | |
| unfold matchingWeight | |
| apply prod_congr rfl | |
| intro e _ | |
| exact bagReweight_cast w wβ K e | |
| Β· norm_cast | |
| lemma observableProbe_cast (w wβ : V β V β β) (K : β) (u : LogicalEdge V) | |
| (a : SourceMarked (fun x y=>(w x y:β)) K) : | |
| (observableProbe w wβ K u (sourceMarkedEquiv w K a):β)= | |
| Enlargement.observableProbe (fun x y=>(w x y:β)) (fun x y=>(wβ x y:β)) K u a := by | |
| have hh:=markedEquiv_probe (inc:=BagEdge.Incident (bags:=sourceBags (fun x y=>(w x y:β)) K)) | |
| (j:=BagEdge.Incident (bags:=bags w K)) (sourceEdgeEquiv w K) (sourceEdgeEquiv_incidence w K) a | |
| (Enlargement.centralEdge (fun x y=>(w x y:β)) K u) | |
| rw [sourceEdgeEquiv_central] at hh | |
| change ({centralEdge w K u}β(sourceMarkedEquiv w K a).1.val β§ | |
| (sourceMarkedEquiv w K a).2=(fun e=>if e.valβ({centralEdge w K u}:Finset _) then 2 else 0)) β _ at hh | |
| simp only [observableProbe,Enlargement.observableProbe,hh] | |
| simp only [mem_singleton] at hh β’ | |
| split_ifs <;> try contradiction | |
| Β· push_cast | |
| rw [βsourceEdgeEquiv_central w K u] | |
| change (β e β (pmEquiv (inc:=BagEdge.Incident (bags:=sourceBags (fun x y=>(w x y:β)) K)) | |
| (j:=BagEdge.Incident (bags:=bags w K)) (sourceEdgeEquiv w K) (sourceEdgeEquiv_incidence w K) a.1).val \ | |
| {sourceEdgeEquiv w K (Enlargement.centralEdge (fun x y=>(w x y:β)) K u)}, | |
| (bagReweight w wβ K e:β))=_ | |
| rw [pmEquiv_product_erase (sourceEdgeEquiv w K) (sourceEdgeEquiv_incidence w K)] | |
| refine prod_congr (by ext; simp) ?_ | |
| intro e _ | |
| exact bagReweight_cast w wβ K e | |
| Β· norm_cast | |
| end MatchingFPRAS.RationalSource | |
| end OAI | |