Skip to content

feat(Combinatorics/Enumerative): Latin squares#36698

Open
ghseeli wants to merge 4024 commits into
leanprover-community:masterfrom
cjrl:lr_ls_m_coe
Open

feat(Combinatorics/Enumerative): Latin squares#36698
ghseeli wants to merge 4024 commits into
leanprover-community:masterfrom
cjrl:lr_ls_m_coe

Conversation

@ghseeli

@ghseeli ghseeli commented Mar 15, 2026

Copy link
Copy Markdown

This PR defines Latin rectangles and Latin squares and proves an extension theorem using Hall's Marriage Theorem.

Main results

  • group_to_cayley_table: every finite group G yields a LatinSquare G G.
  • latin_rectangle_extends_one_row: a (non-square) LatinRectangle extends to a LatinRectangle
    with one more row. This is an application of Hall's Marriage Theorem, hallMatchingsOn.nonempty.
  • latin_rectangle_extends_to_latin_square: a LatinRectangle extends to a LatinSquare.

This is included in a new file Combinatorics/Enumerative/LatinSquare.lean.


sgouezel and others added 30 commits January 27, 2026 20:36
…ma for disambiguation (leanprover-community#34413)

Cherry picked from leanprover-community#34055.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
…ation and variance (leanprover-community#33815)

Make mathlib's style consistent by always putting spaces around the pipes.
This is more readable when there are long arguments.
This inconsistency was exposed by extending the `whitespace` linter to proof bodies in leanprover-community#30658.
Define a predicate `HasGaussianLaw X P`, which states that under the measure `P`, the random variable `X` has a Gaussian distribution, i.e. `IsGaussian (P.map X)`.
…ity#34139)

This PR adds an API lemma specializing `comap_iInf` to the case of finsets, which I've found helpful for working with primary decomposition.

Co-authored-by: tb65536 <thomas.l.browning@gmail.com>
…community#34438)

Cherry picked from leanprover-community#34055.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
…olynomial.Degree.Defs` (leanprover-community#34449)

`Defs` is the standard name for files mainly containing definitions.
…sIso_desc` and golf (leanprover-community#34237)

We also fix the name of `Cofan.isColimit_iff_isIso_sigmaDesc` and turn the `iff` around.
…mmunity#34429)

These lemmas work if the codomain is a `MulOneClass`, not necessarily a group.
…27701)

...and analogous results on `CanonicallyOrderedAdd`.
…easure.join` (leanprover-community#34239)

Add some small results which were apparently missing:
* `join` and `bind` give probability measures if fed with probability measures
* `join` and `bind` interchange with `sum`, `bind` interchanges with `smul`

Co-authored-by: pfaffelh <p.p@stochastik.uni-freiburg.de>
Co-authored-by: pfaffelh <pfaffelh@gmail.com>
…nprover-community#34353)

The statement has a nice generalisation which doesn't use tuples, and allows easy expression of a few useful variants.

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
…anprover-community#34468)

When verify_version_tags.py is run from lean4's release_checklist.py, it
runs in a shallow clone without tags. The local/remote consistency check
would return a warning in this case, causing the script to exit with code 1
in single-tag mode (where warnings are treated as failures).

This scenario is explicitly expected (as the existing comment noted), and
the GitHub API check verifies the tag exists remotely. Treat this as a
successful skip rather than a warning.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
…finite sequences of paths (leanprover-community#28208)

Add `Path.concatenate`, which folds the function `Path.trans` across a sequence of paths with compatible endpoints, corresponding to the concatenation of a finite sequence of paths. This is implemented with `Fin.dfoldl` from the Batteries library. Prove basic properties about `concatenate` (i.e., how it behaves with respect to `Path.refl`, `Path.subpath`, and homotopies).
…er-community#34286)

This PR addresses all shellcheck warnings in `scripts/create-adaptation-pr.sh`:

- Quote variables to prevent globbing/word splitting ([SC2086](https://www.shellcheck.net/wiki/SC2086))
- Use `$(...)` instead of legacy backticks ([SC2006](https://www.shellcheck.net/wiki/SC2006))
- Add `-r` flag to `read` commands ([SC2162](https://www.shellcheck.net/wiki/SC2162))

**Related PRs:**
- leanprover/cslib#203 (cslib)
- leanprover-community/batteries#1624 (batteries)

🤖 Prepared with Claude Code
…rover-community#34398)

This PR fixes a bug in the `nightly_detect_failure.yml` workflow where duplicate messages were being posted to Zulip for the same nightly date.

The deduplication logic compared the first 160 characters of the message, but the GitHub Actions run ID appears within those characters. Different workflow runs have different IDs, so the comparison always failed and duplicates were posted.

Now we extract and compare the nightly date and bump branch explicitly using regex, which correctly identifies duplicate messages.

**Update:** Also now fetches the last 20 messages and looks for the most recent one from the bot, ignoring human replies in between. This handles the case where someone replies to a bot message before the next workflow run.

See https://leanprover.zulipchat.com/#narrow/channel/428973-nightly-testing/topic/Cslib.20bump.20branch.20reminders/near/569853848 for context.
Suggested improvement by Chris Henson: https://leanprover.zulipchat.com/#narrow/channel/428973-nightly-testing/topic/Cslib.20bump.20branch.20reminders/near/569945200

🤖 Prepared with Claude Code
The current definition of `Quiver`  allows morphisms to be in `Prop`. The docstring explicitly mentions that if you want to use Props as morphisms, you can do this with `Quiver.{0}`. But in fact there are only two occurrences of the string `Quiver.{0}` in mathlib, one in the docstring of `Quiver`, and one in the docstring of `Digraph` explaining why `Quiver.{0}` was not suitable for digraphs (because `Quiver` is a class); the definition of `Digraph` is precisely `Quiver.{0}` but as a structure. In contrast, there are many many occurrences of `Quiver.{v + 1}` in mathlib, all of which can be removed with this refactor.

It turns out that there is actually one `Quiver.{0}` in Mathlib: `Matrix.toQuiver` associates a Prop-valued quiver to a matrix with entries in a linearly ordered ring. There are two possible fixes here; I use `PLift` which was the easier one; another possibility is to make `Matrix.toDigraph` instead.
Define gaps of a finite set of pairwise disjoint closed intervals.

Part of originally planned leanprover-community#29508
…`f v - f u` (leanprover-community#34462)

Cherry picked from leanprover-community#34055. It is the first step of the construction of the vector measure associated to a bounded variation function: later, we will extend the finite additivity given by the current PR to countable additivity thanks to general extension theorems for vector measures.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
…over-community#34052)

Adds `Fintype.not_injective_of_card_lt`, the contrapositive of `card_le_of_injective`. This provides a direct pigeonhole-style statement that a function cannot be injective when the codomain is smaller than the domain.
 
Moved from `Mathlib.Data.Fintype.Pigeonhole` to sit next to `card_le_of_injective` in `Mathlib.Data.Fintype.Card`.
…leanprover-community#34480)

This PR fixes the daily CI workflow for leanchecker.

The `check-leanchecker` job was configured to run only in `mathlib4-nightly-testing`, but the `notify-leanchecker` job runs in `mathlib4` and tries to query the job status from the current workflow run. Since the job was skipped in `mathlib4`, the notification produced broken Zulip messages with empty URLs (see https://leanprover.zulipchat.com/#narrow/channel/428973-nightly-testing/topic/leanchecker.20failure/near/570212817).

This PR:
- Moves `check-leanchecker` to run in `mathlib4` (matching `check-nanoda` and `check-mathlib_test_executable`)
- Enables both `master` and `nightly` branches for leanchecker (the TODO comment indicated this was waiting for leanchecker to land on master)

🤖 Prepared with Claude Code
…nity#30831)

We define the quasi-compact precoverage on the category of schemes as the precoverage given by quasi-compact covers. From this, the fpqc precoverage is obtained in a follow-up PR as the intersection of this precoverage with the precoverage given by flat covers.

From Proetale.
…prover-community#32316)

In this PR we present some  dimension shifting tools in `ModuleCat`.
Co-authored-by: Christopher J. R. Lloyd <cjl8zf@virginia.edu>
Co-authored-by: George H. Seelinger <ghseeli@gmail.com>
ghseeli and others added 16 commits April 7, 2026 20:21
Co-authored-by: Christopher J. R. Lloyd <cjl8zf@virginia.edu>
Co-authored-by: George H. Seelinger <ghseeli@gmail.com>
Co-authored-by: Christopher J. R. Lloyd <cjl8zf@virginia.edu>
Co-authored-by: George H. Seelinger <ghseeli@gmail.com>
Co-authored-by: Iván Renison <85908989+IvanRenison@users.noreply.github.com>
Thanks for this!

Co-authored-by: Iván Renison <85908989+IvanRenison@users.noreply.github.com>
Co-authored-by: Dagur Asgeirsson <dagurtomas@gmail.com>
Co-authored-by: Christopher J. R. Lloyd <cjl8zf@virginia.edu>
Co-authored-by: George H. Seelinger <ghseeli@gmail.com>
@ghseeli ghseeli temporarily deployed to cache-upload-forks June 5, 2026 03:01 — with GitHub Actions Inactive
ghseeli and others added 3 commits June 6, 2026 20:06
Placed it lower in the file so it can use dependent lemmas in proof.

Co-authored-by: Christopher J. R. Lloyd <cjl8zf@virginia.edu>
Co-authored-by: George H. Seelinger <ghseeli@gmail.com>
Co-authored-by: Christopher J. R. Lloyd <cjl8zf@virginia.edu>
Co-authored-by: George H. Seelinger <ghseeli@gmail.com>
@ghseeli ghseeli temporarily deployed to cache-upload-forks June 7, 2026 01:07 — with GitHub Actions Inactive
@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jun 12, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-combinatorics Combinatorics

Projects

None yet

Development

Successfully merging this pull request may close these issues.