1-- Points of the cube of one dimension lower, extended by the value p at the2-- last coordinate, and points on the far wall restricted back; labels and3-- reduced labels pass through both ways4-- Part of Cumulus, the Grace17 mathematics library.5-- Copyright (c) 2026 Grant Passmore.6-- Released under the Apache License 2.0. See LICENSE in the repository root.7-- Authors: Grant Passmore89module Grace.Cumulus.FixedPoint.KuhnExtend10import KuhnWallFace1112def cubeExtend (m p y : Set) : Set:= y ∪ constantFunction({m}, succ(p), p)1314theorem cubeExtend.disjoint (m : Set)15shows Disjoint(m, {m})16proof17apply Disjoint.iff.backward18intros x hx inside19have same := singleton.membership.forward with inside20rw same at hx21exact membership.irreflexive with hx2223theorem cubeExtend.function (m p : Nat) (y : Set)24requires hy : y ∈ functionSpace(m, succ(p))25shows cubeExtend(m, p, y) : succ(m) → succ(p)26proof27have yFunction := functionSpace.mem_iff.forward with hy28have pIn := bootstrap.succ.self at p29have constant := constantFunction.function at {m}, succ(p), p with pIn30have disjoint := cubeExtend.disjoint at m31have union := FunctionBetween.union_disjoint with yFunction, constant, disjoint32have asInsert := natural.successor_as_insert at m33have unfolded : insert(m, m) = {m} ∪ m34unfold insert35rfl36have domain : m ∪ {m} = succ(m)37rw [asInsert, unfolded]38exact union2.commutative39have codomain := union2.idempotent at succ(p)40rw [domain, codomain] at union41have same : cubeExtend(m, p, y) = y ∪ constantFunction({m}, succ(p), p)42unfold cubeExtend43rfl44 rwa same4546theorem cubeExtend.apply_below (m p : Nat) (y j : Set)47requires hy : y ∈ functionSpace(m, succ(p))48requires hj : j ∈ m49shows cubeExtend(m, p, y)(j) = y(j)50proof51have yFunction := functionSpace.mem_iff.forward with hy52have pIn := bootstrap.succ.self at p53have constant := constantFunction.function at {m}, succ(p), p with pIn54have disjoint := cubeExtend.disjoint at m55have same : cubeExtend(m, p, y) = y ∪ constantFunction({m}, succ(p), p)56unfold cubeExtend57rfl58rw same59exact FunctionBetween.union_apply_left with yFunction, constant, disjoint, hj6061theorem cubeExtend.apply_top (m p : Nat) (y : Set)62requires hy : y ∈ functionSpace(m, succ(p))63shows cubeExtend(m, p, y)(m) = p64proof65have yFunction := functionSpace.mem_iff.forward with hy66have pIn := bootstrap.succ.self at p67have constant := constantFunction.function at {m}, succ(p), p with pIn68have disjoint := cubeExtend.disjoint at m69have mIn : m ∈ {m}70apply singleton.membership.backward71rfl72have same : cubeExtend(m, p, y) = y ∪ constantFunction({m}, succ(p), p)73unfold cubeExtend74rfl75rw same76have value := FunctionBetween.union_apply_right with yFunction, constant, disjoint, mIn77rw value78exact constantFunction.apply with mIn, pIn7980theorem cubeExtend.member (m p : Nat) (y : Set)81requires hy : y ∈ functionSpace(m, succ(p))82shows cubeExtend(m, p, y) ∈ functionSpace(succ(m), succ(p))83proof84exact functionSpace.mem_iff.backward with (cubeExtend.function with hy)8586theorem successor.subset (m : Nat)87shows m ⊆ succ(m)88proof89intros l hl90exact membership.into_successor with hl9192theorem cubeExtend.restrict (m p : Nat) (y : Set)93requires hy : y ∈ functionSpace(m, succ(p))94shows restrict(cubeExtend(m, p, y), m) = y95proof96have yFunction := functionSpace.mem_iff.forward with hy97have extended := cubeExtend.function with hy98have mSubset := successor.subset at m99have restricted := restrict.domain_function with extended, mSubset100apply FunctionBetween.ext with restricted, yFunction101intros j hj102have value := restrict.domain_apply with extended, mSubset, hj103rw value104exact cubeExtend.apply_below with hy, hj105106theorem cubeRestrict.member (m p : Nat) (x : Set)107requires hx : x ∈ functionSpace(succ(m), succ(p))108shows restrict(x, m) ∈ functionSpace(m, succ(p))109proof110have xFunction := functionSpace.mem_iff.forward with hx111have mSubset := successor.subset at m112exact functionSpace.mem_iff.backward with (restrict.domain_function with xFunction, mSubset)113114-- A point on the far wall is the extension of its restriction.115theorem cubeRestrict.extend (m p : Nat) (x : Set)116requires hx : x ∈ functionSpace(succ(m), succ(p))117requires top : x(m) = p118shows cubeExtend(m, p, restrict(x, m)) = x119proof120have xFunction := functionSpace.mem_iff.forward with hx121have mSubset := successor.subset at m122have restrictedIn := cubeRestrict.member with hx123have extended := cubeExtend.function with restrictedIn124apply FunctionBetween.ext with extended, xFunction125intros j hj126havesplit:= bootstrap.succ.membership.forward with hj127casessplitwith below | same128 . have value := cubeExtend.apply_below with restrictedIn, below129rw value130exact restrict.domain_apply with xFunction, mSubset, below131 . rw same132have value := cubeExtend.apply_top with restrictedIn133rw [value, top]134rfl135136defgraph cubeRestrict (m p : Set) (x ∈ functionSpace(succ(m), succ(p))) : functionSpace(m, succ(p)) := restrict(x, m)137requires mNat : Nat(m)138requires pNat : Nat(p)139proof140exact cubeRestrict.member with member141142-- The labelling of the lower cube induced by a labelling of the cube.143defgraph wallLabels (m p lab L : Set) (y ∈ functionSpace(m, succ(p))) : L := lab(cubeExtend(m, p, y))144requires mNat : Nat(m)145requires pNat : Nat(p)146requires labFunction : lab : functionSpace(succ(m), succ(p)) → L147proof148have extendedIn := cubeExtend.member with member149exact FunctionBetween.apply_closed with labFunction, extendedIn150151theorem wallLabels.zero_wall (m p : Nat) (lab L : Set)152requires labFunction : lab : functionSpace(succ(m), succ(p)) → L153requires zeroWall : ∀ x ∈ functionSpace(succ(m), succ(p)), ∀ j ∈ succ(m), x(j) =0→ lab(x)(j) =0154shows∀ y ∈ functionSpace(m, succ(p)), ∀ j ∈ m, y(j) =0→ wallLabels(m, p, lab, L)(y)(j) =0155proof156intros y hy j hj zero157have value := wallLabels.value at m, p, lab, L, y with*158rw value159have extendedIn := cubeExtend.member with hy160have jIn := membership.into_successor with hj161have below := cubeExtend.apply_below with hy, hj162have forX := zeroWall with extendedIn163apply forX with jIn164 rwa below165166theorem wallLabels.full_wall (m p : Nat) (lab L : Set)167requires labFunction : lab : functionSpace(succ(m), succ(p)) → L168requires fullWall : ∀ x ∈ functionSpace(succ(m), succ(p)), ∀ j ∈ succ(m), x(j) = p → lab(x)(j) =1169shows∀ y ∈ functionSpace(m, succ(p)), ∀ j ∈ m, y(j) = p → wallLabels(m, p, lab, L)(y)(j) =1170proof171intros y hy j hj full172have value := wallLabels.value at m, p, lab, L, y with*173rw value174have extendedIn := cubeExtend.member with hy175have jIn := membership.into_successor with hj176have below := cubeExtend.apply_below with hy, hj177have forX := fullWall with extendedIn178apply forX with jIn179 rwa below180181-- On the far wall the reduced label survives restriction.182theorem reduced.restrict (m p : Nat) (lab L x : Set)183requires labFunction : lab : functionSpace(succ(m), succ(p)) → L184requires fullWall : ∀ x ∈ functionSpace(succ(m), succ(p)), ∀ j ∈ succ(m), x(j) = p → lab(x)(j) =1185requires hx : x ∈ functionSpace(succ(m), succ(p))186requires top : x(m) = p187shows reduced(m, wallLabels(m, p, lab, L), restrict(x, m)) = reduced(succ(m), lab, x)188proof189have yIn := cubeRestrict.member with hx190have labelValue := wallLabels.value at m, p, lab, L, restrict(x, m) with*191have back := cubeRestrict.extend with hx, top192rw back at labelValue193have mIn := bootstrap.succ.self at m194have forX := fullWall with hx195have labelOne := forX with mIn, top196have nonzero : lab(x)(m) ≠0197rw labelOne198intro equal199arith200have bound := reduced.le_of_nonzero with mIn, nonzero201have less : reduced(succ(m), lab, x) < succ(m) byarith202have rIn := membership.of_Less with less203apply reduced.unique204 . exact rIn205 . intros i hi206have zero := reduced.below with hi207 rwa labelValue208 . have stop := reduced.stop at succ(m), lab, x209cases stop with top2 | nonzero2210 . exfalso211rw top2 at rIn212exact membership.irreflexive with rIn213 . right214 rwa labelValue215216theorem labelImage.restrict_wall (m p : Nat) (lab L f : Set)217requires labFunction : lab : functionSpace(succ(m), succ(p)) → L218requires fullWall : ∀ x ∈ functionSpace(succ(m), succ(p)), ∀ j ∈ succ(m), x(j) = p → lab(x)(j) =1219requires inCube : f ⊆ functionSpace(succ(m), succ(p))220requires top : ∀ x ∈ f, x(m) = p221shows labelImage(m, wallLabels(m, p, lab, L), functionImage(cubeRestrict(m, p), f, functionSpace(m, succ(p)))) =222 labelImage(succ(m), lab, f)223proof224ext k225constructor226 . intro hk227obtain⟨kIn, y, hy, shape⟩:= labelImage.membership.forward with hk228obtain⟨yIn, x, hx, yShape⟩:= functionImage.membership.forward with hy229have xIn := inCube with x, hx230have value := cubeRestrict.value with xIn231rw value at yShape232have same := reduced.restrict with labFunction, fullWall, xIn, (top with hx)233apply labelImage.membership.backward234constructor235 . exact membership.into_successor with kIn236 . witness x237constructor238 . exact hx239 . rw [shape, yShape, same]240rfl241 . intro hk242obtain⟨kIn, x, hx, shape⟩:= labelImage.membership.forward with hk243have xIn := inCube with x, hx244have same := reduced.restrict with labFunction, fullWall, xIn, (top with hx)245have value := cubeRestrict.value with xIn246have restrictedIn := cubeRestrict.member with xIn247have reducedBound := reduced.bound at m, wallLabels(m, p, lab, L), restrict(x, m)248apply labelImage.membership.backward249constructor250 . rw [shape, ← same]251exact reducedBound252 . witness restrict(x, m)253constructor254 . apply functionImage.membership.backward255constructor256 . exact restrictedIn257 . witness x258constructor259 . exact hx260 . rw value261rfl262 . rw [shape, ← same]263rfl264