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/Sum): forall_sum_pi #6658

Closed
wants to merge 7 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Mathlib/Data/Sum/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ theorem «exists» {p : Sum α β → Prop} : (∃ x, p x) ↔ (∃ a, p (inl a)
| Or.inr ⟨b, h⟩ => ⟨inr b, h⟩⟩
#align sum.exists Sum.exists

theorem forall_sum_pi (p : α ⊕ β → Sort*)
(q : (∀ a, p a) → Prop) :
(∀ a, q a) ↔ (∀ a b, q (Sum.rec a b)) :=
Copy link
Member

Choose a reason for hiding this comment

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

Can you add the types of a and b here for clarity?

Copy link
Member

Choose a reason for hiding this comment

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

Or at least, name them more clearly, since the a here is different from the a on the line above, and neither is of type α!

Suggested change
(∀ a, q a) ↔ (∀ a b, q (Sum.rec a b)) :=
(∀ fab, q fab) ↔ (∀ fa fb, q (Sum.rec fa fb)) :=

Copy link
Member Author

Choose a reason for hiding this comment

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

done. I also made some arguments implict and improved some other names

⟨fun h a b => h _, fun h a => by
have h1 : a = Sum.rec (fun i => a (Sum.inl i)) (fun i => a (Sum.inr i)) := by
ext b; cases b <;> rfl
rw [h1]; exact h _ _⟩

theorem exists_sum_pi (p : α ⊕ β → Sort*)
(q : (∀ a, p a) → Prop) :
(∃ a, q a) ↔ (∃ a b, q (Sum.rec a b)) := by
rw [← not_forall_not, forall_sum_pi]
simp

theorem inl_injective : Function.Injective (inl : α → Sum α β) := fun _ _ ↦ inl.inj
#align sum.inl_injective Sum.inl_injective

Expand Down
Loading