Since we have Data.Vec
, we know what Vec
is.
I want to prove that Nat and Vec are isomorphic.
I've successfully created a function that proves Nat can be converted to Vec:
ℕ→vec : (n : ℕ) → Vec ⊤ n
ℕ→vec zero = []
ℕ→vec (suc a) = tt ∷ ℕ→vec a
While when I'm trying to write a corresponding vec→ℕ
, I failed.
I want to write something like this (it doesn't compile but it's readable):
vec→ℕ : ∀ {n} → Vec ⊤ n → (n : ℕ)
vec→ℕ [] = zero
vec→ℕ (tt ∷ a) = suc (vec→ℕ a)
In the first code, it's ensured that the argument is exactly the length of the return value. However, how can I ensure that the length of the first argument is exactly the return value?