File size: 5,733 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 | import OAI.Probability.MatroidProphet.Pivots.Arbitrary
import OAI.Probability.MatroidProphet.Pivots.Encoding
import OAI.Probability.MatroidProphet.Pivots.OccurrenceSupport
import OAI.Probability.MatroidProphet.Pivots.Scores
import OAI.Probability.MatroidProphet.Pivots.Sign
import Mathlib.LinearAlgebra.Dimension.Constructions
namespace OAI
namespace MatroidProphet
namespace Pivots
open Set Finset
open scoped BigOperators
variable {Ξ± : Type*} [Fintype Ξ±] {r q n : β}
def occurrenceMark (oldMark : Fin r β Bool) (movableMark : Fin q β Bool) :
Occurrence r q β Bool := Sum.elim oldMark movableMark
noncomputable def markedScore (s : β) (time : Occurrence r q β β)
(oldMark : Fin r β Bool) (movableMark : Fin q β Bool) (o : Occurrence r q) : β :=
if occurrenceMark oldMark movableMark o then (2 : β) ^ scoreExponent s time o
else -(2 : β) ^ scoreExponent s time o
lemma abs_markedScore (s : β) (time : Occurrence r q β β)
(oldMark : Fin r β Bool) (movableMark : Fin q β Bool) (o : Occurrence r q) :
|markedScore s time oldMark movableMark o| = (2 : β) ^ scoreExponent s time o := by
unfold markedScore
split <;> simp [abs_of_nonneg (pow_nonneg (by norm_num : (0 : β) β€ 2) _)]
noncomputable def fixedOldScore (s : β) (oldMark : Fin r β Bool) (i : Fin r) : β :=
if oldMark i then (2 : β)^((s+1)*(i.val+1)) else -(2 : β)^((s+1)*(i.val+1))
noncomputable def constantScore (s : β) (oldMark : Fin r β Bool) : Occurrence r q β β :=
Sum.elim (fixedOldScore s oldMark) (fun _ => 0)
noncomputable def coordinateScore : Occurrence r q β ((Fin q β β) ββ[β] β) :=
Sum.elim (fun _ => 0) (fun i => LinearMap.proj i)
noncomputable def patternLinear (M : Matroid Ξ±) (label : Occurrence r q β Ξ±)
(J : Finset (Occurrence r q)) (e : Ξ±) : (Fin q β β) ββ[β] β :=
β o β occurrenceSupport M label J e, coordinateScore o
noncomputable def patternConstant (M : Matroid Ξ±) (label : Occurrence r q β Ξ±)
(J : Finset (Occurrence r q)) (e : Ξ±) (s : β) (oldMark : Fin r β Bool) : β :=
β o β occurrenceSupport M label J e, constantScore s oldMark o
lemma affineScore_eq_sum
{Ξ± : Type u_1} [Fintype Ξ±] {r : β} {q : β} (M : Matroid Ξ±) (label : Occurrence r q β Ξ±)
(J : Finset (Occurrence r q)) (e : Ξ±) (s : β) (time : Occurrence r q β β)
(oldMark : Fin r β Bool) (movableMark : Fin q β Bool) :
patternLinear M label J e (fun i => markedScore s time oldMark movableMark (Sum.inr i)) +
patternConstant M label J e s oldMark =
β o β occurrenceSupport M label J e, markedScore s time oldMark movableMark o := by
simp only [patternLinear, patternConstant, LinearMap.sum_apply, β Finset.sum_add_distrib]
apply Finset.sum_congr rfl
intro o _
cases o <;> simp [coordinateScore, constantScore, fixedOldScore, markedScore,
occurrenceMark, scoreExponent]
all_goals rfl
def RecordsPivots (M : Matroid Ξ±) (label : Occurrence r q β Ξ±)
(test : Fin n β Ξ±) (time : Occurrence r q β β)
(oldMark : Fin r β Bool) (movableMark : Fin q β Bool) (t : Finset (Fin n)) : Prop :=
β f, β o, IsPivot M label time (test f) o β§
(occurrenceMark oldMark movableMark o = true β f β t)
lemma recordsPivots_affine (M : Matroid Ξ±) (b : β β Ξ±) (a : Fin q β Ξ±)
(test : Fin n β Ξ±) (s : β) (hqs : q β€ s)
(oldMark : Fin r β Bool) (movableMark : Fin q β Bool)
(time : Occurrence r q β β) (horder : OldOrdered time) (htime : Function.Injective time)
(hground : β o : Occurrence r q, occurrenceLabel b a o β M.E) (t : Finset (Fin n))
(hrecords : RecordsPivots M (occurrenceLabel b a) test time oldMark movableMark t) :
β x, RealizesSigns
(fun f => patternLinear M (occurrenceLabel b a) (retained M b a time) (test f))
(fun f => patternConstant M (occurrenceLabel b a) (retained M b a time) (test f) s oldMark)
t x := by
classical
let label : Occurrence r q β Ξ± := occurrenceLabel b a
let J := retained M b a time
let w := markedScore s time oldMark movableMark
let exponent := scoreExponent s time
refine β¨fun i => w (Sum.inr i), ?_β©
intro f
rw [affineScore_eq_sum]
obtain β¨o, hpivot, hmarkβ© := hrecords f
have hp := pivot_mem_support_and_max M label time hground htime hpivot
change o β occurrenceSupport M label J (test f) β§
(β p β occurrenceSupport M label J (test f), time p β€ time o) at hp
have hmax : β p β occurrenceSupport M label J (test f), p β o β exponent p < exponent o := by
intro p hp' hne
apply scoreExponent_preserves_order s hqs time horder
exact lt_of_le_of_ne (hp.2 p hp') (fun heq => hne (htime heq))
have hexp := scoreExponent_injective s hqs time horder htime
have habs : β p β occurrenceSupport M label J (test f), |w p| = 2 ^ exponent p :=
fun p _ => abs_markedScore s time oldMark movableMark p
have hpos := sum_positive_iff_max_exponent _ w exponent hexp hp.1 hmax habs
have hneg := sum_positive_iff_max_exponent _ (fun p => -w p) exponent hexp hp.1 hmax
(by intro p hp'; simpa using habs p hp')
simp only [Finset.sum_neg_distrib, neg_pos] at hneg
have hpow : (0 : β) < 2 ^ exponent o := pow_pos (by norm_num) _
by_cases hf : f β t
Β· simp only [hf, βreduceIte]
apply hpos.mpr
have hm := hmark.mpr hf
simp [w, markedScore, hm]
Β· simp only [hf, βreduceIte]
apply hneg.mpr
have hm : occurrenceMark oldMark movableMark o = false := by
cases h : occurrenceMark oldMark movableMark o
Β· rfl
Β· exact False.elim (hf (hmark.mp h))
simp [w, markedScore, hm]
end Pivots
end MatroidProphet
end OAI
|