File size: 2,188 Bytes
ea76aac | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | import OAI.Computability.LoopMatching.Model
namespace OAI
/-! Polynomial-time approximation of weighted matchings with singleton loops. -/
open scoped BigOperators
namespace LoopMatching
theorem loopVertices_card_le {n : ℕ} (M : PartialMatching n) :
(loopVertices M).card ≤ n := by
classical
simpa using Finset.card_le_card (Finset.subset_univ (loopVertices M))
theorem countWithLoops_eq_zero_of_lt (G : Input) {j : ℕ} (hj : G.n < j) :
countWithLoops G j = 0 := by
classical
unfold countWithLoops
apply Finset.sum_eq_zero
intro M hM
have hne : (loopVertices M).card ≠ j := by
intro heq
have hle := loopVertices_card_le M
rw [heq] at hle
exact (Nat.not_le_of_gt hj) hle
simp only [hne, ↓reduceIte]
theorem count_eq_sum_countWithLoops (G : Input) :
count G = ∑ j ∈ Finset.range (G.n + 1), countWithLoops G j := by
classical
unfold count countWithLoops
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro M hM
symm
calc
_ = (if (loopVertices M).card = (loopVertices M).card then weight G M else 0) := by
apply Finset.sum_eq_single (loopVertices M).card
· intro j hj hne
simp only [Ne.symm hne, ↓reduceIte]
· intro hnot
exact (hnot (Finset.mem_range.mpr
(Nat.lt_succ_of_le (loopVertices_card_le M)))).elim
_ = weight G M := ite_eq_left rfl
theorem weight_eq_zero_of_loopMultiplicity_eq_zero (G : Input)
(M : PartialMatching G.n) (v : Fin G.n)
(hv : v ∈ loopVertices M) (hzero : loopMultiplicity G v = 0) :
weight G M = 0 := by
classical
unfold weight
rw [Finset.prod_eq_zero hv hzero, mul_zero]
theorem weight_eq_zero_of_multiplicity_eq_zero (G : Input)
(M : PartialMatching G.n) (e : BinaryMatching.Pair G.n)
(he : e ∈ M.val) (hzero : BinaryMatching.multiplicity G.ordinary e = 0) :
weight G M = 0 := by
classical
unfold weight
rw [Finset.prod_eq_zero he hzero, zero_mul]
theorem count_eq_zero_of_forall_weight_eq_zero (G : Input)
(hzero : ∀ M : PartialMatching G.n, weight G M = 0) : count G = 0 := by
classical
unfold count
exact Finset.sum_eq_zero (fun M _ => hzero M)
end LoopMatching
end OAI
|