feat(library/data/countable): show that a type is countable by providing an injection to a type already known to be countable

This commit is contained in:
Leonardo de Moura 2015-04-15 10:30:24 -07:00
parent f16eaf8f0f
commit 036900280d

View file

@ -187,3 +187,21 @@ countable.mk
unpickle_list
unpickle_pickle_list
end list
definition countable_of_left_injection
{A B : Type} [h₁ : countable A]
(f : B → A) (finv : A → option B) (linv : ∀ b, finv (f b) = some b) : countable B :=
countable.mk
(λ b, pickle (f b))
(λ n,
match unpickle A n with
| some a := finv a
| none := none
end)
(λ b,
begin
esimp,
rewrite [countable.picklek],
esimp [option.cases_on],
rewrite [linv]
end)