math / data /lean /OAI /Combinatorics /MatchingPSD /AffineSlacks.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
1.71 kB
import Mathlib
import OAI.Combinatorics.MatchingPSD.AffineModel
import OAI.Combinatorics.MatchingPSD.FiniteFactorization
namespace OAI
namespace PerfectMatchingPSD
open MatchingSmoothing Finset Matrix
open scoped BigOperators
noncomputable def slackAffine {n : β„•} (i : Row n) : (Edge n β†’ ℝ) →ᡃ[ℝ] ℝ := by
classical
cases i with
| inl e => exact (LinearMap.proj e).toAffineMap
| inr U =>
exact (βˆ‘ e : Edge n, if Crosses U.1 e then LinearMap.proj e else 0).toAffineMap -
AffineMap.const ℝ (Edge n β†’ ℝ) 1
lemma slackAffine_vertex {n : β„•} (i : Row n) (M : PerfectMatching n) :
slackAffine i (matchingPoint M) = slack i M := by
classical
cases i with
| inl e => rfl
| inr U =>
simp only [slackAffine, AffineMap.coe_sub, Pi.sub_apply, AffineMap.const_apply,
LinearMap.coe_toAffineMap, slack]
congr 1
rw [LinearMap.sum_apply]
calc
_ = βˆ‘ e : Edge n, if Crosses U.1 e ∧ e ∈ M.1 then (1 : ℝ) else 0 := by
apply Finset.sum_congr rfl
intro e _
by_cases h : Crosses U.1 e <;> simp [h, matchingPoint]
_ = _ := by
simp only [Finset.sum_boole, crossingCount]
apply congrArg (fun s : Finset (Edge n) => (s.card : ℝ))
ext e
simp [and_comm]
lemma slackAffine_nonneg {n : β„•} (i : Row n) {x : Edge n β†’ ℝ}
(hx : x ∈ matchingPolytope n) : 0 ≀ slackAffine i x := by
have hc : Convex ℝ {x : Edge n β†’ ℝ | 0 ≀ slackAffine i x} := by
exact (convex_Ici (0 : ℝ)).affine_preimage (slackAffine i)
apply convexHull_min _ hc hx
rintro _ ⟨M, rfl⟩
rw [Set.mem_ofPred_eq, slackAffine_vertex]
exact slack_nonneg i M
end PerfectMatchingPSD
end OAI