Documentation

Formalizations.MachineLearning.ReLU.MaxFive

The maximum of five numbers with two hidden ReLU layers (Bakaev–Brunck–Hertrich–Stade–Yehudayoff) #

A ReLU network with two hidden layers computes max(x₁,…,x₅) exactly: max(x₁,…,x₅) = M(x), where M is half of an explicit signed sum of nine nested maxima (Bakaev, Brunck, Hertrich, Stade and Yehudayoff, arXiv:2505.14338, Claim 4 and Proposition 3). This refutes for n = 5 the conjecture of Hertrich, Basu, Di Summa and Skutella that the maximum of n numbers needs ⌈log₂ n⌉ hidden layers (here 3). Rep n k is the class of functions ℝⁿ → ℝ computed with k hidden layers; it is closed under affine combinations, and max f g = f + ReLU(g − f) raises the depth by one.

Main results #

References #

def ReLUDepth.Rep (n a✝ : ℕ) :
Set ((Fin n → ℝ) → ℝ)

Functions ℝⁿ → ℝ computable by a ReLU network with k hidden layers.

Equations
Instances For
    noncomputable def ReLUDepth.M (x : Fin 5 → ℝ) :

    The function M of equation (2): half of P₁+P₂+P₃+P₄+Q−R₁₃−R₁₄−R₂₃−R₂₄, each term written as in the paper (nested maxima, the form a two-hidden-layer network computes).

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Closure properties of Rep #

      theorem ReLUDepth.const_mem {n : ℕ} (k : ℕ) (c : ℝ) :
      (fun (x : Fin n → ℝ) => c) ∈ Rep n k
      theorem ReLUDepth.add_mem {n : ℕ} (k : ℕ) {f g : (Fin n → ℝ) → ℝ} (hf : f ∈ Rep n k) (hg : g ∈ Rep n k) :
      (fun (x : Fin n → ℝ) => f x + g x) ∈ Rep n k
      theorem ReLUDepth.smul_mem {n : ℕ} (k : ℕ) (r : ℝ) {f : (Fin n → ℝ) → ℝ} (hf : f ∈ Rep n k) :
      (fun (x : Fin n → ℝ) => r * f x) ∈ Rep n k
      theorem ReLUDepth.sub_mem {n : ℕ} (k : ℕ) {f g : (Fin n → ℝ) → ℝ} (hf : f ∈ Rep n k) (hg : g ∈ Rep n k) :
      (fun (x : Fin n → ℝ) => f x - g x) ∈ Rep n k
      theorem ReLUDepth.neg_mem {n : ℕ} (k : ℕ) {f : (Fin n → ℝ) → ℝ} (hf : f ∈ Rep n k) :
      (fun (x : Fin n → ℝ) => -f x) ∈ Rep n k
      theorem ReLUDepth.relu_id (t : ℝ) :
      max 0 t - max 0 (-t) = t
      theorem ReLUDepth.affine_mem {n : ℕ} (k : ℕ) (a : Fin n → ℝ) (c : ℝ) :
      (fun (x : Fin n → ℝ) => c + ∑ i : Fin n, a i * x i) ∈ Rep n k

      Affine maps are in Rep n k for every k.

      theorem ReLUDepth.coord_mem {n : ℕ} (k : ℕ) (i : Fin n) :
      (fun (x : Fin n → ℝ) => x i) ∈ Rep n k
      theorem ReLUDepth.mono_mem {n : ℕ} (k : ℕ) {f : (Fin n → ℝ) → ℝ} (hf : f ∈ Rep n k) :
      f ∈ Rep n (k + 1)

      Rep n k ⊆ Rep n (k+1).

      theorem ReLUDepth.relu_mem {n : ℕ} (k : ℕ) {f : (Fin n → ℝ) → ℝ} (hf : f ∈ Rep n k) :
      (fun (x : Fin n → ℝ) => max 0 (f x)) ∈ Rep n (k + 1)
      theorem ReLUDepth.max_mem {n : ℕ} (k : ℕ) {f g : (Fin n → ℝ) → ℝ} (hf : f ∈ Rep n k) (hg : g ∈ Rep n k) :
      (fun (x : Fin n → ℝ) => max (f x) (g x)) ∈ Rep n (k + 1)

      max f g = f + ReLU (g - f) raises the depth by one.

      M has two hidden layers #

      Claim 4: M = max #

      noncomputable def ReLUDepth.P1 (a b c d e : ℝ) :

      The nine terms of M, as functions of the five coordinates.

      Equations
      Instances For
        noncomputable def ReLUDepth.P2 (a b c d e : ℝ) :
        Equations
        Instances For
          noncomputable def ReLUDepth.P3 (a b c d e : ℝ) :
          Equations
          Instances For
            noncomputable def ReLUDepth.P4 (a b c d e : ℝ) :
            Equations
            Instances For
              noncomputable def ReLUDepth.Q (a b c d e : ℝ) :
              Equations
              Instances For
                noncomputable def ReLUDepth.R13 (a b c d e : ℝ) :
                Equations
                Instances For
                  noncomputable def ReLUDepth.R14 (a b c d e : ℝ) :
                  Equations
                  Instances For
                    noncomputable def ReLUDepth.R23 (a b c d e : ℝ) :
                    Equations
                    Instances For
                      noncomputable def ReLUDepth.R24 (a b c d e : ℝ) :
                      Equations
                      Instances For
                        theorem ReLUDepth.M_eq (x : Fin 5 → ℝ) :
                        M x = 1 / 2 * (P1 (x 0) (x 1) (x 2) (x 3) (x 4) + P2 (x 0) (x 1) (x 2) (x 3) (x 4) + P3 (x 0) (x 1) (x 2) (x 3) (x 4) + P4 (x 0) (x 1) (x 2) (x 3) (x 4) + Q (x 0) (x 1) (x 2) (x 3) (x 4) - R13 (x 0) (x 1) (x 2) (x 3) (x 4) - R14 (x 0) (x 1) (x 2) (x 3) (x 4) - R23 (x 0) (x 1) (x 2) (x 3) (x 4) - R24 (x 0) (x 1) (x 2) (x 3) (x 4))

                        Case analysis: which coordinate is maximal (the paper reduces the four cases to one by symmetry).

                        theorem ReLUDepth.e_P1 (a b c d e : ℝ) (ha : a ≤ e) (hb : b ≤ e) (hc : c ≤ e) (hd : d ≤ e) :
                        P1 a b c d e = 2 * e
                        theorem ReLUDepth.e_P2 (a b c d e : ℝ) (ha : a ≤ e) (hb : b ≤ e) (hc : c ≤ e) (hd : d ≤ e) :
                        P2 a b c d e = 2 * e
                        theorem ReLUDepth.e_P3 (a b c d e : ℝ) (ha : a ≤ e) (hb : b ≤ e) (hc : c ≤ e) (hd : d ≤ e) :
                        P3 a b c d e = 2 * e
                        theorem ReLUDepth.e_P4 (a b c d e : ℝ) (ha : a ≤ e) (hb : b ≤ e) (hc : c ≤ e) (hd : d ≤ e) :
                        P4 a b c d e = 2 * e
                        theorem ReLUDepth.e_Q (a b c d e : ℝ) (ha : a ≤ e) (hb : b ≤ e) (hc : c ≤ e) (hd : d ≤ e) :
                        Q a b c d e = 2 * e
                        theorem ReLUDepth.e_R13 (a b c d e : ℝ) (ha : a ≤ e) (hb : b ≤ e) (hc : c ≤ e) (hd : d ≤ e) :
                        R13 a b c d e = 2 * e
                        theorem ReLUDepth.e_R14 (a b c d e : ℝ) (ha : a ≤ e) (hb : b ≤ e) (hc : c ≤ e) (hd : d ≤ e) :
                        R14 a b c d e = 2 * e
                        theorem ReLUDepth.e_R23 (a b c d e : ℝ) (ha : a ≤ e) (hb : b ≤ e) (hc : c ≤ e) (hd : d ≤ e) :
                        R23 a b c d e = 2 * e
                        theorem ReLUDepth.e_R24 (a b c d e : ℝ) (ha : a ≤ e) (hb : b ≤ e) (hc : c ≤ e) (hd : d ≤ e) :
                        R24 a b c d e = 2 * e
                        theorem ReLUDepth.case_e (a b c d e : ℝ) (ha : a ≤ e) (hb : b ≤ e) (hc : c ≤ e) (hd : d ≤ e) :
                        1 / 2 * (P1 a b c d e + P2 a b c d e + P3 a b c d e + P4 a b c d e + Q a b c d e - R13 a b c d e - R14 a b c d e - R23 a b c d e - R24 a b c d e) = e

                        e maximal.

                        theorem ReLUDepth.a_P1 (a b c d e : ℝ) (hb : b ≤ a) (hc : c ≤ a) (hd : d ≤ a) (he : e ≤ a) :
                        P1 a b c d e = 2 * a
                        theorem ReLUDepth.a_P2 (a b c d e : ℝ) (hb : b ≤ a) (hc : c ≤ a) (hd : d ≤ a) (he : e ≤ a) :
                        P2 a b c d e = R23 a b c d e
                        theorem ReLUDepth.a_P3 (a b c d e : ℝ) (hb : b ≤ a) (hc : c ≤ a) (hd : d ≤ a) (he : e ≤ a) :
                        P3 a b c d e = R13 a b c d e
                        theorem ReLUDepth.a_P4 (a b c d e : ℝ) (hb : b ≤ a) (hc : c ≤ a) (hd : d ≤ a) (he : e ≤ a) :
                        P4 a b c d e = R14 a b c d e
                        theorem ReLUDepth.a_R24 (a b c d e : ℝ) (hb : b ≤ a) (hc : c ≤ a) (hd : d ≤ a) (he : e ≤ a) :
                        R24 a b c d e = Q a b c d e
                        theorem ReLUDepth.case_a (a b c d e : ℝ) (hb : b ≤ a) (hc : c ≤ a) (hd : d ≤ a) (he : e ≤ a) :
                        1 / 2 * (P1 a b c d e + P2 a b c d e + P3 a b c d e + P4 a b c d e + Q a b c d e - R13 a b c d e - R14 a b c d e - R23 a b c d e - R24 a b c d e) = a

                        a maximal.

                        theorem ReLUDepth.b_P2 (a b c d e : ℝ) (ha : a ≤ b) (hc : c ≤ b) (hd : d ≤ b) (he : e ≤ b) :
                        P2 a b c d e = 2 * b
                        theorem ReLUDepth.b_P1 (a b c d e : ℝ) (ha : a ≤ b) (hc : c ≤ b) (hd : d ≤ b) (he : e ≤ b) :
                        P1 a b c d e = R13 a b c d e
                        theorem ReLUDepth.b_P3 (a b c d e : ℝ) (ha : a ≤ b) (hc : c ≤ b) (hd : d ≤ b) (he : e ≤ b) :
                        P3 a b c d e = R23 a b c d e
                        theorem ReLUDepth.b_P4 (a b c d e : ℝ) (ha : a ≤ b) (hc : c ≤ b) (hd : d ≤ b) (he : e ≤ b) :
                        P4 a b c d e = R24 a b c d e
                        theorem ReLUDepth.b_R14 (a b c d e : ℝ) (ha : a ≤ b) (hc : c ≤ b) (hd : d ≤ b) (he : e ≤ b) :
                        R14 a b c d e = Q a b c d e
                        theorem ReLUDepth.case_b (a b c d e : ℝ) (ha : a ≤ b) (hc : c ≤ b) (hd : d ≤ b) (he : e ≤ b) :
                        1 / 2 * (P1 a b c d e + P2 a b c d e + P3 a b c d e + P4 a b c d e + Q a b c d e - R13 a b c d e - R14 a b c d e - R23 a b c d e - R24 a b c d e) = b

                        b maximal.

                        theorem ReLUDepth.c_P3 (a b c d e : ℝ) (ha : a ≤ c) (hb : b ≤ c) (hd : d ≤ c) (he : e ≤ c) :
                        P3 a b c d e = 2 * c
                        theorem ReLUDepth.c_P4 (a b c d e : ℝ) (ha : a ≤ c) (hb : b ≤ c) (hd : d ≤ c) (he : e ≤ c) :
                        P4 a b c d e = R14 a b c d e
                        theorem ReLUDepth.c_P1 (a b c d e : ℝ) (ha : a ≤ c) (hb : b ≤ c) (hd : d ≤ c) (he : e ≤ c) :
                        P1 a b c d e = R13 a b c d e
                        theorem ReLUDepth.c_P2 (a b c d e : ℝ) (ha : a ≤ c) (hb : b ≤ c) (hd : d ≤ c) (he : e ≤ c) :
                        P2 a b c d e = R23 a b c d e
                        theorem ReLUDepth.c_R24 (a b c d e : ℝ) (ha : a ≤ c) (hb : b ≤ c) (hd : d ≤ c) (he : e ≤ c) :
                        R24 a b c d e = Q a b c d e
                        theorem ReLUDepth.case_c (a b c d e : ℝ) (ha : a ≤ c) (hb : b ≤ c) (hd : d ≤ c) (he : e ≤ c) :
                        1 / 2 * (P1 a b c d e + P2 a b c d e + P3 a b c d e + P4 a b c d e + Q a b c d e - R13 a b c d e - R14 a b c d e - R23 a b c d e - R24 a b c d e) = c

                        c maximal.

                        theorem ReLUDepth.d_P4 (a b c d e : ℝ) (ha : a ≤ d) (hb : b ≤ d) (hc : c ≤ d) (he : e ≤ d) :
                        P4 a b c d e = 2 * d
                        theorem ReLUDepth.d_P3 (a b c d e : ℝ) (ha : a ≤ d) (hb : b ≤ d) (hc : c ≤ d) (he : e ≤ d) :
                        P3 a b c d e = R13 a b c d e
                        theorem ReLUDepth.d_P2 (a b c d e : ℝ) (ha : a ≤ d) (hb : b ≤ d) (hc : c ≤ d) (he : e ≤ d) :
                        P2 a b c d e = R24 a b c d e
                        theorem ReLUDepth.d_P1 (a b c d e : ℝ) (ha : a ≤ d) (hb : b ≤ d) (hc : c ≤ d) (he : e ≤ d) :
                        P1 a b c d e = R14 a b c d e
                        theorem ReLUDepth.d_R23 (a b c d e : ℝ) (ha : a ≤ d) (hb : b ≤ d) (hc : c ≤ d) (he : e ≤ d) :
                        R23 a b c d e = Q a b c d e
                        theorem ReLUDepth.case_d (a b c d e : ℝ) (ha : a ≤ d) (hb : b ≤ d) (hc : c ≤ d) (he : e ≤ d) :
                        1 / 2 * (P1 a b c d e + P2 a b c d e + P3 a b c d e + P4 a b c d e + Q a b c d e - R13 a b c d e - R14 a b c d e - R23 a b c d e - R24 a b c d e) = d

                        d maximal.

                        theorem ReLUDepth.max_eq_M (x : Fin 5 → ℝ) :
                        theorem ReLUDepth.max5_two_hidden_layers :
                        (fun (x : Fin 5 → ℝ) => Finset.univ.sup' ⋯ x) ∈ Rep 5 2