introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
9.11 kB
import Mathlib
namespace OAI
open MeasureTheory ProbabilityTheory Set
open scoped BigOperators ENNReal
namespace RepeatedLocalization
abbrev Coordinate (n : β„•) := Fin n β†’ ℝ
abbrev GaussianBlock (n : β„•) := Fin (n / 16) β†’ Fin (n + 1) β†’ ℝ
abbrev Label (n : β„•) := Fin (n / 16) β†’ ℝ
abbrev History (N t : β„•) := Fin t β†’ Fin N
abbrev Cell (n : β„•) := Ξ£ J : β„•, Fin n β†’ Fin (2 ^ J)
instance cellMeasurableSpace (n : β„•) : MeasurableSpace (Cell n) := ⊀
noncomputable def initialCube (n : β„•) : Set (Coordinate n) :=
Set.pi Set.univ (fun _ => Set.Ico (-1 / (2 * Real.sqrt n)) (1 / (2 * Real.sqrt n)))
noncomputable def cubePrior (n : β„•) : Measure (Coordinate n) :=
ProbabilityTheory.cond volume (initialCube n)
noncomputable def chart {n : β„•} (z : Coordinate n) : Fin (n + 1) β†’ ℝ :=
Fin.lastCases (Real.sqrt (1 - βˆ‘ a, (z a) ^ 2)) z
noncomputable def cellSet {n : β„•} (Q : Cell n) : Set (Coordinate n) :=
{z | βˆ€ a, -1 / (2 * Real.sqrt n) + (Q.2 a : ℝ) / (Real.sqrt n * (2 : ℝ) ^ Q.1) ≀ z a ∧
z a < -1 / (2 * Real.sqrt n) + ((Q.2 a : ℝ) + 1) / (Real.sqrt n * (2 : ℝ) ^ Q.1)}
def rootCell (n : β„•) : Cell n := ⟨0, fun _ => 0⟩
noncomputable def gaussianBlockLaw (n : β„•) : Measure (GaussianBlock n) :=
Measure.pi (fun _ => Measure.pi (fun _ => gaussianReal 0 1))
noncomputable def exactLabel {n : β„•} (X : GaussianBlock n) (z : Coordinate n) : Label n :=
fun row => βˆ‘ a, X row a * chart z a
structure BlockRule (n N : β„•) where
prob : (GaussianBlock n Γ— Label n) β†’ Fin N β†’ ℝ
measurable_prob : βˆ€ w, Measurable (fun data => prob data w)
nonneg : βˆ€ data w, 0 ≀ prob data w
sum_one : βˆ€ data, βˆ‘ w, prob data w = 1
abbrev Rules (n N t : β„•) := βˆ€ i : Fin t, History N i.val β†’ BlockRule n N
def past {N t : β„•} (w : History N t) (i : Fin t) : History N i.val :=
fun j => w ⟨j.val, Nat.lt_trans j.isLt i.isLt⟩
def through {N t : β„•} (w : History N t) (i : Fin t) : History N (i.val + 1) :=
fun j => w ⟨j.val, Nat.lt_of_lt_of_le j.isLt i.isLt⟩
noncomputable def blockProbability {n N : β„•} (rule : BlockRule n N)
(z : Coordinate n) (w : Fin N) : ℝ :=
∫ X, rule.prob (X, exactLabel X z) w βˆ‚gaussianBlockLaw n
noncomputable def historyLikelihood {n N t : β„•} (rules : Rules n N t)
(z : Coordinate n) (w : History N t) : ℝ :=
∏ i, blockProbability (rules i (past w i)) z (w i)
noncomputable def experimentLaw {n N t : β„•} (rules : Rules n N t) :
Measure (Coordinate n Γ— History N t) :=
βˆ‘ w : History N t,
((cubePrior n).withDensity (fun z => ENNReal.ofReal (historyLikelihood rules z w))).map
(fun z => (z, w))
abbrev Disclosure (n N t : β„•) := βˆ€ i : Fin t, Coordinate n β†’ History N (i.val + 1) β†’ Cell n
def ValidDisclosure {n N t : β„•} (Q : Disclosure n N t) : Prop :=
(βˆ€ i, Measurable (fun zh : Coordinate n Γ— History N (i.val + 1) => Q i zh.1 zh.2)) ∧
(βˆ€ i, (Set.range (fun zh : Coordinate n Γ— History N (i.val + 1) => Q i zh.1 zh.2)).Finite) ∧
(βˆ€ z ∈ initialCube n, βˆ€ w : History N t, βˆ€ i,
z ∈ cellSet (Q i z (through w i)) ∧ cellSet (Q i z (through w i)) βŠ† initialCube n) ∧
(βˆ€ z ∈ initialCube n, βˆ€ w : History N t, βˆ€ i j : Fin t, i ≀ j β†’
cellSet (Q j z (through w j)) βŠ† cellSet (Q i z (through w i)))
noncomputable def transcriptMap {n N t : β„•} (Q : Disclosure n N t)
(zw : Coordinate n Γ— History N t) : Coordinate n Γ— (History N t Γ— (Fin t β†’ Cell n)) :=
(zw.1, (zw.2, fun i => Q i zw.1 (through zw.2 i)))
noncomputable def augmentedLaw {n N t : β„•} (rules : Rules n N t) (Q : Disclosure n N t) :=
(experimentLaw rules).map (transcriptMap Q)
noncomputable def mutualInformation {Ξ± Ξ² : Type*} [MeasurableSpace Ξ±] [MeasurableSpace Ξ²]
(ΞΌ : Measure (Ξ± Γ— Ξ²)) : ℝβ‰₯0∞ :=
InformationTheory.klDiv ΞΌ ((ΞΌ.map Prod.fst).prod (ΞΌ.map Prod.snd))
noncomputable def finalLevel {n N t : β„•} (Q : Disclosure n N t)
(zw : Coordinate n Γ— History N t) : β„• :=
if ht : 0 < t then
let i : Fin t := ⟨t - 1, by omega⟩
(Q i zw.1 (through zw.2 i)).1
else 0
def MainStatement : Prop :=
βˆƒ c : ℝ, 0 < c ∧ βˆƒ nβ‚€ : β„•, βˆ€ Cβ‚€ : ℝ, 0 < Cβ‚€ β†’
βˆƒ C : ℝ, 0 < C ∧ βˆ€ (n N t : β„•), nβ‚€ ≀ n β†’ 1 ≀ N β†’ βˆ€ rules : Rules n N t,
(2 / (n / 8 : β„•) + Real.exp (-c * (n / 16 : β„•))) * Real.log N ≀ Cβ‚€ * (n + 1) β†’
βˆƒ Q : Disclosure n N t, ValidDisclosure Q ∧
mutualInformation (augmentedLaw rules Q) ≀ ENNReal.ofReal (C * (n + 1) * t) ∧
(∫ zw, (finalLevel Q zw : ℝ) βˆ‚experimentLaw rules) ≀ C * t
namespace FiniteEntropy
noncomputable def uniformCell {n : β„•} (Q : Cell n) : Measure (Coordinate n) :=
ProbabilityTheory.cond volume (cellSet Q)
def Descendant {n : β„•} (Q R : Cell n) : Prop :=
Q.1 ≀ R.1 ∧ cellSet R βŠ† cellSet Q
noncomputable def threshold (n h : β„•) : ℝ := (2:ℝ)^(-(n:ℝ)*h/2)
def Heavy {n : β„•} (P : Measure (Coordinate n)) (Q R : Cell n) : Prop :=
Descendant Q R ∧ Q.1 < R.1 ∧ threshold n (R.1-Q.1) < (P (cellSet R)).toReal
def FirstHeavy {n : β„•} (P : Measure (Coordinate n)) (Q R : Cell n) : Prop :=
Heavy P Q R ∧ βˆ€ E : Cell n, Heavy P Q E β†’ Descendant E R β†’ E = R
noncomputable def residual {n : β„•} (P : Measure (Coordinate n)) (Q : Cell n) : Set (Coordinate n) :=
cellSet Q \ ⋃ R : {R : Cell n // FirstHeavy P Q R}, cellSet R.val
abbrev Letter (n : β„•) := Option (Cell n)
abbrev Log (n : β„•) := List (Letter n)
instance logMeasurableSpace (n : β„•) : MeasurableSpace (Log n) := ⊀
noncomputable def branch {n : β„•} (P : Measure (Coordinate n)) (Q : Cell n) : Letter n β†’ Set (Coordinate n) := by
classical
exact fun
| none => residual P Q
| some R => if FirstHeavy P Q R then cellSet R else βˆ…
noncomputable def attemptLetter {n : β„•} (P : Measure (Coordinate n)) (Q : Cell n)
(z : Coordinate n) : Letter n := by
classical
exact if h : βˆƒ R : Cell n, FirstHeavy P Q R ∧ z ∈ cellSet R then some h.choose else none
structure State (n : β„•) where
cell : Cell n
event : Set (Coordinate n)
stopped : Bool
noncomputable def update {n : β„•} (P : Measure (Coordinate n)) (s : State n) (a : Letter n) : State n :=
if s.stopped then s else
let ΞΌ := ProbabilityTheory.cond P s.event
let E := branch ΞΌ s.cell a
{ cell := a.getD s.cell
event := s.event ∩ E
stopped := if a = none then decide ((1/2:ℝ) ≀ (ΞΌ E).toReal) else false }
noncomputable def state {n : β„•} (P : Measure (Coordinate n)) (Q : Cell n) (h : Log n) : State n :=
h.foldl (update P) ⟨Q,cellSet Q,false⟩
noncomputable def run {n : β„•} (P : Measure (Coordinate n)) (Q : Cell n) : β„• β†’ Coordinate n β†’ Log n
| 0, _ => []
| N+1, z =>
let h := run P Q N z
let s := state P Q h
if s.stopped then h else
h ++ [attemptLetter (ProbabilityTheory.cond P s.event) s.cell z]
def Terminates {n : β„•} (P : Measure (Coordinate n)) (Q : Cell n) (z : Coordinate n) : Prop :=
βˆƒ N, (state P Q (run P Q N z)).stopped = true
noncomputable def attempts {n : β„•} (P : Measure (Coordinate n)) (Q : Cell n) (z : Coordinate n) : β„• := by
classical
exact if h : Terminates P Q z then Nat.find h else 0
noncomputable def terminalLog {n : β„•} (P : Measure (Coordinate n)) (Q : Cell n) (z : Coordinate n) : Log n :=
run P Q (attempts P Q z) z
noncomputable def terminalCell {n : β„•} (P : Measure (Coordinate n)) (Q : Cell n) (h : Log n) : Cell n :=
(state P Q h).cell
noncomputable def terminalLaw {n : β„•} (P : Measure (Coordinate n)) (Q : Cell n) (h : Log n) : Measure (Coordinate n) :=
ProbabilityTheory.cond P {z | terminalLog P Q z = h}
noncomputable def depth {n : β„•} (P : Measure (Coordinate n)) (Q : Cell n) (z : Coordinate n) : β„• :=
(terminalCell P Q (terminalLog P Q z)).1-Q.1
def Regular {n : β„•} (P : Measure (Coordinate n)) (Q : Cell n) : Prop :=
P (cellSet Q) = 1 ∧ βˆ€ R : Cell n, Descendant Q R β†’ Q.1 < R.1 β†’
(P (cellSet R)).toReal ≀ 2 * threshold n (R.1-Q.1)
def FiniteEntropyStatement : Prop :=
βˆƒ nβ‚€ : β„•, βˆ€ n : β„•, nβ‚€ ≀ n β†’ βˆ€ Q : Cell n, βˆ€ P : Measure (Coordinate n),
IsProbabilityMeasure P β†’ P β‰ͺ uniformCell Q β†’ InformationTheory.klDiv P (uniformCell Q) β‰  ∞ β†’
(βˆ€α΅ z βˆ‚P, Terminates P Q z) ∧ Measurable (terminalLog P Q) ∧
(βˆ€ h : Log n, P {z | terminalLog P Q z = h} β‰  0 β†’
Descendant Q (terminalCell P Q h) ∧ Regular (terminalLaw P Q h) (terminalCell P Q h)) ∧
Integrable (fun z => (depth P Q z : ℝ)) P ∧
Integrable (fun z => (attempts P Q z : ℝ)) P ∧
(∫ z,(attempts P Q z : ℝ) βˆ‚P) ≀ 2*(1+∫ z,(depth P Q z : ℝ) βˆ‚P) ∧
(∫⁻ z,InformationTheory.klDiv (terminalLaw P Q (terminalLog P Q z))
(uniformCell (terminalCell P Q (terminalLog P Q z))) βˆ‚P) +
ENNReal.ofReal ((Real.log 2/4)*n*(∫ z,(depth P Q z : ℝ) βˆ‚P)) ≀
InformationTheory.klDiv P (uniformCell Q) + ENNReal.ofReal (2/Real.exp 1)
end FiniteEntropy
end RepeatedLocalization
end OAI