Repository navigation
fix: prepare for Mathlib's Set becoming a structure - #1134
Merged
Merged
Conversation
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.
jessealama
requested review from
SamuelSchlesinger,
arademaker,
chenson2018,
crei,
fmontesi and
sorrachai
as code owners
October 14, 2026 13:47
crei
approved these changes
Oct 14, 2026
chenson2018
reviewed
Oct 14, 2026
| /-- 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. -/ |
Collaborator
There was a problem hiding this comment.
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
approved these changes
Oct 14, 2026
chenson2018
left a comment
Collaborator
There was a problem hiding this comment.
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
enabled auto-merge
October 14, 2026 23:01
This was referenced Oct 16, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mathlib now defines
Set αas a one-field structure instead ofα → Prop, soSetno 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_ofPredicatescan no longer be stated, and since it had no uses, it is removed.NA.concatnow describes its start states with a set-builder instead of a classicalif, which would otherwise make it noncomputable.