roseking's picture
Add lean source and binary files (part 84)
cdec422 verified
Raw History Blame Contribute Delete
4.45 kB
10
abbrev Cube (n : ℕ) := Fin n → Bool
12
def sign (b : Bool) : ℝ := if b then 1 else -1
14
def avg {n : ℕ} (g : Cube n → ℝ) : ℝ := (∑ x, g x) / (2 : ℝ) ^ n
16
def L : ℝ := Real.log 2
18
def psi (r : ℝ) : ℝ :=
body · 1 line
  (1 + r) / 2 * Real.log (1 + r) + (1 - r) / 2 * Real.log (1 - r)
21
def H (r : ℝ) : ℝ := L - psi r
23
def info {n : ℕ} (u : Cube n → ℝ) : ℝ := H (avg u) - avg (H ∘ u)
25
def psiInv (s : ℝ) : ℝ := Function.invFunOn psi (Set.Icc 0 1) s
27
def kernel {n : ℕ} (ρ : ℝ) (x y : Cube n) : ℝ :=
body · 1 line
  ∏ i, if x i = y i then (1 + ρ) / 2 else (1 - ρ) / 2
30
def noise {n : ℕ} (ρ : ℝ) (u : Cube n → ℝ) (y : Cube n) : ℝ :=
body · 1 line
  ∑ x, kernel ρ y x * u x
33
def Closed {n : ℕ} (u : Cube n → ℝ) : Prop := ∀ x, u x ∈ Set.Icc (-1) 1
35
def Interior {n : ℕ} (g : Cube n → ℝ) : Prop := ∀ x, g x ∈ Set.Ioo (-1) 1
37
def softCoordinate {n : ℕ} (i : Fin n) (a : ℝ) (x : Cube n) : ℝ := a * sign (x i)
39
def flip {n : ℕ} (i : Fin n) (x : Cube n) : Cube n := Function.update x i (!(x i))
41
def numberOperator {n : ℕ} (g : Cube n → ℝ) (x : Cube n) : ℝ :=
body · 1 line
  (1 / 2 : ℝ) * ∑ i, (g x - g (flip i x))
44
def production {n : ℕ} (g : Cube n → ℝ) : ℝ :=
body · 1 line
  avg (fun x => Real.artanh (g x) * numberOperator g x)

Defined by this formula on [0, L); no finite endpoint value at L is asserted.

48
def F (s : ℝ) : ℝ := psiInv s * Real.artanh (psiInv s)

The excess F s - 2 * s, used for s < L, is extended by zero to negative arguments.

51
def S (s : ℝ) : ℝ := if s < 0 then 0 else F s - 2 * s

The reserve is used for |m| < 1 and 0 ≤ I < H m.

54
def reserve (m I : ℝ) : ℝ :=
body · 1 line
  2 * I + (1 - m ^ 2) * S (L - (H m - I) / (1 - m ^ 2))
57
def hybrid (m I : ℝ) : ℝ := max (reserve m I) (F I)
59
def softJoint {n : ℕ} (ρ : ℝ) (u : Cube n → ℝ) (b : Bool) (y : Cube n) : ℝ :=
body · 1 line
  avg (fun x => (1 + sign b * u x) / 2 * kernel ρ x y)
62
def boolJoint {n : ℕ} (ρ : ℝ) (f : Cube n → Bool) (b : Bool) (y : Cube n) : ℝ :=
body · 1 line
  avg (fun x => if f x = b then kernel ρ x y else 0)
65
def leftMarginal {n : ℕ} (p : Bool → Cube n → ℝ) (b : Bool) : ℝ := ∑ y, p b y
67
def rightMarginal {n : ℕ} (p : Bool → Cube n → ℝ) (y : Cube n) : ℝ := ∑ b, p b y
69
def mutualInformation {n : ℕ} (p : Bool → Cube n → ℝ) : ℝ :=
body · 2 lines
  ∑ b, ∑ y, if 0 < p b y then
    p b y * Real.log (p b y / (leftMarginal p b * rightMarginal p y)) else 0
73
def binaryEntropyBits (ε : ℝ) : ℝ :=
body · 1 line
  -(ε * Real.log ε + (1 - ε) * Real.log (1 - ε)) / L
76
def SoftContraction : Prop := ∀ (n : ℕ) (u : Cube n → ℝ), Closed u →
body · 2 lines
  ∀ ρ ∈ Set.Icc (-1 : ℝ) 1,
    info (noise ρ u) ≤ psi (|ρ| * psiInv (info u))
80
def SoftAttainment : Prop := ∀ (n : ℕ) (i : Fin n) (a : ℝ), |a| ≤ 1 →
body · 3 lines
  ∀ ρ ∈ Set.Icc (-1 : ℝ) 1,
    info (noise ρ (softCoordinate i a)) =
      psi (|ρ| * psiInv (info (softCoordinate i a)))
85
def SoftInformationIdentity : Prop := ∀ (n : ℕ) (u : Cube n → ℝ), Closed u →
body · 2 lines
  ∀ ρ ∈ Set.Icc (-1 : ℝ) 1,
    mutualInformation (softJoint ρ u) = info (noise ρ u)
89
def RefinedBoolean : Prop := ∀ (n : ℕ) (f : Cube n → Bool)
body · 6 lines
  (ρ : ℝ), ρ ∈ Set.Icc (-1 : ℝ) 1 →
  let m := avg (sign ∘ f)
  let bound := psi (|ρ| * psiInv (H m))
  mutualInformation (boolJoint ρ f) = info (noise ρ (sign ∘ f)) ∧
  mutualInformation (boolJoint ρ f) ≤ bound ∧ bound ≤ psi |ρ| ∧
  (0 < |m| → |m| < 1 → 0 < |ρ| → bound < psi |ρ|)
97
def BooleanAttainment : Prop := ∀ (n : ℕ) (i : Fin n)
body · 3 lines
  (ρ : ℝ), ρ ∈ Set.Icc (-1 : ℝ) 1 →
  mutualInformation (boolJoint ρ (fun x => x i)) = psi |ρ| ∧
  mutualInformation (boolJoint ρ (fun x => !(x i))) = psi |ρ|
102
def BitsConversion : Prop := ∀ (n : ℕ) (f : Cube n → Bool)
body · 3 lines
  (ε : ℝ), ε ∈ Set.Icc (0 : ℝ) (1/2) →
  psi (1 - 2 * ε) / L = 1 - binaryEntropyBits ε ∧
  mutualInformation (boolJoint (1 - 2 * ε) f) / L ≤ 1 - binaryEntropyBits ε
107
def SharpProduction : Prop := ∀ (n : ℕ) (g : Cube n → ℝ), Interior g →
body · 1 line
  hybrid (avg g) (info g) ≤ production g ∧ F (info g) ≤ hybrid (avg g) (info g)
110
def FullMain : Prop := SoftContraction ∧ SoftAttainment ∧ SoftInformationIdentity ∧
body · 1 line
  RefinedBoolean ∧ BooleanAttainment ∧ BitsConversion ∧ SharpProduction