Download data/lean/OAI/Combinatorics/MatchingPSD/FiniteFactorization.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 4.58 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingPSD/FiniteFactorization.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingPSD/FiniteFactorization.lean
-
curl -L -o FiniteFactorization.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingPSD/FiniteFactorization.lean
4.58 kB
| import OAI.Combinatorics.MatchingPSD.CellLowerBound | |
| namespace OAI | |
| universe u_1 u_2 | |
| namespace PerfectMatchingPSD | |
| lemma endpoint_count {n : β} (U : Finset (Fin n)) (M : PerfectMatching n) : | |
| (β e β M.1, ((if e.1.1 β U then 1 else 0) + | |
| (if e.1.2 β U then 1 else 0) : β)) = U.card := by | |
| classical | |
| have pair_count (e : Edge n) : | |
| (β v β U, (if e.1.1 = v β¨ e.1.2 = v then 1 else 0 : β)) = | |
| (if e.1.1 β U then 1 else 0) + (if e.1.2 β U then 1 else 0) := by | |
| have pointwise (v : Fin n) : | |
| (if e.1.1 = v β¨ e.1.2 = v then 1 else 0 : β) = | |
| (if e.1.1 = v then 1 else 0) + (if e.1.2 = v then 1 else 0) := by | |
| have hne : e.1.1 β e.1.2 := ne_of_lt e.2 | |
| by_cases hβ : e.1.1 = v <;> by_cases hβ : e.1.2 = v <;> simp_all | |
| simp_rw [pointwise] | |
| simp [Finset.sum_add_distrib] | |
| calc | |
| _ = β e β M.1, β v β U, | |
| (if e.1.1 = v β¨ e.1.2 = v then 1 else 0 : β) := by | |
| apply Finset.sum_congr rfl | |
| intro e _ | |
| exact (pair_count e).symm | |
| _ = β v β U, β e β M.1, | |
| (if e.1.1 = v β¨ e.1.2 = v then 1 else 0 : β) := Finset.sum_comm | |
| _ = β v β U, (M.1.filter fun e => e.1.1 = v β¨ e.1.2 = v).card := by | |
| simp only [Finset.sum_boole, Nat.cast_id] | |
| _ = U.card := by | |
| have hm : β v : Fin n, | |
| (M.1.filter fun e => e.1.1 = v β¨ e.1.2 = v).card = 1 := M.2 | |
| simp [hm] | |
| lemma cut_degree_identity {n : β} (U : Finset (Fin n)) (M : PerfectMatching n) : | |
| U.card = 2 * (M.1.filter fun e => e.1.1 β U β§ e.1.2 β U).card + | |
| crossingCount U M := by | |
| classical | |
| rw [β endpoint_count U M] | |
| have term (e : Edge n) : | |
| ((if e.1.1 β U then 1 else 0) + (if e.1.2 β U then 1 else 0) : β) = | |
| 2 * (if e.1.1 β U β§ e.1.2 β U then 1 else 0) + | |
| (if Crosses U e then 1 else 0) := by | |
| by_cases hβ : e.1.1 β U <;> by_cases hβ : e.1.2 β U <;> | |
| simp [hβ, hβ, Crosses] | |
| simp_rw [term] | |
| rw [Finset.sum_add_distrib, β Finset.mul_sum] | |
| simp only [Finset.sum_boole, Nat.cast_id, crossingCount] | |
| lemma crossingCount_pos {n : β} (U : OddCut n) (M : PerfectMatching n) : | |
| 0 < crossingCount U.1 M := by | |
| obtain β¨k, hkβ© := U.2 | |
| have h := cut_degree_identity U.1 M | |
| omega | |
| lemma slack_nonneg {n : β} (i : Row n) (M : PerfectMatching n) : | |
| 0 β€ slack i M := by | |
| classical | |
| rcases i with e | U | |
| Β· simp only [slack] | |
| split_ifs <;> norm_num | |
| Β· have h : 1 β€ crossingCount U.1 M := crossingCount_pos U M | |
| have hr : (1 : β) β€ (crossingCount U.1 M : β) := by exact_mod_cast h | |
| simpa only [slack, sub_nonneg] using hr | |
| lemma exists_diagonal_factorization {I : Type u_1} {J : Type u_2} [Finite J] | |
| (S : I β J β β) (hS : β i j, 0 β€ S i j) : | |
| β r : β, 0 < r β§ | |
| β (A : I β Matrix (Fin r) (Fin r) β) | |
| (B : J β Matrix (Fin r) (Fin r) β), | |
| (β i, (A i).PosSemidef) β§ (β j, (B j).PosSemidef) β§ | |
| β i j, S i j = Matrix.trace (A i * B j) := by | |
| classical | |
| let : Fintype J := Fintype.ofFinite J | |
| let e := Fintype.equivFin (Option J) | |
| let a (i : I) (k : Option J) : β := k.elim 0 (S i) | |
| let b (j : J) (k : Option J) : β := if k = some j then 1 else 0 | |
| refine β¨Fintype.card (Option J), by simp, | |
| (fun i => (Matrix.diagonal (a i)).submatrix e.symm e.symm), | |
| (fun j => (Matrix.diagonal (b j)).submatrix e.symm e.symm), ?_, ?_, ?_β© | |
| Β· intro i | |
| apply Matrix.PosSemidef.submatrix | |
| apply Matrix.PosSemidef.diagonal | |
| intro k | |
| cases k with | |
| | none => exact le_rfl | |
| | some j => exact hS i j | |
| Β· intro j | |
| apply Matrix.PosSemidef.submatrix | |
| apply Matrix.PosSemidef.diagonal | |
| intro k | |
| dsimp [b] | |
| split_ifs <;> norm_num | |
| Β· intro i j | |
| rw [Matrix.submatrix_mul_equiv, Matrix.diagonal_mul_diagonal, | |
| Matrix.submatrix_diagonal _ _ e.symm.injective, Matrix.trace_diagonal] | |
| dsimp only [Function.comp_def] | |
| rw [e.symm.sum_comp (fun k => a i k * b j k)] | |
| simp [a, b] | |
| lemma factor_orders_nonempty (n : β) : | |
| {r : β | 0 < r β§ HasFactorization n r}.Nonempty := by | |
| obtain β¨r, hr, hβ© := exists_diagonal_factorization (@slack n) slack_nonneg | |
| exact β¨r, hr, hβ© | |
| lemma psdRank_pos (n : β) : 0 < psdRank n := | |
| (Nat.sInf_mem (factor_orders_nonempty n)).1 | |
| lemma hasFactorization_psdRank (n : β) : HasFactorization n (psdRank n) := | |
| (Nat.sInf_mem (factor_orders_nonempty n)).2 | |
| lemma psdRank_le {n r : β} (hr : 0 < r) (h : HasFactorization n r) : | |
| psdRank n β€ r := Nat.sInf_le β¨hr, hβ© | |
| end PerfectMatchingPSD | |
| end OAI | |