Closed
Description
It would be nice to be able to demonstrate that Fin (x * y)
is isomorphic to Fin x × Fin y
. This would be useful for proving, for example, in agda-categories
that FinSetoids
is cartesian, or in something that I'm working on, that you can combine two finite state machines in various way
The inverse function can be implemented as:
combine : ∀ {n k} → Fin k → Fin n → Fin (n ℕ.* k)
combine x zero = inject+ _ x
combine x (suc y) = raise _ (combine x y)
With one direction of inverse proof as:
: ∀ {n k} x (y : Fin n) → quotRem k (combine x y) ≡ (x , y)
quotRem-combine {suc n} {k} x 0F rewrite splitAt-inject+ k (n ℕ.* k) x = refl
quotRem-combine {suc n} {k} x (suc y) rewrite splitAt-raise k (n ℕ.* k) (combine x y) = cong (Data.Product.map₂ suc) (quotRem-combine x y)
But I haven't been able to prove the other direction