Skip to content

refactor: change pset to a structure - #43976

Open
Shreyas4991 wants to merge 6 commits into
leanprover-community:masterfrom
Shreyas4991:psets_structure
Open

Shreyas4991 wants to merge 6 commits into
leanprover-community:masterfrom
Shreyas4991:psets_structure

Conversation

@Shreyas4991

@Shreyas4991 Shreyas4991 commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

I was fiddling with ZFSets when I found that replacing PSets inductive definition with a structure simplified the file. Some proofs were using the wrong API lemmas. The new definition is as follows:

structure PSet : Type (u + 1) where
  «Type» : Type u
  Func : «Type» → PSet

Zulip thread : https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/PSets.20as.20structures.3F/near/625458978


Open in Gitpod

@github-actions

github-actions Bot commented Sep 19, 2026

Copy link
Copy Markdown

PR summary 08bc8e498a

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

- Func
- eta
- mk_func
- mk_type
- «Type»

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean)

Lean-aware diff — post-build, computed from the Lean environment (commit 08bc8e4).

  • +0 new declarations
  • −3 removed declarations
-PSet.eta
-PSet.mk_func
-PSet.mk_type

No changes to strong technical debt.
No changes to weak technical debt.

Current commit 08bc8e498a
Reference commit 0acbe13e16

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@github-actions github-actions Bot added the t-set-theory Set theory label Sep 19, 2026
@eric-wieser

Copy link
Copy Markdown
Member

!radar

@leanprover-radar

leanprover-radar commented Sep 19, 2026

Copy link
Copy Markdown

Benchmark results for d2cfb58 against 0acbe13 are in. No significant results found. @Shreyas4991 @eric-wieser

  • 🟥 build//instructions: +8.6G (+0.01%)

No significant changes detected.

Comment thread Mathlib/SetTheory/ZFC/PSet.lean Outdated
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Comment thread Mathlib/SetTheory/ZFC/PSet.lean Outdated
@[pp_with_univ, use_set_notation_for_order]
inductive PSet : Type (u + 1)
| mk (α : Type u) (A : α → PSet) : PSet
@[pp_with_univ, use_set_notation_for_order, ext]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not convinced ext is useful here; I'd suggest adding it in a later PR, and only if you have a proof that uses it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines -56 to -66
@[simp]
theorem mk_type (α A) : «Type» ⟨α, A⟩ = α :=
rfl

@[simp]
theorem mk_func (α A) : Func ⟨α, A⟩ = A :=
rfl

@[simp]
theorem eta : ∀ x : PSet, mk x.Type x.Func = x
| ⟨_, _⟩ => rfl

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think these should be kept but deprecated (and de-simped)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-set-theory Set theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants