Download data/lean/OAI/Probability/MatroidSecretary/Transport/GeneralSimulationModel.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.03 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MatroidSecretary/Transport/GeneralSimulationModel.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/MatroidSecretary/Transport/GeneralSimulationModel.lean
-
curl -L -o GeneralSimulationModel.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MatroidSecretary/Transport/GeneralSimulationModel.lean
6.03 kB
| import OAI.Probability.MatroidProphet.Main | |
| import Mathlib.Probability.Independence.Basic | |
| import Mathlib.MeasureTheory.Integral.Bochner.Basic | |
| namespace OAI | |
| namespace MatroidProphet.General | |
| open MeasureTheory ProbabilityTheory | |
| /-- A decision uses only the entire initial seed, the initially observed vector, | |
| and the label/value history through the current arrival. -/ | |
| structure OnlineRule (n : β) (R : Type*) [MeasurableSpace R] where | |
| decide : (k : Fin n) β R β Weights n β History n k β Bool | |
| measurable_decide : β k, Measurable | |
| (fun x : R Γ (Weights n Γ History n k) => decide k x.1 x.2.1 x.2.2) | |
| def decisionAt {n : β} {R : Type*} [MeasurableSpace R] | |
| (A : OnlineRule n R) (r : R) (s v : Weights n) | |
| (Ο : ArrivalOrder n) (k : Fin n) : Bool := | |
| A.decide k r s (history v Ο k) | |
| noncomputable def acceptedThrough {n : β} {R : Type*} [MeasurableSpace R] | |
| (A : OnlineRule n R) (r : R) (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 reward {n : β} {R : Type*} [MeasurableSpace R] | |
| (A : OnlineRule n R) (r : R) (s v : Weights n) (Ο : ArrivalOrder n) : β := | |
| β e β acceptedThrough A r s v Ο n, v e | |
| def Feasible {n : β} {R : Type*} [MeasurableSpace R] | |
| (M : Matroid (Fin n)) (A : OnlineRule n R) : Prop := | |
| β (r : R) (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)) | |
| /-- The observation mask is a measurable function of the seed alone. -/ | |
| structure HiddenRule (n : β) (R : Type*) [MeasurableSpace R] where | |
| mask : R β Finset (Fin n) | |
| measurable_mask : Measurable mask | |
| core : OnlineRule n R | |
| noncomputable def observed {n : β} {R : Type*} [MeasurableSpace R] | |
| (A : HiddenRule n R) (r : R) (w : Weights n) : Weights n := by | |
| classical | |
| exact fun e => if e β A.mask r then w e else 0 | |
| noncomputable def hiddenAcceptedThrough {n : β} {R : Type*} [MeasurableSpace R] | |
| (A : HiddenRule n R) (r : R) (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 : β} {R : Type*} [MeasurableSpace R] | |
| (A : HiddenRule n R) (r : R) (w : Weights n) (Ο : ArrivalOrder n) : β := | |
| β e β hiddenAcceptedThrough A r w Ο n, w e | |
| noncomputable def hiddenWorstReward {n : β} {R : Type*} [MeasurableSpace R] | |
| (A : HiddenRule n R) (w : Weights n) (r : R) : β := by | |
| classical | |
| exact Finset.univ.inf' Finset.univ_nonempty (hiddenReward A r w) | |
| def HiddenFeasible {n : β} {R : Type*} [MeasurableSpace R] | |
| (M : Matroid (Fin n)) (A : HiddenRule n R) : Prop := | |
| β (w : Weights n), (β e, 0 β€ w e) β | |
| β (r : R) (Ο : ArrivalOrder n) (t : β), | |
| M.Indep (hiddenAcceptedThrough A r w Ο t : Set (Fin n)) | |
| /-- Sample values on the sacrificed mask, and realized values elsewhere. -/ | |
| noncomputable def glue {n : β} (mask : Finset (Fin n)) (s v : Weights n) : Weights n := by | |
| classical | |
| exact fun e => if e β mask then s e else v e | |
| noncomputable def simulationHistory {n : β} {R : Type*} [MeasurableSpace R] | |
| (A : HiddenRule n R) (r : R) (s : Weights n) | |
| {k : Fin n} (h : History n k) : History n k := by | |
| classical | |
| exact fun j => ((h j).1, if (h j).1 β A.mask r then s (h j).1 else (h j).2) | |
| noncomputable def simulationDecision {n : β} {R : Type*} [MeasurableSpace R] | |
| (A : HiddenRule n R) (k : Fin n) (r : R) (s : Weights n) | |
| (h : History n k) : Bool := by | |
| classical | |
| exact if (h β¨k.val, Nat.lt_succ_self _β©).1 β A.mask r then false | |
| else A.core.decide k r (observed A r s) (simulationHistory A r s h) | |
| /-- Full source contract for `lem:simulation`, with arbitrary measurable seed | |
| and probability spaces. The simulator is constructed before the distributions | |
| and adversary are supplied. Its decision function is specified concretely; | |
| the conjunction includes exact execution, feasibility, the seed/glued-vector | |
| joint law, integrability, and preservation of the same competitive ratio. -/ | |
| def SimulationContract.{u, v} : Prop := | |
| β (n : β) (R : Type v) [MeasurableSpace R] | |
| (M : Matroid (Fin n)) (A : HiddenRule n R) | |
| (Ξ½ : Measure R), IsProbabilityMeasure Ξ½ β | |
| β (c : β), HiddenFeasible M A β | |
| (β (w : Weights n), (β e, 0 β€ w e) β | |
| c * optimum M w β€ β« r, hiddenWorstReward A w r βΞ½) β | |
| β B : OnlineRule n R, | |
| (β (k : Fin n) (r : R) (s : Weights n) (h : History n k), | |
| B.decide k r s h = simulationDecision A k r s h) β§ | |
| Feasible M B β§ | |
| (β (r : R) (s v : Weights n) (Ο : ArrivalOrder n) (t : β), | |
| acceptedThrough B r s v Ο t = | |
| hiddenAcceptedThrough A r (glue (A.mask r) s v) Ο t) β§ | |
| (β (r : R) (s v : Weights n) (Ο : ArrivalOrder n), | |
| reward B r s v Ο = hiddenReward A r (glue (A.mask r) s v) Ο) β§ | |
| β {Ξ© : Type u} [MeasurableSpace Ξ©] (ΞΌ : Measure Ξ©) [IsProbabilityMeasure ΞΌ] | |
| (S V : Ξ© β Weights n) (seed : Ξ© β R), | |
| Measurable S β Measurable V β Measurable seed β | |
| (βα΅ Ο βΞΌ, β e, 0 β€ S Ο e) β | |
| (βα΅ Ο βΞΌ, β e, 0 β€ V Ο e) β | |
| iIndepFun (pairedCoordinates S V) ΞΌ β | |
| (β e, ΞΌ.map (fun Ο => S Ο e) = ΞΌ.map (fun Ο => V Ο e)) β | |
| IndepFun (fun Ο => (S Ο, V Ο)) seed ΞΌ β ΞΌ.map seed = Ξ½ β | |
| Integrable (fun Ο => optimum M (V Ο)) ΞΌ β | |
| β (Ο : Ξ© β ArrivalOrder n), Measurable Ο β | |
| MeasurePreserving (fun Ο => (seed Ο, glue (A.mask (seed Ο)) (S Ο) (V Ο))) | |
| ΞΌ (Ξ½.prod (ΞΌ.map V)) β§ | |
| Integrable (fun Ο => reward B (seed Ο) (S Ο) (V Ο) (Ο Ο)) ΞΌ β§ | |
| c * (β« Ο, optimum M (V Ο) βΞΌ) β€ | |
| β« Ο, reward B (seed Ο) (S Ο) (V Ο) (Ο Ο) βΞΌ | |
| end MatroidProphet.General | |
| end OAI | |