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