diff --git a/library/data/countable.lean b/library/data/countable.lean index d4da9ed15..309d8ae8d 100644 --- a/library/data/countable.lean +++ b/library/data/countable.lean @@ -73,5 +73,41 @@ countable.mk (λ s, pickle_sum s) (λ n, unpickle_sum n) (λ s, unpickle_pickle_sum s) - end sum + +section prod +variables {A B : Type} +variables [h₁ : countable A] [h₂ : countable B] +include h₁ h₂ + +definition pickle_prod : A × B → nat +| (a, b) := mkpair (pickle a) (pickle b) + +definition unpickle_prod (n : nat) : option (A × B) := +match unpair n with +| (n₁, n₂) := + match unpickle A n₁ with + | some a := + match unpickle B n₂ with + | some b := some (a, b) + | none := none + end + | none := none + end +end + +theorem unpickle_pickle_prod : ∀ p : A × B, unpickle_prod (pickle_prod p) = some p +| (a, b) := + begin + esimp [pickle_prod, unpickle_prod, prod.cases_on], + rewrite [unpair_mkpair], + esimp, + rewrite [*countable.picklek] + end + +definition countable_product [instance] {A B : Type} [h₁ : countable A] [h₂ : countable B] : countable (A × B) := +countable.mk + pickle_prod + unpickle_prod + unpickle_pickle_prod +end prod diff --git a/library/data/nat/default.lean b/library/data/nat/default.lean index dcb1f4ec1..3349fb2b9 100644 --- a/library/data/nat/default.lean +++ b/library/data/nat/default.lean @@ -3,4 +3,4 @@ Copyright (c) 2014 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Jeremy Avigad -/ -import .basic .order .sub .div .bquant .sqrt +import .basic .order .sub .div .bquant .sqrt .pairing .power