definition theorem example

A diffeological space (Baez & Hoffnung, Definition 2, after Souriau) is a set with, for every open , a set of functions called plots, such that

  1. a plot precomposed with a smooth map of open sets is a plot (smooth reparametrisation);
  2. a function that is a plot on each set of an open cover of is a plot on (locality);
  3. every map from the one point to is a plot (points are smooth).

A function is smooth (Definition 3) when is a plot of for every plot of . A diffeology says which maps into are smooth, where a manifold says which maps out of it are (through charts): it is the smooth analogue of a Quasi-Borel Space, which says which maps from are random variables.

Sources: Baez & Hoffnung arXiv:0807.1704 (notes) Definitions 1–3, 8, Theorem 9, §1 (manifolds as a full subcategory); Huot, Staton & Vákár arXiv:2001.02209 (notes) Definition 1, Example 5, Theorems 1, 2, 4, 5; Karwowski, Nielsen & Staton arXiv:2610.17886 (notes) Definitions 33–35, Theorem 4.

Why not manifolds: no space of smooth functions

Huot, Staton & Vákár, Theorems 4 and 5. Neither (the spaces and smooth maps) nor (smooth manifolds) is cartesian closed.

The obstruction is dimension: is infinite-dimensional and cannot be a finite-dimensional manifold. Diffeological spaces have function spaces for free:

  • Functional diffeology (Huot et al., Example 5): is a plot iff its uncurrying is smooth. This makes the category of diffeological spaces cartesian closed.
  • Much more (Baez & Hoffnung, Theorem 9): is a quasitopos (Definition 8: locally cartesian closed, finite colimits, a weak subobject classifier) with all small limits and colimits. Subspaces, quotients (orbifolds, spaces with corners) and spaces of paths are all diffeological spaces.
  • Manifolds sit inside as a full subcategory, so the smooth maps between manifolds are the familiar ones.

Use: correctness of automatic differentiation

A differentiable programming language with higher-order functions (map, fold, closures, functions passed to an optimiser) needs a semantics with function types and smoothness at once; is one. Huot, Staton & Vákár interpret forward-mode AD as a macro on terms that replaces each real by a dual number (value, tangent).

Theorem 1 (semantic correctness of , limited). For a term , is the dual-number representation of : on inputs it returns .

Theorem 2 (full). For ground result types and first-order contexts, coincides with the tangent bundle functor, even if uses higher-order functions internally.

The proof is a logical relation, built by categorical gluing over : the higher-order intermediate steps are smooth maps between function spaces, which only a cartesian closed setting can express.

Relatives

categoryfunction spacesprobabilityused for
no (Theorem 5)—classical differential geometry
cartesian differential categoriesnot required—the algebra of derivatives (axioms on )
yes—differentiable programs (Huot et al.)
yesyesprobabilistic programs
DQBS (Karwowski et al., Definition 33)yes (Theorem 4)yesInformation Geometry of Probabilistic Programs

A diffeological quasi-Borel space carries both structures on one set, compatibly; its internal tangent space (their Definition 35) is where the score and the velocity of a program live.

Docs: Julia manual: methods and multiple dispatch — dual numbers by overloading +, *, sin, as the macro does.

# Forward-mode AD by dual numbers (Huot–Staton–Vákár, Theorem 1), run through a HIGHER-ORDER
# program: θ ↦ ∫₀¹ sin(θx) dx, where the integrand x ↦ sin(θx) is a smooth curve in the function
# space C∞(ℝ, ℝ) (the functional diffeology, Example 5).
struct Dual <: Number; v::Float64; d::Float64; end
Base.:+(a::Dual, b::Dual) = Dual(a.v + b.v, a.d + b.d)
Base.:*(a::Dual, b::Dual) = Dual(a.v * b.v, a.d * b.v + a.v * b.d)
Base.:*(a::Real, b::Dual) = Dual(a * b.v, a * b.d)
Base.:*(a::Dual, b::Real) = b * a
Base.:/(a::Dual, n::Real) = Dual(a.v / n, a.d / n)
Base.sin(a::Dual) = Dual(sin(a.v), cos(a.v) * a.d)
Base.zero(::Type{Dual}) = Dual(0.0, 0.0)
 
integrate(f; n = 20_000) = sum(f((k - 0.5) / n) for k in 1:n) / n   # takes a FUNCTION
F(θ) = integrate(x -> sin(θ * x))                                    # a higher-order program
θ = 1.3
dF = F(Dual(θ, 1.0)).d                                               # the tangent part
exact = sin(θ) / θ - (1 - cos(θ)) / θ^2                              # d/dθ (1 − cos θ)/θ
isapprox(dF, exact; atol = 1e-8)                                     # true
import Mathlib
open Diffeology
open scoped ContDiff
 
-- Mathlib's diffeologies take plots on all of ℝⁿ (EuclideanSpace ℝ (Fin n)) rather than on open
-- subsets; by locality (axiom 2) the two notions agree.
#check @DiffeologicalSpace.plots
#check @DiffeologicalSpace.plot_reparam        -- axiom 1
#check @DiffeologicalSpace.locality            -- axiom 2
#check @Diffeology.IsPlot
#check @Diffeology.DSmooth                     -- Definition 3
#check @Diffeology.DSmooth.comp                -- smooth maps compose: the category Diff
#check @Diffeology.dSmooth_iff_contDiff        -- on ℝⁿ, diffeologically smooth = C∞
 
example : DSmooth (fun x : ℝ => x ^ 2 + 1) :=
  (by fun_prop : ContDiff ℝ ∞ fun x : ℝ => x ^ 2 + 1).dSmooth
-- Dual numbers through a higher-order program (Huot–Staton–Vákár, Theorems 1–2)
data Dual = Dual Double Double deriving Show
 
instance Num Dual where
  Dual a a' + Dual b b' = Dual (a + b) (a' + b')
  Dual a a' * Dual b b' = Dual (a * b) (a' * b + a * b')
  negate (Dual a a')    = Dual (negate a) (negate a')
  fromInteger n         = Dual (fromInteger n) 0
  abs    = undefined
  signum = undefined
instance Fractional Dual where
  Dual a a' / Dual b b' = Dual (a / b) ((a' * b - a * b') / (b * b))
  fromRational r = Dual (fromRational r) 0
instance Floating Dual where
  pi = Dual pi 0
  sin (Dual a a') = Dual (sin a) (cos a * a')
  cos (Dual a a') = Dual (cos a) (negate (sin a) * a')
  exp = undefined; log = undefined; asin = undefined; acos = undefined; atan = undefined
  sinh = undefined; cosh = undefined; asinh = undefined; acosh = undefined; atanh = undefined
 
integrate :: Fractional a => Int -> (a -> a) -> a      -- a higher-order function
integrate n f = sum [ f ((fromIntegral k - 0.5) / fromIntegral n) | k <- [1 .. n] ] / fromIntegral n
 
bigF :: (Floating a) => a -> a
bigF th = integrate 20000 (\x -> sin (th * x))
 
main :: IO ()
main = do
  let th = 1.3
      Dual _ d = bigF (Dual th 1)
  print (d, sin th / th - (1 - cos th) / th ^ 2)      -- the two agree