Skip to content

Commit

Permalink
feat(data/pnat/basic) pnat can_lift instances (#5977)
Browse files Browse the repository at this point in the history
Add can_lift instances for pnat from nat and int
  • Loading branch information
alexjbest committed Feb 1, 2021
1 parent 89c7963 commit 398e7ad
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/data/pnat/basic.lean
Expand Up @@ -372,3 +372,15 @@ begin
end

end pnat

section can_lift

instance nat.can_lift_pnat : can_lift ℕ ℕ+ :=
⟨coe, λ n, 0 < n, λ n hn, ⟨nat.to_pnat' n, pnat.to_pnat'_coe hn⟩⟩

instance int.can_lift_pnat : can_lift ℤ ℕ+ :=
⟨coe, λ n, 0 < n, λ n hn, ⟨nat.to_pnat' (int.nat_abs n),
by rw [coe_coe, nat.to_pnat'_coe, if_pos (int.nat_abs_pos_of_ne_zero (ne_of_gt hn)),
int.nat_abs_of_nonneg hn.le]⟩⟩

end can_lift

0 comments on commit 398e7ad

Please sign in to comment.