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

[Merged by Bors] - feat(data/dfinsupp): Add dfinsupp.single_eq_single_iff, and subtype.heq_iff_coe_eq #4810

Closed
wants to merge 4 commits into from

Conversation

eric-wieser
Copy link
Member

This ought to make working with dfinsupps over subtypes easier


With thanks to @kckennylau for pointing me in the right direction in https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Difficulty.20with.20dependent.20rewrites/near/214824136

@eric-wieser eric-wieser added the awaiting-review The author would like community review of the PR label Oct 28, 2020
…xt_iff_heq

This ought to make working with dfinsupps over subtypes easier
@eric-wieser eric-wieser force-pushed the eric-wieser/dfinsupp.single_eq_single_iff branch from 614b31a to 2b36292 Compare October 28, 2020 15:49
src/data/subtype.lean Outdated Show resolved Hide resolved
src/data/subtype.lean Outdated Show resolved Hide resolved
…eq_iff_coe_eq

This ought to make working with dfinsupps over subtypes easier
@eric-wieser eric-wieser changed the title feat(data/dfinsupp): Add dfinsupp.single_eq_single_iff, and subtype.ext_iff_heq feat(data/dfinsupp): Add dfinsupp.single_eq_single_iff, and subtype.heq_iff_coe_eq Oct 30, 2020
@github-actions github-actions bot added the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Oct 30, 2020
@github-actions github-actions bot removed the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Oct 30, 2020
src/data/subtype.lean Outdated Show resolved Hide resolved
Copy link
Member

@fpvandoorn fpvandoorn left a comment

Choose a reason for hiding this comment

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

LGTM, this seems like a fine use of heq.

bors d+

@@ -313,6 +313,28 @@ by simp only [single_apply, dif_neg h]
lemma single_injective {i} : function.injective (single i : β i → Π₀ i, β i) :=
λ x y H, congr_fun (mk_injective _ H) ⟨i, by simp⟩

/-- Like `finsupp.single_eq_single_iff`, but with a `heq` due to dependent types -/
lemma single_eq_single_iff (i j : ι) (xi : β i) (xj : β j) :
dfinsupp.single i xi = dfinsupp.single j xj ↔ i = j ∧ xi == xj ∨ xi = 0 ∧ xj = 0 :=
Copy link
Member

Choose a reason for hiding this comment

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

For a lemma like this I tend to also want a lemma of the form i = j → xi == xj → dfinsupp.single i xi = dfinsupp.single j xj (the most common case that dfinsupp.single are equal)

Copy link
Member Author

Choose a reason for hiding this comment

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

I found that if I want that case, I can just use congr. Is the lemma form still worthwhile?

@@ -43,6 +43,10 @@ protected theorem forall' {q : ∀x, p x → Prop} :
lemma ext_iff {a1 a2 : {x // p x}} : a1 = a2 ↔ (a1 : α) = (a2 : α) :=
⟨congr_arg _, subtype.ext⟩

lemma heq_iff_coe_eq (h : ∀ x, p x ↔ q x) {a1 : {x // p x}} {a2 : {x // q x}} :
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
lemma heq_iff_coe_eq (h : ∀ x, p x ↔ q x) {a1 : {x // p x}} {a2 : {x // q x}} :
@[simp] lemma heq_iff_coe_eq (h : ∀ x, p x ↔ q x) {a1 : {x // p x}} {a2 : {x // q x}} :

Copy link
Member Author

Choose a reason for hiding this comment

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

If I do that then this lemma takes priority over the stronger heq_iff_eq. Note also that this is a conditional lemma, so probably shouldn't be simp

@bors
Copy link

bors bot commented Oct 30, 2020

✌️ eric-wieser can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@fpvandoorn fpvandoorn added delegated The PR author may merge after reviewing final suggestions. and removed awaiting-review The author would like community review of the PR labels Oct 30, 2020
@fpvandoorn
Copy link
Member

Ok, I agree with both your comments.

bors merge

Btw: you can use @[simp, priority 900] to make the lemma heq_iff_coe_eq a lower priority than heq_iff_eq (this doesn't always work, since simp always simplifies from the leaves, but in this case the lemmas would apply to the same term).

@github-actions github-actions bot added the ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) label Oct 31, 2020
bors bot pushed a commit that referenced this pull request Oct 31, 2020
…eq_iff_coe_eq (#4810)

This ought to make working with dfinsupps over subtypes easier
@bors
Copy link

bors bot commented Oct 31, 2020

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(data/dfinsupp): Add dfinsupp.single_eq_single_iff, and subtype.heq_iff_coe_eq [Merged by Bors] - feat(data/dfinsupp): Add dfinsupp.single_eq_single_iff, and subtype.heq_iff_coe_eq Oct 31, 2020
@bors bors bot closed this Oct 31, 2020
@bors bors bot deleted the eric-wieser/dfinsupp.single_eq_single_iff branch October 31, 2020 11:35
lecopivo pushed a commit to lecopivo/mathlib that referenced this pull request Oct 31, 2020
…eq_iff_coe_eq (leanprover-community#4810)

This ought to make working with dfinsupps over subtypes easier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
delegated The PR author may merge after reviewing final suggestions. ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants