AFTD Auto-Formalizing Theoretical Domains

good_slopes_fiber_product_saturation

theoremverified

If a finite set has as many points as a finite product and the pair of coordinate maps is injective, each first-coordinate fiber has the full size of the second coordinate and contains one point with each second coordinate.

Statement

theorem good_slopes_fiber_product_saturation
    {α ι κ : Type*} [DecidableEq α] [DecidableEq ι] [Fintype ι] [DecidableEq κ] [Fintype κ]
    (S : Finset α) (f : α → ι) (g : α → κ)
    (hcard : S.card = Fintype.card ι * Fintype.card κ)
    (hinj : Set.InjOn (fun z => (f z, g z)) S) :
    ∀ i : ι, (S.filter fun z => f z = i).card = Fintype.card κ ∧
      ∀ k : κ, ∃ z ∈ S, f z = i ∧ g z = k
Source
Product-fiber saturation step for OP-1027.
Verified
19 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 4

The proof, explained

The theorem is proved by a finite-cardinality pigeonhole argument. Since (f, g) : S → ι × κ is injective and |S| = |ι| * |κ| = |ι × κ|, the image of (f, g) must be all of ι × κ, making it surjective. Restricting to any fiber A = {z ∈ S | f(z) = i}, the map g is injective on A because the first coordinate is constant, and surjective onto κ by the surjectivity of the pair map, which simultaneously proves that |A| = |κ| and that each second coordinate is attained.

  1. The image of S under the coordinate pair map (f, g) is the entire product ι × κ.

    Because the pair map (f, g) is injective on S, the size of its image equals the size of S, which is given as |ι| * |κ| = |ι × κ|. In a finite type, any sub-finset having the same cardinality as the ambient type must be the entire universal finset.

    lines 11–14

    uses Finset.eq_univ_of_card, Finset.card_image_of_injOn, Fintype.card_prod

      classical
      have hP : S.image (fun z => (f z,g z)) = Finset.univ := by
        apply Finset.eq_univ_of_card
        rw [Finset.card_image_of_injOn hinj, hcard, Fintype.card_prod]
  2. The map (f, g) is surjective: for every i ∈ ι and k ∈ κ, there exists z ∈ S with f(z) = i and g(z) = k.

    Any pair (i, k) belongs to the universal finset of ι × κ and thus to the image of S under (f, g). By definition of the image of a finset, there is some z ∈ S whose image under (f, g) is (i, k), so projecting to the first and second coordinates yields f(z) = i and g(z) = k.

    lines 15–20

    uses Finset.mem_univ, Finset.mem_image.mp, congrArg

      have hall : ∀ i : ι, ∀ k : κ, ∃ z ∈ S, f z = i ∧ g z = k := by
        intro i k
        have hk : (i,k) ∈ S.image (fun z => (f z,g z)) := by
          rw [hP]; exact Finset.mem_univ _
        obtain ⟨z,hz,he⟩ := Finset.mem_image.mp hk
        exact ⟨z,hz,congrArg Prod.fst he,congrArg Prod.snd he⟩
  3. For each fixed i ∈ ι, the second projection g is injective on the fiber A = {z ∈ S | f(z) = i}.

    If z, z' ∈ A satisfy g(z) = g(z'), their first coordinates are also equal (f(z) = i = f(z')) because both lie in the fiber over i. Consequently, (f(z), g(z)) = (f(z'), g(z')), and by the injectivity of the pair map on S, z = z'.

    lines 21–28

    uses Finset.mem_filter.mp, Prod.ext

      intro i
      let A := S.filter fun z => f z = i
      have hginj : Set.InjOn g A := by
        intro z hz z' hz' heq
        have hza := Finset.mem_filter.mp hz
        have hz'a := Finset.mem_filter.mp hz'
        apply hinj hza.1 hz'a.1
        exact Prod.ext (hza.2.trans hz'a.2.symm) heq
  4. The image of the fiber A under g is the entire type κ.

    To show g(A) is the universal finset of κ, it suffices to show every k ∈ κ is in g(A). By the surjectivity established earlier, there exists z ∈ S with f(z) = i and g(z) = k. Since f(z) = i, this z lies in A, and since g(z) = k, the element k belongs to g(A).

    lines 29–33

    uses Finset.eq_univ_iff_forall.mpr, Finset.mem_image.mpr, Finset.mem_filter.mpr

      have hG : A.image g = Finset.univ := by
        apply Finset.eq_univ_iff_forall.mpr
        intro k
        obtain ⟨z,hz,hf,hg⟩ := hall i k
        exact Finset.mem_image.mpr ⟨z,Finset.mem_filter.mpr ⟨hz,hf⟩,hg⟩
  5. The fiber over i has cardinality equal to |κ|, and contains an element mapping to k for each k ∈ κ.

    The conclusion splits into two parts. For the cardinality, because g is injective on A, |A| = |g(A)|; since g(A) is the universal finset of κ, its size is |κ|. The second part is simply the surjectivity of (f, g) specialized to the given i.

    lines 34–38

    uses Finset.card_image_of_injOn, Finset.card_univ

      constructor
      · calc
          (S.filter fun z => f z = i).card = (A.image g).card := (Finset.card_image_of_injOn hginj).symm
          _ = Fintype.card κ := by rw [hG, Finset.card_univ]
      · exact hall i
Finset.eq_univ_of_card
A finset in a finite type whose cardinality equals that of the type is the entire universal set.
Finset.card_image_of_injOn
If a function is injective on a finset, the cardinality of its image equals the cardinality of the domain finset.
Fintype.card_prod
The cardinality of the product of two finite types is the product of their cardinalities.
Finset.mem_univ
Every element of a finite type belongs to its universal finset.
Finset.mem_image.mp
If an element belongs to the image of a finset under a function, it is the value of that function at some element of the finset.
congrArg
Equal inputs to a function yield equal outputs.
Finset.mem_filter.mp
If an element belongs to a filtered finset, it belongs to the original finset and satisfies the filtering predicate.
Prod.ext
Two ordered pairs are equal if their first coordinates are equal and their second coordinates are equal.
Finset.eq_univ_iff_forall.mpr
A finset that contains every element of a finite type is the universal finset.
Finset.mem_image.mpr
If an element is the image of a point in a finset under a function, it belongs to the image of that finset.
Finset.mem_filter.mpr
If an element belongs to a finset and satisfies a predicate, it belongs to the filtered finset.
Finset.card_univ
The cardinality of the universal finset of a finite type is the cardinality of the type itself.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

set_option maxRecDepth 10000set_option maxHeartbeats 5000000theorem good_slopes_fiber_product_saturation    {α ι κ : Type*} [DecidableEq α] [DecidableEq ι] [Fintype ι] [DecidableEq κ] [Fintype κ]    (S : Finset α) (f : α → ι) (g : α → κ)    (hcard : S.card = Fintype.card ι * Fintype.card κ)    (hinj : Set.InjOn (fun z => (f z, g z)) S) :    ∀ i : ι, (S.filter fun z => f z = i).card = Fintype.card κ ∧      ∀ k : κ, ∃ z ∈ S, f z = i ∧ g z = k := by  classical  have hP : S.image (fun z => (f z,g z)) = Finset.univ := by    apply Finset.eq_univ_of_card    rw [Finset.card_image_of_injOn hinj, hcard, Fintype.card_prod]  have hall : ∀ i : ι, ∀ k : κ, ∃ z ∈ S, f z = i ∧ g z = k := by    intro i k    have hk : (i,k) ∈ S.image (fun z => (f z,g z)) := by      rw [hP]; exact Finset.mem_univ _    obtain ⟨z,hz,he⟩ := Finset.mem_image.mp hk    exact ⟨z,hz,congrArg Prod.fst he,congrArg Prod.snd he⟩  intro i  let A := S.filter fun z => f z = i  have hginj : Set.InjOn g A := by    intro z hz z' hz' heq    have hza := Finset.mem_filter.mp hz    have hz'a := Finset.mem_filter.mp hz'    apply hinj hza.1 hz'a.1    exact Prod.ext (hza.2.trans hz'a.2.symm) heq  have hG : A.image g = Finset.univ := by    apply Finset.eq_univ_iff_forall.mpr    intro k    obtain ⟨z,hz,hf,hg⟩ := hall i k    exact Finset.mem_image.mpr ⟨z,Finset.mem_filter.mpr ⟨hz,hf⟩,hg⟩  constructor  · calc      (S.filter fun z => f z = i).card = (A.image g).card := (Finset.card_image_of_injOn hginj).symm      _ = Fintype.card κ := by rw [hG, Finset.card_univ]  · exact hall i
See it in the graphDiscuss this resultChallenge it