Skip to content

fix: prepare for Mathlib's Set becoming a structure - #1134

Merged
chenson2018 merged 5 commits into
leanprover:mainfrom
jessealama:fix/set-structure
Oct 14, 2026
Merged

chenson2018 merged 5 commits into
leanprover:mainfrom
jessealama:fix/set-structure

Conversation

@jessealama

Copy link
Copy Markdown
Contributor

Mathlib now defines Set α as a one-field structure instead of α → Prop, so Set no longer unfolds to a predicate. Rewrite the proofs and statements that relied on this to use membership and set-builder notation, which works with both definitions.

Model.ofSets_eq_ofPredicates can no longer be stated, and since it had no uses, it is removed. NA.concat now describes its start states with a set-builder instead of a classical if, which would otherwise make it noncomputable.

Mathlib now defines `Set α` as a one-field structure rather than
`α → Prop`. Rewrite proofs that relied on the old definitional
unfolding so they go through membership lemmas instead, and work with
both definitions.
`linImpl_iff_implies` applied the set `imp G H` to an element, and
`net_completeTraces` compared a set of traces with a `fun`. Use `∈`
and `{x | …}` instead, which also typecheck once `Set` is a structure.
The theorem equates models with atom types `Set α` and `α → Prop`,
which only typechecks while `Set α` unfolds to `α → Prop`. Mathlib now
defines `Set` as a structure, so it can no longer be stated. It has no
uses.
`concat` chose its `na2` start states with `if [] ∈ language na1`,
which needs classical decidability. This compiled only while `Set` was
a function type, because the compiler erased the field. With `Set` a
structure, the compiler keeps the field, and the definition is rejected
as noncomputable. Describe those start states with a set-builder instead.
/-- Abbreviation for `Model.ofContainers` where the container type is a `Set`. -/
abbrev ofSets (f : Frame α τ) : Model α τ (Set α) := ofContainers f

/-- The set model and predicate model of a frame are definitionally equal. -/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @fmontesi for this one.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the interest of not holding up an upcoming toolchain PR I've added the fix suggested in downstream-lean4. (Please of course feel free to otherwise adjust later on)

@chenson2018 chenson2018 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for anticipating this. I would usually wait until the adaptation PR automatically opens (in a few hours) but see nothing wrong with doing this ahead of time in the relatively rare cases where this is possible.

I'll give Fabrizio a little time in case he wants something different for the modal logic change. An alternative (suggested by AI) exists at leanprover/downstream-lean4#166 for comparison.

@chenson2018
chenson2018 enabled auto-merge October 14, 2026 23:01
@chenson2018
chenson2018 added this pull request to the merge queue Oct 14, 2026
Merged via the queue into leanprover:main with commit e8be434 Oct 14, 2026
2 checks passed
Kha pushed a commit to leanprover/downstream-lean4 that referenced this pull request Oct 16, 2026
`master` went red with the bump to `nightly-2026-10-16` ([run
38888679712](https://github.com/leanprover/downstream-lean4/actions/runs/38888679712)):
`mathlib4` fails to build, and `cslib` (skipped behind it) and `repl`
(its test phase compiles Mathlib) fall over with it. One repo needed a
change.

## mathlib4

lean4#15317 (*feat: add `Bool.dand` and `Ordering.dthen` along with more
lemmas*, Robin Arnez) moved `Ordering.dthen` into core, so
`Mathlib/Data/Ordering/Basic.lean:37` fails with

```
error: Mathlib/Data/Ordering/Basic.lean:37:20: `Ordering.dthen` has already been declared
```

Core's `Ordering.dthen` has mathlib's signature and mathlib's two
equations, and core also ships `@[simp] theorem Ordering.dthen_eq_then`
— the same statement, the same attribute, as mathlib's lemma in
`Mathlib/Data/Ordering/Lemmas.lean`. Both mathlib copies are therefore
plain duplicates (and keeping the lemma while dropping the definition
would just move the collision onto the lemma's name), so this deletes
both.

Nothing else from lean4#15317 collides: `Bool.dand`,
`Bool.Reflects.of_imp`, the root-namespace instance
`forall_forall_prop_decidable` and the `then`/`dand` lemma batch have no
mathlib counterparts, and mathlib has no other user of `Ordering.dthen`.

Upstream `mathlib4-nightly-testing` is still on `nightly-2026-10-15` and
still carries both declarations, so it will need the same deletion when
it bumps.

## Verified locally on `16428f35`

| repo | build | test | lint |
| --- | --- | --- | --- |
| mathlib4 | `Mathlib Archive Counterexamples Wanted cache --wfail`,
18440 jobs, 0 errors, 0 warnings | `lake test --iofail`, 18962 jobs |
`Linting passed for Mathlib.` |
| cslib | `--wfail --iofail`, 6690 jobs, 0 warnings | `--wfail
--iofail`, 18727 jobs | `Linting passed for Cslib.` |
| repl | `lake build` | `lake test` — all cases PASSED, including the
`test/Mathlib` batch | (no driver) |

`cslib` and `repl` are green **unpatched** on this master; they only
needed `mathlib4` to build. In particular `cslib`'s own breakage from
the `Set`-as-structure change is gone from `master`: upstream
[cslib#1134](leanprover/cslib#1134) merged on
2026-10-14 and the bot brought it in, which is why `cslib` was fully
green in [run
38840386618](https://github.com/leanprover/downstream-lean4/actions/runs/38840386618).
#166 is superseded and is being closed.

Nothing was left unfinished.

<!-- downstream-watch: unattended -->

Co-authored-by: downstream-lean4[bot] <downstream-lean4[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <[email protected]>
fmontesi pushed a commit that referenced this pull request Oct 31, 2026
Mathlib now defines `Set α` as a one-field structure instead of `α →
Prop`, so `Set` no longer unfolds to a predicate. Rewrite the proofs and
statements that relied on this to use membership and set-builder
notation, which works with both definitions.

`Model.ofSets_eq_ofPredicates` can no longer be stated, and since it had
no uses, it is removed. `NA.concat` now describes its start states with
a set-builder instead of a classical `if`, which would otherwise make it
noncomputable.

---------

Co-authored-by: Chris Henson <[email protected]>
@jessealama
jessealama deleted the fix/set-structure branch November 21, 2026 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants