Download data/lean/OAI/Probability/MatroidProphet/Model.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 9.25 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MatroidProphet/Model.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/MatroidProphet/Model.lean
-
curl -L -o Model.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MatroidProphet/Model.lean
9.25 kB
| import Mathlib | |
| namespace OAI | |
| /-! | |
| # One-sample matroid selection | |
| The rule and its finite seed law depend only on the known labeled matroid. | |
| A decision sees the initial sample vector, the entire seed, and the arriving | |
| label/value prefix. Every prefix is feasible, and decisions are irrevocable. | |
| The arrival permutation may depend on all samples, values, and seed bits. | |
| Only the actual offline optimum is required to be integrable. | |
| -/ | |
| open scoped BigOperators | |
| section | |
| open MeasureTheory ProbabilityTheory | |
| open scoped BigOperators | |
| namespace MatroidProphet | |
| abbrev Weights (n : β) := Fin n β β | |
| abbrev Seed (bits : β) := Fin bits β Bool | |
| abbrev ArrivalOrder (n : β) := Equiv.Perm (Fin n) | |
| instance arrivalOrderMeasurableSpace (n : β) : MeasurableSpace (ArrivalOrder n) := β€ | |
| abbrev History (n : β) (k : Fin n) := Fin (k.val + 1) β Fin n Γ β | |
| structure OnlineRule (n bits : β) where | |
| decide : (k : Fin n) β Seed bits β Weights n β History n k β Bool | |
| measurable_decide : β k, Measurable | |
| (fun x : Seed bits Γ (Weights n Γ History n k) => decide k x.1 x.2.1 x.2.2) | |
| def prefixIndex {n : β} (k : Fin n) (j : Fin (k.val + 1)) : Fin n := | |
| β¨j.val, Nat.lt_of_lt_of_le j.isLt (Nat.succ_le_of_lt k.isLt)β© | |
| def history {n : β} (v : Weights n) (Ο : ArrivalOrder n) (k : Fin n) : History n k := | |
| fun j => let e := Ο (prefixIndex k j); (e, v e) | |
| def decisionAt {n bits : β} (A : OnlineRule n bits) (r : Seed bits) | |
| (s v : Weights n) (Ο : ArrivalOrder n) (k : Fin n) : Bool := | |
| A.decide k r s (history v Ο k) | |
| noncomputable def acceptedThrough {n bits : β} (A : OnlineRule n bits) (r : Seed bits) | |
| (s v : Weights n) (Ο : ArrivalOrder n) (t : β) : Finset (Fin n) := by | |
| classical | |
| exact Finset.univ.filter fun e => | |
| (Ο.symm e).val < t β§ decisionAt A r s v Ο (Ο.symm e) = true | |
| noncomputable def accepted {n bits : β} (A : OnlineRule n bits) (r : Seed bits) | |
| (s v : Weights n) (Ο : ArrivalOrder n) : Finset (Fin n) := | |
| acceptedThrough A r s v Ο n | |
| noncomputable def reward {n bits : β} (A : OnlineRule n bits) (r : Seed bits) | |
| (s v : Weights n) (Ο : ArrivalOrder n) : β := | |
| β e β accepted A r s v Ο, v e | |
| noncomputable def optimum {n : β} (M : Matroid (Fin n)) (v : Weights n) : β := by | |
| classical | |
| exact Finset.univ.sup' Finset.univ_nonempty | |
| (fun I : Finset (Fin n) => if M.Indep (I : Set (Fin n)) then β e β I, v e else 0) | |
| def Feasible {n bits : β} (M : Matroid (Fin n)) (A : OnlineRule n bits) : Prop := | |
| β (r : Seed bits) (s v : Weights n) (Ο : ArrivalOrder n) (t : β), | |
| (β e, 0 β€ s e) β (β e, 0 β€ v e) β | |
| M.Indep (acceptedThrough A r s v Ο t : Set (Fin n)) | |
| def pairedCoordinates.{u} {n : β} {Ξ© : Type u} (S V : Ξ© β Weights n) | |
| (i : Fin n Γ Bool) : Ξ© β β := | |
| if i.2 then fun Ο => S Ο i.1 else fun Ο => V Ο i.1 | |
| def OneSampleChallenge.{u} : Prop := | |
| β (n : β) (M : Matroid (Fin n)), M.E = Set.univ β | |
| β (bits : β) (Ξ½ : Measure (Seed bits)), IsProbabilityMeasure Ξ½ β§ | |
| β (A : OnlineRule n bits), Feasible M A β§ | |
| β {Ξ© : Type u} [MeasurableSpace Ξ©] (ΞΌ : Measure Ξ©) [IsProbabilityMeasure ΞΌ] | |
| (S V : Ξ© β Weights n) (R : Ξ© β Seed bits), | |
| Measurable S β Measurable V β Measurable R β | |
| (βα΅ Ο βΞΌ, β e, 0 β€ S Ο e) β | |
| (βα΅ Ο βΞΌ, β e, 0 β€ V Ο e) β | |
| iIndepFun (pairedCoordinates S V) ΞΌ β | |
| (β e, Measure.map (fun Ο => S Ο e) ΞΌ = Measure.map (fun Ο => V Ο e) ΞΌ) β | |
| IndepFun (fun Ο => (S Ο, V Ο)) R ΞΌ β | |
| Measure.map R ΞΌ = Ξ½ β | |
| Integrable (fun Ο => optimum M (V Ο)) ΞΌ β | |
| β (Ο : Ξ© β ArrivalOrder n), Measurable Ο β | |
| Integrable (fun Ο => reward A (R Ο) (S Ο) (V Ο) (Ο Ο)) ΞΌ β§ | |
| ((2 : β) ^ 310)β»ΒΉ * (β« Ο, optimum M (V Ο) βΞΌ) β€ | |
| β« Ο, reward A (R Ο) (S Ο) (V Ο) (Ο Ο) βΞΌ | |
| end MatroidProphet | |
| end | |
| section | |
| open MeasureTheory | |
| open scoped BigOperators | |
| namespace MatroidProphet | |
| instance arrivalOrderMeasurableSingletonClass (n : β) : | |
| MeasurableSingletonClass (ArrivalOrder n) := β¨fun _ => trivialβ© | |
| structure HiddenRule (n bits : β) where | |
| mask : Seed bits β Finset (Fin n) | |
| core : OnlineRule n bits | |
| noncomputable def observed {n bits : β} (A : HiddenRule n bits) (r : Seed bits) | |
| (w : Weights n) : Weights n := by | |
| classical | |
| exact fun e => if e β A.mask r then w e else 0 | |
| noncomputable def hiddenAcceptedThrough {n bits : β} (A : HiddenRule n bits) | |
| (r : Seed bits) (w : Weights n) (Ο : ArrivalOrder n) (t : β) : Finset (Fin n) := | |
| acceptedThrough A.core r (observed A r w) w Ο t \ A.mask r | |
| noncomputable def hiddenReward {n bits : β} (A : HiddenRule n bits) | |
| (r : Seed bits) (w : Weights n) (Ο : ArrivalOrder n) : β := | |
| β e β hiddenAcceptedThrough A r w Ο n, w e | |
| noncomputable def hiddenWorstReward {n bits : β} (A : HiddenRule n bits) | |
| (w : Weights n) (r : Seed bits) : β := by | |
| classical | |
| exact Finset.univ.inf' Finset.univ_nonempty (hiddenReward A r w) | |
| end MatroidProphet | |
| end | |
| section | |
| open MeasureTheory ProbabilityTheory | |
| namespace MatroidProphet | |
| def HiddenVectorChallenge : Prop := | |
| β (n : β) (M : Matroid (Fin n)), M.E = Set.univ β | |
| β (bits : β) (Ξ½ : Measure (Seed bits)), IsProbabilityMeasure Ξ½ β§ | |
| β (A : HiddenRule n bits), | |
| (β (w : Weights n), (β e, 0 β€ w e) β | |
| β (r : Seed bits) (Ο : ArrivalOrder n) (t : β), | |
| M.Indep (hiddenAcceptedThrough A r w Ο t : Set (Fin n))) β§ | |
| β (w : Weights n), (β e, 0 β€ w e) β | |
| ((2 : β) ^ 293)β»ΒΉ * optimum M w β€ | |
| β« r, hiddenWorstReward A w r βΞ½ | |
| end MatroidProphet | |
| end | |
| section | |
| open MeasureTheory | |
| namespace MatroidProphet | |
| /-- A measurable secretary rule with an initially fixed observation-prefix length. -/ | |
| structure SecretaryRule (n : β) (Q : Type*) [MeasurableSpace Q] where | |
| prefixLength : Q β Fin (n + 1) | |
| measurable_prefixLength : Measurable prefixLength | |
| decide : (k : Fin n) β Q β History n k β Bool | |
| measurable_decide : β k, Measurable | |
| (fun x : Q Γ History n k => decide k x.1 x.2) | |
| /-- Full permutations describing the same ordered observation prefix. -/ | |
| def SamePrefix {n : β} (K : β) (Ο Ο : ArrivalOrder n) : Prop := | |
| β k : Fin n, k.val < K β Ο k = Ο k | |
| /-- Execution forces rejection of every observation-prefix arrival. -/ | |
| def secretaryDecisionAt {n : β} {Q : Type*} [MeasurableSpace Q] | |
| (A : SecretaryRule n Q) (q : Q) (w : Weights n) (Ο : ArrivalOrder n) | |
| (k : Fin n) : Bool := | |
| if k.val < (A.prefixLength q).val then false else A.decide k q (history w Ο k) | |
| /-- Irrevocable accepted labels through an arbitrary number of arrivals. -/ | |
| noncomputable def secretaryAcceptedThrough {n : β} {Q : Type*} [MeasurableSpace Q] | |
| (A : SecretaryRule n Q) (q : Q) (w : Weights n) (Ο : ArrivalOrder n) | |
| (t : β) : Finset (Fin n) := by | |
| classical | |
| exact Finset.univ.filter fun e => | |
| (Ο.symm e).val < t β§ secretaryDecisionAt A q w Ο (Ο.symm e) = true | |
| noncomputable def secretaryReward {n : β} {Q : Type*} [MeasurableSpace Q] | |
| (A : SecretaryRule n Q) (q : Q) (w : Weights n) (Ο : ArrivalOrder n) : β := | |
| β e β secretaryAcceptedThrough A q w Ο n, w e | |
| /-- Feasibility is pointwise for every seed, vector, order, and arrival prefix. -/ | |
| def SecretaryFeasible {n : β} {Q : Type*} [MeasurableSpace Q] | |
| (M : Matroid (Fin n)) (A : SecretaryRule n Q) : Prop := | |
| β (q : Q) (w : Weights n), (β e, 0 β€ w e) β | |
| β (Ο : ArrivalOrder n) (t : β), | |
| M.Indep (secretaryAcceptedThrough A q w Ο t : Set (Fin n)) | |
| end MatroidProphet | |
| end | |
| section | |
| namespace MatroidProphet.Secretary | |
| open MeasureTheory | |
| /-- Uniform random arrival order, including the unique order on the empty ground set. -/ | |
| noncomputable def uniformArrivalLaw (n : β) : Measure (ArrivalOrder n) := | |
| (PMF.uniformOfFintype (ArrivalOrder n)).toMeasure | |
| end MatroidProphet.Secretary | |
| end | |
| section | |
| open MeasureTheory ProbabilityTheory | |
| namespace MatroidProphet | |
| /-- The full order-oblivious conclusion of `cor:secretary`, including a | |
| measurable history-only rule, every-prefix feasibility, prefix rejection, | |
| arbitrary full-seed suffix adversaries, and the unchanged `2β»Β²βΉΒ³` ratio. -/ | |
| def SecretaryChallenge.{u} : Prop := | |
| β (n : β) (M : Matroid (Fin n)), M.E = Set.univ β | |
| β (q : β) (Ξ½ : Measure (Fin q)), IsProbabilityMeasure Ξ½ β§ | |
| β (A : SecretaryRule n (Fin q)), SecretaryFeasible M A β§ | |
| β (w : Weights n), (β e, 0 β€ w e) β | |
| β {Ξ© : Type u} [MeasurableSpace Ξ©] (ΞΌ : Measure Ξ©) [IsProbabilityMeasure ΞΌ] | |
| (Q : Ξ© β Fin q) (Ο Ο : Ξ© β ArrivalOrder n), | |
| Measurable Q β Measurable Ο β Measurable Ο β | |
| Measure.map Q ΞΌ = Ξ½ β | |
| Measure.map Ο ΞΌ = Secretary.uniformArrivalLaw n β | |
| IndepFun Q Ο ΞΌ β | |
| (βα΅ Ο βΞΌ, SamePrefix (A.prefixLength (Q Ο)).val (Ο Ο) (Ο Ο)) β | |
| Integrable (fun Ο => secretaryReward A (Q Ο) w (Ο Ο)) ΞΌ β§ | |
| ((2 : β) ^ 293)β»ΒΉ * optimum M w β€ | |
| β« Ο, secretaryReward A (Q Ο) w (Ο Ο) βΞΌ | |
| end MatroidProphet | |
| end | |
| end OAI | |