Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: lemmas to simplify equalities with Option-typed dependent if-then-else #4037

Merged
merged 3 commits into from
May 6, 2024

Conversation

wupr
Copy link
Contributor

@wupr wupr commented Apr 30, 2024

Closes #4013.

Add dite_some_none_eq_none and dite_some_none_eq_some, analogous to the existing ite_some_none_eq_none and ite_some_none_eq_some.

@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Apr 30, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Apr 30, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Apr 30, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Apr 30, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator

leanprover-community-mathlib4-bot commented Apr 30, 2024

Mathlib CI status (docs):

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Apr 30, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Apr 30, 2024
@nomeata
Copy link
Contributor

nomeata commented May 1, 2024

Hmm, looks like this breaks mathlib, this might need diagnosing

@wupr
Copy link
Contributor Author

wupr commented May 1, 2024

It looks like the problem could be with the use of a non-final simp in Mathlib. But I think I need to merge the new commits in nightly-with-mathlib first.

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request May 1, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request May 1, 2024
@wupr
Copy link
Contributor Author

wupr commented May 1, 2024

The errors was thrown in Mathlib/Data/FinEnum.lean at the third line below:

instance Subtype.finEnum [FinEnum α] (p : α → Prop) [DecidablePred p] : FinEnum { x // p x } :=
  ofList ((toList α).filterMap fun x => if h : p x then some ⟨_, h⟩ else none)
    (by rintro ⟨x, h⟩; simp; exists x; simp [*])

But the proof can be simplified as follows now:

instance Subtype.finEnum [FinEnum α] (p : α → Prop) [DecidablePred p] : FinEnum { x // p x } :=
  ofList ((toList α).filterMap fun x => if h : p x then some ⟨_, h⟩ else none)
    (by simp)

There may be other problems like this and I'm trying to compile Mathlib locally to identify them.

Where should I push the fix? To the lean-pr-testing-4037 branch on Mathlib?

@nomeata
Copy link
Contributor

nomeata commented May 1, 2024

Where should I push the fix? To the lean-pr-testing-4037 branch on Mathlib?

Exactly! Just keep pushing fixed until mathlib is happy, then we can see if the changes needed are benign

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added builds-mathlib CI has verified that Mathlib builds against this PR and removed breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan labels May 1, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request May 1, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request May 1, 2024
@semorrison
Copy link
Collaborator

Changes to Mathlib look fine, so lets proceed!

@semorrison semorrison added this pull request to the merge queue May 6, 2024
Merged via the queue into leanprover:master with commit 07be352 May 6, 2024
19 checks passed
@wupr wupr deleted the dite-some-none branch May 7, 2024 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding new lemmas dite_some_none_eq_some and dite_some_none_eq_none
4 participants