1-- The reduced labelling of a point of the cube: the first coordinate whose2-- label is one, or the dimension when every label is zero3-- 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.KuhnLabel9import KuhnThrough1011-- The indices where a labelling stops: the dimension itself and every12-- coordinate whose label is not zero.13def labelStops (n lab x : Set) : Set:= { k ∈ succ(n) | k = n ∨ lab(x)(k) ≠0 }1415def reduced (n lab x : Set) : Set:= leastNatural(labelStops(n, lab, x))1617theorem labelStops.nonempty (n : Nat) (lab x : Set)18shows Nonempty(labelStops(n, lab, x))19proof20witness n21apply labelStops.membership.backward22constructor23 . exact bootstrap.succ.self at n24 . left25rfl2627theorem labelStops.naturals (n : Nat) (lab x : Set)28shows labelStops(n, lab, x) ⊆ ℕ29proof30intros k hk31have parts := labelStops.membership.forward with hk32have kNat := natural.member at succ(n) with parts.left33exact nat.omega.forward with kNat3435theorem reduced.stops (n : Nat) (lab x : Set)36shows reduced(n, lab, x) ∈ labelStops(n, lab, x)37proof38have inhabited := labelStops.nonempty at n, lab, x39have naturals := labelStops.naturals at n, lab, x40have same : reduced(n, lab, x) = leastNatural(labelStops(n, lab, x))41unfold reduced42rfl43rw same44exact leastNatural.member with inhabited, naturals4546theorem reduced.bound (n : Nat) (lab x : Set)47shows reduced(n, lab, x) ∈ succ(n)48proof49have stops := reduced.stops at n, lab, x50have parts := labelStops.membership.forward with stops51exact parts.left5253theorem reduced.natural (n : Nat) (lab x : Set)54showsNat(reduced(n, lab, x))55proof56have bound := reduced.bound at n, lab, x57exact natural.member at succ(n) with bound5859theorem reduced.stop (n : Nat) (lab x : Set)60shows reduced(n, lab, x) = n ∨ lab(x)(reduced(n, lab, x)) ≠061proof62have stops := reduced.stops at n, lab, x63have parts := labelStops.membership.forward with stops64exact parts.right6566theorem reduced.least (n : Nat) (lab x k : Set)67requires hk : k ∈ labelStops(n, lab, x)68shows reduced(n, lab, x) ≤ k69proof70have inhabited := labelStops.nonempty at n, lab, x71have naturals := labelStops.naturals at n, lab, x72have parts := labelStops.membership.forward with hk73have kNat := natural.member at succ(n) with parts.left74have same : reduced(n, lab, x) = leastNatural(labelStops(n, lab, x))75unfold reduced76rfl77rw same78exact leastNatural.least with inhabited, naturals, hk7980-- Below the reduced label every label is zero.81theorem reduced.below (n : Nat) (lab x i : Set)82requires hi : i ∈ reduced(n, lab, x)83shows lab(x)(i) =084proof85have reducedNat := reduced.natural at n, lab, x86have iNat := natural.member at reduced(n, lab, x) with hi87have iLess := Less.of_membership with hi88have bound := reduced.bound at n, lab, x89have reducedLess := Less.of_membership with bound90by_contra nonzero91have less : i < succ(n) byarith92have iIn := membership.of_Less with less93have stop : i ∈ labelStops(n, lab, x)94apply labelStops.membership.backward95constructor96 . exact iIn97 . right98exact nonzero99have least := reduced.least with stop100arith101102theorem reduced.unique (n : Nat) (lab x r : Set)103requires hr : r ∈ succ(n)104requires zeros : ∀ i ∈ r, lab(x)(i) =0105requires stop : r = n ∨ lab(x)(r) ≠0106shows reduced(n, lab, x) = r107proof108have rNat := natural.member at succ(n) with hr109have rLess := Less.of_membership with hr110have inStops : r ∈ labelStops(n, lab, x) := labelStops.membership.backward with⟨hr, stop⟩111have least := reduced.least with inStops112by_contra different113have strict : reduced(n, lab, x) < r114by_contra notLess115have reverse := LessEqual.of_not_Less with notLess116apply different117exact LessEqual.antisymmetric with least, reverse118have inside := membership.of_Less with strict119have zero := zeros with inside120have reducedStop := reduced.stop at n, lab, x121cases reducedStop with top | nonzero122 . rw top at strict123arith124 . exact nonzero with zero125126theorem reduced.ne_of_zero (n : Nat) (lab x j : Set)127requires hj : j ∈ n128requires zero : lab(x)(j) =0129shows reduced(n, lab, x) ≠ j130proof131intro equal132have stop := reduced.stop at n, lab, x133rw equal at stop134cases stop with top | nonzero135 . rw top at hj136exact membership.irreflexive with hj137 . exact nonzero with zero138139theorem reduced.le_of_nonzero (n : Nat) (lab x j : Set)140requires hj : j ∈ n141requires nonzero : lab(x)(j) ≠0142shows reduced(n, lab, x) ≤ j143proof144have inStops : j ∈ labelStops(n, lab, x)145apply labelStops.membership.backward146constructor147 . exact membership.into_successor with hj148 . right149exact nonzero150exact reduced.least with inStops151152-- The reduced labelling as a function on a set of points.153defgraph reducedMap (n lab S : Set) (x ∈ S) : succ(n) := reduced(n, lab, x)154requires nNat : Nat(n)155proof156exact reduced.bound157158def labelImage (n lab S : Set) : Set:= functionImage(reducedMap(n, lab, S), S, succ(n))159160theorem labelImage.membership (n : Nat) (k lab S : Set)161shows k ∈ labelImage(n, lab, S) ↔ k ∈ succ(n) ∧∃ x ∈ S, k = reduced(n, lab, x)162proof163have same : labelImage(n, lab, S) = functionImage(reducedMap(n, lab, S), S, succ(n))164unfold labelImage165rfl166rw same167constructor168 . intro hk169obtain⟨inSucc, x, hx, shape⟩:= functionImage.membership.forward with hk170have value := reducedMap.value at n, lab, S, x with*171constructor172 . exact inSucc173 . witness x174constructor175 . exact hx176 . rw [shape, value]177rfl178 . intro hk179obtain⟨inSucc, x, hx, shape⟩:= hk180have value := reducedMap.value at n, lab, S, x with*181apply functionImage.membership.backward182constructor183 . exact inSucc184 . witness x185constructor186 . exact hx187 . rw [shape, value]188rfl189190-- The simplices all of whose vertices carry different reduced labels.191def completeSimplices (p n lab : Set) : Set:=192 { s ∈ kuhnSimplices(p, n) | labelImage(n, lab, s) = succ(n) }193