1-- Continuous self-maps of the cube in the sup metric, and their action on2-- convergent sequences of points3-- Part of Cumulus, the Grace17 mathematics library.4-- Copyright (c) 2026 Grant Passmore.5-- Released under the Apache License 2.0. See LICENSE in the repository root.6-- Authors: Grant Passmore78module Grace.Cumulus.FixedPoint.CubeContinuity9import CubeSequences1011predicate CubeMap (f n : Set) := FunctionBetween(f, unitCube(n), unitCube(n))1213predicate CubeContinuousAt (f n x : Set) :=14∀ E ∈ ℝ, (0:R) < E →∃ D ∈ ℝ, (0:R) < D ∧15 (∀ y ∈ unitCube(n), ((∀ i ∈ n, dist(y(i), x(i)) < D) → (∀ i ∈ n, dist(f(y)(i), f(x)(i)) < E)))1617predicate CubeContinuous (f n : Set) := CubeMap(f, n) ∧∀ x ∈ unitCube(n), CubeContinuousAt(f, n, x)1819theorem CubeMap.function (f n : Set)20requires map : CubeMap(f, n)21shows f : unitCube(n) → unitCube(n)22proof23exact map2425theorem unitCube.point (n x : Set)26requires hx : x ∈ unitCube(n)27shows x : n → ℝ28proof29have parts := unitCube.membership.forward with hx30exact functionSpace.mem_iff.forward with parts.left3132theorem unitCube.coordinate (n x i : Set)33requires hx : x ∈ unitCube(n)34requires hi : i ∈ n35shows x(i) ∈ closedInterval((0:R), (1:R))36proof37have parts := unitCube.membership.forward with hx38exact parts.right with hi3940theorem unitCube.coordinate_real (n x i : Set)41requires hx : x ∈ unitCube(n)42requires hi : i ∈ n43shows x(i) ∈ ℝ44proof45have interval := unitCube.coordinate with hx, hi46have parts := closedInterval.membership.forward with interval47exact parts.left4849-- A sequence of cube points, as a function into the cube.50theorem PointSequence.into_cube (X n : Set)51requires sequence : PointSequence(X, n)52requires inCube : ∀ k ∈ ℕ, X(k) ∈ unitCube(n)53shows X : ℕ → unitCube(n)54proof55have function := PointSequence.function with sequence56exact FunctionBetween.codomain_of_values with function, inCube5758def imageSequence (f X n : Set) : Set:= compose(f, X, ℕ, unitCube(n), unitCube(n))5960theorem imageSequence.sequence (f X n : Set)61requires map : CubeMap(f, n)62requires sequence : PointSequence(X, n)63requires inCube : ∀ k ∈ ℕ, X(k) ∈ unitCube(n)64shows PointSequence(imageSequence(f, X, n), n)65proof66have fFunction := CubeMap.function with map67have XFunction := PointSequence.into_cube with sequence, inCube68have composed := compose.function with XFunction, fFunction69have values : ∀ k ∈ ℕ, compose(f, X, ℕ, unitCube(n), unitCube(n))(k) ∈ functionSpace(n, ℝ)70intros k hk71have valueIn := FunctionBetween.apply_closed with composed, hk72have parts := unitCube.membership.forward with valueIn73exact parts.left74have same : imageSequence(f, X, n) = compose(f, X, ℕ, unitCube(n), unitCube(n))75unfold imageSequence76rfl77unfold PointSequence78rw same79exact FunctionBetween.codomain_of_values with composed, values8081theorem imageSequence.value (f X n k : Set)82requires map : CubeMap(f, n)83requires sequence : PointSequence(X, n)84requires inCube : ∀ k ∈ ℕ, X(k) ∈ unitCube(n)85requires hk : k ∈ ℕ86shows imageSequence(f, X, n)(k) = f(X(k))87proof88have fFunction := CubeMap.function with map89have XFunction := PointSequence.into_cube with sequence, inCube90have same : imageSequence(f, X, n) = compose(f, X, ℕ, unitCube(n), unitCube(n))91unfold imageSequence92rfl93rw same94exact compose.apply with XFunction, fFunction, hk9596theorem imageSequence.in_cube (f X n k : Set)97requires map : CubeMap(f, n)98requires sequence : PointSequence(X, n)99requires inCube : ∀ k ∈ ℕ, X(k) ∈ unitCube(n)100requires hk : k ∈ ℕ101shows imageSequence(f, X, n)(k) ∈ unitCube(n)102proof103have fFunction := CubeMap.function with map104have value := imageSequence.value with map, sequence, inCube, hk105rw value106exact FunctionBetween.apply_closed with fFunction, (inCube with hk)107108-- Finitely many coordinates converging gives a common tail within any109-- distance, by induction on the number of coordinates.110theorem coordinateSequence.common_tail (n m : Nat) (X x D : Set)111requires sequence : PointSequence(X, n)112requires xFunction : x : n → ℝ113requires DReal : D ∈ ℝ114requires positive : (0:R) < D115requires converges : ∀ i ∈ n, ConvergesTo(coordinateSequence(X, n, i), x(i))116shows m ∈ succ(n) →∃ N ∈ ℕ, ∀ i ∈ m, ∀ k ∈ ℕ, N ≤ k → dist(X(k)(i), x(i)) < D117proof118induction m119| zero =>120intro hm121witness0122constructor123 . have zeroNat : Nat(0) bytypecheck124exact nat.omega.forward with zeroNat125 . intros i hi126exfalso127rw nat.zero at hi128 simpa using hi129| succ(j) using ih =>130intro hm131have jNat : Nat(j) bytypecheck132have jIn : j ∈ succ(n)133have less := Less.of_membership with hm134have below : j < succ(n) byarith135exact membership.of_Less with below136have jInN : j ∈ n137have less := Less.of_membership with hm138have below : j < n byarith139exact membership.of_Less with below140obtain⟨N, NIn, tail⟩:= ih with jIn141have convergesJ := converges with jInN142have xReal := FunctionBetween.apply_closed with xFunction, jInN143obtain⟨M, MIn, tailJ⟩:= ConvergesTo.eventually with convergesJ, positive144have NNat := nat.omega.backward with NIn145have MNat := nat.omega.backward with MIn146witness N + M147constructor148 . have sumNat : Nat(N + M) bytypecheck149exact nat.omega.forward with sumNat150 . intros i hi k hk bound151have kNat := nat.omega.backward with hk152havesplit:= bootstrap.succ.membership.forward with hi153casessplitwith below | same154 . have NBound : N≤ k byarith155have forI := tail with below156exact forI with hk, NBound157 . rw same158have MBound : M ≤ k byarith159have inBall := tailJ with hk, MBound160have value := coordinateSequence.value at X, n, j, k with sequence, jInN161rw value at inBall162have parts := openBall.membership.forward with inBall163exact parts.right164165-- A continuous map sends a coordinatewise convergent sequence of cube points166-- to a sequence converging to the image of the limit.167theorem CubeContinuous.sequential (n : Nat) (f X x : Set)168requires continuous : CubeContinuous(f, n)169requires sequence : PointSequence(X, n)170requires inCube : ∀ k ∈ ℕ, X(k) ∈ unitCube(n)171requires hx : x ∈ unitCube(n)172requires converges : ∀ i ∈ n, ConvergesTo(coordinateSequence(X, n, i), x(i))173shows∀ i ∈ n, ConvergesTo(coordinateSequence(imageSequence(f, X, n), n, i), f(x)(i))174proof175obtain⟨map, pointwise⟩:= continuous176have fFunction := CubeMap.function with map177have imageSeq := imageSequence.sequence with map, sequence, inCube178have xFunction := unitCube.point with hx179have fxIn := FunctionBetween.apply_closed with fFunction, hx180have fxFunction := unitCube.point with fxIn181intros i hi182have fxReal := FunctionBetween.apply_closed with fxFunction, hi183unfold ConvergesTo184constructor185 . exact coordinateSequence.sequence with imageSeq, hi186 . intros E EIn Epos187have atX := pointwise with hx188obtain⟨D, DIn, Dpos, close⟩:= atX with EIn, Epos189have all := coordinateSequence.common_tail at n, n, X, x, D with sequence, xFunction, DIn, Dpos, converges190obtain⟨N, NIn, tail⟩:= all with (bootstrap.succ.self at n)191witness N192constructor193 . exact NIn194 . intros k hk bound195have value := coordinateSequence.value at imageSequence(f, X, n), n, i, k with imageSeq, hi196have imageValue := imageSequence.value with map, sequence, inCube, hk197rw [value, imageValue]198have near : ∀ j ∈ n, dist(X(k)(j), x(j)) < D199intros j hj200have forJ := tail with hj201exact forJ with hk, bound202have XkIn := inCube with hk203have images := close with XkIn, near204have distance := images with hi205apply openBall.membership.backward206constructor207 . have fXkIn := FunctionBetween.apply_closed with fFunction, XkIn208have fXkFunction := unitCube.point with fXkIn209exact FunctionBetween.apply_closed with fXkFunction, hi210 . exact distance211