πŸ›οΈ Atlasβœ’οΈFormalizations.Analysis.InnerProductSpace.Hlawka view on GitHub β†—6 theorems
/-Copyright (c) 2026 Carles MarΓ­n. All rights reserved.Released under Apache 2.0 license as described in the file LICENSE.Authors: Carles MarΓ­n, Claude (AI assistant)-/module public import Mathlib.Analysis.InnerProductSpace.Basicpublic import Mathlib.Data.Finset.Powersetpublic import Mathlib.Algebra.BigOperators.Ring.Finsetpublic import Mathlib.Algebra.BigOperators.Group.Finset.Powersetpublic import Mathlib.Algebra.Order.BigOperators.Group.Finset /-!# Hlawka's inequality and its generalisation by DjokoviΔ‡ Hlawka's inequality `β€–x+yβ€– + β€–y+zβ€– + β€–z+xβ€– ≀ β€–xβ€– + β€–yβ€– + β€–zβ€– + β€–x+y+zβ€–` in a real inner productspace, and its generalisation (DjokoviΔ‡ 1963; Smiley–Smiley 1964): for `n β‰₯ 3` vectors, with `d_k`the sum of the norms of all `k`-element subsums, `d_2 + β‹― + d_{n-1} ≀ (2^(n-2) - 1) (d_1 + d_n)`.The general case is equivalent to `4F ≀ 2^n (d_1 + d_n)`, where `F` sums the norms of the subsumsover all subsets; it is proved by strong induction on the number of vectors, merging two of them,`x a` and `x b`, into `x a + x b`: the subsets containing both or neither form the merged family,and each subset `T` containing exactly one of them is handled by Hlawka's inequality for`(Ξ£_T, x a, x b)`. ## Main results * `Hlawka.norm_add_add_le`: Hlawka's inequality for three vectors* `Hlawka.generalised`: d_2 + ... + d_(n-1) <= (2^(n-2) - 1)(d_1 + d_n) for n >= 3 vectors ## References * D. Ε½. DjokoviΔ‡, *Generalizations of Hlawka's inequality*, Glasnik Mat.-Fiz. Astronom. 18 (1963), 169–175.* D. M. Smiley and M. F. Smiley, *The polygonal inequalities*, Amer. Math. Monthly 71 (1964), 755–760.-/ @[expose] public section open Finset namespace Hlawka variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] /-- **Hlawka's inequality** (`n = 3`). -/theorem norm_add_add_le (x y z : E) :    β€–x + yβ€– + β€–y + zβ€– + β€–z + xβ€– ≀ β€–xβ€– + β€–yβ€– + β€–zβ€– + β€–x + y + zβ€– := by  have e1 := norm_add_sq_real x y  have e2 := norm_add_sq_real y z  have e3 := norm_add_sq_real z x  have e4 := norm_add_sq_real (x + y) z  rw [inner_add_left] at e4  have c1 := real_inner_comm x z  have h : β€–xβ€– ^ 2 + β€–yβ€– ^ 2 + β€–zβ€– ^ 2 + β€–x + y + zβ€– ^ 2      = β€–x + yβ€– ^ 2 + β€–y + zβ€– ^ 2 + β€–z + xβ€– ^ 2 := by    linarith  have t1 : β€–x + yβ€– ≀ β€–xβ€– + β€–yβ€– := norm_add_le x y  have t2 : β€–y + zβ€– ≀ β€–yβ€– + β€–zβ€– := norm_add_le y z  have t3 : β€–z + xβ€– ≀ β€–zβ€– + β€–xβ€– := norm_add_le z x  have u1 : β€–x + yβ€– ≀ β€–x + y + zβ€– + β€–zβ€– := by    calc β€–x + yβ€– = β€–(x + y + z) - zβ€– := by rw [add_sub_cancel_right]      _ ≀ β€–x + y + zβ€– + β€–zβ€– := norm_sub_le _ _  have u2 : β€–y + zβ€– ≀ β€–x + y + zβ€– + β€–xβ€– := by    calc β€–y + zβ€– = β€–(x + y + z) - xβ€– := by congr 1; abel      _ ≀ β€–x + y + zβ€– + β€–xβ€– := norm_sub_le _ _  have u3 : β€–z + xβ€– ≀ β€–x + y + zβ€– + β€–yβ€– := by    calc β€–z + xβ€– = β€–(x + y + z) - yβ€– := by congr 1; abel      _ ≀ β€–x + y + zβ€– + β€–yβ€– := norm_sub_le _ _  have key : (β€–xβ€– + β€–yβ€– + β€–zβ€– + β€–x + y + zβ€–) *      (β€–xβ€– + β€–yβ€– + β€–zβ€– + β€–x + y + zβ€– - β€–x + yβ€– - β€–y + zβ€– - β€–z + xβ€–) =      (β€–xβ€– + β€–yβ€– - β€–x + yβ€–) * (β€–zβ€– - β€–x + yβ€– + β€–x + y + zβ€–) +      (β€–yβ€– + β€–zβ€– - β€–y + zβ€–) * (β€–xβ€– - β€–y + zβ€– + β€–x + y + zβ€–) +      (β€–zβ€– + β€–xβ€– - β€–z + xβ€–) * (β€–yβ€– - β€–z + xβ€– + β€–x + y + zβ€–) := by    linear_combination h  have p1 : 0 ≀ (β€–xβ€– + β€–yβ€– - β€–x + yβ€–) * (β€–zβ€– - β€–x + yβ€– + β€–x + y + zβ€–) :=    mul_nonneg (by linarith) (by linarith)  have p2 : 0 ≀ (β€–yβ€– + β€–zβ€– - β€–y + zβ€–) * (β€–xβ€– - β€–y + zβ€– + β€–x + y + zβ€–) :=    mul_nonneg (by linarith) (by linarith)  have p3 : 0 ≀ (β€–zβ€– + β€–xβ€– - β€–z + xβ€–) * (β€–yβ€– - β€–z + xβ€– + β€–x + y + zβ€–) :=    mul_nonneg (by linarith) (by linarith)  have n1 := norm_nonneg x  have n2 := norm_nonneg y  have n3 := norm_nonneg z  have n4 := norm_nonneg (x + y + z)  rcases (add_nonneg (add_nonneg (add_nonneg n1 n2) n3) n4).eq_or_lt with hs | hs  Β· linarith  Β· by_contra hc    have hneg : (β€–xβ€– + β€–yβ€– + β€–zβ€– + β€–x + y + zβ€– - β€–x + yβ€– - β€–y + zβ€– - β€–z + xβ€–) < 0 := by      linarith    have := mul_neg_of_pos_of_neg hs hneg    linarith /-- Pointwise step: Hlawka rewritten for merging two summands. -/private lemma pt (u v w : E) :    β€–uβ€– + β€–w + uβ€– + β€–v + uβ€– + β€–v + (w + u)β€– ≀      2 * (β€–uβ€– + β€–v + w + uβ€–) + (β€–vβ€– + β€–wβ€– - β€–v + wβ€–) := by  have h := norm_add_add_le u v w  have e1 : β€–v + uβ€– = β€–u + vβ€– := by rw [add_comm]  have e2 : β€–v + (w + u)β€– = β€–u + v + wβ€– := by congr 1; abel  have e3 : β€–v + w + uβ€– = β€–u + v + wβ€– := by congr 1; abel  linarith private lemma sum_powerset_four {ΞΉ : Type*} [DecidableEq ΞΉ] {a b : ΞΉ} {R : Finset ΞΉ}    (ha : a βˆ‰ insert b R) (hb : b βˆ‰ R) (f : Finset ΞΉ β†’ ℝ) :    βˆ‘ S ∈ (insert a (insert b R)).powerset, f S =      βˆ‘ T ∈ R.powerset, (f T + f (insert b T) + f (insert a T) + f (insert a (insert b T))) := by  rw [Finset.sum_powerset_insert ha, Finset.sum_powerset_insert hb f,    Finset.sum_powerset_insert hb (fun t => f (insert a t))]  simp only [Finset.sum_add_distrib]  ring /-- Key induction: `4 Β· F ≀ 2^m (d₁ + dβ‚˜)` where `F` sums the norms of all subsums. -/private lemma key {ΞΉ : Type*} [DecidableEq ΞΉ] (m : β„•) : βˆ€ (s : Finset ΞΉ) (x : ΞΉ β†’ E),    s.card = m β†’    4 * βˆ‘ S ∈ s.powerset, β€–βˆ‘ i ∈ S, x iβ€– ≀      2 ^ m * (βˆ‘ i ∈ s, β€–x iβ€– + β€–βˆ‘ i ∈ s, x iβ€–) := by  induction m using Nat.strong_induction_on with  | _ m ih =>  intro s x hs  rcases m with _ | _ | k  Β· have h0 : s = βˆ… := Finset.card_eq_zero.mp hs    subst h0    simp  Β· obtain ⟨a, rfl⟩ := Finset.card_eq_one.mp hs    rw [show ({a} : Finset ΞΉ) = insert a βˆ… from rfl,      Finset.sum_powerset_insert (Finset.notMem_empty a)]    simp    linarith  Β· obtain ⟨a, ha, b, hb, hab⟩ := Finset.one_lt_card.mp (by omega : 1 < s.card)    have hb' : b ∈ s.erase a := Finset.mem_erase.mpr ⟨hab.symm, hb⟩    have hsR : insert a (insert b ((s.erase a).erase b)) = s := by      rw [Finset.insert_erase hb', Finset.insert_erase ha]    have haR : a βˆ‰ insert b ((s.erase a).erase b) := by simp [hab]    have hbR : b βˆ‰ (s.erase a).erase b := by simp    obtain ⟨R, hsR', haR', hbR'⟩ : βˆƒ R : Finset ΞΉ, insert a (insert b R) = s ∧        a βˆ‰ insert b R ∧ b βˆ‰ R := ⟨_, hsR, haR, hbR⟩    subst hsR'    have haR2 : a βˆ‰ R := fun h => haR' (Finset.mem_insert_of_mem h)    have hRc : R.card = k := by      rw [Finset.card_insert_of_notMem haR', Finset.card_insert_of_notMem hbR'] at hs      omega    -- merged family    let x' : ΞΉ β†’ E := fun i => if i = a then x a + x b else x i    have hx' : βˆ€ T βŠ† R, βˆ‘ i ∈ T, x' i = βˆ‘ i ∈ T, x i := by      intro T hT      refine Finset.sum_congr rfl fun i hi => ?_      have hia : i β‰  a := fun h => haR2 (h β–Έ hT hi)      simp [x', hia]    have hnx' : βˆ‘ i ∈ R, β€–x' iβ€– = βˆ‘ i ∈ R, β€–x iβ€– := by      refine Finset.sum_congr rfl fun i hi => ?_      have hia : i β‰  a := fun h => haR2 (h β–Έ hi)      simp [x', hia]    have IH := ih (k + 1) (by omega) (insert a R) x' (by rw [Finset.card_insert_of_notMem haR2, hRc])    have hF' : βˆ‘ S ∈ (insert a R).powerset, β€–βˆ‘ i ∈ S, x' iβ€– =        βˆ‘ T ∈ R.powerset, (β€–βˆ‘ i ∈ T, x iβ€– + β€–x a + x b + βˆ‘ i ∈ T, x iβ€–) := by      rw [Finset.sum_powerset_insert haR2, ← Finset.sum_add_distrib]      refine Finset.sum_congr rfl fun T hT => ?_      have hTR := Finset.mem_powerset.mp hT      have haT : a βˆ‰ T := fun h => haR2 (hTR h)      rw [Finset.sum_insert haT, hx' T hTR]      simp [x']    have hF : βˆ‘ S ∈ (insert a (insert b R)).powerset, β€–βˆ‘ i ∈ S, x iβ€– ≀        βˆ‘ T ∈ R.powerset, (2 * (β€–βˆ‘ i ∈ T, x iβ€– + β€–x a + x b + βˆ‘ i ∈ T, x iβ€–) +          (β€–x aβ€– + β€–x bβ€– - β€–x a + x bβ€–)) := by      rw [sum_powerset_four haR' hbR']      refine Finset.sum_le_sum fun T hT => ?_      have hTR := Finset.mem_powerset.mp hT      have haT : a βˆ‰ T := fun h => haR2 (hTR h)      have hbT : b βˆ‰ T := fun h => hbR' (hTR h)      have haT' : a βˆ‰ insert b T := fun h => haR' (by        rcases Finset.mem_insert.mp h with h | h        Β· exact Finset.mem_insert.mpr (Or.inl h)        Β· exact Finset.mem_insert_of_mem (hTR h))      rw [Finset.sum_insert hbT, Finset.sum_insert haT, Finset.sum_insert haT',        Finset.sum_insert hbT]      exact pt (βˆ‘ i ∈ T, x i) (x a) (x b)    have hsum : βˆ‘ T ∈ R.powerset, (2 * (β€–βˆ‘ i ∈ T, x iβ€– + β€–x a + x b + βˆ‘ i ∈ T, x iβ€–) +          (β€–x aβ€– + β€–x bβ€– - β€–x a + x bβ€–)) =        2 * βˆ‘ S ∈ (insert a R).powerset, β€–βˆ‘ i ∈ S, x' iβ€– +          2 ^ k * (β€–x aβ€– + β€–x bβ€– - β€–x a + x bβ€–) := by      rw [hF', Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_const, Finset.card_powerset,        hRc, nsmul_eq_mul]      push_cast      ring    rw [Finset.sum_insert haR2, Finset.sum_insert haR2, hnx', hx' R (subset_refl R)] at IH    have e1 : x' a = x a + x b := by simp [x']    rw [e1] at IH    rw [Finset.sum_insert haR', Finset.sum_insert hbR', Finset.sum_insert haR',      Finset.sum_insert hbR', ← add_assoc (x a) (x b)]    have p1 : (2 : ℝ) ^ (k + 1 + 1) = 4 * 2 ^ k := by ring    have p2 : (2 : ℝ) ^ (k + 1) = 2 * 2 ^ k := by ring    rw [p2] at IH    rw [p1]    have := hF.trans_eq hsum    nlinarith [this, IH] private lemma sum_range_split (h : β„• β†’ ℝ) (m : β„•) :    βˆ‘ k ∈ range (m + 4), h k = h 0 + h 1 + βˆ‘ k ∈ Icc 2 (m + 2), h k + h (m + 3) := by  induction m with  | zero => simp [Finset.sum_range_succ]  | succ m ih =>    rw [Finset.sum_range_succ, ih, show m + 1 + 2 = (m + 2) + 1 from rfl,      Finset.sum_Icc_succ_top (a := 2) (b := m + 2) (by omega)]    ring /-- **Generalised Hlawka inequality (DjokoviΔ‡ 1963; Smiley–Smiley 1964).** For `n β‰₯ 3` vectors of a realinner product space, write `d_k` for the sum of the norms of all `k`-element subsums. Then`d_2 + β‹― + d_{n-1} ≀ (2^(n-2) - 1) (d_1 + d_n)`. For `n = 3` this is Hlawka's inequality`β€–x+yβ€– + β€–y+zβ€– + β€–z+xβ€– ≀ β€–xβ€– + β€–yβ€– + β€–zβ€– + β€–x+y+zβ€–`. -/theorem generalised {n : β„•} (hn : 3 ≀ n) (x : Fin n β†’ E) :    βˆ‘ k ∈ Finset.Icc 2 (n - 1), βˆ‘ S ∈ (Finset.univ : Finset (Fin n)).powersetCard k, β€–βˆ‘ i ∈ S, x iβ€–      ≀ (2 ^ (n - 2) - 1 : ℝ) * (βˆ‘ i, β€–x iβ€– + β€–βˆ‘ i, x iβ€–) := by  obtain ⟨m, rfl⟩ : βˆƒ m, n = m + 3 := ⟨n - 3, by omega⟩  have hK := key (m + 3) (Finset.univ : Finset (Fin (m + 3))) x (by simp)  have hF : βˆ‘ S ∈ (Finset.univ : Finset (Fin (m + 3))).powerset, β€–βˆ‘ i ∈ S, x iβ€– =      βˆ‘ k ∈ range (m + 4), βˆ‘ S ∈ (Finset.univ : Finset (Fin (m + 3))).powersetCard k,        β€–βˆ‘ i ∈ S, x iβ€– := by    rw [Finset.powerset_card_biUnion,      Finset.sum_biUnion ((Finset.pairwise_disjoint_powersetCard _).set_pairwise _)]    simp  rw [hF, sum_range_split (fun k => βˆ‘ S ∈ (Finset.univ : Finset (Fin (m + 3))).powersetCard k,    β€–βˆ‘ i ∈ S, x iβ€–)] at hK  have h0 : βˆ‘ S ∈ (Finset.univ : Finset (Fin (m + 3))).powersetCard 0, β€–βˆ‘ i ∈ S, x iβ€– = 0 := by    simp  have h1 : βˆ‘ S ∈ (Finset.univ : Finset (Fin (m + 3))).powersetCard 1, β€–βˆ‘ i ∈ S, x iβ€– =      βˆ‘ i, β€–x iβ€– := by    rw [Finset.powersetCard_one, Finset.sum_map]    simp  have hn : βˆ‘ S ∈ (Finset.univ : Finset (Fin (m + 3))).powersetCard (m + 3), β€–βˆ‘ i ∈ S, x iβ€– =      β€–βˆ‘ i, x iβ€– := by    have := Finset.powersetCard_self (Finset.univ : Finset (Fin (m + 3)))    rw [Finset.card_univ, Fintype.card_fin] at this    rw [this]    simp  simp only [h0, h1, hn] at hK  have e1 : m + 3 - 1 = m + 2 := rfl  have e2 : m + 3 - 2 = m + 1 := rfl  rw [e1, e2]  have p : (2 : ℝ) ^ (m + 3) = 4 * 2 ^ (m + 1) := by ring  rw [p] at hK  nlinarith [hK] end Hlawka