File size: 5,627 Bytes
4a56cd6 | 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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | import OAI.Probability.MatroidProphet.Algorithm.Selection
import OAI.Probability.MatroidProphet.Groups
import OAI.Probability.MatroidProphet.PathRankCost
namespace OAI
namespace MatroidProphet
open Set Finset
variable {Ξ± : Type*} [Fintype Ξ±]
lemma mem_nominal_difference_iff (M : Matroid Ξ±) (hE : M.E = Set.univ)
(ΞΊ : β) (D C : β β Set Ξ±) (h : β) (e : Ξ±) (he : e β M.closure β
) (b : β€) :
e β nominalPath M hE ΞΊ D C h b \ nominalPath M hE ΞΊ D C h (b-1) β
nominalBirth M hE ΞΊ D C h e = b := by
simp only [Set.mem_sdiff, mem_nominal_iff_birth_le M hE ΞΊ D C h e he]
omega
lemma lowerCompetition_member (M : Matroid Ξ±) (hE : M.E = Set.univ)
(ΞΊ : β) (D C T : β β Set Ξ±) (b : β€) {j h : β} (hj : j < h)
{e : Ξ±} (he : e β T j β© (nominalPath M hE ΞΊ D C j b \
nominalPath M hE ΞΊ D C j (b-1))) :
e β lowerCompetition M hE ΞΊ D C T b h := by
induction h with
| zero => omega
| succ h ih =>
change e β lowerCompetition M hE ΞΊ D C T b h βͺ
(T h β© (nominalPath M hE ΞΊ D C h b \ nominalPath M hE ΞΊ D C h (b-1)))
by_cases heq : j = h
Β· exact Or.inr (heq βΈ he)
Β· exact Or.inl (ih (by omega))
namespace MainAlgorithm
variable {n : β}
lemma candidate_nonloop (M : Matroid (Fin n)) (d : MainMasks n)
(w : Fin n β Option β€) (e : Fin n) (v : Option β€)
(he : candidate M d w e v) : e β M.closure β
:=
fun hx => he.2.2 (M.closure_subset_closure (Set.empty_subset _) hx)
lemma groups_index_of_get (M : Matroid (Fin n)) (d : MainMasks n)
(w : Fin n β Option β€) {h : β} {i : β€} (hi : (groups M d w)[h]? = some i) :
i β groups M d w β§ (groups M d w).idxOf i = h := by
obtain β¨hh, rflβ© := List.getElem?_eq_some_iff.mp hi
exact β¨List.getElem_mem hh, (groups_nodup M d w).idxOf_getElem h hhβ©
noncomputable def groupBirthRegion (M : Matroid (Fin n)) (hE : M.E = Set.univ)
(d : MainMasks n) (w : Fin n β Option β€) (h : β) (b : β€) : Set (Fin n) :=
unobservedBirthRegion M hE (2^100) (groupMask M d w d.D) (groupMask M d w d.C)
(groupMask M d w univ h) (d.H βͺ d.D βͺ d.C : Finset (Fin n)) h b
noncomputable def competition (M : Matroid (Fin n)) (hE : M.E = Set.univ)
(d : MainMasks n) (w : Fin n β Option β€) (h : β) (b : β€) : Set (Fin n) :=
lowerCompetition M hE (2^100) (groupMask M d w d.D) (groupMask M d w d.C)
(groupMask M d w d.T) b h
lemma groupBirthRegion_eligible (M : Matroid (Fin n)) (hE : M.E = Set.univ)
(d : MainMasks n) (w : Fin n β Option β€) (h : β) (b : β€)
(hb : b % 2 = (if d.odd then 1 else 0)) {e : Fin n}
(he : e β groupBirthRegion M hE d w h b β© (d.T : Set (Fin n)))
(hf : e β finalPath M hE d w (b-2)) :
e β assignedEligible (assign M hE d w) w β§
assignedLayer (assign M hE d w) w e = b := by
classical
have ht := he.2
have hr := he.1
unfold groupBirthRegion unobservedBirthRegion at hr
split_ifs at hr with ha
Β· obtain β¨β¨β¨_, hc, hgβ©, hXβ©, hOβ© := hr
obtain β¨i, hwiβ© : β i, w e = some i := Option.ne_none_iff_exists'.mp hc.1
have hget : (groups M d w)[h]? = some i := hg.symm.trans hwi
obtain β¨hi, hidxβ© := groups_index_of_get M d w hget
have hbirth : birth M hE d w e i = b := by
unfold birth
rw [hidx]
exact (mem_nominal_difference_iff M hE (2^100) _ _ h e
(candidate_nonloop M d w e _ hc) b).mp hX
have hel : eligible M hE d w e i := by
refine β¨hO, ?_, hi, ht, ?_, ?_, ?_β©
Β· rwa [β hwi]
Β· rwa [hidx, hbirth]
Β· rwa [hbirth]
Β· rwa [hbirth]
have has : assign M hE d w e (w e) = some b :=
(assign_spec M hE d w e _ b).mpr β¨i, hwi, hel, hbirthβ©
constructor
Β· simp [assignedEligible, has]
Β· simp [assignedLayer, has]
Β· exact False.elim hr
lemma selection_low_mem_competition (M : Matroid (Fin n)) (hE : M.E = Set.univ)
(d : MainMasks n) (w : Fin n β Option β€) (Ο : ArrivalOrder n)
(h : β) (b : β€) {e : Fin n} (he : e β selection M hE d w Ο)
(hb : assignedLayer (assign M hE d w) w e = b)
(hlow : Β¬ β i, w e = some i β§ h β€ (groups M d w).idxOf i) :
e β competition M hE d w h b := by
have hel := layerGreedy_subset M _ _ _ _ he
obtain β¨i, hwi, hi, hbiβ© := (assign_spec M hE d w e _ _).mp
(assigned_some_of_eligible (assign M hE d w) w e hel)
have hidx : (groups M d w).idxOf i < h := by
by_contra hn
exact hlow β¨i, hwi, by omegaβ©
apply lowerCompetition_member M hE (2^100) _ _ _ b hidx
constructor
Β· exact β¨hi.2.2.2.1, by simpa only [hwi] using hi.2.1, hwi.trans (groups_get?_idxOf M d w i hi.2.2.1).symmβ©
Β· apply (mem_nominal_difference_iff M hE (2^100) _ _ _ e
(candidate_nonloop M d w e _ hi.2.1) b).mpr
exact hbi.trans hb
theorem selection_cumulative_rank (M : Matroid (Fin n)) (hE : M.E = Set.univ)
(d : MainMasks n) (w : Fin n β Option β€) (Ο : ArrivalOrder n)
(h : β) (L : Finset β€) (hL : β b β L, b % 2 = (if d.odd then 1 else 0)) :
(β b β L, conditionalRank M
(groupBirthRegion M hE d w h b β© (d.T : Set (Fin n)))
(finalPath M hE d w (b-2) βͺ competition M hE d w h b)) β€
((selection M hE d w Ο).filter (fun e =>
β i, w e = some i β§ h β€ (groups M d w).idxOf i)).card := by
classical
exact layerGreedy_sum_rank_lower M hE _ _ _ _ L _ _ _
(fun b hb e he => groupBirthRegion_eligible M hE d w h b (hL b hb) he.1 he.2)
(fun b _ e he hb hn => selection_low_mem_competition M hE d w Ο h b he hb hn)
end MainAlgorithm
end MatroidProphet
end OAI
|