Download data/lean/OAI/MeasureTheory/DyadicAvoidance/FiniteTableModel.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 8.21 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MeasureTheory/DyadicAvoidance/FiniteTableModel.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/MeasureTheory/DyadicAvoidance/FiniteTableModel.lean
-
curl -L -o FiniteTableModel.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MeasureTheory/DyadicAvoidance/FiniteTableModel.lean
8.21 kB
| import OAI.MeasureTheory.DyadicAvoidance.GridSeparation | |
| namespace OAI | |
| noncomputable section | |
| open MeasureTheory | |
| namespace Problem310.FiniteTableModel | |
| /-- Child `M` is default and the other `M` children have selectors. -/ | |
| abbrev Child (M : β) := Fin (M + 1) | |
| /-- Nodes at which a depth-`d` router still makes a decision. -/ | |
| abbrev Node (M d : β) := {P : List (Child M) // P.length < d} | |
| /-- A terminal path. This is definitionally a list with the required length. -/ | |
| abbrev Leaf (M d : β) := List.Vector (Child M) d | |
| instance nodeFintype (M d : β) : Fintype (Node M d) := by | |
| classical | |
| let f : (Ξ£ k : Fin d, List.Vector (Child M) k.val) β Node M d := | |
| fun p => β¨p.2.val, by simpa only [p.2.property] using p.1.isLtβ© | |
| apply Fintype.ofSurjective f | |
| intro P | |
| exact β¨β¨β¨P.val.length, P.propertyβ©, β¨P.val, rflβ©β©, rflβ© | |
| instance nodeMeasurableSpace (M d : β) : MeasurableSpace (Node M d) := β€ | |
| instance nodeDiscreteMeasurableSpace (M d : β) : DiscreteMeasurableSpace (Node M d) := by constructor; intro s; trivial | |
| instance leafMeasurableSpace (M d : β) : MeasurableSpace (Leaf M d) := β€ | |
| instance leafDiscreteMeasurableSpace (M d : β) : DiscreteMeasurableSpace (Leaf M d) := by constructor; intro s; trivial | |
| /-- Finite selector-table addresses include the table name as well as its key. -/ | |
| abbrev SelectorAddress {M d : β} (b : Node M d β Fin M β β) := | |
| Ξ£ e : Node M d Γ Fin M, Fin (2 ^ (b e.1 e.2 + 2)) | |
| /-- Terminal addresses include the leaf name, preventing collisions between tables. -/ | |
| abbrev TerminalAddress {M d : β} (b : Leaf M d β β) := | |
| Ξ£ L : Leaf M d, Fin (2 ^ (b L + 2)) | |
| instance selectorAddressMeasurableSpace {M d : β} (b : Node M d β Fin M β β) : | |
| MeasurableSpace (SelectorAddress b) := β€ | |
| instance selectorAddressDiscreteMeasurableSpace {M d : β} (b : Node M d β Fin M β β) : | |
| DiscreteMeasurableSpace (SelectorAddress b) := by constructor; intro s; trivial | |
| instance terminalAddressMeasurableSpace {M d : β} (b : Leaf M d β β) : | |
| MeasurableSpace (TerminalAddress b) := β€ | |
| instance terminalAddressDiscreteMeasurableSpace {M d : β} (b : Leaf M d β β) : | |
| DiscreteMeasurableSpace (TerminalAddress b) := by constructor; intro s; trivial | |
| abbrev SelectorTable {M d : β} (b : Node M d β Fin M β β) := SelectorAddress b β Bool | |
| abbrev TerminalTable {M d : β} (b : Leaf M d β β) := TerminalAddress b β Bool | |
| /-- The center exposure consults exactly one deterministic coordinate per selector table. -/ | |
| def selectorAddress {M d : β} (b : Node M d β Fin M β β) | |
| (P : Node M d) (i : Fin M) (x : β) : SelectorAddress b := | |
| β¨(P, i), GridSeparation.dyadicKey (b P i) xβ© | |
| /-- The terminal coordinate read along the selected leaf. -/ | |
| def terminalAddress {M d : β} (b : Leaf M d β β) | |
| (L : Leaf M d) (x : β) : TerminalAddress b := | |
| β¨L, GridSeparation.dyadicKey (b L) xβ© | |
| /-- Selector values are extended to all lists; routing uses only valid nodes. -/ | |
| def selectorValue {M d : β} (b : Node M d β Fin M β β) (Ο : SelectorTable b) | |
| (P : List (Child M)) (i : Fin M) (x : β) : Bool := | |
| if h : P.length < d then Ο (selectorAddress b β¨P, hβ© i x) else false | |
| @[simp] theorem selectorValue_valid {M d : β} (b : Node M d β Fin M β β) | |
| (Ο : SelectorTable b) (P : Node M d) (i : Fin M) (x : β) : | |
| selectorValue b Ο P.val i x = Ο (selectorAddress b P i x) := by | |
| simp [selectorValue, P.property] | |
| lemma measurable_dyadicKey (b : β) : Measurable (GridSeparation.dyadicKey b) := by | |
| apply measurable_to_countable | |
| intro y | |
| have hm : Measurable (GridSeparation.periodicKey ((2 : β) ^ (b + 2))) := by | |
| exact (measurable_const.mul measurable_fract).floor | |
| convert (measurableSet_singleton (GridSeparation.periodicKey ((2 : β) ^ (b + 2)) y)).preimage hm using 1 | |
| ext x | |
| exact GridSeparation.dyadicKey_eq_iff b x y | |
| lemma dyadicKey_add_one (b : β) (x : β) : | |
| GridSeparation.dyadicKey b (x + 1) = GridSeparation.dyadicKey b x := by | |
| apply (GridSeparation.dyadicKey_eq_iff _ _ _).mpr | |
| exact GridSeparation.periodicKey_add_one _ _ | |
| lemma measurable_selectorAddress {M d : β} (b : Node M d β Fin M β β) | |
| (P : Node M d) (i : Fin M) : Measurable (selectorAddress b P i) := by | |
| exact (measurable_of_finite (fun k => (β¨(P, i), kβ© : SelectorAddress b))).comp | |
| (measurable_dyadicKey (b P i)) | |
| lemma measurable_terminalAddress {M d : β} (b : Leaf M d β β) | |
| (L : Leaf M d) : Measurable (terminalAddress b L) := by | |
| exact (measurable_of_finite (fun k => (β¨L, kβ© : TerminalAddress b))).comp | |
| (measurable_dyadicKey (b L)) | |
| lemma measurable_selectorValue {M d : β} (b : Node M d β Fin M β β) | |
| (Ο : SelectorTable b) (P : List (Child M)) (i : Fin M) : | |
| Measurable (selectorValue b Ο P i) := by | |
| change Measurable (fun x : β => if h : P.length < d then | |
| Ο (selectorAddress b β¨P, hβ© i x) else false) | |
| by_cases h : P.length < d | |
| Β· simp only [dite_eq_left h] | |
| exact (measurable_of_finite Ο).comp (measurable_selectorAddress b β¨P, hβ© i) | |
| Β· simpa only [dite_eq_right h] using (measurable_const : Measurable (fun _ : β => false)) | |
| @[simp] lemma selectorAddress_add_one {M d : β} (b : Node M d β Fin M β β) | |
| (P : Node M d) (i : Fin M) (x : β) : | |
| selectorAddress b P i (x + 1) = selectorAddress b P i x := by | |
| simp [selectorAddress, dyadicKey_add_one] | |
| @[simp] lemma terminalAddress_add_one {M d : β} (b : Leaf M d β β) | |
| (L : Leaf M d) (x : β) : | |
| terminalAddress b L (x + 1) = terminalAddress b L x := by | |
| simp [terminalAddress, dyadicKey_add_one] | |
| @[simp] lemma selectorValue_add_one {M d : β} (b : Node M d β Fin M β β) | |
| (Ο : SelectorTable b) (P : List (Child M)) (i : Fin M) (x : β) : | |
| selectorValue b Ο P i (x + 1) = selectorValue b Ο P i x := by | |
| by_cases h : P.length < d <;> simp [selectorValue, h] | |
| /-- Exposing the center reads distinct coordinates because table names are retained. -/ | |
| lemma center_selectorAddress_injective {M d : β} (b : Node M d β Fin M β β) | |
| (x : β) : Function.Injective (fun e : Node M d Γ Fin M => selectorAddress b e.1 e.2 x) := by | |
| intro e f h | |
| exact congrArg Sigma.fst h | |
| lemma selectorAddress_ne_center {M d : β} (b : Node M d β Fin M β β) | |
| (P : Node M d) (i : Fin M) {x t : β} {n : β} | |
| (hn : 3 β€ n) (hnb : n β€ b P i) (ht : t β Set.Icc (1 : β) 2) : | |
| selectorAddress b P i x β selectorAddress b P i (x + t * ((2 : β)β»ΒΉ) ^ n) := by | |
| intro h | |
| have hk := (Sigma.mk.inj h).2 | |
| exact GridSeparation.dyadicKey_ne_center hn hnb ht.1 ht.2 (eq_of_heq hk) | |
| lemma dyadicKey_eq_of_refine {b B : β} (hb : b β€ B) {x y : β} | |
| (hkey : GridSeparation.dyadicKey B x = GridSeparation.dyadicKey B y) : | |
| GridSeparation.dyadicKey b x = GridSeparation.dyadicKey b y := by | |
| apply (GridSeparation.dyadicKey_eq_iff b x y).mpr | |
| exact GridSeparation.periodicKey_dyadic_eq_of_refine hb | |
| ((GridSeparation.dyadicKey_eq_iff B x y).mp hkey) | |
| /-- Any selector lookup at a coarser resolution is determined by a finest key. -/ | |
| lemma selectorValue_eq_of_key_eq {M d : β} (b : Node M d β Fin M β β) | |
| (Ο : SelectorTable b) (P : List (Child M)) (i : Fin M) (B : β) | |
| (hlevel : β h : P.length < d, b β¨P, hβ© i β€ B) {x y : β} | |
| (hkey : GridSeparation.dyadicKey B x = GridSeparation.dyadicKey B y) : | |
| selectorValue b Ο P i x = selectorValue b Ο P i y := by | |
| by_cases h : P.length < d | |
| Β· simp only [selectorValue, dite_eq_left h] | |
| apply congrArg Ο | |
| unfold selectorAddress | |
| congr 1 | |
| exact dyadicKey_eq_of_refine (hlevel h) hkey | |
| Β· simp only [selectorValue, dite_eq_right h] | |
| /-- At a fixed leaf, the finer key also determines the terminal table lookup. -/ | |
| lemma terminal_lookup_eq_of_key_eq {M d : β} (b : Leaf M d β β) | |
| (Ο : TerminalTable b) (L : Leaf M d) (B : β) (hlevel : b L β€ B) {x y : β} | |
| (hkey : GridSeparation.dyadicKey B x = GridSeparation.dyadicKey B y) : | |
| Ο (terminalAddress b L x) = Ο (terminalAddress b L y) := by | |
| apply congrArg Ο | |
| unfold terminalAddress | |
| congr 1 | |
| exact dyadicKey_eq_of_refine hlevel hkey | |
| end Problem310.FiniteTableModel | |
| end | |
| end OAI | |