/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
module
public import Mathlib.Logic.Equiv.List
set_option doc.verso true
set_option doc.verso.suggestions false
/-!
# Equivalences involving `Array`
-/
@[expose] public section
namespace Equiv
/-- The natural equivalence between arrays and lists. -/
def arrayEquivList (α : Type*) : Array α ≃ List α where
toFun := Array.toList
invFun := Array.mk
end Equiv
/- Porting note: removed instances for what would be ported as `Traversable (Array α)` and
`LawfulTraversable (Array α)`. These would
1. be implemented directly in terms of `Array` functionality for efficiency, rather than being the
traversal of some other type transported along an equivalence to `Array α` (as the traversable
instance for `array` was)
2. belong in `Mathlib/Control/Traversable/Instances.lean` instead of this file. -/
-- namespace Array'
-- open Function
-- variable {n : ℕ}
-- instance : Traversable (Array' n) :=
-- @Equiv.traversable (flip Vector n) _ (fun α => Equiv.vectorEquivArray α n) _
-- instance : LawfulTraversable (Array' n) :=
-- @Equiv.isLawfulTraversable (flip Vector n) _ (fun α => Equiv.vectorEquivArray α n) _ _
-- end Array'
/-- If `α` is encodable, then so is `Array α`. -/
instance Array.encodable {α} [Encodable α] : Encodable (Array α) :=
Encodable.ofEquiv _ (Equiv.arrayEquivList _)
/-- If `α` is countable, then so is `Array α`. -/
instance Array.countable {α} [Countable α] : Countable (Array α) :=
Countable.of_equiv _ (Equiv.arrayEquivList α).symm
¤ Dauer der Verarbeitung: 0.3 Sekunden
¤
*© Formatika GbR, Deutschland