1-- Prepending a fixed entry to the lists of a set is an injection, so a2-- cons image of a finite set is finite and has the size of its source3-- 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.List.ConsImage9import Basic10import Cardinal.NaturalSum1112-- The cons map ys ↦ x :: ys onto the cons image.13defgraph consMap (x S : Set) (ys ∈ S) : consImage(x, S) := x :: ys14proof15apply consImage.membership.backward16refine⟨ys, member, rfl⟩1718theorem consMap.injective (x S : Set)19shows InjectiveBetween(consMap(x, S), S, consImage(x, S))20proof21have function := consMap.function at x, S22constructor23 . exact function24 . intros u hu v hv z hz huz hvz25have uValue := FunctionBetween.apply_value with function, hu, huz26have vValue := FunctionBetween.apply_value with function, hv, hvz27have uShape := consMap.value at x, S, u with hu28have vShape := consMap.value at x, S, v with hv29have equal : x :: u = x :: v30rw [← uShape, ← vShape, uValue, vValue]31rfl32have parts := List.inductive.injective.cons with equal33exact parts.right3435theorem consMap.image (x S : Set)36shows functionImage(consMap(x, S), S, consImage(x, S)) = consImage(x, S)37proof38ext zs39constructor40 . intro hz41have parts := functionImage.membership.forward with hz42exact parts.left43 . intro hz44obtain⟨ys, hy, shape⟩:= consImage.membership.forward with hz45apply functionImage.membership.backward46constructor47 . exact hz48 . witness ys49constructor50 . exact hy51 . rw← shape52 symm53exact consMap.value at x, S, ys with hy5455theorem consImage.finite (x S : Set)56requires finite : Finite(S)57shows Finite(consImage(x, S))58proof59have function := consMap.function at x, S60have reflexive := Subset.reflexive at S61have image := Finite.function_image with function, finite, reflexive62 rwa consMap.image at image6364theorem consImage.cardinality (x S : Set)65requires finite : Finite(S)66shows cardinality(consImage(x, S)) = cardinality(S)67proof68have injective := consMap.injective at x, S69have reflexive := Subset.reflexive at S70have image := cardinality.injective_image with injective, reflexive, finite71 rwa consMap.image at image72