Download data/lean/OAI/Probability/MatroidProphet/Algorithm/Rule.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 3.74 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MatroidProphet/Algorithm/Rule.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/MatroidProphet/Algorithm/Rule.lean
-
curl -L -o Rule.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MatroidProphet/Algorithm/Rule.lean
3.74 kB
| import OAI.Probability.MatroidProphet.LayerOnline | |
| import OAI.Probability.MatroidProphet.Density.Birth | |
| import Mathlib.Data.Finset.Sort | |
| namespace OAI | |
| namespace MatroidProphet | |
| open Set Finset | |
| structure MainMasks (n : β) where | |
| H : Finset (Fin n) | |
| D : Finset (Fin n) | |
| C : Finset (Fin n) | |
| T : Finset (Fin n) | |
| odd : Bool | |
| def mainSeedBits (n : β) : β := 4*n+2 | |
| def seedMask {n : β} (r : Seed (mainSeedBits n)) (j : Fin 4) : Finset (Fin n) := | |
| univ.filter fun e => r β¨4*e.val+j.val, by dsimp [mainSeedBits]; omegaβ© = true | |
| def mainMasks {n : β} (r : Seed (mainSeedBits n)) : MainMasks n where | |
| H := seedMask r 0 | |
| D := seedMask r 1 | |
| C := seedMask r 2 | |
| T := seedMask r 3 | |
| odd := r β¨4*n+1, by dsimp [mainSeedBits]; omegaβ© | |
| def mainBranch {n : β} (r : Seed (mainSeedBits n)) : Bool := | |
| r β¨4*n, by dsimp [mainSeedBits]; omegaβ© | |
| namespace MainAlgorithm | |
| variable {n : β} | |
| def higher (f : Fin n) (a : Option β€) (e : Fin n) (b : Option β€) : Prop := | |
| match a, b with | |
| | some i, some j => j < i β¨ j = i β§ f < e | |
| | some _, none => True | |
| | _, _ => False | |
| def candidate (M : Matroid (Fin n)) (d : MainMasks n) (seen : Fin n β Option β€) | |
| (e : Fin n) (w : Option β€) : Prop := | |
| w β none β§ e β d.H β§ e β M.closure {f | f β d.H β§ higher f (seen f) e w} | |
| noncomputable def listed (M : Matroid (Fin n)) (d : MainMasks n) | |
| (seen : Fin n β Option β€) : Finset β€ := by | |
| classical | |
| exact d.D.biUnion fun e => if candidate M d seen e (seen e) then (seen e).toFinset else β | |
| noncomputable def groups (M : Matroid (Fin n)) (d : MainMasks n) | |
| (seen : Fin n β Option β€) : List β€ := (listed M d seen).sort (Β· β€ Β·) | |
| def groupMask (M : Matroid (Fin n)) (d : MainMasks n) (seen : Fin n β Option β€) | |
| (mask : Finset (Fin n)) (h : β) : Set (Fin n) := | |
| {e | e β mask β§ candidate M d seen e (seen e) β§ seen e = (groups M d seen)[h]?} | |
| noncomputable def finalPath (M : Matroid (Fin n)) (hE : M.E = Set.univ) | |
| (d : MainMasks n) (seen : Fin n β Option β€) : β€ β Set (Fin n) := | |
| guardedPath M hE (2^100) (groupMask M d seen d.D) (groupMask M d seen d.C) | |
| (groups M d seen).length | |
| noncomputable def birth (M : Matroid (Fin n)) (hE : M.E = Set.univ) | |
| (d : MainMasks n) (seen : Fin n β Option β€) (e : Fin n) (i : β€) : β€ := | |
| nominalBirth M hE (2^100) (groupMask M d seen d.D) (groupMask M d seen d.C) | |
| ((groups M d seen).idxOf i) e | |
| def eligible (M : Matroid (Fin n)) (hE : M.E = Set.univ) | |
| (d : MainMasks n) (seen : Fin n β Option β€) (e : Fin n) (i : β€) : Prop := | |
| e β d.H βͺ d.D βͺ d.C β§ candidate M d seen e (some i) β§ i β groups M d seen β§ | |
| e β d.T β§ activation ((groups M d seen).idxOf i) + 2 β€ birth M hE d seen e i β§ | |
| (birth M hE d seen e i) % 2 = (if d.odd then 1 else 0) β§ | |
| e β finalPath M hE d seen (birth M hE d seen e i - 2) | |
| noncomputable def assign (M : Matroid (Fin n)) (hE : M.E = Set.univ) | |
| (d : MainMasks n) (seen : Fin n β Option β€) (e : Fin n) : Option β€ β Option β€ := by | |
| classical | |
| exact fun w => match w with | |
| | none => none | |
| | some i => if eligible M hE d seen e i then some (birth M hE d seen e i) else none | |
| noncomputable def core (M : Matroid (Fin n)) (hE : M.E = Set.univ) : | |
| OnlineRule n (mainSeedBits n) := | |
| layerOnlineRule M (roundedLevel weightBase) (measurable_roundedLevel weightBase) | |
| (fun r seen b => finalPath M hE (mainMasks r) seen (b-2)) | |
| (fun r seen => assign M hE (mainMasks r) seen) | |
| noncomputable def hidden (M : Matroid (Fin n)) (hE : M.E = Set.univ) : | |
| HiddenRule n (mainSeedBits n) where | |
| mask r := (mainMasks r).H βͺ (mainMasks r).D βͺ (mainMasks r).C | |
| core := core M hE | |
| end MainAlgorithm | |
| end MatroidProphet | |
| end OAI | |