-
Notifications
You must be signed in to change notification settings - Fork 299
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/pnat/find): port over nat.find
API
#12413
Conversation
Didn't port `pnat.find_add` because I got lost in the proof.
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
To be clear, what I'm suggesting is: /-- The `pnat` version of `nat.find_x` -/
protected def find_x : {n // p n ∧ ∀ m : ℕ+, m < n → ¬p m} :=
begin
have : ∃ (n' : ℕ) (n : ℕ+) (hn' : n' = n), p n, from exists.elim h (λ n hn, ⟨n, n, rfl, hn⟩),
have n := nat.find_x this,
refine ⟨⟨n, _⟩, _, λ m hm pm, _⟩,
{ obtain ⟨n', hn', -⟩ := n.prop.1,
rw hn',
exact n'.prop },
{ obtain ⟨n', hn', pn'⟩ := n.prop.1,
simp_rw [hn', subtype.coe_eta],
exact pn' },
{ exact n.prop.2 m hm ⟨m, rfl, pm⟩, }
end I don't really understand what you're doing with the |
I've found that when a definition or usage of a definition requires a proof, and we need two such proofs, where one implies the other, having both still as arguments is better, where the implication is stored in an opt_param. This opt_param laundering often works better when the statements interact with I will work on using your implementation. |
In the case of my definition you should probably never need the rewrite, as all the API for |
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
src/data/pnat/basic.lean
Outdated
{ simp [←pnat.coe_le_coe, subtype.ext_iff, nat.succ_le_succ_iff, nat.succ_inj'], } | ||
end | ||
|
||
lemma lt_add_right (n m : ℕ+) : n < n + m := |
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.
Can you add lt_add_left
too for completeness? We have both for nat
.
src/data/pnat/basic.lean
Outdated
⟨begin | ||
rintro ⟨a, ha⟩ ⟨b, hb⟩ ⟨c, hc⟩, | ||
simp [←pnat.coe_le_coe] | ||
end⟩ |
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 would guess
⟨begin | |
rintro ⟨a, ha⟩ ⟨b, hb⟩ ⟨c, hc⟩, | |
simp [←pnat.coe_le_coe] | |
end⟩ | |
⟨λ ⟨a, ha⟩ ⟨b, hb⟩ ⟨c, hc⟩, by simp [←pnat.coe_le_coe]⟩ |
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.
@[priority 10]
instance : covariant_class ℕ+ ℕ+ ((+)) (≤) :=
⟨λ ⟨a, ha⟩, by { extract_goal, }⟩
example (_x : ℕ+)
(_fun_match : ∀ (_a : ℕ+) {n₁ n₂ : ℕ+},
n₁ ≤ n₂ → _a + n₁ ≤ _a + n₂) (a : ℕ)
(_mlocal._fresh.304.3605 _mlocal._fresh.304.3606 : ℕ+)
(ha : 0 < a) :
__mlocal__fresh_304_3605 ≤ __mlocal__fresh_304_3606 →
⟨a, ha⟩ + __mlocal__fresh_304_3605 ≤
⟨a, ha⟩ + __mlocal__fresh_304_3606 :=
begin
admit,
end
I think the destruction notation doesn't work properly with implicit arguments.
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.
bors d+
✌️ pechersky can now approve this pull request. To approve and merge a pull request, simply reply with |
bors r+ |
Pull request successfully merged into master. Build succeeded: |
nat.find
APInat.find
API
Didn't port
pnat.find_add
because I got lost in the proof.