File size: 4,199 Bytes
dd14c26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.Probability.MatroidProphet.BranchMix

namespace OAI

namespace MatroidProphet

open MeasureTheory Finset

noncomputable def maximumRounded {n : ℕ} (M : Matroid (Fin n)) (w : Weights n) : ℝ := by
  classical
  exact Finset.univ.sup' Finset.univ_nonempty (fun o : Option (Fin n) =>
    match o with
    | none => 0
    | some e => if M.Indep ({e} : Set (Fin n)) then roundedWeight weightBase (w e) else 0)

lemma maximumRounded_nonneg {n : ℕ} (M : Matroid (Fin n)) (w : Weights n) :
    0 ≤ maximumRounded M w := by
  classical
  exact Finset.le_sup' (s := Finset.univ)
    (f := fun o : Option (Fin n) => match o with
      | none => 0
      | some e => if M.Indep ({e} : Set (Fin n)) then roundedWeight weightBase (w e) else 0)
    (Finset.mem_univ none)

lemma roundedWeight_le_maximumRounded {n : ℕ} (M : Matroid (Fin n)) (w : Weights n)
    (e : Fin n) (he : M.Indep ({e} : Set (Fin n))) :
    roundedWeight weightBase (w e) ≤ maximumRounded M w := by
  classical
  have h := Finset.le_sup' (s := Finset.univ)
    (f := fun o : Option (Fin n) => match o with
      | none => 0
      | some e => if M.Indep ({e} : Set (Fin n)) then roundedWeight weightBase (w e) else 0)
    (Finset.mem_univ (some e))
  change (if M.Indep ({e} : Set (Fin n)) then roundedWeight weightBase (w e) else 0) ≤
    maximumRounded M w at h
  rwa [ite_eq_left he] at h

noncomputable def maximumPayoff {n : ℕ} (M : Matroid (Fin n)) (w : Weights n) : ℝ :=
  ∫ r, hiddenWorstReward (roundedMaximumHidden M (seedSet (bits := n))) w r
    ∂bernoulliSeedLaw (fun _ => (1 / 2 : ℝ)) (fun _ => by norm_num) (fun _ => by norm_num)

lemma maximumPayoff_nonneg {n : ℕ} (M : Matroid (Fin n)) (w : Weights n) (hw : ∀ e, 0 ≤ w e) :
    0 ≤ maximumPayoff M w :=
  integral_nonneg (fun r => hiddenWorstReward_nonneg _ w hw r)

lemma roundedWeight_le_four_maximumPayoff {n : ℕ} (M : Matroid (Fin n)) (w : Weights n)
    (hw : ∀ e, 0 ≤ w e) (e : Fin n) (he : M.Indep ({e} : Set (Fin n))) :
    roundedWeight weightBase (w e) ≤ 4 * maximumPayoff M w := by
  classical
  let a : Fin n → WithBot ℤ := fun f => Priority.asLevel (roundedLevel weightBase (w f))
  by_cases hea : a e = ⊥
  · have hu : roundedWeight weightBase (w e) = 0 := by
      change levelWeight weightBase (a e) = 0
      rw [hea]
      rfl
    rw [hu]
    exact mul_nonneg (by norm_num) (maximumPayoff_nonneg M w hw)
  · let P : Finset (Fin n) := Finset.univ.filter fun f => M.Indep ({f} : Set (Fin n)) ∧ a f ≠ ⊥
    have heP : e ∈ P := Finset.mem_filter.mpr ⟨Finset.mem_univ e, he, hea⟩
    obtain ⟨g, hgP, htop⟩ := Maximum.exists_top a P ⟨e, heP⟩
    have hg := (Finset.mem_filter.mp hgP).2
    have hwin : w g / 4 ≤ maximumPayoff M w :=
      Maximum.maximum_integral_top M (fun x => Priority.asLevel (roundedLevel weightBase x))
        ((measurable_of_countable Priority.asLevel).comp (measurable_roundedLevel weightBase))
        (fun x => x ≠ ⊥) w hw g hg.1 hg.2
        (fun f hf haf hfg => htop f (Finset.mem_filter.mpr ⟨Finset.mem_univ f, hf, haf⟩) hfg)
    have hkey : a e ≤ a g := by
      by_cases heg : e = g
      · exact heg ▸ le_rfl
      · rcases htop e heP heg with hlt | ⟨heq, _⟩
        · exact hlt.le
        · exact heq.symm.le
    have hu : roundedWeight weightBase (w e) ≤ roundedWeight weightBase (w g) :=
      levelWeight_mono (by norm_num [weightBase]) hkey
    have hraw := roundedWeight_le (by norm_num [weightBase] : 1 < weightBase) (hw g)
    nlinarith

theorem maximum_branch_guarantee {n : ℕ} (M : Matroid (Fin n)) (w : Weights n)
    (hw : ∀ e, 0 ≤ w e) : maximumRounded M w / 4 ≤ maximumPayoff M w := by
  classical
  have hnonneg := maximumPayoff_nonneg M w hw
  have hfour : maximumRounded M w ≤ 4 * maximumPayoff M w := by
    apply Finset.sup'_le
    intro o _
    cases o with
    | none => exact mul_nonneg (by norm_num) hnonneg
    | some e =>
      change (if M.Indep ({e} : Set (Fin n)) then roundedWeight weightBase (w e) else 0) ≤ _
      split_ifs with he
      · exact roundedWeight_le_four_maximumPayoff M w hw e he
      · exact mul_nonneg (by norm_num) hnonneg
  nlinarith

end MatroidProphet

end OAI