Download data/lean/OAI/Computability/MatchingCount/CutAlgebra.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 4.5 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MatchingCount/CutAlgebra.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/MatchingCount/CutAlgebra.lean
-
curl -L -o CutAlgebra.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MatchingCount/CutAlgebra.lean
4.5 kB
| import OAI.Computability.MatchingCount.UnitFlow | |
| namespace OAI | |
| section | |
| namespace BinaryMatching.CutAlgebra | |
| open Finset UnitFlow | |
| variable {V W : Type*} [Fintype V] [DecidableEq V] [Fintype W] [DecidableEq W] | |
| abbrev cross (S : Finset V) (i j : V) : Prop := iβS β§ jβS | |
| lemma cutCapacity_eq (c : V β V β β) (S : Finset V) : | |
| cutCapacity c S = β i, β j, if cross S i j then c i j else 0 := by | |
| simp only [cutCapacity,cross,ite_and] | |
| simp [Finset.sum_ite_irrel] | |
| apply sum_congr rfl; intro i hi | |
| have hSc : SαΆ = univ.filter (fun j => jβS) := by ext j; simp | |
| rw [hSc,sum_filter] | |
| simp | |
| lemma cut_compl (c : V β V β β) (hc : β i j, c i j=c j i) (S : Finset V) : | |
| cutCapacity c SαΆ = cutCapacity c S := by | |
| rw [cutCapacity_eq,cutCapacity_eq,sum_comm] | |
| apply sum_congr rfl; intro i hi | |
| apply sum_congr rfl; intro j hj | |
| simp only [cross,mem_compl,not_not] | |
| rw [hc j i] | |
| by_cases his : iβS <;> by_cases hjs : jβS <;> simp [his,hjs] | |
| lemma cut_submodular (c : V β V β β) (S A : Finset V) : | |
| cutCapacity c (Sβ©A) + cutCapacity c (SβͺA) β€ cutCapacity c S + cutCapacity c A := by | |
| simp only [cutCapacity_eq,β sum_add_distrib] | |
| apply sum_le_sum; intro i hi | |
| apply sum_le_sum; intro j hj | |
| by_cases his : iβS <;> by_cases hia : iβA <;> | |
| by_cases hjs : jβS <;> by_cases hja : jβA <;> | |
| simp [cross,his,hia,hjs,hja] | |
| def push (c : V β V β β) (f : V β W) (i j : W) : β := | |
| if i=j then 0 else β u, β v, if f u=i β§ f v=j then c u v else 0 | |
| def lift (f : V β W) (T : Finset W) : Finset V := univ.filter (fun v => f vβT) | |
| omit [DecidableEq V] [Fintype W] in | |
| lemma mem_lift (f : V β W) (T : Finset W) (v : V) : vβlift f T β f vβT := by | |
| simp [lift] | |
| omit [DecidableEq V] [Fintype W] in | |
| lemma push_symm (c : V β V β β) (hc : β i j, c i j=c j i) (f : V β W) : | |
| β i j, push c f i j=push c f j i := by | |
| intro i j | |
| by_cases hij : i=j | |
| Β· subst j; rfl | |
| simp only [push,ite_eq_right hij,ite_eq_right (Ne.symm hij)] | |
| rw [sum_comm] | |
| apply sum_congr rfl; intro u hu | |
| apply sum_congr rfl; intro v hv | |
| rw [hc v u] | |
| simp only [and_comm] | |
| omit [DecidableEq V] [Fintype W] in | |
| lemma push_diag (c : V β V β β) (f : V β W) (i : W) : push c f i i=0 := by | |
| simp [push] | |
| omit [DecidableEq V] [DecidableEq W] in | |
| lemma sum_four_swap (h : W β W β V β V β β) : | |
| (β i, β j, β u, β v, h i j u v) = β u, β v, β i, β j, h i j u v := by | |
| calc | |
| _ = β i, β u, β j, β v, h i j u v := by | |
| apply sum_congr rfl; intro i hi | |
| rw [sum_comm] | |
| _ = β u, β i, β j, β v, h i j u v := by rw [sum_comm] | |
| _ = β u, β i, β v, β j, h i j u v := by | |
| apply sum_congr rfl; intro u hu | |
| apply sum_congr rfl; intro i hi | |
| rw [sum_comm] | |
| _ = _ := by | |
| apply sum_congr rfl; intro u hu | |
| rw [sum_comm] | |
| lemma cut_push (c : V β V β β) (f : V β W) (T : Finset W) : | |
| cutCapacity (push c f) T = cutCapacity c (lift f T) := by | |
| rw [cutCapacity_eq,cutCapacity_eq] | |
| have he : β i j, (if cross T i j then push c f i j else 0) = | |
| β u, β v, if cross T (f u) (f v) β§ f u=i β§ f v=j then c u v else 0 := by | |
| intro i j | |
| by_cases hh : cross T i j | |
| Β· have hij : iβ j := by intro h; subst j; exact hh.2 hh.1 | |
| simp only [ite_eq_left hh,push,ite_eq_right hij] | |
| apply sum_congr rfl; intro u hu | |
| apply sum_congr rfl; intro v hv | |
| by_cases hui : f u=i <;> by_cases hvj : f v=j <;> simp_all | |
| Β· simp only [ite_eq_right hh] | |
| symm | |
| apply sum_eq_zero; intro u hu | |
| apply sum_eq_zero; intro v hv | |
| by_cases hui : f u=i <;> by_cases hvj : f v=j <;> simp_all | |
| simp_rw [he] | |
| rw [sum_four_swap] | |
| apply sum_congr rfl; intro u hu | |
| apply sum_congr rfl; intro v hv | |
| simp only [cross,mem_lift] | |
| by_cases hh : f uβT β§ f vβT | |
| Β· simp only [hh,true_and] | |
| simp [ite_and,Finset.sum_ite_irrel,eq_comm] | |
| Β· simp [hh] | |
| omit [DecidableEq V] in | |
| lemma push_total_le (c : V β V β β) (f : V β W) : | |
| (β i, β j, push c f i j) β€ β u, β v, c u v := by | |
| calc | |
| _ β€ β i, β j, β u, β v, if f u=i β§ f v=j then c u v else 0 := by | |
| apply sum_le_sum; intro i hi | |
| apply sum_le_sum; intro j hj | |
| simp only [push] | |
| split_ifs <;> omega | |
| _ = _ := by | |
| rw [sum_four_swap] | |
| apply sum_congr rfl; intro u hu | |
| apply sum_congr rfl; intro v hv | |
| simp [ite_and,Finset.sum_ite_irrel,eq_comm] | |
| end BinaryMatching.CutAlgebra | |
| end | |
| end OAI | |