/-Copyright (c) 2026 Carles Marín. All rights reserved.Released under Apache 2.0 license as described in the file LICENSE.Authors: Carles Marín-/module public import Formalizations.NumberTheory.NumericalSemigroup.GapBound /-!# Submonoids of `ℕ` with exactly three gaps A submonoid of `ℕ` with exactly three gaps has gap set `{1,2,3}`, `{1,2,4}`, `{1,2,5}` or `{1,3,5}`, i.e. it is`⟨4,5,6,7⟩`, `⟨3,5,7⟩`, `⟨3,4⟩` or `⟨2,7⟩` (classical, Rosales–García-Sánchez; Lemma 4 of«The order generated by a column of the SU(n)ₖ S-matrix», Part II). Every gap is at most `2δ − 1 = 5`(`P3b.gap_le_two_mul_genus_sub_one`), `1` is a gap, sums of non-gaps are not gaps, and a finite case analysis(`decide` over the subsets of `{1,…,5}`) leaves the four sets. ## Main results * `P3a.gaps_of_genus_eq_three`: the four gap sets of genus three. ## References * C. Marín, *The order generated by a column of the SU(n)_k S-matrix is locally a numerical semigroup ring (Part II)*, Zenodo (2026), doi:10.5281/zenodo.22864267, Lemma `lem:delta3`.-/ @[expose] public section namespace P3a /-- No gap: `0` is in every submonoid. -/theorem zero_not_mem_gaps (A : Set ℕ) : 0 ∉ gaps A := by aesop /-- With a positive genus, `1` is a gap (otherwise the submonoid is all of `ℕ`). -/theorem one_mem_gaps {A : Set ℕ} (h : 0 < genus A) : 1 ∈ gaps A := by by_contra h1 simp only [gaps, Set.mem_ofPred_eq, not_not] at h1 have hvac : gaps A = ∅ := by ext x simp only [gaps, Set.mem_ofPred_eq, Set.mem_empty_iff_false, iff_false, not_not] simpa using AddSubmonoid.nsmul_mem _ h1 x rw [genus, hvac, Set.ncard_empty] at h omega /-- The sum of two non-gaps is not a gap. -/theorem add_not_mem_gaps {A : Set ℕ} {a b : ℕ} (ha : a ∉ gaps A) (hb : b ∉ gaps A) : a + b ∉ gaps A := by simp only [gaps, Set.mem_ofPred_eq, not_not] at * exact AddSubmonoid.add_mem _ ha hb /-- The finite case analysis: a 3-subset of `{1,…,5}` with `1`, closed as the gaps of a monoid must be. -/theorem finset_case_genus_three : ∀ T ∈ (Finset.Icc 1 5).powerset, T.card = 3 → 1 ∈ T → (2 ∉ T → 4 ∉ T) → (2 ∉ T → 3 ∉ T → 5 ∉ T) → T = {1, 2, 3} ∨ T = {1, 2, 4} ∨ T = {1, 2, 5} ∨ T = {1, 3, 5} := by decide /-- Lemma 4 of s-matrix-orders-II (classical, Rosales–García-Sánchez): a submonoid of `ℕ` with exactly threegaps has gap set `{1,2,3}`, `{1,2,4}`, `{1,2,5}` or `{1,3,5}`, i.e. it is `⟨4,5,6,7⟩`, `⟨3,5,7⟩`, `⟨3,4⟩` or`⟨2,7⟩`. -/theorem gaps_of_genus_eq_three {A : Set ℕ} (hfin : (gaps A).Finite) (h : genus A = 3) : gaps A = {1, 2, 3} ∨ gaps A = {1, 2, 4} ∨ gaps A = {1, 2, 5} ∨ gaps A = {1, 3, 5} := by classical -- every gap lies in {1,…,5} have hle : ∀ x ∈ gaps A, 1 ≤ x ∧ x ≤ 5 := by intro x hx have h5 := P3b.gap_le_two_mul_genus_sub_one A hfin hx rw [h] at h5 refine ⟨Nat.one_le_iff_ne_zero.mpr fun h0 => zero_not_mem_gaps A (h0 ▸ hx), by omega⟩ set T : Finset ℕ := (Finset.Icc 1 5).filter (· ∈ gaps A) with hT have hGT : gaps A = ↑T := by ext x simp only [hT, Finset.coe_filter, Finset.mem_Icc, Set.mem_ofPred_eq] exact ⟨fun hx => ⟨hle x hx, hx⟩, fun hx => hx.2⟩ have hcard : T.card = 3 := by rw [← h, genus, hGT, Set.ncard_coe_finset] have hmem : ∀ x, x ∈ T ↔ x ∈ gaps A := by intro x; rw [hGT]; rfl have h1 : 1 ∈ T := (hmem 1).2 (one_mem_gaps (by omega)) have h24 : 2 ∉ T → 4 ∉ T := fun h2 h4 => add_not_mem_gaps (A := A) (a := 2) (b := 2) (fun g => h2 ((hmem 2).2 g)) (fun g => h2 ((hmem 2).2 g)) ((hmem 4).1 h4) have h235 : 2 ∉ T → 3 ∉ T → 5 ∉ T := fun h2 h3 h5 => add_not_mem_gaps (A := A) (a := 2) (b := 3) (fun g => h2 ((hmem 2).2 g)) (fun g => h3 ((hmem 3).2 g)) ((hmem 5).1 h5) have hsub : T ∈ (Finset.Icc 1 5).powerset := Finset.mem_powerset.mpr (Finset.filter_subset _ _) rcases finset_case_genus_three T hsub hcard h1 h24 h235 with e | e | e | e <;> rw [hGT, e] <;> simp end P3a