Download data/lean/OAI/Probability/MatroidSecretary/Secretary/Replay.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.25 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MatroidSecretary/Secretary/Replay.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/MatroidSecretary/Secretary/Replay.lean
-
curl -L -o Replay.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MatroidSecretary/Secretary/Replay.lean
6.25 kB
| import OAI.Probability.MatroidProphet.Main | |
| namespace OAI | |
| /-! | |
| # Deterministic virtual-prefix replay for the secretary transport | |
| The prefix is observed and rejected, but its history is retained when the hidden | |
| rule is run on the suffix. The following lemmas are pointwise in the *complete* | |
| seed and order; no independence of the suffix order is assumed. | |
| Source: `sections/secretary.tex`, the paragraph beginning "Initialize the | |
| hidden-weight rule". These are supporting transport lemmas, not a proof of the | |
| random-prefix law or of the complete secretary endpoint. | |
| -/ | |
| namespace MatroidProphet.SecretaryReplay | |
| open MeasureTheory | |
| /-- Labels in the first `K` positions of an arrival order. This also handles | |
| `K = 0` and `K β₯ n` without a special convention. -/ | |
| def prefixSet {n : β} (Ο : ArrivalOrder n) (K : β) : Finset (Fin n) := | |
| Finset.univ.filter fun e => (Ο.symm e).val < K | |
| @[simp] theorem mem_prefixSet {n : β} (Ο : ArrivalOrder n) (K : β) (e : Fin n) : | |
| e β prefixSet Ο K β (Ο.symm e).val < K := by | |
| simp [prefixSet] | |
| /-- Replay every observed arrival in the core history, while forcibly rejecting | |
| all positions strictly before `K`. At suffix arrivals the complete *past* | |
| history (including the rejected prefix) is supplied, never a future weight. -/ | |
| noncomputable def prefixReplay {n bits : β} (A : HiddenRule n bits) (K : β) : | |
| OnlineRule n bits where | |
| decide k r s h := if k.val < K then false else (sampleSimulation A).decide k r s h | |
| measurable_decide k := by | |
| by_cases hk : k.val < K | |
| Β· simp only [hk, ite_true] | |
| exact measurable_const | |
| Β· simp only [hk, ite_false] | |
| exact (sampleSimulation A).measurable_decide k | |
| /-- Prefix rejection removes exactly the prefix labels from the simulated run. -/ | |
| theorem acceptedThrough_prefixReplay {n bits : β} (A : HiddenRule n bits) (K : β) | |
| (r : Seed bits) (s v : Weights n) (Ο : ArrivalOrder n) (t : β) : | |
| acceptedThrough (prefixReplay A K) r s v Ο t = | |
| acceptedThrough (sampleSimulation A) r s v Ο t \ prefixSet Ο K := by | |
| classical | |
| ext e | |
| simp only [acceptedThrough, Finset.mem_sdiff, mem_prefixSet, Finset.mem_filter, | |
| Finset.mem_univ, true_and] | |
| by_cases hk : (Ο.symm e).val < K | |
| Β· simp [decisionAt, prefixReplay, hk] | |
| Β· simp [decisionAt, prefixReplay, hk] | |
| /-- If the observed prefix is sacrificed by the hidden rule, explicit prefix | |
| rejection changes no accepted label, at any arrival prefix. -/ | |
| theorem acceptedThrough_eq_hidden {n bits : β} (A : HiddenRule n bits) (K : β) | |
| (r : Seed bits) (s v : Weights n) (Ο : ArrivalOrder n) (t : β) | |
| (hprefix : prefixSet Ο K β A.mask r) : | |
| acceptedThrough (prefixReplay A K) r s v Ο t = | |
| hiddenAcceptedThrough A r (glue (A.mask r) s v) Ο t := by | |
| classical | |
| rw [acceptedThrough_prefixReplay, sampleSimulation_acceptedThrough] | |
| ext e | |
| simp only [Finset.mem_sdiff] | |
| constructor | |
| Β· exact fun h => h.1 | |
| Β· intro he | |
| refine β¨he, ?_β© | |
| intro hp | |
| exact (Finset.mem_sdiff.mp he).2 (hprefix hp) | |
| /-- Only agreement on the revealed mask is required of the initial observation. -/ | |
| theorem glue_eq_of_agrees {n bits : β} (A : HiddenRule n bits) (r : Seed bits) | |
| (s w : Weights n) (hobs : β e β A.mask r, s e = w e) : | |
| glue (A.mask r) s w = w := by | |
| classical | |
| funext e | |
| by_cases he : e β A.mask r | |
| Β· simp [glue, he, hobs e he] | |
| Β· simp [glue, he] | |
| /-- Exact virtual replay, with equality at every prefix, not just equal reward. -/ | |
| theorem fixedVector_acceptedThrough {n bits : β} (A : HiddenRule n bits) (K : β) | |
| (r : Seed bits) (s w : Weights n) (Ο : ArrivalOrder n) (t : β) | |
| (hprefix : prefixSet Ο K β A.mask r) | |
| (hobs : β e β A.mask r, s e = w e) : | |
| acceptedThrough (prefixReplay A K) r s w Ο t = | |
| hiddenAcceptedThrough A r w Ο t := by | |
| rw [acceptedThrough_eq_hidden A K r s w Ο t hprefix, | |
| glue_eq_of_agrees A r s w hobs] | |
| /-- The replay accepts nothing during the observation period. -/ | |
| theorem prefix_rejected {n bits : β} (A : HiddenRule n bits) (K : β) | |
| (r : Seed bits) (s v : Weights n) (Ο : ArrivalOrder n) {t : β} (ht : t β€ K) : | |
| acceptedThrough (prefixReplay A K) r s v Ο t = β := by | |
| classical | |
| apply Finset.eq_empty_iff_forall_notMem.mpr | |
| intro e he | |
| rw [acceptedThrough_prefixReplay] at he | |
| have ha := acceptedThrough_arrived (sampleSimulation A) r s v Ο t e | |
| (Finset.mem_sdiff.mp he).1 | |
| exact (Finset.mem_sdiff.mp he).2 ((mem_prefixSet Ο K e).mpr (ha.trans_le ht)) | |
| /-- All actual accepted weights equal their hidden-run weights. -/ | |
| theorem fixedVector_reward {n bits : β} (A : HiddenRule n bits) (K : β) | |
| (r : Seed bits) (s w : Weights n) (Ο : ArrivalOrder n) | |
| (hprefix : prefixSet Ο K β A.mask r) | |
| (hobs : β e β A.mask r, s e = w e) : | |
| reward (prefixReplay A K) r s w Ο = hiddenReward A r w Ο := by | |
| unfold reward accepted hiddenReward | |
| rw [fixedVector_acceptedThrough A K r s w Ο n hprefix hobs] | |
| /-- Pointwise domination holds even when the order depends on extra visible | |
| secretary randomness beyond the reconstructed source seed. -/ | |
| theorem worstReward_le_replay {n bits : β} (A : HiddenRule n bits) (K : β) | |
| (r : Seed bits) (s w : Weights n) (Ο : ArrivalOrder n) | |
| (hprefix : prefixSet Ο K β A.mask r) | |
| (hobs : β e β A.mask r, s e = w e) : | |
| hiddenWorstReward A w r β€ reward (prefixReplay A K) r s w Ο := by | |
| rw [fixedVector_reward A K r s w Ο hprefix hobs] | |
| exact hiddenWorstReward_le A w r Ο | |
| /-- Pointwise feasibility of the source rule transfers at every replay prefix. -/ | |
| theorem fixedVector_feasible {n bits : β} (M : Matroid (Fin n)) | |
| (A : HiddenRule n bits) (K : β) | |
| (hA : β (w : Weights n), (β e, 0 β€ w e) β | |
| β (r : Seed bits) (Ο : ArrivalOrder n) (t : β), | |
| M.Indep (hiddenAcceptedThrough A r w Ο t : Set (Fin n))) | |
| (r : Seed bits) (s w : Weights n) (Ο : ArrivalOrder n) (t : β) | |
| (hw : β e, 0 β€ w e) | |
| (hprefix : prefixSet Ο K β A.mask r) | |
| (hobs : β e β A.mask r, s e = w e) : | |
| M.Indep (acceptedThrough (prefixReplay A K) r s w Ο t : Set (Fin n)) := by | |
| rw [fixedVector_acceptedThrough A K r s w Ο t hprefix hobs] | |
| exact hA w hw r Ο t | |
| end MatroidProphet.SecretaryReplay | |
| end OAI | |