Download data/lean/OAI/MeasureTheory/DyadicAvoidance/LocalPredicateFactor.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.09 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MeasureTheory/DyadicAvoidance/LocalPredicateFactor.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/MeasureTheory/DyadicAvoidance/LocalPredicateFactor.lean
-
curl -L -o LocalPredicateFactor.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MeasureTheory/DyadicAvoidance/LocalPredicateFactor.lean
6.09 kB
| import OAI.MeasureTheory.DyadicAvoidance.RoutingPath | |
| import OAI.MeasureTheory.DyadicAvoidance.GridSeparation | |
| namespace OAI | |
| universe u_ΞΉ u_X u_K u_V u_J | |
| noncomputable section | |
| namespace Problem310.LocalPredicateFactor | |
| open RoutingPath GridSeparation | |
| variable {ΞΉ : Type u_ΞΉ} {X : Type u_X} {K : Type u_K} {V : Type u_V} | |
| /-- Routing through a subtree only uses its strict-descendant choices. | |
| If those choices factor through one key, the terminal leaf does too. -/ | |
| theorem route_eq_of_key_eq (choose : List ΞΉ β X β ΞΉ) | |
| (key : X β K) (r : β) (P : List ΞΉ) | |
| (hchoice : β Q : List ΞΉ, P.IsPrefix Q β Q.length < P.length + r β | |
| β x y : X, key x = key y β choose Q x = choose Q y) | |
| {x y : X} (hxy : key x = key y) : | |
| routeFrom choose r P x = routeFrom choose r P y := by | |
| apply routeFrom_eq_of_choices_eq choose r P y x | |
| intro k hk | |
| apply hchoice (routeFrom choose k P y) (prefix_routeFrom choose k P y) | |
| Β· rw [length_routeFrom] | |
| omega | |
| Β· exact hxy | |
| /-- A terminal output on a routed subtree factors through a common key | |
| provided every choice and every possible terminal output does. -/ | |
| theorem terminal_eq_of_key_eq (choose : List ΞΉ β X β ΞΉ) | |
| (terminal : List ΞΉ β X β V) (key : X β K) (r : β) (P : List ΞΉ) | |
| (hchoice : β Q : List ΞΉ, P.IsPrefix Q β Q.length < P.length + r β | |
| β x y : X, key x = key y β choose Q x = choose Q y) | |
| (hterminal : β Q : List ΞΉ, P.IsPrefix Q β Q.length = P.length + r β | |
| β x y : X, key x = key y β terminal Q x = terminal Q y) | |
| {x y : X} (hxy : key x = key y) : | |
| terminal (routeFrom choose r P x) x = terminal (routeFrom choose r P y) y := by | |
| have hroute := route_eq_of_key_eq choose key r P hchoice hxy | |
| rw [hroute] | |
| exact hterminal _ (prefix_routeFrom choose r P y) | |
| (length_routeFrom choose r P y) x y hxy | |
| /-- An incoming selector multiplied by a local terminal predicate also | |
| factors through that key. This includes a child which is already a leaf. -/ | |
| theorem local_predicate_eq_of_key_eq (choose : List ΞΉ β X β ΞΉ) | |
| (terminal : List ΞΉ β X β Bool) (incoming : X β Bool) | |
| (key : X β K) (r : β) (P : List ΞΉ) | |
| (hchoice : β Q : List ΞΉ, P.IsPrefix Q β Q.length < P.length + r β | |
| β x y : X, key x = key y β choose Q x = choose Q y) | |
| (hterminal : β Q : List ΞΉ, P.IsPrefix Q β Q.length = P.length + r β | |
| β x y : X, key x = key y β terminal Q x = terminal Q y) | |
| (hincoming : β x y : X, key x = key y β incoming x = incoming y) | |
| {x y : X} (hxy : key x = key y) : | |
| (incoming x && terminal (routeFrom choose r P x) x) = | |
| (incoming y && terminal (routeFrom choose r P y) y) := by | |
| rw [hincoming x y hxy, | |
| terminal_eq_of_key_eq choose terminal key r P hchoice hterminal hxy] | |
| /-- A single table evaluated at any coarser grid is a function of the finest key. -/ | |
| theorem table_eq_of_finest_key {b B : β} (hb : b β€ B) | |
| (table : Fin (2 ^ (b + 2)) β V) {x y : β} | |
| (hxy : β(2 : β) ^ (B + 2) * Int.fract xβ = | |
| β(2 : β) ^ (B + 2) * Int.fract yβ) : | |
| table (dyadicKey b x) = table (dyadicKey b y) := by | |
| apply congrArg table | |
| apply (dyadicKey_eq_iff b x y).mpr | |
| exact periodicKey_dyadic_eq_of_refine hb hxy | |
| variable {J : Type u_J} | |
| /-- An arbitrary deterministic rule applied to selector-table lookups depends | |
| only on a common finer key. In particular this applies to first-success routing. -/ | |
| theorem choice_eq_of_finest_key (b : J β β) (B : β) | |
| (tables : β j, Fin (2 ^ (b j + 2)) β Bool) | |
| (rule : (J β Bool) β ΞΉ) (hb : β j, b j β€ B) {x y : β} | |
| (hxy : β(2 : β) ^ (B + 2) * Int.fract xβ = | |
| β(2 : β) ^ (B + 2) * Int.fract yβ) : | |
| rule (fun j => tables j (dyadicKey (b j) x)) = | |
| rule (fun j => tables j (dyadicKey (b j) y)) := by | |
| apply congrArg rule | |
| funext j | |
| exact table_eq_of_finest_key (hb j) (tables j) hxy | |
| /-- A table-based node rule, with no restriction on which deterministic | |
| first-success/default convention the rule uses. -/ | |
| def gridChoice (b : List ΞΉ β J β β) | |
| (tables : β Q j, Fin (2 ^ (b Q j + 2)) β Bool) | |
| (rule : List ΞΉ β (J β Bool) β ΞΉ) (Q : List ΞΉ) (x : β) : ΞΉ := | |
| rule Q (fun j => tables Q j (dyadicKey (b Q j) x)) | |
| def gridTerminal (c : List ΞΉ β β) | |
| (tables : β Q, Fin (2 ^ (c Q + 2)) β Bool) (Q : List ΞΉ) (x : β) : Bool := | |
| tables Q (dyadicKey (c Q) x) | |
| /-- The incoming selector and every table in a child subtree may have different | |
| resolutions. A bound on all those resolutions gives exactly the common-key | |
| factorization needed for deterministic scale representatives. -/ | |
| theorem grid_local_predicate_factors | |
| (b : List ΞΉ β J β β) (c : List ΞΉ β β) (bIn B : β) | |
| (selectors : β Q j, Fin (2 ^ (b Q j + 2)) β Bool) | |
| (terminals : β Q, Fin (2 ^ (c Q + 2)) β Bool) | |
| (incoming : Fin (2 ^ (bIn + 2)) β Bool) | |
| (rule : List ΞΉ β (J β Bool) β ΞΉ) (r : β) (P : List ΞΉ) | |
| (hb : β Q : List ΞΉ, P.IsPrefix Q β Q.length < P.length + r β | |
| β j, b Q j β€ B) | |
| (hc : β Q : List ΞΉ, P.IsPrefix Q β Q.length = P.length + r β c Q β€ B) | |
| (hIn : bIn β€ B) {x y : β} | |
| (hxy : β(2 : β) ^ (B + 2) * Int.fract xβ = | |
| β(2 : β) ^ (B + 2) * Int.fract yβ) : | |
| (incoming (dyadicKey bIn x) && | |
| gridTerminal c terminals (routeFrom (gridChoice b selectors rule) r P x) x) = | |
| (incoming (dyadicKey bIn y) && | |
| gridTerminal c terminals (routeFrom (gridChoice b selectors rule) r P y) y) := by | |
| apply local_predicate_eq_of_key_eq | |
| (gridChoice b selectors rule) (gridTerminal c terminals) | |
| (fun z => incoming (dyadicKey bIn z)) | |
| (fun z => β(2 : β) ^ (B + 2) * Int.fract zβ) r P | |
| Β· intro Q hPQ hlen u v huv | |
| exact choice_eq_of_finest_key (b Q) B (selectors Q) (rule Q) | |
| (hb Q hPQ hlen) huv | |
| Β· intro Q hPQ hlen u v huv | |
| exact table_eq_of_finest_key (hc Q hPQ hlen) (terminals Q) huv | |
| Β· intro u v huv | |
| exact table_eq_of_finest_key hIn incoming huv | |
| Β· exact hxy | |
| end Problem310.LocalPredicateFactor | |
| end | |
| end OAI | |