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(logic/basic): Add forall_apply_eq_imp_iff #4109
Conversation
LGTM, let's see if the |
@eric-wieser CI doesn't like this 😢 |
src/data/set/basic.lean
Outdated
@[simp] theorem forall_range_iff {p : α → Prop} : (∀ a ∈ range f, p a) ↔ (∀ i, p (f i)) := | ||
⟨assume h i, h (f i) (mem_range_self _), assume h a ⟨i, (hi : f i = a)⟩, hi ▸ h i⟩ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I can fix this with
@[simp] theorem forall_range_iff {p : α → Prop} : (∀ a ∈ range f, p a) ↔ (∀ i, p (f i)) := | |
⟨assume h i, h (f i) (mem_range_self _), assume h a ⟨i, (hi : f i = a)⟩, hi ▸ h i⟩ | |
@[simp] theorem forall_range_iff_aux {p : α → Prop} : (∀ a i, f i = a → p a) ↔ (∀ i, p (f i)) := | |
⟨assume h i, h (f i) i rfl, assume h a i hi, hi ▸ h i⟩ | |
theorem forall_range_iff {p : α → Prop} : (∀ a ∈ range f, p a) ↔ (∀ i, p (f i)) := | |
by simp |
What would be a better name for forall_range_iff_aux
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The best I can come up with is forall_apply_eq_imp_iff
. And it certainly is a good simp
lemma 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If if helps, parts of it look like forall_eq'
, and the lemma used to prove exists_range_iff
is exists_exists_eq_and
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also happy with forall_range_iff'
. Whatever you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, added using your suggested name.
Also adds forall_apply_eq_imp_iff' for swapped forall arguments
(∀ a, ∀ b, f a = b → p b) ↔ (∀ a, p (f a)) := | ||
⟨λ h i, h i (f i) rfl, λ h i a hi, hi ▸ h i⟩ | ||
|
||
@[simp] theorem forall_apply_eq_imp_iff' {f : α → β} {p : β → Prop} : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's less likely to show up, but b = f a
could also be a pattern: forall_eq_apply_iff
?
Do you want to add those?
Feel free to merge if the linter is happy
bors d+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tempting, yeah. Is there a way for me to run the simp linter without waiting for a full mathlib build? The CI is taking a very long time on this PR, thanks to touching such low-level files I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can (temporarily) add #lint
at the bottom of the file, but it's not completely foolproof since simp
lemmas in later files may change what the simp normal form is. I guess that's not likely for stuff in logic.basic
though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given how slow the build was for this one, I think I'll come back and add the reversed-equality lemmas in a follow-up PR.
✌️ eric-wieser can now approve this pull request. To approve and merge a pull request, simply reply with |
19dea2f
to
5316a2d
Compare
by simp [@eq_comm _ a'] | ||
@[simp] theorem forall_apply_eq_imp_iff {f : α → β} {p : β → Prop} : | ||
(∀ a, ∀ b, f a = b → p b) ↔ (∀ a, p (f a)) := | ||
⟨λ h a, h a (f a) rfl, λ h a b hab, hab ▸ h a⟩ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would by tidy
be better or worse here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worse, but I'm almost certain that tactic.tidy
depends on this file anyways.
@@ -612,11 +612,7 @@ rel.core_inter _ s t | |||
|
|||
lemma mem_core_res (f : α → β) (s : set α) (t : set β) (x : α) : | |||
x ∈ core (res f s) t ↔ (x ∈ s → f x ∈ t) := | |||
begin | |||
simp [mem_core, mem_res], split, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-terminal simp
is to blame here, but I suppose writing it this way lead to the proof being removable which is a good thing
More non-terminal |
|
src/measure_theory/borel_space.lean
Outdated
{ simp only [mem_range, exists_imp_distrib, forall_apply_eq_imp_iff'], | ||
intro a, | ||
exact generate_measurable.basic _ is_open_Iio } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is a reasonable fix, since I don't think I can rewrite this to put the simp last.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I can eliminate this simp
entirely
d2c12d8
to
dcdd822
Compare
bors r+ |
👎 Rejected by label |
@jcommelin: Can I remove your changes requested label? |
Yes, and in the future feel free to do so without asking. bors r+ |
Also adds forall_apply_eq_imp_iff' for swapped forall arguments This means that `forall_range_iff` can now be solved by `simp`. This requires changes in data/pfun and measure_theory/borel_space, where non-terminal `simp`s broke.
Pull request successfully merged into master. Build succeeded: |
Also adds forall_apply_eq_imp_iff' for swapped forall arguments
This means that
forall_range_iff
can now be solved bysimp
.This requires changes in data/pfun and measure_theory/borel_space, where non-terminal
simp
s broke.Discussed at https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/Should.20.60set.2Eforall_range_iff.60.20be.20taged.20.60simp.60.3F