File size: 4,620 Bytes
81674f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import LipschitzTransformerFormal.RestrictedStoneWeierstrass

open scoped Topology

namespace LipschitzTransformerFormal

open Set

/--
The separate query/context Lipschitz assumptions in Theorem 8 imply the
single product-budget inequality needed by Lemma 9.
-/
theorem separatelyLipschitz_productBudget
    {U V : Type*} [MetricSpace U] [MetricSpace V]
    {C : ℝ} (C_nonneg : 0 ≀ C)
    (target : C(U Γ— V, ℝ))
    (query_lipschitz :
      βˆ€ u x y, |target (u, x) - target (u, y)| ≀ dist x y)
    (context_lipschitz :
      βˆ€ u v x, |target (u, x) - target (v, x)| ≀ C * dist u v)
    (p q : U Γ— V) :
    |target p - target q| ≀ productBudget C p q := by
  calc
    |target p - target q| =
        |(target p - target (p.1, q.2)) +
          (target (p.1, q.2) - target q)| := by
            congr 1
            ring
    _ ≀ |target p - target (p.1, q.2)| +
        |target (p.1, q.2) - target q| := abs_add_le _ _
    _ ≀ dist p.2 q.2 + C * dist p.1 q.1 :=
      add_le_add
        (query_lipschitz p.1 p.2 q.2)
        (context_lipschitz p.1 q.1 q.2)
    _ = productBudget C p q := rfl

/--
The sign-safe interpolation coefficient used in Lemma 12.  The paper writes
the coefficient as belonging to `[0,1]`; when `a < b` the correct invariant is
its absolute value being below one.
-/
theorem interpolationCoefficient_abs_lt_one
    {a b fp fq : ℝ} (gap : |a - b| < fp - fq) :
    |(a - b) / (fp - fq)| < 1 := by
  have denominator_pos : 0 < fp - fq :=
    lt_of_le_of_lt (abs_nonneg (a - b)) gap
  rw [abs_div, abs_of_pos denominator_pos]
  exact (div_lt_one denominator_pos).2 gap

/--
Affine rescaling realizes either ordering of two requested values.  This
closes the negative-coefficient edge case in the printed proof of Lemma 12.
-/
theorem affineRescale_interpolates
    {a b fp fq : ℝ} (denominator_ne : fp - fq β‰  0) :
    let Ξ± := (a - b) / (fp - fq)
    let Ξ² := b - Ξ± * fq
    β + α * fp = a ∧ β + α * fq = b := by
  dsimp
  constructor
  Β· field_simp
    ring
  Β· ring

/--
The exact universal-quantifier deduction in Theorem 8 after the paper's
architecture lemmas have established nonemptiness, lattice closure, and
strict two-point interpolation for `G_C`.

This theorem ranges over arbitrary compact metric context/query spaces and
arbitrary separately Lipschitz targets.  It contains no finite sample, chosen
basis, or target fit.
-/
theorem transformerUniversalApproximation
    {U V : Type*} [MetricSpace U] [MetricSpace V]
    [CompactSpace U] [CompactSpace V] [Nontrivial (U Γ— V)]
    {C : ℝ} (C_pos : 0 < C)
    (G : Set C(U Γ— V, ℝ)) (nG : G.Nonempty)
    (inf_mem : βˆ€ f ∈ G, βˆ€ g ∈ G, f βŠ“ g ∈ G)
    (sup_mem : βˆ€ f ∈ G, βˆ€ g ∈ G, f βŠ” g ∈ G)
    (strict_interpolate :
      βˆ€ p q : U Γ— V, p β‰  q β†’ βˆ€ a b : ℝ,
        |a - b| < productBudget C p q β†’
        βˆƒ g ∈ G, g p = a ∧ g q = b)
    (target : C(U Γ— V, ℝ))
    (query_lipschitz :
      βˆ€ u x y, |target (u, x) - target (u, y)| ≀ dist x y)
    (context_lipschitz :
      βˆ€ u v x, |target (u, x) - target (v, x)| ≀ C * dist u v)
    {Ξ΅ : ℝ} (Ξ΅_pos : 0 < Ξ΅) :
    βˆƒ g ∈ G, dist g target < Ξ΅ :=
  restrictedStoneWeierstrassProduct C_pos G nG inf_mem sup_mem
    strict_interpolate target
    (separatelyLipschitz_productBudget C_pos.le target
      query_lipschitz context_lipschitz)
    Ξ΅_pos

/--
Murari et al., Theorem 3.1, reduced to its two exact architecture obligations:
the scalar gradient-descent ResNet family is a lattice and strictly
interpolates admissible two-point data.  The compact-domain density conclusion
is then kernel checked rather than imported as a citation.
-/
theorem scalarResNetDensity
    {X : Type*} [MetricSpace X] [CompactSpace X] [Nontrivial X]
    (R : Set C(X, ℝ)) (nR : R.Nonempty)
    (inf_mem : βˆ€ f ∈ R, βˆ€ g ∈ R, f βŠ“ g ∈ R)
    (sup_mem : βˆ€ f ∈ R, βˆ€ g ∈ R, f βŠ” g ∈ R)
    (strict_interpolate :
      βˆ€ x y : X, x β‰  y β†’ βˆ€ a b : ℝ, |a - b| < dist x y β†’
        βˆƒ g ∈ R, g x = a ∧ g y = b)
    (target : C(X, ℝ))
    (target_lipschitz : βˆ€ x y, |target x - target y| ≀ dist x y)
    {Ξ΅ : ℝ} (Ξ΅_pos : 0 < Ξ΅) :
    βˆƒ g ∈ R, dist g target < Ξ΅ :=
  restrictedStoneWeierstrass dist
    (fun _ _ h => dist_pos.mpr h) R nR inf_mem sup_mem strict_interpolate
    target target_lipschitz Ξ΅_pos

#print axioms separatelyLipschitz_productBudget
#print axioms interpolationCoefficient_abs_lt_one
#print axioms affineRescale_interpolates
#print axioms transformerUniversalApproximation
#print axioms scalarResNetDensity

end LipschitzTransformerFormal