File size: 4,809 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 | import OAI.Probability.MatroidProphet.Algorithm.LayerRank
import OAI.Probability.MatroidProphet.PathStatistics
namespace OAI
namespace MatroidProphet.MainAlgorithm
open Set Finset Pivots
variable {n : β}
noncomputable def pathGroups (M : Matroid (Fin n)) (d : MainMasks n)
(w : Fin n β Option β€) (h : β) : Finset (Fin n) := by
classical
exact (groupMask M d w univ h).toFinset
lemma pathGroups_coe (M : Matroid (Fin n)) (d : MainMasks n)
(w : Fin n β Option β€) (h : β) :
(pathGroups M d w h : Set (Fin n)) = groupMask M d w univ h := by
classical
exact Set.coe_toFinset _
lemma groupMask_eq_inter (M : Matroid (Fin n)) (d : MainMasks n)
(w : Fin n β Option β€) (mask : Finset (Fin n)) (h : β) :
groupMask M d w mask h = (mask : Set (Fin n)) β© (pathGroups M d w h : Set (Fin n)) := by
classical
rw [pathGroups_coe]
ext e
simp [groupMask]
lemma pathGroups_disjoint (M : Matroid (Fin n)) (d : MainMasks n)
(w : Fin n β Option β€) : Pairwise (fun i j => Disjoint (pathGroups M d w i) (pathGroups M d w j)) := by
classical
intro i j hij
apply Finset.disjoint_left.mpr
intro e hei hej
have heI : e β groupMask M d w univ i := by simpa only [pathGroups, Set.mem_toFinset] using hei
have heJ : e β groupMask M d w univ j := by simpa only [pathGroups, Set.mem_toFinset] using hej
obtain β¨k, hkβ© := Option.ne_none_iff_exists'.mp heI.2.1.1
have hi := (groups_index_of_get M d w (heI.2.2.symm.trans hk)).2
have hj := (groups_index_of_get M d w (heJ.2.2.symm.trans hk)).2
exact hij (hi.symm.trans hj)
noncomputable def listedLambda (M : Matroid (Fin n)) (hE : M.E = Set.univ)
(d : MainMasks n) (w : Fin n β Option β€) (h : β) : β :=
finalRankStatistic M hE (2^100) (groupMask M d w d.D) (groupMask M d w d.C)
(groupMask M d w d.T) h (groups M d w).length (groupMask M d w univ h)
((d.H βͺ d.D βͺ d.C : Finset (Fin n)) : Set (Fin n)) (d.T : Set (Fin n)) (boolParity d.odd)
noncomputable def listedZ (M : Matroid (Fin n)) (hE : M.E = Set.univ)
(d : MainMasks n) (w : Fin n β Option β€) (h : β) : β :=
nominalRankStatistic M hE (2^100) (groupMask M d w d.D) (groupMask M d w d.C)
(groupMask M d w d.T) h (groupMask M d w univ h)
((d.H βͺ d.D βͺ d.C : Finset (Fin n)) : Set (Fin n)) (boolParity d.odd)
noncomputable def trueLambda (M : Matroid (Fin n)) (hE : M.E = Set.univ)
(d : MainMasks n) (w : Fin n β Option β€) (i : β€) : β := by
classical
exact if i β groups M d w then listedLambda M hE d w ((groups M d w).idxOf i) else 0
noncomputable def trueZ (M : Matroid (Fin n)) (hE : M.E = Set.univ)
(d : MainMasks n) (w : Fin n β Option β€) (i : β€) : β := by
classical
exact if i β groups M d w then listedZ M hE d w ((groups M d w).idxOf i) else 0
theorem listedLambda_le_count (M : Matroid (Fin n)) (hE : M.E = Set.univ)
(d : MainMasks n) (w : Fin n β Option β€) (Ο : ArrivalOrder n) (h : β) :
listedLambda M hE d w h β€
((selection M hE d w Ο).filter (fun e =>
β i, w e = some i β§ h β€ (groups M d w).idxOf i)).card := by
classical
have hc := selection_cumulative_rank M hE d w Ο h
(parityPoints (activation h) (boolParity d.odd)) (by
intro b hb
have hm := ((mem_parityPoints _ _ _).mp hb).2.2
rwa [boolParity_val] at hm)
rw [sum_parityPoints] at hc
have hreg (b : ParityWindow (activation h) (boolParity d.odd)) :
groupBirthRegion M hE d w h b.val.val =
nominalLayerSet M hE (2^100) (groupMask M d w d.D) (groupMask M d w d.C)
h (groupMask M d w univ h) (boolParity d.odd) b \
((d.H βͺ d.D βͺ d.C : Finset (Fin n)) : Set (Fin n)) :=
unobservedBirthRegion_eq_nominalLayer M hE (2^100) _ _ h _ _ _ b
simp_rw [hreg] at hc
exact hc
theorem trueLambda_le_count (M : Matroid (Fin n)) (hE : M.E = Set.univ)
(d : MainMasks n) (w : Fin n β Option β€) (Ο : ArrivalOrder n) (i : β€) :
trueLambda M hE d w i β€
((selection M hE d w Ο).filter (fun e => β j, w e = some j β§ i β€ j)).card := by
classical
unfold trueLambda
split_ifs with hi
Β· apply (listedLambda_le_count M hE d w Ο _).trans
apply Finset.card_le_card
intro e he
obtain β¨hea, j, hwj, hijβ© := Finset.mem_filter.mp he
refine Finset.mem_filter.mpr β¨hea, j, hwj, ?_β©
have hel := layerGreedy_subset M _ _ _ _ hea
obtain β¨k, hwk, hek, _β© := (assign_spec M hE d w e _ _).mp
(assigned_some_of_eligible (assign M hE d w) w e hel)
have hjk : j = k := Option.some.inj (hwj.symm.trans hwk)
have hj : j β groups M d w := hjk βΈ hek.2.2.1
by_contra hn
have hlt := (groups_idxOf_lt_iff M d w j i hj hi).mpr (by omega)
omega
Β· exact Nat.zero_le _
end MatroidProphet.MainAlgorithm
end OAI
|